mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2025-12-31 08:33:44 +01:00
73976 lines
3.9 MiB
73976 lines
3.9 MiB
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/generator/templates/cli/main.rs.mako'
|
|
// DO NOT EDIT !
|
|
#![allow(unused_variables, unused_imports, dead_code, unused_mut)]
|
|
|
|
extern crate tokio;
|
|
|
|
#[macro_use]
|
|
extern crate clap;
|
|
|
|
use std::env;
|
|
use std::io::{self, Write};
|
|
use clap::{App, SubCommand, Arg};
|
|
|
|
use google_compute1::{api, Error, oauth2};
|
|
|
|
mod client;
|
|
|
|
use client::{InvalidOptionsError, CLIError, arg_from_str, writer_from_opts, parse_kv_arg,
|
|
input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol,
|
|
calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo};
|
|
|
|
use std::default::Default;
|
|
use std::error::Error as StdError;
|
|
use std::str::FromStr;
|
|
|
|
use serde_json as json;
|
|
use clap::ArgMatches;
|
|
use http::Uri;
|
|
use hyper::client::connect;
|
|
use tokio::io::{AsyncRead, AsyncWrite};
|
|
use tower_service;
|
|
|
|
enum DoitError {
|
|
IoError(String, io::Error),
|
|
ApiError(Error),
|
|
}
|
|
|
|
struct Engine<'n, S> {
|
|
opt: ArgMatches<'n>,
|
|
hub: api::Compute<S>,
|
|
gp: Vec<&'static str>,
|
|
gpm: Vec<(&'static str, &'static str)>,
|
|
}
|
|
|
|
|
|
impl<'n, S> Engine<'n, S>
|
|
where
|
|
S: tower_service::Service<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>>,
|
|
{
|
|
async fn _accelerator_types_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.accelerator_types().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _accelerator_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.accelerator_types().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("accelerator-type").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _accelerator_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.accelerator_types().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _addresses_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.addresses().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _addresses_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.addresses().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("address").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _addresses_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.addresses().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("address").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _addresses_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"address" => Some(("address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"address-type" => Some(("addressType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-version" => Some(("ipVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"prefix-length" => Some(("prefixLength", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"purpose" => Some(("purpose", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"users" => Some(("users", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["address", "address-type", "creation-timestamp", "description", "id", "ip-version", "kind", "name", "network", "network-tier", "prefix-length", "purpose", "region", "self-link", "status", "subnetwork", "users"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Address = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.addresses().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _addresses_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.addresses().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _autoscalers_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.autoscalers().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _autoscalers_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.autoscalers().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("autoscaler").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _autoscalers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.autoscalers().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("autoscaler").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _autoscalers_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.predictive-method" => Some(("autoscalingPolicy.cpuUtilization.predictiveMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.mode" => Some(("autoscalingPolicy.mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.calculated" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.fixed" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.percent" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.time-window-sec" => Some(("autoscalingPolicy.scaleInControl.timeWindowSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"recommended-size" => Some(("recommendedSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "calculated", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "fixed", "id", "kind", "load-balancing-utilization", "max-num-replicas", "max-scaled-in-replicas", "min-num-replicas", "mode", "name", "percent", "predictive-method", "recommended-size", "region", "scale-in-control", "self-link", "status", "target", "time-window-sec", "utilization-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Autoscaler = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.autoscalers().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _autoscalers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.autoscalers().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _autoscalers_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.predictive-method" => Some(("autoscalingPolicy.cpuUtilization.predictiveMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.mode" => Some(("autoscalingPolicy.mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.calculated" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.fixed" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.percent" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.time-window-sec" => Some(("autoscalingPolicy.scaleInControl.timeWindowSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"recommended-size" => Some(("recommendedSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "calculated", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "fixed", "id", "kind", "load-balancing-utilization", "max-num-replicas", "max-scaled-in-replicas", "min-num-replicas", "mode", "name", "percent", "predictive-method", "recommended-size", "region", "scale-in-control", "self-link", "status", "target", "time-window-sec", "utilization-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Autoscaler = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.autoscalers().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"autoscaler" => {
|
|
call = call.autoscaler(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["autoscaler", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _autoscalers_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.predictive-method" => Some(("autoscalingPolicy.cpuUtilization.predictiveMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.mode" => Some(("autoscalingPolicy.mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.calculated" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.fixed" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.percent" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.time-window-sec" => Some(("autoscalingPolicy.scaleInControl.timeWindowSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"recommended-size" => Some(("recommendedSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "calculated", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "fixed", "id", "kind", "load-balancing-utilization", "max-num-replicas", "max-scaled-in-replicas", "min-num-replicas", "mode", "name", "percent", "predictive-method", "recommended-size", "region", "scale-in-control", "self-link", "status", "target", "time-window-sec", "utilization-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Autoscaler = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.autoscalers().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"autoscaler" => {
|
|
call = call.autoscaler(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["autoscaler", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_add_signed_url_key(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"key-value" => Some(("keyValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["key-name", "key-value"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SignedUrlKey = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_buckets().add_signed_url_key(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-bucket").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_buckets().delete(opt.value_of("project").unwrap_or(""), opt.value_of("backend-bucket").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_delete_signed_url_key(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_buckets().delete_signed_url_key(opt.value_of("project").unwrap_or(""), opt.value_of("backend-bucket").unwrap_or(""), opt.value_of("key-name").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_buckets().get(opt.value_of("project").unwrap_or(""), opt.value_of("backend-bucket").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"bucket-name" => Some(("bucketName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCdn", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket-name", "cache-key-policy", "cache-mode", "cdn-policy", "client-ttl", "creation-timestamp", "custom-response-headers", "default-ttl", "description", "edge-security-policy", "enable-cdn", "id", "include-http-headers", "kind", "max-ttl", "name", "negative-caching", "query-string-whitelist", "request-coalescing", "self-link", "serve-while-stale", "signed-url-cache-max-age-sec", "signed-url-key-names"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendBucket = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_buckets().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_buckets().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"bucket-name" => Some(("bucketName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCdn", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket-name", "cache-key-policy", "cache-mode", "cdn-policy", "client-ttl", "creation-timestamp", "custom-response-headers", "default-ttl", "description", "edge-security-policy", "enable-cdn", "id", "include-http-headers", "kind", "max-ttl", "name", "negative-caching", "query-string-whitelist", "request-coalescing", "self-link", "serve-while-stale", "signed-url-cache-max-age-sec", "signed-url-key-names"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendBucket = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_buckets().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-bucket").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_set_edge_security_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["security-policy"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SecurityPolicyReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_buckets().set_edge_security_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-bucket").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_buckets_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"bucket-name" => Some(("bucketName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCdn", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket-name", "cache-key-policy", "cache-mode", "cdn-policy", "client-ttl", "creation-timestamp", "custom-response-headers", "default-ttl", "description", "edge-security-policy", "enable-cdn", "id", "include-http-headers", "kind", "max-ttl", "name", "negative-caching", "query-string-whitelist", "request-coalescing", "self-link", "serve-while-stale", "signed-url-cache-max-age-sec", "signed-url-key-names"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendBucket = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_buckets().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-bucket").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_add_signed_url_key(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"key-name" => Some(("keyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"key-value" => Some(("keyValue", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["key-name", "key-value"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SignedUrlKey = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_services().add_signed_url_key(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_services().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_services().delete(opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_delete_signed_url_key(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_services().delete_signed_url_key(opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""), opt.value_of("key-name").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_services().get(opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_get_health(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"group" => Some(("group", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["group"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ResourceGroupReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_services().get_health(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-host" => Some(("cdnPolicy.cacheKeyPolicy.includeHost", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-named-cookies" => Some(("cdnPolicy.cacheKeyPolicy.includeNamedCookies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-protocol" => Some(("cdnPolicy.cacheKeyPolicy.includeProtocol", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-query-string" => Some(("cdnPolicy.cacheKeyPolicy.includeQueryString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.query-string-blacklist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringBlacklist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"circuit-breakers.max-connections" => Some(("circuitBreakers.maxConnections", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-pending-requests" => Some(("circuitBreakers.maxPendingRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests" => Some(("circuitBreakers.maxRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests-per-connection" => Some(("circuitBreakers.maxRequestsPerConnection", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-retries" => Some(("circuitBreakers.maxRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.connection-persistence-on-unhealthy-backends" => Some(("connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackends", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.enable-strong-affinity" => Some(("connectionTrackingPolicy.enableStrongAffinity", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.idle-timeout-sec" => Some(("connectionTrackingPolicy.idleTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.tracking-mode" => Some(("connectionTrackingPolicy.trackingMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.name" => Some(("consistentHash.httpCookie.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.path" => Some(("consistentHash.httpCookie.path", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.nanos" => Some(("consistentHash.httpCookie.ttl.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.seconds" => Some(("consistentHash.httpCookie.ttl.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-header-name" => Some(("consistentHash.httpHeaderName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.minimum-ring-size" => Some(("consistentHash.minimumRingSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-request-headers" => Some(("customRequestHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.disable-connection-drain-on-failover" => Some(("failoverPolicy.disableConnectionDrainOnFailover", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.drop-traffic-if-unhealthy" => Some(("failoverPolicy.dropTrafficIfUnhealthy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.failover-ratio" => Some(("failoverPolicy.failoverRatio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"iap.enabled" => Some(("iap.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-id" => Some(("iap.oauth2ClientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret" => Some(("iap.oauth2ClientSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret-sha256" => Some(("iap.oauth2ClientSecretSha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"locality-lb-policy" => Some(("localityLbPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.sample-rate" => Some(("logConfig.sampleRate", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.nanos" => Some(("maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.seconds" => Some(("maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.nanos" => Some(("outlierDetection.baseEjectionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.seconds" => Some(("outlierDetection.baseEjectionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-errors" => Some(("outlierDetection.consecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-gateway-failure" => Some(("outlierDetection.consecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-errors" => Some(("outlierDetection.enforcingConsecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-gateway-failure" => Some(("outlierDetection.enforcingConsecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-success-rate" => Some(("outlierDetection.enforcingSuccessRate", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.nanos" => Some(("outlierDetection.interval.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.seconds" => Some(("outlierDetection.interval.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.max-ejection-percent" => Some(("outlierDetection.maxEjectionPercent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-minimum-hosts" => Some(("outlierDetection.successRateMinimumHosts", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-request-volume" => Some(("outlierDetection.successRateRequestVolume", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-stdev-factor" => Some(("outlierDetection.successRateStdevFactor", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.client-tls-policy" => Some(("securitySettings.clientTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.subject-alt-names" => Some(("securitySettings.subjectAltNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subsetting.policy" => Some(("subsetting.policy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "base-ejection-time", "cache-key-policy", "cache-mode", "cdn-policy", "circuit-breakers", "client-tls-policy", "client-ttl", "connection-draining", "connection-persistence-on-unhealthy-backends", "connection-tracking-policy", "consecutive-errors", "consecutive-gateway-failure", "consistent-hash", "creation-timestamp", "custom-request-headers", "custom-response-headers", "default-ttl", "description", "disable-connection-drain-on-failover", "draining-timeout-sec", "drop-traffic-if-unhealthy", "edge-security-policy", "enable", "enable-cdn", "enable-strong-affinity", "enabled", "enforcing-consecutive-errors", "enforcing-consecutive-gateway-failure", "enforcing-success-rate", "failover-policy", "failover-ratio", "fingerprint", "health-checks", "http-cookie", "http-header-name", "iap", "id", "idle-timeout-sec", "include-host", "include-http-headers", "include-named-cookies", "include-protocol", "include-query-string", "interval", "kind", "load-balancing-scheme", "locality-lb-policy", "log-config", "max-connections", "max-ejection-percent", "max-pending-requests", "max-requests", "max-requests-per-connection", "max-retries", "max-stream-duration", "max-ttl", "minimum-ring-size", "name", "nanos", "negative-caching", "network", "oauth2-client-id", "oauth2-client-secret", "oauth2-client-secret-sha256", "outlier-detection", "path", "policy", "port", "port-name", "protocol", "query-string-blacklist", "query-string-whitelist", "region", "request-coalescing", "sample-rate", "seconds", "security-policy", "security-settings", "self-link", "serve-while-stale", "session-affinity", "signed-url-cache-max-age-sec", "signed-url-key-names", "subject-alt-names", "subsetting", "success-rate-minimum-hosts", "success-rate-request-volume", "success-rate-stdev-factor", "timeout-sec", "tracking-mode", "ttl"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendService = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_services().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.backend_services().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-host" => Some(("cdnPolicy.cacheKeyPolicy.includeHost", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-named-cookies" => Some(("cdnPolicy.cacheKeyPolicy.includeNamedCookies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-protocol" => Some(("cdnPolicy.cacheKeyPolicy.includeProtocol", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-query-string" => Some(("cdnPolicy.cacheKeyPolicy.includeQueryString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.query-string-blacklist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringBlacklist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"circuit-breakers.max-connections" => Some(("circuitBreakers.maxConnections", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-pending-requests" => Some(("circuitBreakers.maxPendingRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests" => Some(("circuitBreakers.maxRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests-per-connection" => Some(("circuitBreakers.maxRequestsPerConnection", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-retries" => Some(("circuitBreakers.maxRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.connection-persistence-on-unhealthy-backends" => Some(("connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackends", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.enable-strong-affinity" => Some(("connectionTrackingPolicy.enableStrongAffinity", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.idle-timeout-sec" => Some(("connectionTrackingPolicy.idleTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.tracking-mode" => Some(("connectionTrackingPolicy.trackingMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.name" => Some(("consistentHash.httpCookie.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.path" => Some(("consistentHash.httpCookie.path", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.nanos" => Some(("consistentHash.httpCookie.ttl.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.seconds" => Some(("consistentHash.httpCookie.ttl.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-header-name" => Some(("consistentHash.httpHeaderName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.minimum-ring-size" => Some(("consistentHash.minimumRingSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-request-headers" => Some(("customRequestHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.disable-connection-drain-on-failover" => Some(("failoverPolicy.disableConnectionDrainOnFailover", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.drop-traffic-if-unhealthy" => Some(("failoverPolicy.dropTrafficIfUnhealthy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.failover-ratio" => Some(("failoverPolicy.failoverRatio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"iap.enabled" => Some(("iap.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-id" => Some(("iap.oauth2ClientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret" => Some(("iap.oauth2ClientSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret-sha256" => Some(("iap.oauth2ClientSecretSha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"locality-lb-policy" => Some(("localityLbPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.sample-rate" => Some(("logConfig.sampleRate", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.nanos" => Some(("maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.seconds" => Some(("maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.nanos" => Some(("outlierDetection.baseEjectionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.seconds" => Some(("outlierDetection.baseEjectionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-errors" => Some(("outlierDetection.consecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-gateway-failure" => Some(("outlierDetection.consecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-errors" => Some(("outlierDetection.enforcingConsecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-gateway-failure" => Some(("outlierDetection.enforcingConsecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-success-rate" => Some(("outlierDetection.enforcingSuccessRate", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.nanos" => Some(("outlierDetection.interval.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.seconds" => Some(("outlierDetection.interval.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.max-ejection-percent" => Some(("outlierDetection.maxEjectionPercent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-minimum-hosts" => Some(("outlierDetection.successRateMinimumHosts", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-request-volume" => Some(("outlierDetection.successRateRequestVolume", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-stdev-factor" => Some(("outlierDetection.successRateStdevFactor", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.client-tls-policy" => Some(("securitySettings.clientTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.subject-alt-names" => Some(("securitySettings.subjectAltNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subsetting.policy" => Some(("subsetting.policy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "base-ejection-time", "cache-key-policy", "cache-mode", "cdn-policy", "circuit-breakers", "client-tls-policy", "client-ttl", "connection-draining", "connection-persistence-on-unhealthy-backends", "connection-tracking-policy", "consecutive-errors", "consecutive-gateway-failure", "consistent-hash", "creation-timestamp", "custom-request-headers", "custom-response-headers", "default-ttl", "description", "disable-connection-drain-on-failover", "draining-timeout-sec", "drop-traffic-if-unhealthy", "edge-security-policy", "enable", "enable-cdn", "enable-strong-affinity", "enabled", "enforcing-consecutive-errors", "enforcing-consecutive-gateway-failure", "enforcing-success-rate", "failover-policy", "failover-ratio", "fingerprint", "health-checks", "http-cookie", "http-header-name", "iap", "id", "idle-timeout-sec", "include-host", "include-http-headers", "include-named-cookies", "include-protocol", "include-query-string", "interval", "kind", "load-balancing-scheme", "locality-lb-policy", "log-config", "max-connections", "max-ejection-percent", "max-pending-requests", "max-requests", "max-requests-per-connection", "max-retries", "max-stream-duration", "max-ttl", "minimum-ring-size", "name", "nanos", "negative-caching", "network", "oauth2-client-id", "oauth2-client-secret", "oauth2-client-secret-sha256", "outlier-detection", "path", "policy", "port", "port-name", "protocol", "query-string-blacklist", "query-string-whitelist", "region", "request-coalescing", "sample-rate", "seconds", "security-policy", "security-settings", "self-link", "serve-while-stale", "session-affinity", "signed-url-cache-max-age-sec", "signed-url-key-names", "subject-alt-names", "subsetting", "success-rate-minimum-hosts", "success-rate-request-volume", "success-rate-stdev-factor", "timeout-sec", "tracking-mode", "ttl"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendService = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_services().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_set_edge_security_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["security-policy"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SecurityPolicyReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_services().set_edge_security_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_set_security_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["security-policy"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SecurityPolicyReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_services().set_security_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _backend_services_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-host" => Some(("cdnPolicy.cacheKeyPolicy.includeHost", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-named-cookies" => Some(("cdnPolicy.cacheKeyPolicy.includeNamedCookies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-protocol" => Some(("cdnPolicy.cacheKeyPolicy.includeProtocol", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-query-string" => Some(("cdnPolicy.cacheKeyPolicy.includeQueryString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.query-string-blacklist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringBlacklist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"circuit-breakers.max-connections" => Some(("circuitBreakers.maxConnections", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-pending-requests" => Some(("circuitBreakers.maxPendingRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests" => Some(("circuitBreakers.maxRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests-per-connection" => Some(("circuitBreakers.maxRequestsPerConnection", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-retries" => Some(("circuitBreakers.maxRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.connection-persistence-on-unhealthy-backends" => Some(("connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackends", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.enable-strong-affinity" => Some(("connectionTrackingPolicy.enableStrongAffinity", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.idle-timeout-sec" => Some(("connectionTrackingPolicy.idleTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.tracking-mode" => Some(("connectionTrackingPolicy.trackingMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.name" => Some(("consistentHash.httpCookie.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.path" => Some(("consistentHash.httpCookie.path", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.nanos" => Some(("consistentHash.httpCookie.ttl.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.seconds" => Some(("consistentHash.httpCookie.ttl.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-header-name" => Some(("consistentHash.httpHeaderName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.minimum-ring-size" => Some(("consistentHash.minimumRingSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-request-headers" => Some(("customRequestHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.disable-connection-drain-on-failover" => Some(("failoverPolicy.disableConnectionDrainOnFailover", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.drop-traffic-if-unhealthy" => Some(("failoverPolicy.dropTrafficIfUnhealthy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.failover-ratio" => Some(("failoverPolicy.failoverRatio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"iap.enabled" => Some(("iap.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-id" => Some(("iap.oauth2ClientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret" => Some(("iap.oauth2ClientSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret-sha256" => Some(("iap.oauth2ClientSecretSha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"locality-lb-policy" => Some(("localityLbPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.sample-rate" => Some(("logConfig.sampleRate", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.nanos" => Some(("maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.seconds" => Some(("maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.nanos" => Some(("outlierDetection.baseEjectionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.seconds" => Some(("outlierDetection.baseEjectionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-errors" => Some(("outlierDetection.consecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-gateway-failure" => Some(("outlierDetection.consecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-errors" => Some(("outlierDetection.enforcingConsecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-gateway-failure" => Some(("outlierDetection.enforcingConsecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-success-rate" => Some(("outlierDetection.enforcingSuccessRate", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.nanos" => Some(("outlierDetection.interval.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.seconds" => Some(("outlierDetection.interval.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.max-ejection-percent" => Some(("outlierDetection.maxEjectionPercent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-minimum-hosts" => Some(("outlierDetection.successRateMinimumHosts", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-request-volume" => Some(("outlierDetection.successRateRequestVolume", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-stdev-factor" => Some(("outlierDetection.successRateStdevFactor", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.client-tls-policy" => Some(("securitySettings.clientTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.subject-alt-names" => Some(("securitySettings.subjectAltNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subsetting.policy" => Some(("subsetting.policy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "base-ejection-time", "cache-key-policy", "cache-mode", "cdn-policy", "circuit-breakers", "client-tls-policy", "client-ttl", "connection-draining", "connection-persistence-on-unhealthy-backends", "connection-tracking-policy", "consecutive-errors", "consecutive-gateway-failure", "consistent-hash", "creation-timestamp", "custom-request-headers", "custom-response-headers", "default-ttl", "description", "disable-connection-drain-on-failover", "draining-timeout-sec", "drop-traffic-if-unhealthy", "edge-security-policy", "enable", "enable-cdn", "enable-strong-affinity", "enabled", "enforcing-consecutive-errors", "enforcing-consecutive-gateway-failure", "enforcing-success-rate", "failover-policy", "failover-ratio", "fingerprint", "health-checks", "http-cookie", "http-header-name", "iap", "id", "idle-timeout-sec", "include-host", "include-http-headers", "include-named-cookies", "include-protocol", "include-query-string", "interval", "kind", "load-balancing-scheme", "locality-lb-policy", "log-config", "max-connections", "max-ejection-percent", "max-pending-requests", "max-requests", "max-requests-per-connection", "max-retries", "max-stream-duration", "max-ttl", "minimum-ring-size", "name", "nanos", "negative-caching", "network", "oauth2-client-id", "oauth2-client-secret", "oauth2-client-secret-sha256", "outlier-detection", "path", "policy", "port", "port-name", "protocol", "query-string-blacklist", "query-string-whitelist", "region", "request-coalescing", "sample-rate", "seconds", "security-policy", "security-settings", "self-link", "serve-while-stale", "session-affinity", "signed-url-cache-max-age-sec", "signed-url-key-names", "subject-alt-names", "subsetting", "success-rate-minimum-hosts", "success-rate-request-volume", "success-rate-stdev-factor", "timeout-sec", "tracking-mode", "ttl"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendService = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.backend_services().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disk_types_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.disk_types().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disk_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.disk_types().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk-type").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disk_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.disk_types().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_add_resource_policies(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["resource-policies"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::DisksAddResourcePoliciesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.disks().add_resource_policies(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.disks().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_create_snapshot(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"auto-created" => Some(("autoCreated", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"chain-name" => Some(("chainName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-size-gb" => Some(("diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"download-bytes" => Some(("downloadBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"license-codes" => Some(("licenseCodes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"location-hint" => Some(("locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.kms-key-name" => Some(("snapshotEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.kms-key-service-account" => Some(("snapshotEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.raw-key" => Some(("snapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.rsa-encrypted-key" => Some(("snapshotEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.sha256" => Some(("snapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-name" => Some(("sourceDiskEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-service-account" => Some(("sourceDiskEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.raw-key" => Some(("sourceDiskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.rsa-encrypted-key" => Some(("sourceDiskEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.sha256" => Some(("sourceDiskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-bytes" => Some(("storageBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-bytes-status" => Some(("storageBytesStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-locations" => Some(("storageLocations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["auto-created", "chain-name", "creation-timestamp", "description", "disk-size-gb", "download-bytes", "id", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "license-codes", "licenses", "location-hint", "name", "raw-key", "rsa-encrypted-key", "satisfies-pzs", "self-link", "sha256", "snapshot-encryption-key", "source-disk", "source-disk-encryption-key", "source-disk-id", "status", "storage-bytes", "storage-bytes-status", "storage-locations"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Snapshot = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.disks().create_snapshot(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"guest-flush" => {
|
|
call = call.guest_flush(arg_from_str(value.unwrap_or("false"), err, "guest-flush", "boolean"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["guest-flush", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.disks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.disks().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.disks().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.kms-key-name" => Some(("diskEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.kms-key-service-account" => Some(("diskEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.raw-key" => Some(("diskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.rsa-encrypted-key" => Some(("diskEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.sha256" => Some(("diskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"last-attach-timestamp" => Some(("lastAttachTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"last-detach-timestamp" => Some(("lastDetachTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-codes" => Some(("licenseCodes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"location-hint" => Some(("locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"options" => Some(("options", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"physical-block-size-bytes" => Some(("physicalBlockSizeBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"provisioned-iops" => Some(("provisionedIops", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"replica-zones" => Some(("replicaZones", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"size-gb" => Some(("sizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image" => Some(("sourceImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.kms-key-name" => Some(("sourceImageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.kms-key-service-account" => Some(("sourceImageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.raw-key" => Some(("sourceImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.rsa-encrypted-key" => Some(("sourceImageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.sha256" => Some(("sourceImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-id" => Some(("sourceImageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot" => Some(("sourceSnapshot", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.kms-key-name" => Some(("sourceSnapshotEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.kms-key-service-account" => Some(("sourceSnapshotEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.raw-key" => Some(("sourceSnapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.rsa-encrypted-key" => Some(("sourceSnapshotEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.sha256" => Some(("sourceSnapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-id" => Some(("sourceSnapshotId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-storage-object" => Some(("sourceStorageObject", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"users" => Some(("users", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "disk-encryption-key", "id", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "last-attach-timestamp", "last-detach-timestamp", "license-codes", "licenses", "location-hint", "name", "options", "physical-block-size-bytes", "provisioned-iops", "raw-key", "region", "replica-zones", "resource-policies", "rsa-encrypted-key", "satisfies-pzs", "self-link", "sha256", "size-gb", "source-disk", "source-disk-id", "source-image", "source-image-encryption-key", "source-image-id", "source-snapshot", "source-snapshot-encryption-key", "source-snapshot-id", "source-storage-object", "status", "type", "users", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Disk = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.disks().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"source-image" => {
|
|
call = call.source_image(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id", "source-image"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.disks().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_remove_resource_policies(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["resource-policies"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::DisksRemoveResourcePoliciesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.disks().remove_resource_policies(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_resize(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"size-gb" => Some(("sizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["size-gb"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::DisksResizeRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.disks().resize(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ZoneSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.disks().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ZoneSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.disks().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _disks_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.disks().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _external_vpn_gateways_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.external_vpn_gateways().delete(opt.value_of("project").unwrap_or(""), opt.value_of("external-vpn-gateway").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _external_vpn_gateways_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.external_vpn_gateways().get(opt.value_of("project").unwrap_or(""), opt.value_of("external-vpn-gateway").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _external_vpn_gateways_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"redundancy-type" => Some(("redundancyType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "label-fingerprint", "labels", "name", "redundancy-type", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ExternalVpnGateway = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.external_vpn_gateways().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _external_vpn_gateways_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.external_vpn_gateways().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _external_vpn_gateways_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.external_vpn_gateways().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _external_vpn_gateways_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.external_vpn_gateways().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_add_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"attachment-target" => Some(("attachmentTarget", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"firewall-policy-id" => Some(("firewallPolicyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["attachment-target", "display-name", "firewall-policy-id", "name", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyAssociation = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewall_policies().add_association(request, opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"replace-existing-association" => {
|
|
call = call.replace_existing_association(arg_from_str(value.unwrap_or("false"), err, "replace-existing-association", "boolean"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["replace-existing-association", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_add_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"action" => Some(("action", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"enable-logging" => Some(("enableLogging", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.dest-ip-ranges" => Some(("match.destIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"match.src-ip-ranges" => Some(("match.srcIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"target-resources" => Some(("targetResources", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "description", "dest-ip-ranges", "direction", "disabled", "enable-logging", "kind", "match", "priority", "rule-tuple-count", "src-ip-ranges", "target-resources", "target-service-accounts"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewall_policies().add_rule(request, opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_clone_rules(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().clone_rules(opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"source-firewall-policy" => {
|
|
call = call.source_firewall_policy(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id", "source-firewall-policy"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().delete(opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().get(opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_get_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().get_association(opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"name" => {
|
|
call = call.name(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["name"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().get_iam_policy(opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_get_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().get_rule(opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent" => Some(("parent", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "display-name", "fingerprint", "id", "kind", "name", "parent", "region", "rule-tuple-count", "self-link", "self-link-with-id", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewall_policies().insert(request);
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"parent-id" => {
|
|
call = call.parent_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["parent-id", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().list();
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"parent-id" => {
|
|
call = call.parent_id(value.unwrap_or(""));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "parent-id", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_list_associations(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().list_associations();
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"target-resource" => {
|
|
call = call.target_resource(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["target-resource"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_move(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().move_(opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"parent-id" => {
|
|
call = call.parent_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["parent-id", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent" => Some(("parent", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "display-name", "fingerprint", "id", "kind", "name", "parent", "region", "rule-tuple-count", "self-link", "self-link-with-id", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewall_policies().patch(request, opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_patch_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"action" => Some(("action", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"enable-logging" => Some(("enableLogging", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.dest-ip-ranges" => Some(("match.destIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"match.src-ip-ranges" => Some(("match.srcIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"target-resources" => Some(("targetResources", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "description", "dest-ip-ranges", "direction", "disabled", "enable-logging", "kind", "match", "priority", "rule-tuple-count", "src-ip-ranges", "target-resources", "target-service-accounts"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewall_policies().patch_rule(request, opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_remove_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().remove_association(opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"name" => {
|
|
call = call.name(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["name", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_remove_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewall_policies().remove_rule(opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalOrganizationSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewall_policies().set_iam_policy(request, opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewall_policies_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewall_policies().test_iam_permissions(request, opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewalls_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewalls().delete(opt.value_of("project").unwrap_or(""), opt.value_of("firewall").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewalls_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewalls().get(opt.value_of("project").unwrap_or(""), opt.value_of("firewall").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewalls_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"destination-ranges" => Some(("destinationRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.metadata" => Some(("logConfig.metadata", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-ranges" => Some(("sourceRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"source-service-accounts" => Some(("sourceServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"source-tags" => Some(("sourceTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-tags" => Some(("targetTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "destination-ranges", "direction", "disabled", "enable", "id", "kind", "log-config", "metadata", "name", "network", "priority", "self-link", "source-ranges", "source-service-accounts", "source-tags", "target-service-accounts", "target-tags"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Firewall = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewalls().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewalls_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.firewalls().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewalls_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"destination-ranges" => Some(("destinationRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.metadata" => Some(("logConfig.metadata", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-ranges" => Some(("sourceRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"source-service-accounts" => Some(("sourceServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"source-tags" => Some(("sourceTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-tags" => Some(("targetTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "destination-ranges", "direction", "disabled", "enable", "id", "kind", "log-config", "metadata", "name", "network", "priority", "self-link", "source-ranges", "source-service-accounts", "source-tags", "target-service-accounts", "target-tags"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Firewall = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewalls().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("firewall").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _firewalls_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"destination-ranges" => Some(("destinationRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.metadata" => Some(("logConfig.metadata", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-ranges" => Some(("sourceRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"source-service-accounts" => Some(("sourceServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"source-tags" => Some(("sourceTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-tags" => Some(("targetTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "destination-ranges", "direction", "disabled", "enable", "id", "kind", "log-config", "metadata", "name", "network", "priority", "self-link", "source-ranges", "source-service-accounts", "source-tags", "target-service-accounts", "target-tags"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Firewall = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.firewalls().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("firewall").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _forwarding_rules_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.forwarding_rules().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _forwarding_rules_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.forwarding_rules().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _forwarding_rules_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.forwarding_rules().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _forwarding_rules_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ip-address" => Some(("IPAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-protocol" => Some(("IPProtocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"all-ports" => Some(("allPorts", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"allow-global-access" => Some(("allowGlobalAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"backend-service" => Some(("backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-version" => Some(("ipVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"is-mirroring-collector" => Some(("isMirroringCollector", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port-range" => Some(("portRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ports" => Some(("ports", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"psc-connection-id" => Some(("pscConnectionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-connection-status" => Some(("pscConnectionStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service-label" => Some(("serviceLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service-name" => Some(("serviceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-address", "ip-protocol", "all-ports", "allow-global-access", "backend-service", "creation-timestamp", "description", "fingerprint", "id", "ip-version", "is-mirroring-collector", "kind", "label-fingerprint", "labels", "load-balancing-scheme", "name", "network", "network-tier", "port-range", "ports", "psc-connection-id", "psc-connection-status", "region", "self-link", "service-label", "service-name", "subnetwork", "target"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ForwardingRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.forwarding_rules().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _forwarding_rules_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.forwarding_rules().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _forwarding_rules_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ip-address" => Some(("IPAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-protocol" => Some(("IPProtocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"all-ports" => Some(("allPorts", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"allow-global-access" => Some(("allowGlobalAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"backend-service" => Some(("backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-version" => Some(("ipVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"is-mirroring-collector" => Some(("isMirroringCollector", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port-range" => Some(("portRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ports" => Some(("ports", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"psc-connection-id" => Some(("pscConnectionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-connection-status" => Some(("pscConnectionStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service-label" => Some(("serviceLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service-name" => Some(("serviceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-address", "ip-protocol", "all-ports", "allow-global-access", "backend-service", "creation-timestamp", "description", "fingerprint", "id", "ip-version", "is-mirroring-collector", "kind", "label-fingerprint", "labels", "load-balancing-scheme", "name", "network", "network-tier", "port-range", "ports", "psc-connection-id", "psc-connection-status", "region", "self-link", "service-label", "service-name", "subnetwork", "target"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ForwardingRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.forwarding_rules().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _forwarding_rules_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.forwarding_rules().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _forwarding_rules_set_target(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["target"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.forwarding_rules().set_target(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_addresses_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_addresses().delete(opt.value_of("project").unwrap_or(""), opt.value_of("address").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_addresses_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_addresses().get(opt.value_of("project").unwrap_or(""), opt.value_of("address").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_addresses_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"address" => Some(("address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"address-type" => Some(("addressType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-version" => Some(("ipVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"prefix-length" => Some(("prefixLength", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"purpose" => Some(("purpose", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"users" => Some(("users", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["address", "address-type", "creation-timestamp", "description", "id", "ip-version", "kind", "name", "network", "network-tier", "prefix-length", "purpose", "region", "self-link", "status", "subnetwork", "users"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Address = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_addresses().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_addresses_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_addresses().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_forwarding_rules_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_forwarding_rules().delete(opt.value_of("project").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_forwarding_rules_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_forwarding_rules().get(opt.value_of("project").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_forwarding_rules_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ip-address" => Some(("IPAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-protocol" => Some(("IPProtocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"all-ports" => Some(("allPorts", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"allow-global-access" => Some(("allowGlobalAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"backend-service" => Some(("backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-version" => Some(("ipVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"is-mirroring-collector" => Some(("isMirroringCollector", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port-range" => Some(("portRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ports" => Some(("ports", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"psc-connection-id" => Some(("pscConnectionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-connection-status" => Some(("pscConnectionStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service-label" => Some(("serviceLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service-name" => Some(("serviceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-address", "ip-protocol", "all-ports", "allow-global-access", "backend-service", "creation-timestamp", "description", "fingerprint", "id", "ip-version", "is-mirroring-collector", "kind", "label-fingerprint", "labels", "load-balancing-scheme", "name", "network", "network-tier", "port-range", "ports", "psc-connection-id", "psc-connection-status", "region", "self-link", "service-label", "service-name", "subnetwork", "target"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ForwardingRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_forwarding_rules().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_forwarding_rules_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_forwarding_rules().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_forwarding_rules_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ip-address" => Some(("IPAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-protocol" => Some(("IPProtocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"all-ports" => Some(("allPorts", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"allow-global-access" => Some(("allowGlobalAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"backend-service" => Some(("backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-version" => Some(("ipVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"is-mirroring-collector" => Some(("isMirroringCollector", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port-range" => Some(("portRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ports" => Some(("ports", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"psc-connection-id" => Some(("pscConnectionId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-connection-status" => Some(("pscConnectionStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service-label" => Some(("serviceLabel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service-name" => Some(("serviceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-address", "ip-protocol", "all-ports", "allow-global-access", "backend-service", "creation-timestamp", "description", "fingerprint", "id", "ip-version", "is-mirroring-collector", "kind", "label-fingerprint", "labels", "load-balancing-scheme", "name", "network", "network-tier", "port-range", "ports", "psc-connection-id", "psc-connection-status", "region", "self-link", "service-label", "service-name", "subnetwork", "target"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ForwardingRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_forwarding_rules().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_forwarding_rules_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_forwarding_rules().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_forwarding_rules_set_target(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["target"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_forwarding_rules().set_target(request, opt.value_of("project").unwrap_or(""), opt.value_of("forwarding-rule").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_network_endpoint_groups_attach_network_endpoints(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalNetworkEndpointGroupsAttachEndpointsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_network_endpoint_groups().attach_network_endpoints(request, opt.value_of("project").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_network_endpoint_groups_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_network_endpoint_groups().delete(opt.value_of("project").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_network_endpoint_groups_detach_network_endpoints(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalNetworkEndpointGroupsDetachEndpointsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_network_endpoint_groups().detach_network_endpoints(request, opt.value_of("project").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_network_endpoint_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_network_endpoint_groups().get(opt.value_of("project").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_network_endpoint_groups_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"annotations" => Some(("annotations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"app-engine.service" => Some(("appEngine.service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"app-engine.url-mask" => Some(("appEngine.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"app-engine.version" => Some(("appEngine.version", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-function.function" => Some(("cloudFunction.function", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-function.url-mask" => Some(("cloudFunction.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.service" => Some(("cloudRun.service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.tag" => Some(("cloudRun.tag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.url-mask" => Some(("cloudRun.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-port" => Some(("defaultPort", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-endpoint-type" => Some(("networkEndpointType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-target-service" => Some(("pscTargetService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"size" => Some(("size", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["annotations", "app-engine", "cloud-function", "cloud-run", "creation-timestamp", "default-port", "description", "function", "id", "kind", "name", "network", "network-endpoint-type", "psc-target-service", "region", "self-link", "service", "size", "subnetwork", "tag", "url-mask", "version", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworkEndpointGroup = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_network_endpoint_groups().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_network_endpoint_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_network_endpoint_groups().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_network_endpoint_groups_list_network_endpoints(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_network_endpoint_groups().list_network_endpoints(opt.value_of("project").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_operations_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_operations().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_operations_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_operations().delete(opt.value_of("project").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok(mut response) => {
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_operations().get(opt.value_of("project").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_operations().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_operations_wait(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_operations().wait(opt.value_of("project").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_organization_operations_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_organization_operations().delete(opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"parent-id" => {
|
|
call = call.parent_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["parent-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok(mut response) => {
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_organization_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_organization_operations().get(opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"parent-id" => {
|
|
call = call.parent_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["parent-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_organization_operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_organization_operations().list();
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"parent-id" => {
|
|
call = call.parent_id(value.unwrap_or(""));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "parent-id", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_public_delegated_prefixes_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_public_delegated_prefixes().delete(opt.value_of("project").unwrap_or(""), opt.value_of("public-delegated-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_public_delegated_prefixes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_public_delegated_prefixes().get(opt.value_of("project").unwrap_or(""), opt.value_of("public-delegated-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_public_delegated_prefixes_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"is-live-migration" => Some(("isLiveMigration", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent-prefix" => Some(("parentPrefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "ip-cidr-range", "is-live-migration", "kind", "name", "parent-prefix", "region", "self-link", "status"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::PublicDelegatedPrefix = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_public_delegated_prefixes().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_public_delegated_prefixes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.global_public_delegated_prefixes().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _global_public_delegated_prefixes_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"is-live-migration" => Some(("isLiveMigration", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent-prefix" => Some(("parentPrefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "ip-cidr-range", "is-live-migration", "kind", "name", "parent-prefix", "region", "self-link", "status"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::PublicDelegatedPrefix = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.global_public_delegated_prefixes().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("public-delegated-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _health_checks_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.health_checks().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _health_checks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.health_checks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _health_checks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.health_checks().get(opt.value_of("project").unwrap_or(""), opt.value_of("health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _health_checks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.grpc-service-name" => Some(("grpcHealthCheck.grpcServiceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port" => Some(("grpcHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-name" => Some(("grpcHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-specification" => Some(("grpcHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-specification" => Some(("http2HealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.response" => Some(("http2HealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-specification" => Some(("httpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.response" => Some(("httpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-specification" => Some(("httpsHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.response" => Some(("httpsHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-specification" => Some(("sslHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-specification" => Some(("tcpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "enable", "grpc-health-check", "grpc-service-name", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "log-config", "name", "port", "port-name", "port-specification", "proxy-header", "region", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.health_checks().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _health_checks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.health_checks().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _health_checks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.grpc-service-name" => Some(("grpcHealthCheck.grpcServiceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port" => Some(("grpcHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-name" => Some(("grpcHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-specification" => Some(("grpcHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-specification" => Some(("http2HealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.response" => Some(("http2HealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-specification" => Some(("httpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.response" => Some(("httpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-specification" => Some(("httpsHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.response" => Some(("httpsHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-specification" => Some(("sslHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-specification" => Some(("tcpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "enable", "grpc-health-check", "grpc-service-name", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "log-config", "name", "port", "port-name", "port-specification", "proxy-header", "region", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.health_checks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _health_checks_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.grpc-service-name" => Some(("grpcHealthCheck.grpcServiceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port" => Some(("grpcHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-name" => Some(("grpcHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-specification" => Some(("grpcHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-specification" => Some(("http2HealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.response" => Some(("http2HealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-specification" => Some(("httpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.response" => Some(("httpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-specification" => Some(("httpsHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.response" => Some(("httpsHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-specification" => Some(("sslHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-specification" => Some(("tcpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "enable", "grpc-health-check", "grpc-service-name", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "log-config", "name", "port", "port-name", "port-specification", "proxy-header", "region", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.health_checks().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _http_health_checks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.http_health_checks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("http-health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _http_health_checks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.http_health_checks().get(opt.value_of("project").unwrap_or(""), opt.value_of("http-health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _http_health_checks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HttpHealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.http_health_checks().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _http_health_checks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.http_health_checks().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _http_health_checks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HttpHealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.http_health_checks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("http-health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _http_health_checks_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HttpHealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.http_health_checks().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("http-health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _https_health_checks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.https_health_checks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("https-health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _https_health_checks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.https_health_checks().get(opt.value_of("project").unwrap_or(""), opt.value_of("https-health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _https_health_checks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HttpsHealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.https_health_checks().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _https_health_checks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.https_health_checks().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _https_health_checks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HttpsHealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.https_health_checks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("https-health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _https_health_checks_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"request-path" => Some(("requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "healthy-threshold", "host", "id", "kind", "name", "port", "request-path", "self-link", "timeout-sec", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HttpsHealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.https_health_checks().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("https-health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _image_family_views_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.image_family_views().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("family").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.images().delete(opt.value_of("project").unwrap_or(""), opt.value_of("image").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_deprecate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"deleted" => Some(("deleted", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated" => Some(("deprecated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"obsolete" => Some(("obsolete", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"replacement" => Some(("replacement", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["deleted", "deprecated", "obsolete", "replacement", "state"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::DeprecationStatus = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.images().deprecate(request, opt.value_of("project").unwrap_or(""), opt.value_of("image").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.images().get(opt.value_of("project").unwrap_or(""), opt.value_of("image").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_get_from_family(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.images().get_from_family(opt.value_of("project").unwrap_or(""), opt.value_of("family").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.images().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"archive-size-bytes" => Some(("archiveSizeBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.deleted" => Some(("deprecated.deleted", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.deprecated" => Some(("deprecated.deprecated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.obsolete" => Some(("deprecated.obsolete", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.replacement" => Some(("deprecated.replacement", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.state" => Some(("deprecated.state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-size-gb" => Some(("diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"family" => Some(("family", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.kms-key-name" => Some(("imageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.kms-key-service-account" => Some(("imageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.raw-key" => Some(("imageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.rsa-encrypted-key" => Some(("imageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.sha256" => Some(("imageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"license-codes" => Some(("licenseCodes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"raw-disk.container-type" => Some(("rawDisk.containerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"raw-disk.sha1-checksum" => Some(("rawDisk.sha1Checksum", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"raw-disk.source" => Some(("rawDisk.source", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shielded-instance-initial-state.pk.content" => Some(("shieldedInstanceInitialState.pk.content", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shielded-instance-initial-state.pk.file-type" => Some(("shieldedInstanceInitialState.pk.fileType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-name" => Some(("sourceDiskEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-service-account" => Some(("sourceDiskEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.raw-key" => Some(("sourceDiskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.rsa-encrypted-key" => Some(("sourceDiskEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.sha256" => Some(("sourceDiskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image" => Some(("sourceImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.kms-key-name" => Some(("sourceImageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.kms-key-service-account" => Some(("sourceImageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.raw-key" => Some(("sourceImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.rsa-encrypted-key" => Some(("sourceImageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.sha256" => Some(("sourceImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-id" => Some(("sourceImageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot" => Some(("sourceSnapshot", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.kms-key-name" => Some(("sourceSnapshotEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.kms-key-service-account" => Some(("sourceSnapshotEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.raw-key" => Some(("sourceSnapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.rsa-encrypted-key" => Some(("sourceSnapshotEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.sha256" => Some(("sourceSnapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-id" => Some(("sourceSnapshotId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-type" => Some(("sourceType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-locations" => Some(("storageLocations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["archive-size-bytes", "container-type", "content", "creation-timestamp", "deleted", "deprecated", "description", "disk-size-gb", "family", "file-type", "id", "image-encryption-key", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "license-codes", "licenses", "name", "obsolete", "pk", "raw-disk", "raw-key", "replacement", "rsa-encrypted-key", "satisfies-pzs", "self-link", "sha1-checksum", "sha256", "shielded-instance-initial-state", "source", "source-disk", "source-disk-encryption-key", "source-disk-id", "source-image", "source-image-encryption-key", "source-image-id", "source-snapshot", "source-snapshot-encryption-key", "source-snapshot-id", "source-type", "state", "status", "storage-locations"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Image = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.images().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"force-create" => {
|
|
call = call.force_create(arg_from_str(value.unwrap_or("false"), err, "force-create", "boolean"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["force-create", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.images().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"archive-size-bytes" => Some(("archiveSizeBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.deleted" => Some(("deprecated.deleted", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.deprecated" => Some(("deprecated.deprecated", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.obsolete" => Some(("deprecated.obsolete", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.replacement" => Some(("deprecated.replacement", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deprecated.state" => Some(("deprecated.state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-size-gb" => Some(("diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"family" => Some(("family", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.kms-key-name" => Some(("imageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.kms-key-service-account" => Some(("imageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.raw-key" => Some(("imageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.rsa-encrypted-key" => Some(("imageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"image-encryption-key.sha256" => Some(("imageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"license-codes" => Some(("licenseCodes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"raw-disk.container-type" => Some(("rawDisk.containerType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"raw-disk.sha1-checksum" => Some(("rawDisk.sha1Checksum", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"raw-disk.source" => Some(("rawDisk.source", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shielded-instance-initial-state.pk.content" => Some(("shieldedInstanceInitialState.pk.content", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shielded-instance-initial-state.pk.file-type" => Some(("shieldedInstanceInitialState.pk.fileType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-name" => Some(("sourceDiskEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-service-account" => Some(("sourceDiskEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.raw-key" => Some(("sourceDiskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.rsa-encrypted-key" => Some(("sourceDiskEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.sha256" => Some(("sourceDiskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image" => Some(("sourceImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.kms-key-name" => Some(("sourceImageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.kms-key-service-account" => Some(("sourceImageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.raw-key" => Some(("sourceImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.rsa-encrypted-key" => Some(("sourceImageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.sha256" => Some(("sourceImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-id" => Some(("sourceImageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot" => Some(("sourceSnapshot", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.kms-key-name" => Some(("sourceSnapshotEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.kms-key-service-account" => Some(("sourceSnapshotEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.raw-key" => Some(("sourceSnapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.rsa-encrypted-key" => Some(("sourceSnapshotEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.sha256" => Some(("sourceSnapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-id" => Some(("sourceSnapshotId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-type" => Some(("sourceType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-locations" => Some(("storageLocations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["archive-size-bytes", "container-type", "content", "creation-timestamp", "deleted", "deprecated", "description", "disk-size-gb", "family", "file-type", "id", "image-encryption-key", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "license-codes", "licenses", "name", "obsolete", "pk", "raw-disk", "raw-key", "replacement", "rsa-encrypted-key", "satisfies-pzs", "self-link", "sha1-checksum", "sha256", "shielded-instance-initial-state", "source", "source-disk", "source-disk-encryption-key", "source-disk-id", "source-image", "source-image-encryption-key", "source-image-id", "source-snapshot", "source-snapshot-encryption-key", "source-snapshot-id", "source-type", "state", "status", "storage-locations"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Image = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.images().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("image").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.images().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.images().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _images_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.images().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_abandon_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instances"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersAbandonInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().abandon_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_group_managers().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_apply_updates_to_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"all-instances" => Some(("allInstances", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"minimal-action" => Some(("minimalAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"most-disruptive-allowed-action" => Some(("mostDisruptiveAllowedAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["all-instances", "instances", "minimal-action", "most-disruptive-allowed-action"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersApplyUpdatesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().apply_updates_to_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_create_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersCreateInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().create_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_group_managers().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_delete_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"skip-instances-on-validation-error" => Some(("skipInstancesOnValidationError", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instances", "skip-instances-on-validation-error"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersDeleteInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().delete_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_delete_per_instance_configs(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"names" => Some(("names", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["names"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersDeletePerInstanceConfigsReq = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().delete_per_instance_configs(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_group_managers().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"base-instance-name" => Some(("baseInstanceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"current-actions.abandoning" => Some(("currentActions.abandoning", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.creating" => Some(("currentActions.creating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.creating-without-retries" => Some(("currentActions.creatingWithoutRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.deleting" => Some(("currentActions.deleting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.none" => Some(("currentActions.none", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.recreating" => Some(("currentActions.recreating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.refreshing" => Some(("currentActions.refreshing", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.restarting" => Some(("currentActions.restarting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.resuming" => Some(("currentActions.resuming", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.starting" => Some(("currentActions.starting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.stopping" => Some(("currentActions.stopping", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.suspending" => Some(("currentActions.suspending", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.verifying" => Some(("currentActions.verifying", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"distribution-policy.target-shape" => Some(("distributionPolicy.targetShape", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-group" => Some(("instanceGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-template" => Some(("instanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status.autoscaler" => Some(("status.autoscaler", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status.is-stable" => Some(("status.isStable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.stateful.has-stateful-config" => Some(("status.stateful.hasStatefulConfig", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.stateful.per-instance-configs.all-effective" => Some(("status.stateful.perInstanceConfigs.allEffective", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.version-target.is-reached" => Some(("status.versionTarget.isReached", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"target-pools" => Some(("targetPools", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-size" => Some(("targetSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.instance-redistribution-type" => Some(("updatePolicy.instanceRedistributionType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.calculated" => Some(("updatePolicy.maxSurge.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.fixed" => Some(("updatePolicy.maxSurge.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.percent" => Some(("updatePolicy.maxSurge.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.calculated" => Some(("updatePolicy.maxUnavailable.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.fixed" => Some(("updatePolicy.maxUnavailable.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.percent" => Some(("updatePolicy.maxUnavailable.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.minimal-action" => Some(("updatePolicy.minimalAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.most-disruptive-allowed-action" => Some(("updatePolicy.mostDisruptiveAllowedAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.replacement-method" => Some(("updatePolicy.replacementMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.type" => Some(("updatePolicy.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abandoning", "all-effective", "autoscaler", "base-instance-name", "calculated", "creating", "creating-without-retries", "creation-timestamp", "current-actions", "deleting", "description", "distribution-policy", "fingerprint", "fixed", "has-stateful-config", "id", "instance-group", "instance-redistribution-type", "instance-template", "is-reached", "is-stable", "kind", "max-surge", "max-unavailable", "minimal-action", "most-disruptive-allowed-action", "name", "none", "per-instance-configs", "percent", "recreating", "refreshing", "region", "replacement-method", "restarting", "resuming", "self-link", "starting", "stateful", "status", "stopping", "suspending", "target-pools", "target-shape", "target-size", "type", "update-policy", "verifying", "version-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManager = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_group_managers().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_list_errors(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_group_managers().list_errors(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_list_managed_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_group_managers().list_managed_instances(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_list_per_instance_configs(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_group_managers().list_per_instance_configs(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"base-instance-name" => Some(("baseInstanceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"current-actions.abandoning" => Some(("currentActions.abandoning", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.creating" => Some(("currentActions.creating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.creating-without-retries" => Some(("currentActions.creatingWithoutRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.deleting" => Some(("currentActions.deleting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.none" => Some(("currentActions.none", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.recreating" => Some(("currentActions.recreating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.refreshing" => Some(("currentActions.refreshing", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.restarting" => Some(("currentActions.restarting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.resuming" => Some(("currentActions.resuming", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.starting" => Some(("currentActions.starting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.stopping" => Some(("currentActions.stopping", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.suspending" => Some(("currentActions.suspending", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.verifying" => Some(("currentActions.verifying", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"distribution-policy.target-shape" => Some(("distributionPolicy.targetShape", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-group" => Some(("instanceGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-template" => Some(("instanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status.autoscaler" => Some(("status.autoscaler", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status.is-stable" => Some(("status.isStable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.stateful.has-stateful-config" => Some(("status.stateful.hasStatefulConfig", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.stateful.per-instance-configs.all-effective" => Some(("status.stateful.perInstanceConfigs.allEffective", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.version-target.is-reached" => Some(("status.versionTarget.isReached", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"target-pools" => Some(("targetPools", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-size" => Some(("targetSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.instance-redistribution-type" => Some(("updatePolicy.instanceRedistributionType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.calculated" => Some(("updatePolicy.maxSurge.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.fixed" => Some(("updatePolicy.maxSurge.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.percent" => Some(("updatePolicy.maxSurge.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.calculated" => Some(("updatePolicy.maxUnavailable.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.fixed" => Some(("updatePolicy.maxUnavailable.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.percent" => Some(("updatePolicy.maxUnavailable.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.minimal-action" => Some(("updatePolicy.minimalAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.most-disruptive-allowed-action" => Some(("updatePolicy.mostDisruptiveAllowedAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.replacement-method" => Some(("updatePolicy.replacementMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.type" => Some(("updatePolicy.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abandoning", "all-effective", "autoscaler", "base-instance-name", "calculated", "creating", "creating-without-retries", "creation-timestamp", "current-actions", "deleting", "description", "distribution-policy", "fingerprint", "fixed", "has-stateful-config", "id", "instance-group", "instance-redistribution-type", "instance-template", "is-reached", "is-stable", "kind", "max-surge", "max-unavailable", "minimal-action", "most-disruptive-allowed-action", "name", "none", "per-instance-configs", "percent", "recreating", "refreshing", "region", "replacement-method", "restarting", "resuming", "self-link", "starting", "stateful", "status", "stopping", "suspending", "target-pools", "target-shape", "target-size", "type", "update-policy", "verifying", "version-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManager = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_patch_per_instance_configs(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersPatchPerInstanceConfigsReq = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().patch_per_instance_configs(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_recreate_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instances"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersRecreateInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().recreate_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_resize(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let size: i32 = arg_from_str(&opt.value_of("size").unwrap_or(""), err, "<size>", "integer");
|
|
let mut call = self.hub.instance_group_managers().resize(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""), size);
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_set_instance_template(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instance-template" => Some(("instanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instance-template"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersSetInstanceTemplateRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().set_instance_template(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_set_target_pools(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target-pools" => Some(("targetPools", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "target-pools"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersSetTargetPoolsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().set_target_pools(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_group_managers_update_per_instance_configs(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManagersUpdatePerInstanceConfigsReq = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_group_managers().update_per_instance_configs(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_add_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupsAddInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_groups().add_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_groups().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_groups().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_groups().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"size" => Some(("size", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "kind", "name", "network", "region", "self-link", "size", "subnetwork", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroup = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_groups().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_groups().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_list_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instance-state" => Some(("instanceState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instance-state"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupsListInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_groups().list_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_remove_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupsRemoveInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_groups().remove_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_groups_set_named_ports(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupsSetNamedPortsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_groups().set_named_ports(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_templates_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_templates().delete(opt.value_of("project").unwrap_or(""), opt.value_of("instance-template").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_templates_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_templates().get(opt.value_of("project").unwrap_or(""), opt.value_of("instance-template").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_templates_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_templates().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_templates_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.advanced-machine-features.enable-nested-virtualization" => Some(("properties.advancedMachineFeatures.enableNestedVirtualization", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.advanced-machine-features.enable-uefi-networking" => Some(("properties.advancedMachineFeatures.enableUefiNetworking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.advanced-machine-features.threads-per-core" => Some(("properties.advancedMachineFeatures.threadsPerCore", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"properties.can-ip-forward" => Some(("properties.canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.confidential-instance-config.enable-confidential-compute" => Some(("properties.confidentialInstanceConfig.enableConfidentialCompute", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.description" => Some(("properties.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.labels" => Some(("properties.labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"properties.machine-type" => Some(("properties.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.metadata.fingerprint" => Some(("properties.metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.metadata.kind" => Some(("properties.metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.min-cpu-platform" => Some(("properties.minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.network-performance-config.total-egress-bandwidth-tier" => Some(("properties.networkPerformanceConfig.totalEgressBandwidthTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.private-ipv6-google-access" => Some(("properties.privateIpv6GoogleAccess", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.reservation-affinity.consume-reservation-type" => Some(("properties.reservationAffinity.consumeReservationType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.reservation-affinity.key" => Some(("properties.reservationAffinity.key", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.reservation-affinity.values" => Some(("properties.reservationAffinity.values", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"properties.resource-manager-tags" => Some(("properties.resourceManagerTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"properties.resource-policies" => Some(("properties.resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"properties.scheduling.automatic-restart" => Some(("properties.scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.scheduling.instance-termination-action" => Some(("properties.scheduling.instanceTerminationAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.scheduling.location-hint" => Some(("properties.scheduling.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.scheduling.min-node-cpus" => Some(("properties.scheduling.minNodeCpus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"properties.scheduling.on-host-maintenance" => Some(("properties.scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.scheduling.preemptible" => Some(("properties.scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.scheduling.provisioning-model" => Some(("properties.scheduling.provisioningModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.shielded-instance-config.enable-integrity-monitoring" => Some(("properties.shieldedInstanceConfig.enableIntegrityMonitoring", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.shielded-instance-config.enable-secure-boot" => Some(("properties.shieldedInstanceConfig.enableSecureBoot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.shielded-instance-config.enable-vtpm" => Some(("properties.shieldedInstanceConfig.enableVtpm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"properties.tags.fingerprint" => Some(("properties.tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"properties.tags.items" => Some(("properties.tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance" => Some(("sourceInstance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advanced-machine-features", "automatic-restart", "can-ip-forward", "confidential-instance-config", "consume-reservation-type", "creation-timestamp", "description", "enable-confidential-compute", "enable-integrity-monitoring", "enable-nested-virtualization", "enable-secure-boot", "enable-uefi-networking", "enable-vtpm", "fingerprint", "id", "instance-termination-action", "items", "key", "kind", "labels", "location-hint", "machine-type", "metadata", "min-cpu-platform", "min-node-cpus", "name", "network-performance-config", "on-host-maintenance", "preemptible", "private-ipv6-google-access", "properties", "provisioning-model", "reservation-affinity", "resource-manager-tags", "resource-policies", "scheduling", "self-link", "shielded-instance-config", "source-instance", "tags", "threads-per-core", "total-egress-bandwidth-tier", "values"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceTemplate = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_templates().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_templates_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instance_templates().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_templates_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_templates().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instance_templates_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instance_templates().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_add_access_config(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"external-ipv6" => Some(("externalIpv6", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"external-ipv6-prefix-length" => Some(("externalIpv6PrefixLength", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"nat-ip" => Some(("natIP", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"public-ptr-domain-name" => Some(("publicPtrDomainName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"set-public-ptr" => Some(("setPublicPtr", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["external-ipv6", "external-ipv6-prefix-length", "kind", "name", "nat-ip", "network-tier", "public-ptr-domain-name", "set-public-ptr", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::AccessConfig = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().add_access_config(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("network-interface").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_add_resource_policies(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["resource-policies"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstancesAddResourcePoliciesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().add_resource_policies(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_attach_disk(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"auto-delete" => Some(("autoDelete", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"boot" => Some(("boot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"device-name" => Some(("deviceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.kms-key-name" => Some(("diskEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.kms-key-service-account" => Some(("diskEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.raw-key" => Some(("diskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.rsa-encrypted-key" => Some(("diskEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.sha256" => Some(("diskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-size-gb" => Some(("diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"index" => Some(("index", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"initialize-params.description" => Some(("initializeParams.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.disk-name" => Some(("initializeParams.diskName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.disk-size-gb" => Some(("initializeParams.diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.disk-type" => Some(("initializeParams.diskType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.labels" => Some(("initializeParams.labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"initialize-params.licenses" => Some(("initializeParams.licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"initialize-params.on-update-action" => Some(("initializeParams.onUpdateAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.provisioned-iops" => Some(("initializeParams.provisionedIops", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.resource-policies" => Some(("initializeParams.resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"initialize-params.source-image" => Some(("initializeParams.sourceImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-image-encryption-key.kms-key-name" => Some(("initializeParams.sourceImageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-image-encryption-key.kms-key-service-account" => Some(("initializeParams.sourceImageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-image-encryption-key.raw-key" => Some(("initializeParams.sourceImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-image-encryption-key.rsa-encrypted-key" => Some(("initializeParams.sourceImageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-image-encryption-key.sha256" => Some(("initializeParams.sourceImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-snapshot" => Some(("initializeParams.sourceSnapshot", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-snapshot-encryption-key.kms-key-name" => Some(("initializeParams.sourceSnapshotEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-snapshot-encryption-key.kms-key-service-account" => Some(("initializeParams.sourceSnapshotEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-snapshot-encryption-key.raw-key" => Some(("initializeParams.sourceSnapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-snapshot-encryption-key.rsa-encrypted-key" => Some(("initializeParams.sourceSnapshotEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"initialize-params.source-snapshot-encryption-key.sha256" => Some(("initializeParams.sourceSnapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"interface" => Some(("interface", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"mode" => Some(("mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shielded-instance-initial-state.pk.content" => Some(("shieldedInstanceInitialState.pk.content", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shielded-instance-initial-state.pk.file-type" => Some(("shieldedInstanceInitialState.pk.fileType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source" => Some(("source", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["auto-delete", "boot", "content", "description", "device-name", "disk-encryption-key", "disk-name", "disk-size-gb", "disk-type", "file-type", "index", "initialize-params", "interface", "kind", "kms-key-name", "kms-key-service-account", "labels", "licenses", "mode", "on-update-action", "pk", "provisioned-iops", "raw-key", "resource-policies", "rsa-encrypted-key", "sha256", "shielded-instance-initial-state", "source", "source-image", "source-image-encryption-key", "source-snapshot", "source-snapshot-encryption-key", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::AttachedDisk = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().attach_disk(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"force-attach" => {
|
|
call = call.force_attach(arg_from_str(value.unwrap_or("false"), err, "force-attach", "boolean"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["force-attach", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_bulk_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"count" => Some(("count", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.enable-nested-virtualization" => Some(("instanceProperties.advancedMachineFeatures.enableNestedVirtualization", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.enable-uefi-networking" => Some(("instanceProperties.advancedMachineFeatures.enableUefiNetworking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.threads-per-core" => Some(("instanceProperties.advancedMachineFeatures.threadsPerCore", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"instance-properties.can-ip-forward" => Some(("instanceProperties.canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.confidential-instance-config.enable-confidential-compute" => Some(("instanceProperties.confidentialInstanceConfig.enableConfidentialCompute", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.description" => Some(("instanceProperties.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.labels" => Some(("instanceProperties.labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"instance-properties.machine-type" => Some(("instanceProperties.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.metadata.fingerprint" => Some(("instanceProperties.metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.metadata.kind" => Some(("instanceProperties.metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.min-cpu-platform" => Some(("instanceProperties.minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.network-performance-config.total-egress-bandwidth-tier" => Some(("instanceProperties.networkPerformanceConfig.totalEgressBandwidthTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.private-ipv6-google-access" => Some(("instanceProperties.privateIpv6GoogleAccess", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.consume-reservation-type" => Some(("instanceProperties.reservationAffinity.consumeReservationType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.key" => Some(("instanceProperties.reservationAffinity.key", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.values" => Some(("instanceProperties.reservationAffinity.values", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"instance-properties.resource-manager-tags" => Some(("instanceProperties.resourceManagerTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"instance-properties.resource-policies" => Some(("instanceProperties.resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"instance-properties.scheduling.automatic-restart" => Some(("instanceProperties.scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.instance-termination-action" => Some(("instanceProperties.scheduling.instanceTerminationAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.location-hint" => Some(("instanceProperties.scheduling.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.min-node-cpus" => Some(("instanceProperties.scheduling.minNodeCpus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.on-host-maintenance" => Some(("instanceProperties.scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.preemptible" => Some(("instanceProperties.scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.provisioning-model" => Some(("instanceProperties.scheduling.provisioningModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-integrity-monitoring" => Some(("instanceProperties.shieldedInstanceConfig.enableIntegrityMonitoring", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-secure-boot" => Some(("instanceProperties.shieldedInstanceConfig.enableSecureBoot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-vtpm" => Some(("instanceProperties.shieldedInstanceConfig.enableVtpm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.tags.fingerprint" => Some(("instanceProperties.tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.tags.items" => Some(("instanceProperties.tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"min-count" => Some(("minCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"name-pattern" => Some(("namePattern", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-template" => Some(("sourceInstanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advanced-machine-features", "automatic-restart", "can-ip-forward", "confidential-instance-config", "consume-reservation-type", "count", "description", "enable-confidential-compute", "enable-integrity-monitoring", "enable-nested-virtualization", "enable-secure-boot", "enable-uefi-networking", "enable-vtpm", "fingerprint", "instance-properties", "instance-termination-action", "items", "key", "kind", "labels", "location-hint", "machine-type", "metadata", "min-count", "min-cpu-platform", "min-node-cpus", "name-pattern", "network-performance-config", "on-host-maintenance", "preemptible", "private-ipv6-google-access", "provisioning-model", "reservation-affinity", "resource-manager-tags", "resource-policies", "scheduling", "shielded-instance-config", "source-instance-template", "tags", "threads-per-core", "total-egress-bandwidth-tier", "values"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BulkInsertInstanceResource = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().bulk_insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_delete_access_config(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().delete_access_config(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("access-config").unwrap_or(""), opt.value_of("network-interface").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_detach_disk(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().detach_disk(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("device-name").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_get_effective_firewalls(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().get_effective_firewalls(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("network-interface").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_get_guest_attributes(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().get_guest_attributes(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"variable-key" => {
|
|
call = call.variable_key(value.unwrap_or(""));
|
|
},
|
|
"query-path" => {
|
|
call = call.query_path(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["query-path", "variable-key"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_get_screenshot(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().get_screenshot(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_get_serial_port_output(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().get_serial_port_output(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"start" => {
|
|
call = call.start(value.unwrap_or(""));
|
|
},
|
|
"port" => {
|
|
call = call.port(arg_from_str(value.unwrap_or("-0"), err, "port", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["port", "start"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_get_shielded_instance_identity(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().get_shielded_instance_identity(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"advanced-machine-features.enable-nested-virtualization" => Some(("advancedMachineFeatures.enableNestedVirtualization", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"advanced-machine-features.enable-uefi-networking" => Some(("advancedMachineFeatures.enableUefiNetworking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"advanced-machine-features.threads-per-core" => Some(("advancedMachineFeatures.threadsPerCore", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"can-ip-forward" => Some(("canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"confidential-instance-config.enable-confidential-compute" => Some(("confidentialInstanceConfig.enableConfidentialCompute", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cpu-platform" => Some(("cpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deletion-protection" => Some(("deletionProtection", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-device.enable-display" => Some(("displayDevice.enableDisplay", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"hostname" => Some(("hostname", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"last-start-timestamp" => Some(("lastStartTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"last-stop-timestamp" => Some(("lastStopTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"last-suspended-timestamp" => Some(("lastSuspendedTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"machine-type" => Some(("machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"metadata.fingerprint" => Some(("metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"metadata.kind" => Some(("metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"min-cpu-platform" => Some(("minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-performance-config.total-egress-bandwidth-tier" => Some(("networkPerformanceConfig.totalEgressBandwidthTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"params.resource-manager-tags" => Some(("params.resourceManagerTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"private-ipv6-google-access" => Some(("privateIpv6GoogleAccess", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"reservation-affinity.consume-reservation-type" => Some(("reservationAffinity.consumeReservationType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"reservation-affinity.key" => Some(("reservationAffinity.key", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"reservation-affinity.values" => Some(("reservationAffinity.values", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"scheduling.automatic-restart" => Some(("scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"scheduling.instance-termination-action" => Some(("scheduling.instanceTerminationAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"scheduling.location-hint" => Some(("scheduling.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"scheduling.min-node-cpus" => Some(("scheduling.minNodeCpus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"scheduling.on-host-maintenance" => Some(("scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"scheduling.preemptible" => Some(("scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"scheduling.provisioning-model" => Some(("scheduling.provisioningModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shielded-instance-config.enable-integrity-monitoring" => Some(("shieldedInstanceConfig.enableIntegrityMonitoring", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"shielded-instance-config.enable-secure-boot" => Some(("shieldedInstanceConfig.enableSecureBoot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"shielded-instance-config.enable-vtpm" => Some(("shieldedInstanceConfig.enableVtpm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"shielded-instance-integrity-policy.update-auto-learn-policy" => Some(("shieldedInstanceIntegrityPolicy.updateAutoLearnPolicy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"source-machine-image" => Some(("sourceMachineImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.kms-key-name" => Some(("sourceMachineImageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.kms-key-service-account" => Some(("sourceMachineImageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.raw-key" => Some(("sourceMachineImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.rsa-encrypted-key" => Some(("sourceMachineImageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.sha256" => Some(("sourceMachineImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"start-restricted" => Some(("startRestricted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status-message" => Some(("statusMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tags.fingerprint" => Some(("tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tags.items" => Some(("tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advanced-machine-features", "automatic-restart", "can-ip-forward", "confidential-instance-config", "consume-reservation-type", "cpu-platform", "creation-timestamp", "deletion-protection", "description", "display-device", "enable-confidential-compute", "enable-display", "enable-integrity-monitoring", "enable-nested-virtualization", "enable-secure-boot", "enable-uefi-networking", "enable-vtpm", "fingerprint", "hostname", "id", "instance-termination-action", "items", "key", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "last-start-timestamp", "last-stop-timestamp", "last-suspended-timestamp", "location-hint", "machine-type", "metadata", "min-cpu-platform", "min-node-cpus", "name", "network-performance-config", "on-host-maintenance", "params", "preemptible", "private-ipv6-google-access", "provisioning-model", "raw-key", "reservation-affinity", "resource-manager-tags", "resource-policies", "rsa-encrypted-key", "satisfies-pzs", "scheduling", "self-link", "sha256", "shielded-instance-config", "shielded-instance-integrity-policy", "source-machine-image", "source-machine-image-encryption-key", "start-restricted", "status", "status-message", "tags", "threads-per-core", "total-egress-bandwidth-tier", "update-auto-learn-policy", "values", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Instance = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"source-machine-image" => {
|
|
call = call.source_machine_image(value.unwrap_or(""));
|
|
},
|
|
"source-instance-template" => {
|
|
call = call.source_instance_template(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id", "source-instance-template", "source-machine-image"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_list_referrers(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().list_referrers(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_remove_resource_policies(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["resource-policies"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstancesRemoveResourcePoliciesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().remove_resource_policies(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_reset(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().reset(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_resume(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().resume(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_send_diagnostic_interrupt(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().send_diagnostic_interrupt(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok(mut response) => {
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_deletion_protection(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().set_deletion_protection(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"deletion-protection" => {
|
|
call = call.deletion_protection(arg_from_str(value.unwrap_or("false"), err, "deletion-protection", "boolean"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["deletion-protection", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_disk_auto_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let auto_delete: bool = arg_from_str(&opt.value_of("auto-delete").unwrap_or(""), err, "<auto-delete>", "boolean");
|
|
let mut call = self.hub.instances().set_disk_auto_delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), auto_delete, opt.value_of("device-name").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ZoneSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstancesSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_machine_resources(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstancesSetMachineResourcesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_machine_resources(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_machine_type(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"machine-type" => Some(("machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["machine-type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstancesSetMachineTypeRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_machine_type(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_metadata(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "kind"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Metadata = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_metadata(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_min_cpu_platform(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"min-cpu-platform" => Some(("minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["min-cpu-platform"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstancesSetMinCpuPlatformRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_min_cpu_platform(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_scheduling(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"automatic-restart" => Some(("automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-termination-action" => Some(("instanceTerminationAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"location-hint" => Some(("locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"min-node-cpus" => Some(("minNodeCpus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"on-host-maintenance" => Some(("onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"preemptible" => Some(("preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"provisioning-model" => Some(("provisioningModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["automatic-restart", "instance-termination-action", "location-hint", "min-node-cpus", "on-host-maintenance", "preemptible", "provisioning-model"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Scheduling = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_scheduling(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_service_account(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"email" => Some(("email", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"scopes" => Some(("scopes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["email", "scopes"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstancesSetServiceAccountRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_service_account(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_shielded_instance_integrity_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"update-auto-learn-policy" => Some(("updateAutoLearnPolicy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["update-auto-learn-policy"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ShieldedInstanceIntegrityPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_shielded_instance_integrity_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_set_tags(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"items" => Some(("items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "items"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Tags = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().set_tags(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_simulate_maintenance_event(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().simulate_maintenance_event(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_start(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().start(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_start_with_encryption_key(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstancesStartWithEncryptionKeyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().start_with_encryption_key(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_stop(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().stop(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_suspend(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.instances().suspend(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"advanced-machine-features.enable-nested-virtualization" => Some(("advancedMachineFeatures.enableNestedVirtualization", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"advanced-machine-features.enable-uefi-networking" => Some(("advancedMachineFeatures.enableUefiNetworking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"advanced-machine-features.threads-per-core" => Some(("advancedMachineFeatures.threadsPerCore", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"can-ip-forward" => Some(("canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"confidential-instance-config.enable-confidential-compute" => Some(("confidentialInstanceConfig.enableConfidentialCompute", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cpu-platform" => Some(("cpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"deletion-protection" => Some(("deletionProtection", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-device.enable-display" => Some(("displayDevice.enableDisplay", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"hostname" => Some(("hostname", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"last-start-timestamp" => Some(("lastStartTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"last-stop-timestamp" => Some(("lastStopTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"last-suspended-timestamp" => Some(("lastSuspendedTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"machine-type" => Some(("machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"metadata.fingerprint" => Some(("metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"metadata.kind" => Some(("metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"min-cpu-platform" => Some(("minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-performance-config.total-egress-bandwidth-tier" => Some(("networkPerformanceConfig.totalEgressBandwidthTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"params.resource-manager-tags" => Some(("params.resourceManagerTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"private-ipv6-google-access" => Some(("privateIpv6GoogleAccess", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"reservation-affinity.consume-reservation-type" => Some(("reservationAffinity.consumeReservationType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"reservation-affinity.key" => Some(("reservationAffinity.key", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"reservation-affinity.values" => Some(("reservationAffinity.values", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"scheduling.automatic-restart" => Some(("scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"scheduling.instance-termination-action" => Some(("scheduling.instanceTerminationAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"scheduling.location-hint" => Some(("scheduling.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"scheduling.min-node-cpus" => Some(("scheduling.minNodeCpus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"scheduling.on-host-maintenance" => Some(("scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"scheduling.preemptible" => Some(("scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"scheduling.provisioning-model" => Some(("scheduling.provisioningModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shielded-instance-config.enable-integrity-monitoring" => Some(("shieldedInstanceConfig.enableIntegrityMonitoring", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"shielded-instance-config.enable-secure-boot" => Some(("shieldedInstanceConfig.enableSecureBoot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"shielded-instance-config.enable-vtpm" => Some(("shieldedInstanceConfig.enableVtpm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"shielded-instance-integrity-policy.update-auto-learn-policy" => Some(("shieldedInstanceIntegrityPolicy.updateAutoLearnPolicy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"source-machine-image" => Some(("sourceMachineImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.kms-key-name" => Some(("sourceMachineImageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.kms-key-service-account" => Some(("sourceMachineImageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.raw-key" => Some(("sourceMachineImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.rsa-encrypted-key" => Some(("sourceMachineImageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-machine-image-encryption-key.sha256" => Some(("sourceMachineImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"start-restricted" => Some(("startRestricted", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status-message" => Some(("statusMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tags.fingerprint" => Some(("tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tags.items" => Some(("tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advanced-machine-features", "automatic-restart", "can-ip-forward", "confidential-instance-config", "consume-reservation-type", "cpu-platform", "creation-timestamp", "deletion-protection", "description", "display-device", "enable-confidential-compute", "enable-display", "enable-integrity-monitoring", "enable-nested-virtualization", "enable-secure-boot", "enable-uefi-networking", "enable-vtpm", "fingerprint", "hostname", "id", "instance-termination-action", "items", "key", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "last-start-timestamp", "last-stop-timestamp", "last-suspended-timestamp", "location-hint", "machine-type", "metadata", "min-cpu-platform", "min-node-cpus", "name", "network-performance-config", "on-host-maintenance", "params", "preemptible", "private-ipv6-google-access", "provisioning-model", "raw-key", "reservation-affinity", "resource-manager-tags", "resource-policies", "rsa-encrypted-key", "satisfies-pzs", "scheduling", "self-link", "sha256", "shielded-instance-config", "shielded-instance-integrity-policy", "source-machine-image", "source-machine-image-encryption-key", "start-restricted", "status", "status-message", "tags", "threads-per-core", "total-egress-bandwidth-tier", "update-auto-learn-policy", "values", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Instance = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"most-disruptive-allowed-action" => {
|
|
call = call.most_disruptive_allowed_action(value.unwrap_or(""));
|
|
},
|
|
"minimal-action" => {
|
|
call = call.minimal_action(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["minimal-action", "most-disruptive-allowed-action", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_update_access_config(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"external-ipv6" => Some(("externalIpv6", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"external-ipv6-prefix-length" => Some(("externalIpv6PrefixLength", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"nat-ip" => Some(("natIP", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"public-ptr-domain-name" => Some(("publicPtrDomainName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"set-public-ptr" => Some(("setPublicPtr", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["external-ipv6", "external-ipv6-prefix-length", "kind", "name", "nat-ip", "network-tier", "public-ptr-domain-name", "set-public-ptr", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::AccessConfig = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().update_access_config(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("network-interface").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_update_display_device(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"enable-display" => Some(("enableDisplay", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["enable-display"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::DisplayDevice = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().update_display_device(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_update_network_interface(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"internal-ipv6-prefix-length" => Some(("internalIpv6PrefixLength", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"ipv6-access-type" => Some(("ipv6AccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ipv6-address" => Some(("ipv6Address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-ip" => Some(("networkIP", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"nic-type" => Some(("nicType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"queue-count" => Some(("queueCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"stack-type" => Some(("stackType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "internal-ipv6-prefix-length", "ipv6-access-type", "ipv6-address", "kind", "name", "network", "network-ip", "nic-type", "queue-count", "stack-type", "subnetwork"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworkInterface = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().update_network_interface(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""), opt.value_of("network-interface").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _instances_update_shielded_instance_config(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"enable-integrity-monitoring" => Some(("enableIntegrityMonitoring", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"enable-secure-boot" => Some(("enableSecureBoot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"enable-vtpm" => Some(("enableVtpm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["enable-integrity-monitoring", "enable-secure-boot", "enable-vtpm"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ShieldedInstanceConfig = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.instances().update_shielded_instance_config(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnect_attachments_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnect_attachments().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnect_attachments_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnect_attachments().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("interconnect-attachment").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnect_attachments_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnect_attachments().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("interconnect-attachment").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnect_attachments_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"admin-enabled" => Some(("adminEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"bandwidth" => Some(("bandwidth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"candidate-ipv6-subnets" => Some(("candidateIpv6Subnets", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"candidate-subnets" => Some(("candidateSubnets", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cloud-router-ip-address" => Some(("cloudRouterIpAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-router-ipv6-address" => Some(("cloudRouterIpv6Address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-router-ipv6-interface-id" => Some(("cloudRouterIpv6InterfaceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"customer-router-ip-address" => Some(("customerRouterIpAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"customer-router-ipv6-address" => Some(("customerRouterIpv6Address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"customer-router-ipv6-interface-id" => Some(("customerRouterIpv6InterfaceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"dataplane-version" => Some(("dataplaneVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-availability-domain" => Some(("edgeAvailabilityDomain", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"encryption" => Some(("encryption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"google-reference-id" => Some(("googleReferenceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"interconnect" => Some(("interconnect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ipsec-internal-addresses" => Some(("ipsecInternalAddresses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"mtu" => Some(("mtu", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"operational-status" => Some(("operationalStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"pairing-key" => Some(("pairingKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"partner-asn" => Some(("partnerAsn", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"partner-metadata.interconnect-name" => Some(("partnerMetadata.interconnectName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"partner-metadata.partner-name" => Some(("partnerMetadata.partnerName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"partner-metadata.portal-url" => Some(("partnerMetadata.portalUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"private-interconnect-info.tag8021q" => Some(("privateInterconnectInfo.tag8021q", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"router" => Some(("router", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"stack-type" => Some(("stackType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"vlan-tag8021q" => Some(("vlanTag8021q", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["admin-enabled", "bandwidth", "candidate-ipv6-subnets", "candidate-subnets", "cloud-router-ip-address", "cloud-router-ipv6-address", "cloud-router-ipv6-interface-id", "creation-timestamp", "customer-router-ip-address", "customer-router-ipv6-address", "customer-router-ipv6-interface-id", "dataplane-version", "description", "edge-availability-domain", "encryption", "google-reference-id", "id", "interconnect", "interconnect-name", "ipsec-internal-addresses", "kind", "mtu", "name", "operational-status", "pairing-key", "partner-asn", "partner-metadata", "partner-name", "portal-url", "private-interconnect-info", "region", "router", "satisfies-pzs", "self-link", "stack-type", "state", "tag8021q", "type", "vlan-tag8021q"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InterconnectAttachment = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.interconnect_attachments().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"validate-only" => {
|
|
call = call.validate_only(arg_from_str(value.unwrap_or("false"), err, "validate-only", "boolean"));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id", "validate-only"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnect_attachments_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnect_attachments().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnect_attachments_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"admin-enabled" => Some(("adminEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"bandwidth" => Some(("bandwidth", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"candidate-ipv6-subnets" => Some(("candidateIpv6Subnets", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"candidate-subnets" => Some(("candidateSubnets", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cloud-router-ip-address" => Some(("cloudRouterIpAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-router-ipv6-address" => Some(("cloudRouterIpv6Address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-router-ipv6-interface-id" => Some(("cloudRouterIpv6InterfaceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"customer-router-ip-address" => Some(("customerRouterIpAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"customer-router-ipv6-address" => Some(("customerRouterIpv6Address", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"customer-router-ipv6-interface-id" => Some(("customerRouterIpv6InterfaceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"dataplane-version" => Some(("dataplaneVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-availability-domain" => Some(("edgeAvailabilityDomain", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"encryption" => Some(("encryption", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"google-reference-id" => Some(("googleReferenceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"interconnect" => Some(("interconnect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ipsec-internal-addresses" => Some(("ipsecInternalAddresses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"mtu" => Some(("mtu", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"operational-status" => Some(("operationalStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"pairing-key" => Some(("pairingKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"partner-asn" => Some(("partnerAsn", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"partner-metadata.interconnect-name" => Some(("partnerMetadata.interconnectName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"partner-metadata.partner-name" => Some(("partnerMetadata.partnerName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"partner-metadata.portal-url" => Some(("partnerMetadata.portalUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"private-interconnect-info.tag8021q" => Some(("privateInterconnectInfo.tag8021q", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"router" => Some(("router", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"stack-type" => Some(("stackType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"vlan-tag8021q" => Some(("vlanTag8021q", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["admin-enabled", "bandwidth", "candidate-ipv6-subnets", "candidate-subnets", "cloud-router-ip-address", "cloud-router-ipv6-address", "cloud-router-ipv6-interface-id", "creation-timestamp", "customer-router-ip-address", "customer-router-ipv6-address", "customer-router-ipv6-interface-id", "dataplane-version", "description", "edge-availability-domain", "encryption", "google-reference-id", "id", "interconnect", "interconnect-name", "ipsec-internal-addresses", "kind", "mtu", "name", "operational-status", "pairing-key", "partner-asn", "partner-metadata", "partner-name", "portal-url", "private-interconnect-info", "region", "router", "satisfies-pzs", "self-link", "stack-type", "state", "tag8021q", "type", "vlan-tag8021q"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InterconnectAttachment = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.interconnect_attachments().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("interconnect-attachment").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnect_locations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnect_locations().get(opt.value_of("project").unwrap_or(""), opt.value_of("interconnect-location").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnect_locations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnect_locations().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnects_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnects().delete(opt.value_of("project").unwrap_or(""), opt.value_of("interconnect").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnects_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnects().get(opt.value_of("project").unwrap_or(""), opt.value_of("interconnect").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnects_get_diagnostics(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnects().get_diagnostics(opt.value_of("project").unwrap_or(""), opt.value_of("interconnect").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnects_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"admin-enabled" => Some(("adminEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"customer-name" => Some(("customerName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"google-ip-address" => Some(("googleIpAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"google-reference-id" => Some(("googleReferenceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"interconnect-attachments" => Some(("interconnectAttachments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"interconnect-type" => Some(("interconnectType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"link-type" => Some(("linkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"noc-contact-email" => Some(("nocContactEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"operational-status" => Some(("operationalStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"peer-ip-address" => Some(("peerIpAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"provisioned-link-count" => Some(("provisionedLinkCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"requested-link-count" => Some(("requestedLinkCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["admin-enabled", "creation-timestamp", "customer-name", "description", "google-ip-address", "google-reference-id", "id", "interconnect-attachments", "interconnect-type", "kind", "link-type", "location", "name", "noc-contact-email", "operational-status", "peer-ip-address", "provisioned-link-count", "requested-link-count", "satisfies-pzs", "self-link", "state"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Interconnect = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.interconnects().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnects_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.interconnects().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _interconnects_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"admin-enabled" => Some(("adminEnabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"customer-name" => Some(("customerName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"google-ip-address" => Some(("googleIpAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"google-reference-id" => Some(("googleReferenceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"interconnect-attachments" => Some(("interconnectAttachments", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"interconnect-type" => Some(("interconnectType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"link-type" => Some(("linkType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"location" => Some(("location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"noc-contact-email" => Some(("nocContactEmail", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"operational-status" => Some(("operationalStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"peer-ip-address" => Some(("peerIpAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"provisioned-link-count" => Some(("provisionedLinkCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"requested-link-count" => Some(("requestedLinkCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["admin-enabled", "creation-timestamp", "customer-name", "description", "google-ip-address", "google-reference-id", "id", "interconnect-attachments", "interconnect-type", "kind", "link-type", "location", "name", "noc-contact-email", "operational-status", "peer-ip-address", "provisioned-link-count", "requested-link-count", "satisfies-pzs", "self-link", "state"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Interconnect = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.interconnects().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("interconnect").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _license_codes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.license_codes().get(opt.value_of("project").unwrap_or(""), opt.value_of("license-code").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _license_codes_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.license_codes().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _licenses_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.licenses().delete(opt.value_of("project").unwrap_or(""), opt.value_of("license").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _licenses_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.licenses().get(opt.value_of("project").unwrap_or(""), opt.value_of("license").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _licenses_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.licenses().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _licenses_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"charges-use-fee" => Some(("chargesUseFee", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-code" => Some(("licenseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource-requirements.min-guest-cpu-count" => Some(("resourceRequirements.minGuestCpuCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource-requirements.min-memory-mb" => Some(("resourceRequirements.minMemoryMb", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"transferable" => Some(("transferable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["charges-use-fee", "creation-timestamp", "description", "id", "kind", "license-code", "min-guest-cpu-count", "min-memory-mb", "name", "resource-requirements", "self-link", "transferable"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::License = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.licenses().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _licenses_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.licenses().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _licenses_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.licenses().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _licenses_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.licenses().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_images_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.machine_images().delete(opt.value_of("project").unwrap_or(""), opt.value_of("machine-image").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_images_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.machine_images().get(opt.value_of("project").unwrap_or(""), opt.value_of("machine-image").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_images_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.machine_images().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_images_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"guest-flush" => Some(("guestFlush", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.enable-nested-virtualization" => Some(("instanceProperties.advancedMachineFeatures.enableNestedVirtualization", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.enable-uefi-networking" => Some(("instanceProperties.advancedMachineFeatures.enableUefiNetworking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.threads-per-core" => Some(("instanceProperties.advancedMachineFeatures.threadsPerCore", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"instance-properties.can-ip-forward" => Some(("instanceProperties.canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.confidential-instance-config.enable-confidential-compute" => Some(("instanceProperties.confidentialInstanceConfig.enableConfidentialCompute", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.description" => Some(("instanceProperties.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.labels" => Some(("instanceProperties.labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"instance-properties.machine-type" => Some(("instanceProperties.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.metadata.fingerprint" => Some(("instanceProperties.metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.metadata.kind" => Some(("instanceProperties.metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.min-cpu-platform" => Some(("instanceProperties.minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.network-performance-config.total-egress-bandwidth-tier" => Some(("instanceProperties.networkPerformanceConfig.totalEgressBandwidthTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.private-ipv6-google-access" => Some(("instanceProperties.privateIpv6GoogleAccess", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.consume-reservation-type" => Some(("instanceProperties.reservationAffinity.consumeReservationType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.key" => Some(("instanceProperties.reservationAffinity.key", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.values" => Some(("instanceProperties.reservationAffinity.values", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"instance-properties.resource-manager-tags" => Some(("instanceProperties.resourceManagerTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"instance-properties.resource-policies" => Some(("instanceProperties.resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"instance-properties.scheduling.automatic-restart" => Some(("instanceProperties.scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.instance-termination-action" => Some(("instanceProperties.scheduling.instanceTerminationAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.location-hint" => Some(("instanceProperties.scheduling.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.min-node-cpus" => Some(("instanceProperties.scheduling.minNodeCpus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.on-host-maintenance" => Some(("instanceProperties.scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.preemptible" => Some(("instanceProperties.scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.provisioning-model" => Some(("instanceProperties.scheduling.provisioningModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-integrity-monitoring" => Some(("instanceProperties.shieldedInstanceConfig.enableIntegrityMonitoring", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-secure-boot" => Some(("instanceProperties.shieldedInstanceConfig.enableSecureBoot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-vtpm" => Some(("instanceProperties.shieldedInstanceConfig.enableVtpm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.tags.fingerprint" => Some(("instanceProperties.tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.tags.items" => Some(("instanceProperties.tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"machine-image-encryption-key.kms-key-name" => Some(("machineImageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"machine-image-encryption-key.kms-key-service-account" => Some(("machineImageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"machine-image-encryption-key.raw-key" => Some(("machineImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"machine-image-encryption-key.rsa-encrypted-key" => Some(("machineImageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"machine-image-encryption-key.sha256" => Some(("machineImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance" => Some(("sourceInstance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.can-ip-forward" => Some(("sourceInstanceProperties.canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.deletion-protection" => Some(("sourceInstanceProperties.deletionProtection", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.description" => Some(("sourceInstanceProperties.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.labels" => Some(("sourceInstanceProperties.labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"source-instance-properties.machine-type" => Some(("sourceInstanceProperties.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.metadata.fingerprint" => Some(("sourceInstanceProperties.metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.metadata.kind" => Some(("sourceInstanceProperties.metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.min-cpu-platform" => Some(("sourceInstanceProperties.minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.scheduling.automatic-restart" => Some(("sourceInstanceProperties.scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.scheduling.instance-termination-action" => Some(("sourceInstanceProperties.scheduling.instanceTerminationAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.scheduling.location-hint" => Some(("sourceInstanceProperties.scheduling.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.scheduling.min-node-cpus" => Some(("sourceInstanceProperties.scheduling.minNodeCpus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.scheduling.on-host-maintenance" => Some(("sourceInstanceProperties.scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.scheduling.preemptible" => Some(("sourceInstanceProperties.scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.scheduling.provisioning-model" => Some(("sourceInstanceProperties.scheduling.provisioningModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.tags.fingerprint" => Some(("sourceInstanceProperties.tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-properties.tags.items" => Some(("sourceInstanceProperties.tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-locations" => Some(("storageLocations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"total-storage-bytes" => Some(("totalStorageBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advanced-machine-features", "automatic-restart", "can-ip-forward", "confidential-instance-config", "consume-reservation-type", "creation-timestamp", "deletion-protection", "description", "enable-confidential-compute", "enable-integrity-monitoring", "enable-nested-virtualization", "enable-secure-boot", "enable-uefi-networking", "enable-vtpm", "fingerprint", "guest-flush", "id", "instance-properties", "instance-termination-action", "items", "key", "kind", "kms-key-name", "kms-key-service-account", "labels", "location-hint", "machine-image-encryption-key", "machine-type", "metadata", "min-cpu-platform", "min-node-cpus", "name", "network-performance-config", "on-host-maintenance", "preemptible", "private-ipv6-google-access", "provisioning-model", "raw-key", "reservation-affinity", "resource-manager-tags", "resource-policies", "rsa-encrypted-key", "satisfies-pzs", "scheduling", "self-link", "sha256", "shielded-instance-config", "source-instance", "source-instance-properties", "status", "storage-locations", "tags", "threads-per-core", "total-egress-bandwidth-tier", "total-storage-bytes", "values"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::MachineImage = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.machine_images().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"source-instance" => {
|
|
call = call.source_instance(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id", "source-instance"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_images_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.machine_images().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_images_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.machine_images().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_images_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.machine_images().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_types_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.machine_types().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.machine_types().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("machine-type").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _machine_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.machine_types().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_endpoint_groups().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_attach_network_endpoints(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworkEndpointGroupsAttachEndpointsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_endpoint_groups().attach_network_endpoints(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_endpoint_groups().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_detach_network_endpoints(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworkEndpointGroupsDetachEndpointsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_endpoint_groups().detach_network_endpoints(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_endpoint_groups().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"annotations" => Some(("annotations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"app-engine.service" => Some(("appEngine.service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"app-engine.url-mask" => Some(("appEngine.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"app-engine.version" => Some(("appEngine.version", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-function.function" => Some(("cloudFunction.function", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-function.url-mask" => Some(("cloudFunction.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.service" => Some(("cloudRun.service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.tag" => Some(("cloudRun.tag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.url-mask" => Some(("cloudRun.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-port" => Some(("defaultPort", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-endpoint-type" => Some(("networkEndpointType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-target-service" => Some(("pscTargetService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"size" => Some(("size", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["annotations", "app-engine", "cloud-function", "cloud-run", "creation-timestamp", "default-port", "description", "function", "id", "kind", "name", "network", "network-endpoint-type", "psc-target-service", "region", "self-link", "service", "size", "subnetwork", "tag", "url-mask", "version", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworkEndpointGroup = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_endpoint_groups().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_endpoint_groups().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_list_network_endpoints(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"health-status" => Some(("healthStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["health-status"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworkEndpointGroupsListEndpointsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_endpoint_groups().list_network_endpoints(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_endpoint_groups_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_endpoint_groups().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_add_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"attachment-target" => Some(("attachmentTarget", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"firewall-policy-id" => Some(("firewallPolicyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["attachment-target", "display-name", "firewall-policy-id", "name", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyAssociation = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_firewall_policies().add_association(request, opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"replace-existing-association" => {
|
|
call = call.replace_existing_association(arg_from_str(value.unwrap_or("false"), err, "replace-existing-association", "boolean"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["replace-existing-association", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_add_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"action" => Some(("action", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"enable-logging" => Some(("enableLogging", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.dest-ip-ranges" => Some(("match.destIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"match.src-ip-ranges" => Some(("match.srcIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"target-resources" => Some(("targetResources", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "description", "dest-ip-ranges", "direction", "disabled", "enable-logging", "kind", "match", "priority", "rule-tuple-count", "src-ip-ranges", "target-resources", "target-service-accounts"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_firewall_policies().add_rule(request, opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"min-priority" => {
|
|
call = call.min_priority(arg_from_str(value.unwrap_or("-0"), err, "min-priority", "integer"));
|
|
},
|
|
"max-priority" => {
|
|
call = call.max_priority(arg_from_str(value.unwrap_or("-0"), err, "max-priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["max-priority", "min-priority", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_clone_rules(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().clone_rules(opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"source-firewall-policy" => {
|
|
call = call.source_firewall_policy(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id", "source-firewall-policy"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().get(opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_get_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().get_association(opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"name" => {
|
|
call = call.name(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["name"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_get_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().get_rule(opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent" => Some(("parent", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "display-name", "fingerprint", "id", "kind", "name", "parent", "region", "rule-tuple-count", "self-link", "self-link-with-id", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_firewall_policies().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent" => Some(("parent", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "display-name", "fingerprint", "id", "kind", "name", "parent", "region", "rule-tuple-count", "self-link", "self-link-with-id", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_firewall_policies().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_patch_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"action" => Some(("action", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"enable-logging" => Some(("enableLogging", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.dest-ip-ranges" => Some(("match.destIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"match.src-ip-ranges" => Some(("match.srcIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"target-resources" => Some(("targetResources", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "description", "dest-ip-ranges", "direction", "disabled", "enable-logging", "kind", "match", "priority", "rule-tuple-count", "src-ip-ranges", "target-resources", "target-service-accounts"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_firewall_policies().patch_rule(request, opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_remove_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().remove_association(opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"name" => {
|
|
call = call.name(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["name", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_remove_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.network_firewall_policies().remove_rule(opt.value_of("project").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_firewall_policies().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _network_firewall_policies_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.network_firewall_policies().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_add_peering(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"auto-create-routes" => Some(("autoCreateRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-peering.auto-create-routes" => Some(("networkPeering.autoCreateRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.exchange-subnet-routes" => Some(("networkPeering.exchangeSubnetRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.export-custom-routes" => Some(("networkPeering.exportCustomRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.export-subnet-routes-with-public-ip" => Some(("networkPeering.exportSubnetRoutesWithPublicIp", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.import-custom-routes" => Some(("networkPeering.importCustomRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.import-subnet-routes-with-public-ip" => Some(("networkPeering.importSubnetRoutesWithPublicIp", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.name" => Some(("networkPeering.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-peering.network" => Some(("networkPeering.network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-peering.peer-mtu" => Some(("networkPeering.peerMtu", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"network-peering.state" => Some(("networkPeering.state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-peering.state-details" => Some(("networkPeering.stateDetails", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"peer-network" => Some(("peerNetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["auto-create-routes", "exchange-subnet-routes", "export-custom-routes", "export-subnet-routes-with-public-ip", "import-custom-routes", "import-subnet-routes-with-public-ip", "name", "network", "network-peering", "peer-mtu", "peer-network", "state", "state-details"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworksAddPeeringRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.networks().add_peering(request, opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.networks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.networks().get(opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_get_effective_firewalls(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.networks().get_effective_firewalls(opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"i-pv4-range" => Some(("IPv4Range", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"auto-create-subnetworks" => Some(("autoCreateSubnetworks", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-ula-internal-ipv6" => Some(("enableUlaInternalIpv6", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"gateway-i-pv4" => Some(("gatewayIPv4", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"internal-ipv6-range" => Some(("internalIpv6Range", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"mtu" => Some(("mtu", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-firewall-policy-enforcement-order" => Some(("networkFirewallPolicyEnforcementOrder", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"routing-config.routing-mode" => Some(("routingConfig.routingMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetworks" => Some(("subnetworks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["i-pv4-range", "auto-create-subnetworks", "creation-timestamp", "description", "enable-ula-internal-ipv6", "gateway-i-pv4", "id", "internal-ipv6-range", "kind", "mtu", "name", "network-firewall-policy-enforcement-order", "routing-config", "routing-mode", "self-link", "self-link-with-id", "subnetworks"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Network = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.networks().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.networks().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_list_peering_routes(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.networks().list_peering_routes(opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"region" => {
|
|
call = call.region(value.unwrap_or(""));
|
|
},
|
|
"peering-name" => {
|
|
call = call.peering_name(value.unwrap_or(""));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
"direction" => {
|
|
call = call.direction(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["direction", "filter", "max-results", "order-by", "page-token", "peering-name", "region", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"i-pv4-range" => Some(("IPv4Range", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"auto-create-subnetworks" => Some(("autoCreateSubnetworks", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-ula-internal-ipv6" => Some(("enableUlaInternalIpv6", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"gateway-i-pv4" => Some(("gatewayIPv4", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"internal-ipv6-range" => Some(("internalIpv6Range", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"mtu" => Some(("mtu", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-firewall-policy-enforcement-order" => Some(("networkFirewallPolicyEnforcementOrder", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"routing-config.routing-mode" => Some(("routingConfig.routingMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subnetworks" => Some(("subnetworks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["i-pv4-range", "auto-create-subnetworks", "creation-timestamp", "description", "enable-ula-internal-ipv6", "gateway-i-pv4", "id", "internal-ipv6-range", "kind", "mtu", "name", "network-firewall-policy-enforcement-order", "routing-config", "routing-mode", "self-link", "self-link-with-id", "subnetworks"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Network = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.networks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_remove_peering(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworksRemovePeeringRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.networks().remove_peering(request, opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_switch_to_custom_mode(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.networks().switch_to_custom_mode(opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _networks_update_peering(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"network-peering.auto-create-routes" => Some(("networkPeering.autoCreateRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.exchange-subnet-routes" => Some(("networkPeering.exchangeSubnetRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.export-custom-routes" => Some(("networkPeering.exportCustomRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.export-subnet-routes-with-public-ip" => Some(("networkPeering.exportSubnetRoutesWithPublicIp", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.import-custom-routes" => Some(("networkPeering.importCustomRoutes", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.import-subnet-routes-with-public-ip" => Some(("networkPeering.importSubnetRoutesWithPublicIp", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"network-peering.name" => Some(("networkPeering.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-peering.network" => Some(("networkPeering.network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-peering.peer-mtu" => Some(("networkPeering.peerMtu", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"network-peering.state" => Some(("networkPeering.state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-peering.state-details" => Some(("networkPeering.stateDetails", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["auto-create-routes", "exchange-subnet-routes", "export-custom-routes", "export-subnet-routes-with-public-ip", "import-custom-routes", "import-subnet-routes-with-public-ip", "name", "network", "network-peering", "peer-mtu", "state", "state-details"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworksUpdatePeeringRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.networks().update_peering(request, opt.value_of("project").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_add_nodes(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"additional-node-count" => Some(("additionalNodeCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["additional-node-count"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NodeGroupsAddNodesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_groups().add_nodes(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("node-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_groups().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_groups().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("node-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_delete_nodes(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"nodes" => Some(("nodes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["nodes"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NodeGroupsDeleteNodesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_groups().delete_nodes(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("node-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_groups().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("node-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_groups().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"autoscaling-policy.max-nodes" => Some(("autoscalingPolicy.maxNodes", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.min-nodes" => Some(("autoscalingPolicy.minNodes", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.mode" => Some(("autoscalingPolicy.mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"location-hint" => Some(("locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"maintenance-policy" => Some(("maintenancePolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"maintenance-window.maintenance-duration.nanos" => Some(("maintenanceWindow.maintenanceDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"maintenance-window.maintenance-duration.seconds" => Some(("maintenanceWindow.maintenanceDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"maintenance-window.start-time" => Some(("maintenanceWindow.startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"node-template" => Some(("nodeTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"size" => Some(("size", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "creation-timestamp", "description", "fingerprint", "id", "kind", "location-hint", "maintenance-duration", "maintenance-policy", "maintenance-window", "max-nodes", "min-nodes", "mode", "name", "nanos", "node-template", "seconds", "self-link", "size", "start-time", "status", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NodeGroup = json::value::from_value(object).unwrap();
|
|
let initial_node_count: i32 = arg_from_str(&opt.value_of("initial-node-count").unwrap_or(""), err, "<initial-node-count>", "integer");
|
|
let mut call = self.hub.node_groups().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), initial_node_count);
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_groups().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_list_nodes(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_groups().list_nodes(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("node-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"autoscaling-policy.max-nodes" => Some(("autoscalingPolicy.maxNodes", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.min-nodes" => Some(("autoscalingPolicy.minNodes", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.mode" => Some(("autoscalingPolicy.mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"location-hint" => Some(("locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"maintenance-policy" => Some(("maintenancePolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"maintenance-window.maintenance-duration.nanos" => Some(("maintenanceWindow.maintenanceDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"maintenance-window.maintenance-duration.seconds" => Some(("maintenanceWindow.maintenanceDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"maintenance-window.start-time" => Some(("maintenanceWindow.startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"node-template" => Some(("nodeTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"size" => Some(("size", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "creation-timestamp", "description", "fingerprint", "id", "kind", "location-hint", "maintenance-duration", "maintenance-policy", "maintenance-window", "max-nodes", "min-nodes", "mode", "name", "nanos", "node-template", "seconds", "self-link", "size", "start-time", "status", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NodeGroup = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_groups().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("node-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ZoneSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_groups().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_set_node_template(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"node-template" => Some(("nodeTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["node-template"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NodeGroupsSetNodeTemplateRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_groups().set_node_template(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("node-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_groups_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_groups().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_templates_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_templates().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_templates_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_templates().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("node-template").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_templates_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_templates().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("node-template").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_templates_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_templates().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_templates_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"cpu-overcommit-type" => Some(("cpuOvercommitType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"node-affinity-labels" => Some(("nodeAffinityLabels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"node-type" => Some(("nodeType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"node-type-flexibility.cpus" => Some(("nodeTypeFlexibility.cpus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"node-type-flexibility.local-ssd" => Some(("nodeTypeFlexibility.localSsd", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"node-type-flexibility.memory" => Some(("nodeTypeFlexibility.memory", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"server-binding.type" => Some(("serverBinding.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status-message" => Some(("statusMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["cpu-overcommit-type", "cpus", "creation-timestamp", "description", "id", "kind", "local-ssd", "memory", "name", "node-affinity-labels", "node-type", "node-type-flexibility", "region", "self-link", "server-binding", "status", "status-message", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NodeTemplate = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_templates().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_templates_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_templates().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_templates_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_templates().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_templates_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.node_templates().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_types_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_types().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_types().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("node-type").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _node_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.node_types().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _packet_mirrorings_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.packet_mirrorings().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _packet_mirrorings_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.packet_mirrorings().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("packet-mirroring").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _packet_mirrorings_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.packet_mirrorings().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("packet-mirroring").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _packet_mirrorings_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"collector-ilb.canonical-url" => Some(("collectorIlb.canonicalUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"collector-ilb.url" => Some(("collectorIlb.url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable" => Some(("enable", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"filter.ip-protocols" => Some(("filter.IPProtocols", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"filter.cidr-ranges" => Some(("filter.cidrRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"filter.direction" => Some(("filter.direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"mirrored-resources.tags" => Some(("mirroredResources.tags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network.canonical-url" => Some(("network.canonicalUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network.url" => Some(("network.url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-protocols", "canonical-url", "cidr-ranges", "collector-ilb", "creation-timestamp", "description", "direction", "enable", "filter", "id", "kind", "mirrored-resources", "name", "network", "priority", "region", "self-link", "tags", "url"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::PacketMirroring = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.packet_mirrorings().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _packet_mirrorings_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.packet_mirrorings().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _packet_mirrorings_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"collector-ilb.canonical-url" => Some(("collectorIlb.canonicalUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"collector-ilb.url" => Some(("collectorIlb.url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable" => Some(("enable", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"filter.ip-protocols" => Some(("filter.IPProtocols", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"filter.cidr-ranges" => Some(("filter.cidrRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"filter.direction" => Some(("filter.direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"mirrored-resources.tags" => Some(("mirroredResources.tags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network.canonical-url" => Some(("network.canonicalUrl", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network.url" => Some(("network.url", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-protocols", "canonical-url", "cidr-ranges", "collector-ilb", "creation-timestamp", "description", "direction", "enable", "filter", "id", "kind", "mirrored-resources", "name", "network", "priority", "region", "self-link", "tags", "url"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::PacketMirroring = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.packet_mirrorings().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("packet-mirroring").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _packet_mirrorings_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.packet_mirrorings().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_disable_xpn_host(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.projects().disable_xpn_host(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_disable_xpn_resource(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"xpn-resource.id" => Some(("xpnResource.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"xpn-resource.type" => Some(("xpnResource.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "type", "xpn-resource"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ProjectsDisableXpnResourceRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.projects().disable_xpn_resource(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_enable_xpn_host(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.projects().enable_xpn_host(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_enable_xpn_resource(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"xpn-resource.id" => Some(("xpnResource.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"xpn-resource.type" => Some(("xpnResource.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["id", "type", "xpn-resource"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ProjectsEnableXpnResourceRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.projects().enable_xpn_resource(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.projects().get(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_get_xpn_host(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.projects().get_xpn_host(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_get_xpn_resources(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.projects().get_xpn_resources(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_list_xpn_hosts(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"organization" => Some(("organization", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["organization"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ProjectsListXpnHostsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.projects().list_xpn_hosts(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_move_disk(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"destination-zone" => Some(("destinationZone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target-disk" => Some(("targetDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["destination-zone", "target-disk"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::DiskMoveRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.projects().move_disk(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_move_instance(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"destination-zone" => Some(("destinationZone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target-instance" => Some(("targetInstance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["destination-zone", "target-instance"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceMoveRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.projects().move_instance(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_set_common_instance_metadata(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "kind"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Metadata = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.projects().set_common_instance_metadata(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_set_default_network_tier(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"network-tier" => Some(("networkTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["network-tier"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ProjectsSetDefaultNetworkTierRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.projects().set_default_network_tier(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _projects_set_usage_export_bucket(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"bucket-name" => Some(("bucketName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"report-name-prefix" => Some(("reportNamePrefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["bucket-name", "report-name-prefix"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UsageExportLocation = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.projects().set_usage_export_bucket(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_advertised_prefixes_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.public_advertised_prefixes().delete(opt.value_of("project").unwrap_or(""), opt.value_of("public-advertised-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_advertised_prefixes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.public_advertised_prefixes().get(opt.value_of("project").unwrap_or(""), opt.value_of("public-advertised-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_advertised_prefixes_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"dns-verification-ip" => Some(("dnsVerificationIp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shared-secret" => Some(("sharedSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "dns-verification-ip", "fingerprint", "id", "ip-cidr-range", "kind", "name", "self-link", "shared-secret", "status"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::PublicAdvertisedPrefix = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.public_advertised_prefixes().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_advertised_prefixes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.public_advertised_prefixes().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_advertised_prefixes_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"dns-verification-ip" => Some(("dnsVerificationIp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shared-secret" => Some(("sharedSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "dns-verification-ip", "fingerprint", "id", "ip-cidr-range", "kind", "name", "self-link", "shared-secret", "status"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::PublicAdvertisedPrefix = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.public_advertised_prefixes().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("public-advertised-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_delegated_prefixes_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.public_delegated_prefixes().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_delegated_prefixes_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.public_delegated_prefixes().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("public-delegated-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_delegated_prefixes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.public_delegated_prefixes().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("public-delegated-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_delegated_prefixes_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"is-live-migration" => Some(("isLiveMigration", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent-prefix" => Some(("parentPrefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "ip-cidr-range", "is-live-migration", "kind", "name", "parent-prefix", "region", "self-link", "status"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::PublicDelegatedPrefix = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.public_delegated_prefixes().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_delegated_prefixes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.public_delegated_prefixes().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _public_delegated_prefixes_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"is-live-migration" => Some(("isLiveMigration", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent-prefix" => Some(("parentPrefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "ip-cidr-range", "is-live-migration", "kind", "name", "parent-prefix", "region", "self-link", "status"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::PublicDelegatedPrefix = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.public_delegated_prefixes().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("public-delegated-prefix").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_autoscalers_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_autoscalers().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("autoscaler").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_autoscalers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_autoscalers().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("autoscaler").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_autoscalers_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.predictive-method" => Some(("autoscalingPolicy.cpuUtilization.predictiveMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.mode" => Some(("autoscalingPolicy.mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.calculated" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.fixed" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.percent" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.time-window-sec" => Some(("autoscalingPolicy.scaleInControl.timeWindowSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"recommended-size" => Some(("recommendedSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "calculated", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "fixed", "id", "kind", "load-balancing-utilization", "max-num-replicas", "max-scaled-in-replicas", "min-num-replicas", "mode", "name", "percent", "predictive-method", "recommended-size", "region", "scale-in-control", "self-link", "status", "target", "time-window-sec", "utilization-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Autoscaler = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_autoscalers().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_autoscalers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_autoscalers().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_autoscalers_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.predictive-method" => Some(("autoscalingPolicy.cpuUtilization.predictiveMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.mode" => Some(("autoscalingPolicy.mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.calculated" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.fixed" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.percent" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.time-window-sec" => Some(("autoscalingPolicy.scaleInControl.timeWindowSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"recommended-size" => Some(("recommendedSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "calculated", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "fixed", "id", "kind", "load-balancing-utilization", "max-num-replicas", "max-scaled-in-replicas", "min-num-replicas", "mode", "name", "percent", "predictive-method", "recommended-size", "region", "scale-in-control", "self-link", "status", "target", "time-window-sec", "utilization-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Autoscaler = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_autoscalers().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"autoscaler" => {
|
|
call = call.autoscaler(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["autoscaler", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_autoscalers_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"autoscaling-policy.cool-down-period-sec" => Some(("autoscalingPolicy.coolDownPeriodSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.predictive-method" => Some(("autoscalingPolicy.cpuUtilization.predictiveMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.cpu-utilization.utilization-target" => Some(("autoscalingPolicy.cpuUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.load-balancing-utilization.utilization-target" => Some(("autoscalingPolicy.loadBalancingUtilization.utilizationTarget", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.max-num-replicas" => Some(("autoscalingPolicy.maxNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.min-num-replicas" => Some(("autoscalingPolicy.minNumReplicas", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.mode" => Some(("autoscalingPolicy.mode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.calculated" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.fixed" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.max-scaled-in-replicas.percent" => Some(("autoscalingPolicy.scaleInControl.maxScaledInReplicas.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"autoscaling-policy.scale-in-control.time-window-sec" => Some(("autoscalingPolicy.scaleInControl.timeWindowSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"recommended-size" => Some(("recommendedSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["autoscaling-policy", "calculated", "cool-down-period-sec", "cpu-utilization", "creation-timestamp", "description", "fixed", "id", "kind", "load-balancing-utilization", "max-num-replicas", "max-scaled-in-replicas", "min-num-replicas", "mode", "name", "percent", "predictive-method", "recommended-size", "region", "scale-in-control", "self-link", "status", "target", "time-window-sec", "utilization-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Autoscaler = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_autoscalers().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"autoscaler" => {
|
|
call = call.autoscaler(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["autoscaler", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_backend_services_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_backend_services().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_backend_services_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_backend_services().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_backend_services_get_health(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"group" => Some(("group", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["group"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ResourceGroupReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_backend_services().get_health(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_backend_services_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-host" => Some(("cdnPolicy.cacheKeyPolicy.includeHost", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-named-cookies" => Some(("cdnPolicy.cacheKeyPolicy.includeNamedCookies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-protocol" => Some(("cdnPolicy.cacheKeyPolicy.includeProtocol", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-query-string" => Some(("cdnPolicy.cacheKeyPolicy.includeQueryString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.query-string-blacklist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringBlacklist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"circuit-breakers.max-connections" => Some(("circuitBreakers.maxConnections", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-pending-requests" => Some(("circuitBreakers.maxPendingRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests" => Some(("circuitBreakers.maxRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests-per-connection" => Some(("circuitBreakers.maxRequestsPerConnection", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-retries" => Some(("circuitBreakers.maxRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.connection-persistence-on-unhealthy-backends" => Some(("connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackends", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.enable-strong-affinity" => Some(("connectionTrackingPolicy.enableStrongAffinity", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.idle-timeout-sec" => Some(("connectionTrackingPolicy.idleTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.tracking-mode" => Some(("connectionTrackingPolicy.trackingMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.name" => Some(("consistentHash.httpCookie.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.path" => Some(("consistentHash.httpCookie.path", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.nanos" => Some(("consistentHash.httpCookie.ttl.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.seconds" => Some(("consistentHash.httpCookie.ttl.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-header-name" => Some(("consistentHash.httpHeaderName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.minimum-ring-size" => Some(("consistentHash.minimumRingSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-request-headers" => Some(("customRequestHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.disable-connection-drain-on-failover" => Some(("failoverPolicy.disableConnectionDrainOnFailover", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.drop-traffic-if-unhealthy" => Some(("failoverPolicy.dropTrafficIfUnhealthy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.failover-ratio" => Some(("failoverPolicy.failoverRatio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"iap.enabled" => Some(("iap.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-id" => Some(("iap.oauth2ClientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret" => Some(("iap.oauth2ClientSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret-sha256" => Some(("iap.oauth2ClientSecretSha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"locality-lb-policy" => Some(("localityLbPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.sample-rate" => Some(("logConfig.sampleRate", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.nanos" => Some(("maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.seconds" => Some(("maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.nanos" => Some(("outlierDetection.baseEjectionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.seconds" => Some(("outlierDetection.baseEjectionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-errors" => Some(("outlierDetection.consecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-gateway-failure" => Some(("outlierDetection.consecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-errors" => Some(("outlierDetection.enforcingConsecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-gateway-failure" => Some(("outlierDetection.enforcingConsecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-success-rate" => Some(("outlierDetection.enforcingSuccessRate", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.nanos" => Some(("outlierDetection.interval.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.seconds" => Some(("outlierDetection.interval.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.max-ejection-percent" => Some(("outlierDetection.maxEjectionPercent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-minimum-hosts" => Some(("outlierDetection.successRateMinimumHosts", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-request-volume" => Some(("outlierDetection.successRateRequestVolume", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-stdev-factor" => Some(("outlierDetection.successRateStdevFactor", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.client-tls-policy" => Some(("securitySettings.clientTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.subject-alt-names" => Some(("securitySettings.subjectAltNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subsetting.policy" => Some(("subsetting.policy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "base-ejection-time", "cache-key-policy", "cache-mode", "cdn-policy", "circuit-breakers", "client-tls-policy", "client-ttl", "connection-draining", "connection-persistence-on-unhealthy-backends", "connection-tracking-policy", "consecutive-errors", "consecutive-gateway-failure", "consistent-hash", "creation-timestamp", "custom-request-headers", "custom-response-headers", "default-ttl", "description", "disable-connection-drain-on-failover", "draining-timeout-sec", "drop-traffic-if-unhealthy", "edge-security-policy", "enable", "enable-cdn", "enable-strong-affinity", "enabled", "enforcing-consecutive-errors", "enforcing-consecutive-gateway-failure", "enforcing-success-rate", "failover-policy", "failover-ratio", "fingerprint", "health-checks", "http-cookie", "http-header-name", "iap", "id", "idle-timeout-sec", "include-host", "include-http-headers", "include-named-cookies", "include-protocol", "include-query-string", "interval", "kind", "load-balancing-scheme", "locality-lb-policy", "log-config", "max-connections", "max-ejection-percent", "max-pending-requests", "max-requests", "max-requests-per-connection", "max-retries", "max-stream-duration", "max-ttl", "minimum-ring-size", "name", "nanos", "negative-caching", "network", "oauth2-client-id", "oauth2-client-secret", "oauth2-client-secret-sha256", "outlier-detection", "path", "policy", "port", "port-name", "protocol", "query-string-blacklist", "query-string-whitelist", "region", "request-coalescing", "sample-rate", "seconds", "security-policy", "security-settings", "self-link", "serve-while-stale", "session-affinity", "signed-url-cache-max-age-sec", "signed-url-key-names", "subject-alt-names", "subsetting", "success-rate-minimum-hosts", "success-rate-request-volume", "success-rate-stdev-factor", "timeout-sec", "tracking-mode", "ttl"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendService = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_backend_services().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_backend_services_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_backend_services().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_backend_services_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-host" => Some(("cdnPolicy.cacheKeyPolicy.includeHost", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-named-cookies" => Some(("cdnPolicy.cacheKeyPolicy.includeNamedCookies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-protocol" => Some(("cdnPolicy.cacheKeyPolicy.includeProtocol", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-query-string" => Some(("cdnPolicy.cacheKeyPolicy.includeQueryString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.query-string-blacklist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringBlacklist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"circuit-breakers.max-connections" => Some(("circuitBreakers.maxConnections", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-pending-requests" => Some(("circuitBreakers.maxPendingRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests" => Some(("circuitBreakers.maxRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests-per-connection" => Some(("circuitBreakers.maxRequestsPerConnection", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-retries" => Some(("circuitBreakers.maxRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.connection-persistence-on-unhealthy-backends" => Some(("connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackends", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.enable-strong-affinity" => Some(("connectionTrackingPolicy.enableStrongAffinity", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.idle-timeout-sec" => Some(("connectionTrackingPolicy.idleTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.tracking-mode" => Some(("connectionTrackingPolicy.trackingMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.name" => Some(("consistentHash.httpCookie.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.path" => Some(("consistentHash.httpCookie.path", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.nanos" => Some(("consistentHash.httpCookie.ttl.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.seconds" => Some(("consistentHash.httpCookie.ttl.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-header-name" => Some(("consistentHash.httpHeaderName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.minimum-ring-size" => Some(("consistentHash.minimumRingSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-request-headers" => Some(("customRequestHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.disable-connection-drain-on-failover" => Some(("failoverPolicy.disableConnectionDrainOnFailover", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.drop-traffic-if-unhealthy" => Some(("failoverPolicy.dropTrafficIfUnhealthy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.failover-ratio" => Some(("failoverPolicy.failoverRatio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"iap.enabled" => Some(("iap.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-id" => Some(("iap.oauth2ClientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret" => Some(("iap.oauth2ClientSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret-sha256" => Some(("iap.oauth2ClientSecretSha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"locality-lb-policy" => Some(("localityLbPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.sample-rate" => Some(("logConfig.sampleRate", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.nanos" => Some(("maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.seconds" => Some(("maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.nanos" => Some(("outlierDetection.baseEjectionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.seconds" => Some(("outlierDetection.baseEjectionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-errors" => Some(("outlierDetection.consecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-gateway-failure" => Some(("outlierDetection.consecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-errors" => Some(("outlierDetection.enforcingConsecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-gateway-failure" => Some(("outlierDetection.enforcingConsecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-success-rate" => Some(("outlierDetection.enforcingSuccessRate", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.nanos" => Some(("outlierDetection.interval.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.seconds" => Some(("outlierDetection.interval.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.max-ejection-percent" => Some(("outlierDetection.maxEjectionPercent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-minimum-hosts" => Some(("outlierDetection.successRateMinimumHosts", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-request-volume" => Some(("outlierDetection.successRateRequestVolume", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-stdev-factor" => Some(("outlierDetection.successRateStdevFactor", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.client-tls-policy" => Some(("securitySettings.clientTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.subject-alt-names" => Some(("securitySettings.subjectAltNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subsetting.policy" => Some(("subsetting.policy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "base-ejection-time", "cache-key-policy", "cache-mode", "cdn-policy", "circuit-breakers", "client-tls-policy", "client-ttl", "connection-draining", "connection-persistence-on-unhealthy-backends", "connection-tracking-policy", "consecutive-errors", "consecutive-gateway-failure", "consistent-hash", "creation-timestamp", "custom-request-headers", "custom-response-headers", "default-ttl", "description", "disable-connection-drain-on-failover", "draining-timeout-sec", "drop-traffic-if-unhealthy", "edge-security-policy", "enable", "enable-cdn", "enable-strong-affinity", "enabled", "enforcing-consecutive-errors", "enforcing-consecutive-gateway-failure", "enforcing-success-rate", "failover-policy", "failover-ratio", "fingerprint", "health-checks", "http-cookie", "http-header-name", "iap", "id", "idle-timeout-sec", "include-host", "include-http-headers", "include-named-cookies", "include-protocol", "include-query-string", "interval", "kind", "load-balancing-scheme", "locality-lb-policy", "log-config", "max-connections", "max-ejection-percent", "max-pending-requests", "max-requests", "max-requests-per-connection", "max-retries", "max-stream-duration", "max-ttl", "minimum-ring-size", "name", "nanos", "negative-caching", "network", "oauth2-client-id", "oauth2-client-secret", "oauth2-client-secret-sha256", "outlier-detection", "path", "policy", "port", "port-name", "protocol", "query-string-blacklist", "query-string-whitelist", "region", "request-coalescing", "sample-rate", "seconds", "security-policy", "security-settings", "self-link", "serve-while-stale", "session-affinity", "signed-url-cache-max-age-sec", "signed-url-key-names", "subject-alt-names", "subsetting", "success-rate-minimum-hosts", "success-rate-request-volume", "success-rate-stdev-factor", "timeout-sec", "tracking-mode", "ttl"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendService = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_backend_services().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_backend_services_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"affinity-cookie-ttl-sec" => Some(("affinityCookieTtlSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-host" => Some(("cdnPolicy.cacheKeyPolicy.includeHost", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-http-headers" => Some(("cdnPolicy.cacheKeyPolicy.includeHttpHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-named-cookies" => Some(("cdnPolicy.cacheKeyPolicy.includeNamedCookies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.include-protocol" => Some(("cdnPolicy.cacheKeyPolicy.includeProtocol", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.include-query-string" => Some(("cdnPolicy.cacheKeyPolicy.includeQueryString", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.cache-key-policy.query-string-blacklist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringBlacklist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-key-policy.query-string-whitelist" => Some(("cdnPolicy.cacheKeyPolicy.queryStringWhitelist", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"cdn-policy.cache-mode" => Some(("cdnPolicy.cacheMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.client-ttl" => Some(("cdnPolicy.clientTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.default-ttl" => Some(("cdnPolicy.defaultTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.max-ttl" => Some(("cdnPolicy.maxTtl", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.negative-caching" => Some(("cdnPolicy.negativeCaching", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.request-coalescing" => Some(("cdnPolicy.requestCoalescing", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"cdn-policy.serve-while-stale" => Some(("cdnPolicy.serveWhileStale", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-cache-max-age-sec" => Some(("cdnPolicy.signedUrlCacheMaxAgeSec", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cdn-policy.signed-url-key-names" => Some(("cdnPolicy.signedUrlKeyNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"circuit-breakers.max-connections" => Some(("circuitBreakers.maxConnections", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-pending-requests" => Some(("circuitBreakers.maxPendingRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests" => Some(("circuitBreakers.maxRequests", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-requests-per-connection" => Some(("circuitBreakers.maxRequestsPerConnection", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"circuit-breakers.max-retries" => Some(("circuitBreakers.maxRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-draining.draining-timeout-sec" => Some(("connectionDraining.drainingTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.connection-persistence-on-unhealthy-backends" => Some(("connectionTrackingPolicy.connectionPersistenceOnUnhealthyBackends", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.enable-strong-affinity" => Some(("connectionTrackingPolicy.enableStrongAffinity", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.idle-timeout-sec" => Some(("connectionTrackingPolicy.idleTimeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"connection-tracking-policy.tracking-mode" => Some(("connectionTrackingPolicy.trackingMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.name" => Some(("consistentHash.httpCookie.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.path" => Some(("consistentHash.httpCookie.path", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.nanos" => Some(("consistentHash.httpCookie.ttl.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-cookie.ttl.seconds" => Some(("consistentHash.httpCookie.ttl.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.http-header-name" => Some(("consistentHash.httpHeaderName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consistent-hash.minimum-ring-size" => Some(("consistentHash.minimumRingSize", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-request-headers" => Some(("customRequestHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"custom-response-headers" => Some(("customResponseHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"edge-security-policy" => Some(("edgeSecurityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-cdn" => Some(("enableCDN", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.disable-connection-drain-on-failover" => Some(("failoverPolicy.disableConnectionDrainOnFailover", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.drop-traffic-if-unhealthy" => Some(("failoverPolicy.dropTrafficIfUnhealthy", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"failover-policy.failover-ratio" => Some(("failoverPolicy.failoverRatio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"iap.enabled" => Some(("iap.enabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-id" => Some(("iap.oauth2ClientId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret" => Some(("iap.oauth2ClientSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"iap.oauth2-client-secret-sha256" => Some(("iap.oauth2ClientSecretSha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"load-balancing-scheme" => Some(("loadBalancingScheme", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"locality-lb-policy" => Some(("localityLbPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.sample-rate" => Some(("logConfig.sampleRate", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.nanos" => Some(("maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"max-stream-duration.seconds" => Some(("maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.nanos" => Some(("outlierDetection.baseEjectionTime.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.base-ejection-time.seconds" => Some(("outlierDetection.baseEjectionTime.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-errors" => Some(("outlierDetection.consecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.consecutive-gateway-failure" => Some(("outlierDetection.consecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-errors" => Some(("outlierDetection.enforcingConsecutiveErrors", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-consecutive-gateway-failure" => Some(("outlierDetection.enforcingConsecutiveGatewayFailure", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.enforcing-success-rate" => Some(("outlierDetection.enforcingSuccessRate", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.nanos" => Some(("outlierDetection.interval.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.interval.seconds" => Some(("outlierDetection.interval.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"outlier-detection.max-ejection-percent" => Some(("outlierDetection.maxEjectionPercent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-minimum-hosts" => Some(("outlierDetection.successRateMinimumHosts", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-request-volume" => Some(("outlierDetection.successRateRequestVolume", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"outlier-detection.success-rate-stdev-factor" => Some(("outlierDetection.successRateStdevFactor", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port" => Some(("port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"protocol" => Some(("protocol", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-policy" => Some(("securityPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.client-tls-policy" => Some(("securitySettings.clientTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"security-settings.subject-alt-names" => Some(("securitySettings.subjectAltNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subsetting.policy" => Some(("subsetting.policy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["affinity-cookie-ttl-sec", "base-ejection-time", "cache-key-policy", "cache-mode", "cdn-policy", "circuit-breakers", "client-tls-policy", "client-ttl", "connection-draining", "connection-persistence-on-unhealthy-backends", "connection-tracking-policy", "consecutive-errors", "consecutive-gateway-failure", "consistent-hash", "creation-timestamp", "custom-request-headers", "custom-response-headers", "default-ttl", "description", "disable-connection-drain-on-failover", "draining-timeout-sec", "drop-traffic-if-unhealthy", "edge-security-policy", "enable", "enable-cdn", "enable-strong-affinity", "enabled", "enforcing-consecutive-errors", "enforcing-consecutive-gateway-failure", "enforcing-success-rate", "failover-policy", "failover-ratio", "fingerprint", "health-checks", "http-cookie", "http-header-name", "iap", "id", "idle-timeout-sec", "include-host", "include-http-headers", "include-named-cookies", "include-protocol", "include-query-string", "interval", "kind", "load-balancing-scheme", "locality-lb-policy", "log-config", "max-connections", "max-ejection-percent", "max-pending-requests", "max-requests", "max-requests-per-connection", "max-retries", "max-stream-duration", "max-ttl", "minimum-ring-size", "name", "nanos", "negative-caching", "network", "oauth2-client-id", "oauth2-client-secret", "oauth2-client-secret-sha256", "outlier-detection", "path", "policy", "port", "port-name", "protocol", "query-string-blacklist", "query-string-whitelist", "region", "request-coalescing", "sample-rate", "seconds", "security-policy", "security-settings", "self-link", "serve-while-stale", "session-affinity", "signed-url-cache-max-age-sec", "signed-url-key-names", "subject-alt-names", "subsetting", "success-rate-minimum-hosts", "success-rate-request-volume", "success-rate-stdev-factor", "timeout-sec", "tracking-mode", "ttl"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BackendService = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_backend_services().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("backend-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_commitments_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_commitments().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_commitments_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_commitments().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("commitment").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_commitments_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"auto-renew" => Some(("autoRenew", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"category" => Some(("category", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"end-timestamp" => Some(("endTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-resource.amount" => Some(("licenseResource.amount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-resource.cores-per-license" => Some(("licenseResource.coresPerLicense", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-resource.license" => Some(("licenseResource.license", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"plan" => Some(("plan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"start-timestamp" => Some(("startTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status-message" => Some(("statusMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["amount", "auto-renew", "category", "cores-per-license", "creation-timestamp", "description", "end-timestamp", "id", "kind", "license", "license-resource", "name", "plan", "region", "self-link", "start-timestamp", "status", "status-message", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Commitment = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_commitments().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_commitments_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_commitments().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_commitments_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"auto-renew" => Some(("autoRenew", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"category" => Some(("category", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"end-timestamp" => Some(("endTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-resource.amount" => Some(("licenseResource.amount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-resource.cores-per-license" => Some(("licenseResource.coresPerLicense", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-resource.license" => Some(("licenseResource.license", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"plan" => Some(("plan", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"start-timestamp" => Some(("startTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status-message" => Some(("statusMessage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["amount", "auto-renew", "category", "cores-per-license", "creation-timestamp", "description", "end-timestamp", "id", "kind", "license", "license-resource", "name", "plan", "region", "self-link", "start-timestamp", "status", "status-message", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Commitment = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_commitments().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("commitment").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"update-mask" => {
|
|
call = call.update_mask(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"paths" => {
|
|
call = call.add_paths(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["paths", "request-id", "update-mask"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disk_types_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_disk_types().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("disk-type").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disk_types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_disk_types().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_add_resource_policies(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["resource-policies"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionDisksAddResourcePoliciesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_disks().add_resource_policies(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_create_snapshot(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"auto-created" => Some(("autoCreated", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"chain-name" => Some(("chainName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-size-gb" => Some(("diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"download-bytes" => Some(("downloadBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"license-codes" => Some(("licenseCodes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"location-hint" => Some(("locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.kms-key-name" => Some(("snapshotEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.kms-key-service-account" => Some(("snapshotEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.raw-key" => Some(("snapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.rsa-encrypted-key" => Some(("snapshotEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.sha256" => Some(("snapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-name" => Some(("sourceDiskEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-service-account" => Some(("sourceDiskEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.raw-key" => Some(("sourceDiskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.rsa-encrypted-key" => Some(("sourceDiskEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.sha256" => Some(("sourceDiskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-bytes" => Some(("storageBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-bytes-status" => Some(("storageBytesStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-locations" => Some(("storageLocations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["auto-created", "chain-name", "creation-timestamp", "description", "disk-size-gb", "download-bytes", "id", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "license-codes", "licenses", "location-hint", "name", "raw-key", "rsa-encrypted-key", "satisfies-pzs", "self-link", "sha256", "snapshot-encryption-key", "source-disk", "source-disk-encryption-key", "source-disk-id", "status", "storage-bytes", "storage-bytes-status", "storage-locations"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Snapshot = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_disks().create_snapshot(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_disks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_disks().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_disks().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.kms-key-name" => Some(("diskEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.kms-key-service-account" => Some(("diskEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.raw-key" => Some(("diskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.rsa-encrypted-key" => Some(("diskEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-encryption-key.sha256" => Some(("diskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"last-attach-timestamp" => Some(("lastAttachTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"last-detach-timestamp" => Some(("lastDetachTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"license-codes" => Some(("licenseCodes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"location-hint" => Some(("locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"options" => Some(("options", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"physical-block-size-bytes" => Some(("physicalBlockSizeBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"provisioned-iops" => Some(("provisionedIops", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"replica-zones" => Some(("replicaZones", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"size-gb" => Some(("sizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image" => Some(("sourceImage", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.kms-key-name" => Some(("sourceImageEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.kms-key-service-account" => Some(("sourceImageEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.raw-key" => Some(("sourceImageEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.rsa-encrypted-key" => Some(("sourceImageEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-encryption-key.sha256" => Some(("sourceImageEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-image-id" => Some(("sourceImageId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot" => Some(("sourceSnapshot", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.kms-key-name" => Some(("sourceSnapshotEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.kms-key-service-account" => Some(("sourceSnapshotEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.raw-key" => Some(("sourceSnapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.rsa-encrypted-key" => Some(("sourceSnapshotEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-encryption-key.sha256" => Some(("sourceSnapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-snapshot-id" => Some(("sourceSnapshotId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-storage-object" => Some(("sourceStorageObject", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"users" => Some(("users", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "disk-encryption-key", "id", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "last-attach-timestamp", "last-detach-timestamp", "license-codes", "licenses", "location-hint", "name", "options", "physical-block-size-bytes", "provisioned-iops", "raw-key", "region", "replica-zones", "resource-policies", "rsa-encrypted-key", "satisfies-pzs", "self-link", "sha256", "size-gb", "source-disk", "source-disk-id", "source-image", "source-image-encryption-key", "source-image-id", "source-snapshot", "source-snapshot-encryption-key", "source-snapshot-id", "source-storage-object", "status", "type", "users", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Disk = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_disks().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"source-image" => {
|
|
call = call.source_image(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id", "source-image"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_disks().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_remove_resource_policies(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"resource-policies" => Some(("resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["resource-policies"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionDisksRemoveResourcePoliciesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_disks().remove_resource_policies(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_resize(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"size-gb" => Some(("sizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["size-gb"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionDisksResizeRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_disks().resize(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("disk").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_disks().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_disks().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_disks_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_disks().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_check_services_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_health_check_services().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("health-check-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_check_services_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_health_check_services().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("health-check-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_check_services_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"health-status-aggregation-policy" => Some(("healthStatusAggregationPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-endpoint-groups" => Some(("networkEndpointGroups", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"notification-endpoints" => Some(("notificationEndpoints", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "health-checks", "health-status-aggregation-policy", "id", "kind", "name", "network-endpoint-groups", "notification-endpoints", "region", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HealthCheckService = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_health_check_services().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_check_services_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_health_check_services().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_check_services_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"health-status-aggregation-policy" => Some(("healthStatusAggregationPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-endpoint-groups" => Some(("networkEndpointGroups", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"notification-endpoints" => Some(("notificationEndpoints", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "health-checks", "health-status-aggregation-policy", "id", "kind", "name", "network-endpoint-groups", "notification-endpoints", "region", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HealthCheckService = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_health_check_services().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("health-check-service").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_checks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_health_checks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_checks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_health_checks().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_checks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.grpc-service-name" => Some(("grpcHealthCheck.grpcServiceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port" => Some(("grpcHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-name" => Some(("grpcHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-specification" => Some(("grpcHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-specification" => Some(("http2HealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.response" => Some(("http2HealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-specification" => Some(("httpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.response" => Some(("httpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-specification" => Some(("httpsHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.response" => Some(("httpsHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-specification" => Some(("sslHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-specification" => Some(("tcpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "enable", "grpc-health-check", "grpc-service-name", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "log-config", "name", "port", "port-name", "port-specification", "proxy-header", "region", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_health_checks().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_checks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_health_checks().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_checks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.grpc-service-name" => Some(("grpcHealthCheck.grpcServiceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port" => Some(("grpcHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-name" => Some(("grpcHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-specification" => Some(("grpcHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-specification" => Some(("http2HealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.response" => Some(("http2HealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-specification" => Some(("httpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.response" => Some(("httpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-specification" => Some(("httpsHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.response" => Some(("httpsHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-specification" => Some(("sslHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-specification" => Some(("tcpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "enable", "grpc-health-check", "grpc-service-name", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "log-config", "name", "port", "port-name", "port-specification", "proxy-header", "region", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_health_checks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_health_checks_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"check-interval-sec" => Some(("checkIntervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.grpc-service-name" => Some(("grpcHealthCheck.grpcServiceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port" => Some(("grpcHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-name" => Some(("grpcHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-health-check.port-specification" => Some(("grpcHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"healthy-threshold" => Some(("healthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.host" => Some(("http2HealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port" => Some(("http2HealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-name" => Some(("http2HealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.port-specification" => Some(("http2HealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.proxy-header" => Some(("http2HealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.request-path" => Some(("http2HealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http2-health-check.response" => Some(("http2HealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.host" => Some(("httpHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port" => Some(("httpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-name" => Some(("httpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.port-specification" => Some(("httpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.proxy-header" => Some(("httpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.request-path" => Some(("httpHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"http-health-check.response" => Some(("httpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.host" => Some(("httpsHealthCheck.host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port" => Some(("httpsHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-name" => Some(("httpsHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.port-specification" => Some(("httpsHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.proxy-header" => Some(("httpsHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.request-path" => Some(("httpsHealthCheck.requestPath", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"https-health-check.response" => Some(("httpsHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port" => Some(("sslHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-name" => Some(("sslHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.port-specification" => Some(("sslHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.proxy-header" => Some(("sslHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.request" => Some(("sslHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-health-check.response" => Some(("sslHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port" => Some(("tcpHealthCheck.port", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-name" => Some(("tcpHealthCheck.portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.port-specification" => Some(("tcpHealthCheck.portSpecification", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.proxy-header" => Some(("tcpHealthCheck.proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.request" => Some(("tcpHealthCheck.request", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tcp-health-check.response" => Some(("tcpHealthCheck.response", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"timeout-sec" => Some(("timeoutSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"unhealthy-threshold" => Some(("unhealthyThreshold", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["check-interval-sec", "creation-timestamp", "description", "enable", "grpc-health-check", "grpc-service-name", "healthy-threshold", "host", "http2-health-check", "http-health-check", "https-health-check", "id", "kind", "log-config", "name", "port", "port-name", "port-specification", "proxy-header", "region", "request", "request-path", "response", "self-link", "ssl-health-check", "tcp-health-check", "timeout-sec", "type", "unhealthy-threshold"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::HealthCheck = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_health_checks().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("health-check").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_abandon_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instances"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagersAbandonInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().abandon_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_apply_updates_to_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"all-instances" => Some(("allInstances", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"minimal-action" => Some(("minimalAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"most-disruptive-allowed-action" => Some(("mostDisruptiveAllowedAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["all-instances", "instances", "minimal-action", "most-disruptive-allowed-action"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagersApplyUpdatesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().apply_updates_to_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_create_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagersCreateInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().create_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_instance_group_managers().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_delete_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"skip-instances-on-validation-error" => Some(("skipInstancesOnValidationError", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instances", "skip-instances-on-validation-error"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagersDeleteInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().delete_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_delete_per_instance_configs(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"names" => Some(("names", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["names"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagerDeleteInstanceConfigReq = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().delete_per_instance_configs(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_instance_group_managers().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"base-instance-name" => Some(("baseInstanceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"current-actions.abandoning" => Some(("currentActions.abandoning", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.creating" => Some(("currentActions.creating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.creating-without-retries" => Some(("currentActions.creatingWithoutRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.deleting" => Some(("currentActions.deleting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.none" => Some(("currentActions.none", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.recreating" => Some(("currentActions.recreating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.refreshing" => Some(("currentActions.refreshing", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.restarting" => Some(("currentActions.restarting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.resuming" => Some(("currentActions.resuming", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.starting" => Some(("currentActions.starting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.stopping" => Some(("currentActions.stopping", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.suspending" => Some(("currentActions.suspending", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.verifying" => Some(("currentActions.verifying", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"distribution-policy.target-shape" => Some(("distributionPolicy.targetShape", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-group" => Some(("instanceGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-template" => Some(("instanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status.autoscaler" => Some(("status.autoscaler", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status.is-stable" => Some(("status.isStable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.stateful.has-stateful-config" => Some(("status.stateful.hasStatefulConfig", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.stateful.per-instance-configs.all-effective" => Some(("status.stateful.perInstanceConfigs.allEffective", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.version-target.is-reached" => Some(("status.versionTarget.isReached", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"target-pools" => Some(("targetPools", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-size" => Some(("targetSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.instance-redistribution-type" => Some(("updatePolicy.instanceRedistributionType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.calculated" => Some(("updatePolicy.maxSurge.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.fixed" => Some(("updatePolicy.maxSurge.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.percent" => Some(("updatePolicy.maxSurge.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.calculated" => Some(("updatePolicy.maxUnavailable.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.fixed" => Some(("updatePolicy.maxUnavailable.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.percent" => Some(("updatePolicy.maxUnavailable.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.minimal-action" => Some(("updatePolicy.minimalAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.most-disruptive-allowed-action" => Some(("updatePolicy.mostDisruptiveAllowedAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.replacement-method" => Some(("updatePolicy.replacementMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.type" => Some(("updatePolicy.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abandoning", "all-effective", "autoscaler", "base-instance-name", "calculated", "creating", "creating-without-retries", "creation-timestamp", "current-actions", "deleting", "description", "distribution-policy", "fingerprint", "fixed", "has-stateful-config", "id", "instance-group", "instance-redistribution-type", "instance-template", "is-reached", "is-stable", "kind", "max-surge", "max-unavailable", "minimal-action", "most-disruptive-allowed-action", "name", "none", "per-instance-configs", "percent", "recreating", "refreshing", "region", "replacement-method", "restarting", "resuming", "self-link", "starting", "stateful", "status", "stopping", "suspending", "target-pools", "target-shape", "target-size", "type", "update-policy", "verifying", "version-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManager = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_instance_group_managers().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_list_errors(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_instance_group_managers().list_errors(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_list_managed_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_instance_group_managers().list_managed_instances(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_list_per_instance_configs(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_instance_group_managers().list_per_instance_configs(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"base-instance-name" => Some(("baseInstanceName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"current-actions.abandoning" => Some(("currentActions.abandoning", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.creating" => Some(("currentActions.creating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.creating-without-retries" => Some(("currentActions.creatingWithoutRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.deleting" => Some(("currentActions.deleting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.none" => Some(("currentActions.none", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.recreating" => Some(("currentActions.recreating", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.refreshing" => Some(("currentActions.refreshing", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.restarting" => Some(("currentActions.restarting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.resuming" => Some(("currentActions.resuming", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.starting" => Some(("currentActions.starting", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.stopping" => Some(("currentActions.stopping", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.suspending" => Some(("currentActions.suspending", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"current-actions.verifying" => Some(("currentActions.verifying", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"distribution-policy.target-shape" => Some(("distributionPolicy.targetShape", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-group" => Some(("instanceGroup", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-template" => Some(("instanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status.autoscaler" => Some(("status.autoscaler", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status.is-stable" => Some(("status.isStable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.stateful.has-stateful-config" => Some(("status.stateful.hasStatefulConfig", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.stateful.per-instance-configs.all-effective" => Some(("status.stateful.perInstanceConfigs.allEffective", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status.version-target.is-reached" => Some(("status.versionTarget.isReached", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"target-pools" => Some(("targetPools", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-size" => Some(("targetSize", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.instance-redistribution-type" => Some(("updatePolicy.instanceRedistributionType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.calculated" => Some(("updatePolicy.maxSurge.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.fixed" => Some(("updatePolicy.maxSurge.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-surge.percent" => Some(("updatePolicy.maxSurge.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.calculated" => Some(("updatePolicy.maxUnavailable.calculated", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.fixed" => Some(("updatePolicy.maxUnavailable.fixed", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.max-unavailable.percent" => Some(("updatePolicy.maxUnavailable.percent", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"update-policy.minimal-action" => Some(("updatePolicy.minimalAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.most-disruptive-allowed-action" => Some(("updatePolicy.mostDisruptiveAllowedAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.replacement-method" => Some(("updatePolicy.replacementMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"update-policy.type" => Some(("updatePolicy.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abandoning", "all-effective", "autoscaler", "base-instance-name", "calculated", "creating", "creating-without-retries", "creation-timestamp", "current-actions", "deleting", "description", "distribution-policy", "fingerprint", "fixed", "has-stateful-config", "id", "instance-group", "instance-redistribution-type", "instance-template", "is-reached", "is-stable", "kind", "max-surge", "max-unavailable", "minimal-action", "most-disruptive-allowed-action", "name", "none", "per-instance-configs", "percent", "recreating", "refreshing", "region", "replacement-method", "restarting", "resuming", "self-link", "starting", "stateful", "status", "stopping", "suspending", "target-pools", "target-shape", "target-size", "type", "update-policy", "verifying", "version-target", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceGroupManager = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_patch_per_instance_configs(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagerPatchInstanceConfigReq = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().patch_per_instance_configs(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_recreate_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instances"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagersRecreateRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().recreate_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_resize(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let size: i32 = arg_from_str(&opt.value_of("size").unwrap_or(""), err, "<size>", "integer");
|
|
let mut call = self.hub.region_instance_group_managers().resize(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""), size);
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_set_instance_template(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instance-template" => Some(("instanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instance-template"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagersSetTemplateRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().set_instance_template(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_set_target_pools(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target-pools" => Some(("targetPools", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint", "target-pools"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagersSetTargetPoolsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().set_target_pools(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_group_managers_update_per_instance_configs(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupManagerUpdateInstanceConfigReq = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_group_managers().update_per_instance_configs(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group-manager").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_instance_groups().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_instance_groups().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_groups_list_instances(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instance-state" => Some(("instanceState", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"port-name" => Some(("portName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instance-state", "port-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupsListInstancesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_groups().list_instances(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instance_groups_set_named_ports(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["fingerprint"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionInstanceGroupsSetNamedPortsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instance_groups().set_named_ports(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("instance-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_instances_bulk_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"count" => Some(("count", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.enable-nested-virtualization" => Some(("instanceProperties.advancedMachineFeatures.enableNestedVirtualization", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.enable-uefi-networking" => Some(("instanceProperties.advancedMachineFeatures.enableUefiNetworking", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.advanced-machine-features.threads-per-core" => Some(("instanceProperties.advancedMachineFeatures.threadsPerCore", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"instance-properties.can-ip-forward" => Some(("instanceProperties.canIpForward", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.confidential-instance-config.enable-confidential-compute" => Some(("instanceProperties.confidentialInstanceConfig.enableConfidentialCompute", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.description" => Some(("instanceProperties.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.labels" => Some(("instanceProperties.labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"instance-properties.machine-type" => Some(("instanceProperties.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.metadata.fingerprint" => Some(("instanceProperties.metadata.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.metadata.kind" => Some(("instanceProperties.metadata.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.min-cpu-platform" => Some(("instanceProperties.minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.network-performance-config.total-egress-bandwidth-tier" => Some(("instanceProperties.networkPerformanceConfig.totalEgressBandwidthTier", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.private-ipv6-google-access" => Some(("instanceProperties.privateIpv6GoogleAccess", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.consume-reservation-type" => Some(("instanceProperties.reservationAffinity.consumeReservationType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.key" => Some(("instanceProperties.reservationAffinity.key", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.reservation-affinity.values" => Some(("instanceProperties.reservationAffinity.values", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"instance-properties.resource-manager-tags" => Some(("instanceProperties.resourceManagerTags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"instance-properties.resource-policies" => Some(("instanceProperties.resourcePolicies", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"instance-properties.scheduling.automatic-restart" => Some(("instanceProperties.scheduling.automaticRestart", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.instance-termination-action" => Some(("instanceProperties.scheduling.instanceTerminationAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.location-hint" => Some(("instanceProperties.scheduling.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.min-node-cpus" => Some(("instanceProperties.scheduling.minNodeCpus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.on-host-maintenance" => Some(("instanceProperties.scheduling.onHostMaintenance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.preemptible" => Some(("instanceProperties.scheduling.preemptible", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.scheduling.provisioning-model" => Some(("instanceProperties.scheduling.provisioningModel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-integrity-monitoring" => Some(("instanceProperties.shieldedInstanceConfig.enableIntegrityMonitoring", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-secure-boot" => Some(("instanceProperties.shieldedInstanceConfig.enableSecureBoot", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.shielded-instance-config.enable-vtpm" => Some(("instanceProperties.shieldedInstanceConfig.enableVtpm", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"instance-properties.tags.fingerprint" => Some(("instanceProperties.tags.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-properties.tags.items" => Some(("instanceProperties.tags.items", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"min-count" => Some(("minCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"name-pattern" => Some(("namePattern", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-instance-template" => Some(("sourceInstanceTemplate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advanced-machine-features", "automatic-restart", "can-ip-forward", "confidential-instance-config", "consume-reservation-type", "count", "description", "enable-confidential-compute", "enable-integrity-monitoring", "enable-nested-virtualization", "enable-secure-boot", "enable-uefi-networking", "enable-vtpm", "fingerprint", "instance-properties", "instance-termination-action", "items", "key", "kind", "labels", "location-hint", "machine-type", "metadata", "min-count", "min-cpu-platform", "min-node-cpus", "name-pattern", "network-performance-config", "on-host-maintenance", "preemptible", "private-ipv6-google-access", "provisioning-model", "reservation-affinity", "resource-manager-tags", "resource-policies", "scheduling", "shielded-instance-config", "source-instance-template", "tags", "threads-per-core", "total-egress-bandwidth-tier", "values"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::BulkInsertInstanceResource = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_instances().bulk_insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_endpoint_groups_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_endpoint_groups().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_endpoint_groups_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_endpoint_groups().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("network-endpoint-group").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_endpoint_groups_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"annotations" => Some(("annotations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"app-engine.service" => Some(("appEngine.service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"app-engine.url-mask" => Some(("appEngine.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"app-engine.version" => Some(("appEngine.version", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-function.function" => Some(("cloudFunction.function", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-function.url-mask" => Some(("cloudFunction.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.service" => Some(("cloudRun.service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.tag" => Some(("cloudRun.tag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"cloud-run.url-mask" => Some(("cloudRun.urlMask", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-port" => Some(("defaultPort", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network-endpoint-type" => Some(("networkEndpointType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-target-service" => Some(("pscTargetService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"size" => Some(("size", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"subnetwork" => Some(("subnetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["annotations", "app-engine", "cloud-function", "cloud-run", "creation-timestamp", "default-port", "description", "function", "id", "kind", "name", "network", "network-endpoint-type", "psc-target-service", "region", "self-link", "service", "size", "subnetwork", "tag", "url-mask", "version", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NetworkEndpointGroup = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_network_endpoint_groups().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_endpoint_groups_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_endpoint_groups().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_add_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"attachment-target" => Some(("attachmentTarget", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"firewall-policy-id" => Some(("firewallPolicyId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["attachment-target", "display-name", "firewall-policy-id", "name", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyAssociation = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_network_firewall_policies().add_association(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"replace-existing-association" => {
|
|
call = call.replace_existing_association(arg_from_str(value.unwrap_or("false"), err, "replace-existing-association", "boolean"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["replace-existing-association", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_add_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"action" => Some(("action", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"enable-logging" => Some(("enableLogging", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.dest-ip-ranges" => Some(("match.destIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"match.src-ip-ranges" => Some(("match.srcIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"target-resources" => Some(("targetResources", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "description", "dest-ip-ranges", "direction", "disabled", "enable-logging", "kind", "match", "priority", "rule-tuple-count", "src-ip-ranges", "target-resources", "target-service-accounts"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_network_firewall_policies().add_rule(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"min-priority" => {
|
|
call = call.min_priority(arg_from_str(value.unwrap_or("-0"), err, "min-priority", "integer"));
|
|
},
|
|
"max-priority" => {
|
|
call = call.max_priority(arg_from_str(value.unwrap_or("-0"), err, "max-priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["max-priority", "min-priority", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_clone_rules(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().clone_rules(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"source-firewall-policy" => {
|
|
call = call.source_firewall_policy(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id", "source-firewall-policy"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_get_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().get_association(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"name" => {
|
|
call = call.name(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["name"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_get_effective_firewalls(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().get_effective_firewalls(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("network").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_get_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().get_rule(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent" => Some(("parent", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "display-name", "fingerprint", "id", "kind", "name", "parent", "region", "rule-tuple-count", "self-link", "self-link-with-id", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_network_firewall_policies().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"display-name" => Some(("displayName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"parent" => Some(("parent", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"short-name" => Some(("shortName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "display-name", "fingerprint", "id", "kind", "name", "parent", "region", "rule-tuple-count", "self-link", "self-link-with-id", "short-name"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_network_firewall_policies().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_patch_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"action" => Some(("action", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"direction" => Some(("direction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disabled" => Some(("disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"enable-logging" => Some(("enableLogging", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.dest-ip-ranges" => Some(("match.destIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"match.src-ip-ranges" => Some(("match.srcIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rule-tuple-count" => Some(("ruleTupleCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"target-resources" => Some(("targetResources", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"target-service-accounts" => Some(("targetServiceAccounts", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "description", "dest-ip-ranges", "direction", "disabled", "enable-logging", "kind", "match", "priority", "rule-tuple-count", "src-ip-ranges", "target-resources", "target-service-accounts"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::FirewallPolicyRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_network_firewall_policies().patch_rule(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_remove_association(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().remove_association(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"name" => {
|
|
call = call.name(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["name", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_remove_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_network_firewall_policies().remove_rule(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("firewall-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_network_firewall_policies().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_network_firewall_policies_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_network_firewall_policies().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_notification_endpoints_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_notification_endpoints().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("notification-endpoint").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_notification_endpoints_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_notification_endpoints().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("notification-endpoint").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_notification_endpoints_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-settings.authority" => Some(("grpcSettings.authority", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-settings.endpoint" => Some(("grpcSettings.endpoint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-settings.payload-name" => Some(("grpcSettings.payloadName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-settings.resend-interval.nanos" => Some(("grpcSettings.resendInterval.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"grpc-settings.resend-interval.seconds" => Some(("grpcSettings.resendInterval.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"grpc-settings.retry-duration-sec" => Some(("grpcSettings.retryDurationSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["authority", "creation-timestamp", "description", "endpoint", "grpc-settings", "id", "kind", "name", "nanos", "payload-name", "region", "resend-interval", "retry-duration-sec", "seconds", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::NotificationEndpoint = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_notification_endpoints().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_notification_endpoints_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_notification_endpoints().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_operations_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_operations().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok(mut response) => {
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_operations().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_operations().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_operations_wait(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_operations().wait(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_ssl_certificates_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_ssl_certificates().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("ssl-certificate").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_ssl_certificates_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_ssl_certificates().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("ssl-certificate").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_ssl_certificates_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"certificate" => Some(("certificate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"expire-time" => Some(("expireTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"managed.domain-status" => Some(("managed.domainStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"managed.domains" => Some(("managed.domains", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"managed.status" => Some(("managed.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"private-key" => Some(("privateKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-managed.certificate" => Some(("selfManaged.certificate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-managed.private-key" => Some(("selfManaged.privateKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subject-alternative-names" => Some(("subjectAlternativeNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["certificate", "creation-timestamp", "description", "domain-status", "domains", "expire-time", "id", "kind", "managed", "name", "private-key", "region", "self-link", "self-managed", "status", "subject-alternative-names", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SslCertificate = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_ssl_certificates().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_ssl_certificates_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_ssl_certificates().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_http_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_target_http_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_http_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_target_http_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_http_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"proxy-bind" => Some(("proxyBind", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "kind", "name", "proxy-bind", "region", "self-link", "url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetHttpProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_target_http_proxies().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_http_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_target_http_proxies().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_http_proxies_set_url_map(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMapReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_target_http_proxies().set_url_map(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_https_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_target_https_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_https_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_target_https_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_https_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"authorization-policy" => Some(("authorizationPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"proxy-bind" => Some(("proxyBind", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"quic-override" => Some(("quicOverride", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"server-tls-policy" => Some(("serverTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"ssl-policy" => Some(("sslPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["authorization-policy", "creation-timestamp", "description", "fingerprint", "id", "kind", "name", "proxy-bind", "quic-override", "region", "self-link", "server-tls-policy", "ssl-certificates", "ssl-policy", "url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetHttpsProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_target_https_proxies().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_https_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_target_https_proxies().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_https_proxies_set_ssl_certificates(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ssl-certificates"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionTargetHttpsProxiesSetSslCertificatesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_target_https_proxies().set_ssl_certificates(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_target_https_proxies_set_url_map(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMapReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_target_https_proxies().set_url_map(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_url_maps_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_url_maps().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_url_maps_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_url_maps().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_url_maps_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-credentials" => Some(("defaultRouteAction.corsPolicy.allowCredentials", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-headers" => Some(("defaultRouteAction.corsPolicy.allowHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-methods" => Some(("defaultRouteAction.corsPolicy.allowMethods", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origin-regexes" => Some(("defaultRouteAction.corsPolicy.allowOriginRegexes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origins" => Some(("defaultRouteAction.corsPolicy.allowOrigins", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.disabled" => Some(("defaultRouteAction.corsPolicy.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.expose-headers" => Some(("defaultRouteAction.corsPolicy.exposeHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.max-age" => Some(("defaultRouteAction.corsPolicy.maxAge", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.http-status" => Some(("defaultRouteAction.faultInjectionPolicy.abort.httpStatus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.abort.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.nanos" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.seconds" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.delay.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.nanos" => Some(("defaultRouteAction.maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.seconds" => Some(("defaultRouteAction.maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.request-mirror-policy.backend-service" => Some(("defaultRouteAction.requestMirrorPolicy.backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.num-retries" => Some(("defaultRouteAction.retryPolicy.numRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.nanos" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.seconds" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.retry-conditions" => Some(("defaultRouteAction.retryPolicy.retryConditions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.timeout.nanos" => Some(("defaultRouteAction.timeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.timeout.seconds" => Some(("defaultRouteAction.timeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.host-rewrite" => Some(("defaultRouteAction.urlRewrite.hostRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.path-prefix-rewrite" => Some(("defaultRouteAction.urlRewrite.pathPrefixRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.host-redirect" => Some(("defaultUrlRedirect.hostRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.https-redirect" => Some(("defaultUrlRedirect.httpsRedirect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.path-redirect" => Some(("defaultUrlRedirect.pathRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.prefix-redirect" => Some(("defaultUrlRedirect.prefixRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.redirect-response-code" => Some(("defaultUrlRedirect.redirectResponseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.strip-query" => Some(("defaultUrlRedirect.stripQuery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"header-action.request-headers-to-remove" => Some(("headerAction.requestHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"header-action.response-headers-to-remove" => Some(("headerAction.responseHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abort", "allow-credentials", "allow-headers", "allow-methods", "allow-origin-regexes", "allow-origins", "backend-service", "cors-policy", "creation-timestamp", "default-route-action", "default-service", "default-url-redirect", "delay", "description", "disabled", "expose-headers", "fault-injection-policy", "fingerprint", "fixed-delay", "header-action", "host-redirect", "host-rewrite", "http-status", "https-redirect", "id", "kind", "max-age", "max-stream-duration", "name", "nanos", "num-retries", "path-prefix-rewrite", "path-redirect", "per-try-timeout", "percentage", "prefix-redirect", "redirect-response-code", "region", "request-headers-to-remove", "request-mirror-policy", "response-headers-to-remove", "retry-conditions", "retry-policy", "seconds", "self-link", "strip-query", "timeout", "url-rewrite"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMap = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_url_maps().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_url_maps_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.region_url_maps().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_url_maps_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-credentials" => Some(("defaultRouteAction.corsPolicy.allowCredentials", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-headers" => Some(("defaultRouteAction.corsPolicy.allowHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-methods" => Some(("defaultRouteAction.corsPolicy.allowMethods", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origin-regexes" => Some(("defaultRouteAction.corsPolicy.allowOriginRegexes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origins" => Some(("defaultRouteAction.corsPolicy.allowOrigins", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.disabled" => Some(("defaultRouteAction.corsPolicy.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.expose-headers" => Some(("defaultRouteAction.corsPolicy.exposeHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.max-age" => Some(("defaultRouteAction.corsPolicy.maxAge", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.http-status" => Some(("defaultRouteAction.faultInjectionPolicy.abort.httpStatus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.abort.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.nanos" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.seconds" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.delay.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.nanos" => Some(("defaultRouteAction.maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.seconds" => Some(("defaultRouteAction.maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.request-mirror-policy.backend-service" => Some(("defaultRouteAction.requestMirrorPolicy.backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.num-retries" => Some(("defaultRouteAction.retryPolicy.numRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.nanos" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.seconds" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.retry-conditions" => Some(("defaultRouteAction.retryPolicy.retryConditions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.timeout.nanos" => Some(("defaultRouteAction.timeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.timeout.seconds" => Some(("defaultRouteAction.timeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.host-rewrite" => Some(("defaultRouteAction.urlRewrite.hostRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.path-prefix-rewrite" => Some(("defaultRouteAction.urlRewrite.pathPrefixRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.host-redirect" => Some(("defaultUrlRedirect.hostRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.https-redirect" => Some(("defaultUrlRedirect.httpsRedirect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.path-redirect" => Some(("defaultUrlRedirect.pathRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.prefix-redirect" => Some(("defaultUrlRedirect.prefixRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.redirect-response-code" => Some(("defaultUrlRedirect.redirectResponseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.strip-query" => Some(("defaultUrlRedirect.stripQuery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"header-action.request-headers-to-remove" => Some(("headerAction.requestHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"header-action.response-headers-to-remove" => Some(("headerAction.responseHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abort", "allow-credentials", "allow-headers", "allow-methods", "allow-origin-regexes", "allow-origins", "backend-service", "cors-policy", "creation-timestamp", "default-route-action", "default-service", "default-url-redirect", "delay", "description", "disabled", "expose-headers", "fault-injection-policy", "fingerprint", "fixed-delay", "header-action", "host-redirect", "host-rewrite", "http-status", "https-redirect", "id", "kind", "max-age", "max-stream-duration", "name", "nanos", "num-retries", "path-prefix-rewrite", "path-redirect", "per-try-timeout", "percentage", "prefix-redirect", "redirect-response-code", "region", "request-headers-to-remove", "request-mirror-policy", "response-headers-to-remove", "retry-conditions", "retry-policy", "seconds", "self-link", "strip-query", "timeout", "url-rewrite"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMap = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_url_maps().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_url_maps_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-credentials" => Some(("defaultRouteAction.corsPolicy.allowCredentials", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-headers" => Some(("defaultRouteAction.corsPolicy.allowHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-methods" => Some(("defaultRouteAction.corsPolicy.allowMethods", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origin-regexes" => Some(("defaultRouteAction.corsPolicy.allowOriginRegexes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origins" => Some(("defaultRouteAction.corsPolicy.allowOrigins", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.disabled" => Some(("defaultRouteAction.corsPolicy.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.expose-headers" => Some(("defaultRouteAction.corsPolicy.exposeHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.max-age" => Some(("defaultRouteAction.corsPolicy.maxAge", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.http-status" => Some(("defaultRouteAction.faultInjectionPolicy.abort.httpStatus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.abort.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.nanos" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.seconds" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.delay.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.nanos" => Some(("defaultRouteAction.maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.seconds" => Some(("defaultRouteAction.maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.request-mirror-policy.backend-service" => Some(("defaultRouteAction.requestMirrorPolicy.backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.num-retries" => Some(("defaultRouteAction.retryPolicy.numRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.nanos" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.seconds" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.retry-conditions" => Some(("defaultRouteAction.retryPolicy.retryConditions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.timeout.nanos" => Some(("defaultRouteAction.timeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.timeout.seconds" => Some(("defaultRouteAction.timeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.host-rewrite" => Some(("defaultRouteAction.urlRewrite.hostRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.path-prefix-rewrite" => Some(("defaultRouteAction.urlRewrite.pathPrefixRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.host-redirect" => Some(("defaultUrlRedirect.hostRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.https-redirect" => Some(("defaultUrlRedirect.httpsRedirect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.path-redirect" => Some(("defaultUrlRedirect.pathRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.prefix-redirect" => Some(("defaultUrlRedirect.prefixRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.redirect-response-code" => Some(("defaultUrlRedirect.redirectResponseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.strip-query" => Some(("defaultUrlRedirect.stripQuery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"header-action.request-headers-to-remove" => Some(("headerAction.requestHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"header-action.response-headers-to-remove" => Some(("headerAction.responseHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abort", "allow-credentials", "allow-headers", "allow-methods", "allow-origin-regexes", "allow-origins", "backend-service", "cors-policy", "creation-timestamp", "default-route-action", "default-service", "default-url-redirect", "delay", "description", "disabled", "expose-headers", "fault-injection-policy", "fingerprint", "fixed-delay", "header-action", "host-redirect", "host-rewrite", "http-status", "https-redirect", "id", "kind", "max-age", "max-stream-duration", "name", "nanos", "num-retries", "path-prefix-rewrite", "path-redirect", "per-try-timeout", "percentage", "prefix-redirect", "redirect-response-code", "region", "request-headers-to-remove", "request-mirror-policy", "response-headers-to-remove", "retry-conditions", "retry-policy", "seconds", "self-link", "strip-query", "timeout", "url-rewrite"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMap = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_url_maps().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _region_url_maps_validate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"resource.creation-timestamp" => Some(("resource.creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.cors-policy.allow-credentials" => Some(("resource.defaultRouteAction.corsPolicy.allowCredentials", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.cors-policy.allow-headers" => Some(("resource.defaultRouteAction.corsPolicy.allowHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.allow-methods" => Some(("resource.defaultRouteAction.corsPolicy.allowMethods", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.allow-origin-regexes" => Some(("resource.defaultRouteAction.corsPolicy.allowOriginRegexes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.allow-origins" => Some(("resource.defaultRouteAction.corsPolicy.allowOrigins", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.disabled" => Some(("resource.defaultRouteAction.corsPolicy.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.cors-policy.expose-headers" => Some(("resource.defaultRouteAction.corsPolicy.exposeHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.max-age" => Some(("resource.defaultRouteAction.corsPolicy.maxAge", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.abort.http-status" => Some(("resource.defaultRouteAction.faultInjectionPolicy.abort.httpStatus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.abort.percentage" => Some(("resource.defaultRouteAction.faultInjectionPolicy.abort.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.delay.fixed-delay.nanos" => Some(("resource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.delay.fixed-delay.seconds" => Some(("resource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.delay.percentage" => Some(("resource.defaultRouteAction.faultInjectionPolicy.delay.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.max-stream-duration.nanos" => Some(("resource.defaultRouteAction.maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.max-stream-duration.seconds" => Some(("resource.defaultRouteAction.maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.request-mirror-policy.backend-service" => Some(("resource.defaultRouteAction.requestMirrorPolicy.backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.retry-policy.num-retries" => Some(("resource.defaultRouteAction.retryPolicy.numRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.retry-policy.per-try-timeout.nanos" => Some(("resource.defaultRouteAction.retryPolicy.perTryTimeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.retry-policy.per-try-timeout.seconds" => Some(("resource.defaultRouteAction.retryPolicy.perTryTimeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.retry-policy.retry-conditions" => Some(("resource.defaultRouteAction.retryPolicy.retryConditions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.timeout.nanos" => Some(("resource.defaultRouteAction.timeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.timeout.seconds" => Some(("resource.defaultRouteAction.timeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.url-rewrite.host-rewrite" => Some(("resource.defaultRouteAction.urlRewrite.hostRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.url-rewrite.path-prefix-rewrite" => Some(("resource.defaultRouteAction.urlRewrite.pathPrefixRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-service" => Some(("resource.defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.host-redirect" => Some(("resource.defaultUrlRedirect.hostRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.https-redirect" => Some(("resource.defaultUrlRedirect.httpsRedirect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.path-redirect" => Some(("resource.defaultUrlRedirect.pathRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.prefix-redirect" => Some(("resource.defaultUrlRedirect.prefixRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.redirect-response-code" => Some(("resource.defaultUrlRedirect.redirectResponseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.strip-query" => Some(("resource.defaultUrlRedirect.stripQuery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"resource.description" => Some(("resource.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.fingerprint" => Some(("resource.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.header-action.request-headers-to-remove" => Some(("resource.headerAction.requestHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.header-action.response-headers-to-remove" => Some(("resource.headerAction.responseHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.id" => Some(("resource.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.kind" => Some(("resource.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.name" => Some(("resource.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.region" => Some(("resource.region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.self-link" => Some(("resource.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abort", "allow-credentials", "allow-headers", "allow-methods", "allow-origin-regexes", "allow-origins", "backend-service", "cors-policy", "creation-timestamp", "default-route-action", "default-service", "default-url-redirect", "delay", "description", "disabled", "expose-headers", "fault-injection-policy", "fingerprint", "fixed-delay", "header-action", "host-redirect", "host-rewrite", "http-status", "https-redirect", "id", "kind", "max-age", "max-stream-duration", "name", "nanos", "num-retries", "path-prefix-rewrite", "path-redirect", "per-try-timeout", "percentage", "prefix-redirect", "redirect-response-code", "region", "request-headers-to-remove", "request-mirror-policy", "resource", "response-headers-to-remove", "retry-conditions", "retry-policy", "seconds", "self-link", "strip-query", "timeout", "url-rewrite"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionUrlMapsValidateRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.region_url_maps().validate(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _regions_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.regions().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _regions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.regions().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.reservations().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.reservations().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("reservation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.reservations().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("reservation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.reservations().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"commitment" => Some(("commitment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"share-settings.share-type" => Some(("shareSettings.shareType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation.count" => Some(("specificReservation.count", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation.in-use-count" => Some(("specificReservation.inUseCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"specific-reservation.instance-properties.location-hint" => Some(("specificReservation.instanceProperties.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation.instance-properties.machine-type" => Some(("specificReservation.instanceProperties.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation.instance-properties.min-cpu-platform" => Some(("specificReservation.instanceProperties.minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation-required" => Some(("specificReservationRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["commitment", "count", "creation-timestamp", "description", "id", "in-use-count", "instance-properties", "kind", "location-hint", "machine-type", "min-cpu-platform", "name", "satisfies-pzs", "self-link", "share-settings", "share-type", "specific-reservation", "specific-reservation-required", "status", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Reservation = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.reservations().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.reservations().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_resize(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"specific-sku-count" => Some(("specificSkuCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["specific-sku-count"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ReservationsResizeRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.reservations().resize(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("reservation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ZoneSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.reservations().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.reservations().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _reservations_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"commitment" => Some(("commitment", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"share-settings.share-type" => Some(("shareSettings.shareType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation.count" => Some(("specificReservation.count", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation.in-use-count" => Some(("specificReservation.inUseCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"specific-reservation.instance-properties.location-hint" => Some(("specificReservation.instanceProperties.locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation.instance-properties.machine-type" => Some(("specificReservation.instanceProperties.machineType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation.instance-properties.min-cpu-platform" => Some(("specificReservation.instanceProperties.minCpuPlatform", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"specific-reservation-required" => Some(("specificReservationRequired", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["commitment", "count", "creation-timestamp", "description", "id", "in-use-count", "instance-properties", "kind", "location-hint", "machine-type", "min-cpu-platform", "name", "satisfies-pzs", "self-link", "share-settings", "share-type", "specific-reservation", "specific-reservation-required", "status", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Reservation = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.reservations().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("reservation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"update-mask" => {
|
|
call = call.update_mask(value.unwrap_or(""));
|
|
},
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"paths" => {
|
|
call = call.add_paths(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["paths", "request-id", "update-mask"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _resource_policies_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.resource_policies().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _resource_policies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.resource_policies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _resource_policies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.resource_policies().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _resource_policies_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.resource_policies().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _resource_policies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"group-placement-policy.availability-domain-count" => Some(("groupPlacementPolicy.availabilityDomainCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"group-placement-policy.collocation" => Some(("groupPlacementPolicy.collocation", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"group-placement-policy.vm-count" => Some(("groupPlacementPolicy.vmCount", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-schedule-policy.expiration-time" => Some(("instanceSchedulePolicy.expirationTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-schedule-policy.start-time" => Some(("instanceSchedulePolicy.startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-schedule-policy.time-zone" => Some(("instanceSchedulePolicy.timeZone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-schedule-policy.vm-start-schedule.schedule" => Some(("instanceSchedulePolicy.vmStartSchedule.schedule", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance-schedule-policy.vm-stop-schedule.schedule" => Some(("instanceSchedulePolicy.vmStopSchedule.schedule", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource-status.instance-schedule-policy.last-run-start-time" => Some(("resourceStatus.instanceSchedulePolicy.lastRunStartTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource-status.instance-schedule-policy.next-run-start-time" => Some(("resourceStatus.instanceSchedulePolicy.nextRunStartTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.retention-policy.max-retention-days" => Some(("snapshotSchedulePolicy.retentionPolicy.maxRetentionDays", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.retention-policy.on-source-disk-delete" => Some(("snapshotSchedulePolicy.retentionPolicy.onSourceDiskDelete", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.schedule.daily-schedule.days-in-cycle" => Some(("snapshotSchedulePolicy.schedule.dailySchedule.daysInCycle", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.schedule.daily-schedule.duration" => Some(("snapshotSchedulePolicy.schedule.dailySchedule.duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.schedule.daily-schedule.start-time" => Some(("snapshotSchedulePolicy.schedule.dailySchedule.startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.schedule.hourly-schedule.duration" => Some(("snapshotSchedulePolicy.schedule.hourlySchedule.duration", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.schedule.hourly-schedule.hours-in-cycle" => Some(("snapshotSchedulePolicy.schedule.hourlySchedule.hoursInCycle", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.schedule.hourly-schedule.start-time" => Some(("snapshotSchedulePolicy.schedule.hourlySchedule.startTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.snapshot-properties.chain-name" => Some(("snapshotSchedulePolicy.snapshotProperties.chainName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.snapshot-properties.guest-flush" => Some(("snapshotSchedulePolicy.snapshotProperties.guestFlush", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"snapshot-schedule-policy.snapshot-properties.labels" => Some(("snapshotSchedulePolicy.snapshotProperties.labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"snapshot-schedule-policy.snapshot-properties.storage-locations" => Some(("snapshotSchedulePolicy.snapshotProperties.storageLocations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["availability-domain-count", "chain-name", "collocation", "creation-timestamp", "daily-schedule", "days-in-cycle", "description", "duration", "expiration-time", "group-placement-policy", "guest-flush", "hourly-schedule", "hours-in-cycle", "id", "instance-schedule-policy", "kind", "labels", "last-run-start-time", "max-retention-days", "name", "next-run-start-time", "on-source-disk-delete", "region", "resource-status", "retention-policy", "schedule", "self-link", "snapshot-properties", "snapshot-schedule-policy", "start-time", "status", "storage-locations", "time-zone", "vm-count", "vm-start-schedule", "vm-stop-schedule"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ResourcePolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.resource_policies().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _resource_policies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.resource_policies().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _resource_policies_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.resource_policies().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _resource_policies_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.resource_policies().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routers().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routers().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routers().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_get_nat_mapping_info(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routers().get_nat_mapping_info(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_get_router_status(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routers().get_router_status(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"bgp.advertise-mode" => Some(("bgp.advertiseMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"bgp.advertised-groups" => Some(("bgp.advertisedGroups", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"bgp.asn" => Some(("bgp.asn", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"bgp.keepalive-interval" => Some(("bgp.keepaliveInterval", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"encrypted-interconnect-router" => Some(("encryptedInterconnectRouter", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advertise-mode", "advertised-groups", "asn", "bgp", "creation-timestamp", "description", "encrypted-interconnect-router", "id", "keepalive-interval", "kind", "name", "network", "region", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Router = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.routers().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routers().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"bgp.advertise-mode" => Some(("bgp.advertiseMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"bgp.advertised-groups" => Some(("bgp.advertisedGroups", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"bgp.asn" => Some(("bgp.asn", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"bgp.keepalive-interval" => Some(("bgp.keepaliveInterval", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"encrypted-interconnect-router" => Some(("encryptedInterconnectRouter", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advertise-mode", "advertised-groups", "asn", "bgp", "creation-timestamp", "description", "encrypted-interconnect-router", "id", "keepalive-interval", "kind", "name", "network", "region", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Router = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.routers().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_preview(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"bgp.advertise-mode" => Some(("bgp.advertiseMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"bgp.advertised-groups" => Some(("bgp.advertisedGroups", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"bgp.asn" => Some(("bgp.asn", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"bgp.keepalive-interval" => Some(("bgp.keepaliveInterval", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"encrypted-interconnect-router" => Some(("encryptedInterconnectRouter", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advertise-mode", "advertised-groups", "asn", "bgp", "creation-timestamp", "description", "encrypted-interconnect-router", "id", "keepalive-interval", "kind", "name", "network", "region", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Router = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.routers().preview(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routers_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"bgp.advertise-mode" => Some(("bgp.advertiseMode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"bgp.advertised-groups" => Some(("bgp.advertisedGroups", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"bgp.asn" => Some(("bgp.asn", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"bgp.keepalive-interval" => Some(("bgp.keepaliveInterval", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"encrypted-interconnect-router" => Some(("encryptedInterconnectRouter", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["advertise-mode", "advertised-groups", "asn", "bgp", "creation-timestamp", "description", "encrypted-interconnect-router", "id", "keepalive-interval", "kind", "name", "network", "region", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Router = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.routers().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("router").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routes_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routes().delete(opt.value_of("project").unwrap_or(""), opt.value_of("route").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routes_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routes().get(opt.value_of("project").unwrap_or(""), opt.value_of("route").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routes_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"dest-range" => Some(("destRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"next-hop-gateway" => Some(("nextHopGateway", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"next-hop-ilb" => Some(("nextHopIlb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"next-hop-instance" => Some(("nextHopInstance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"next-hop-ip" => Some(("nextHopIp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"next-hop-network" => Some(("nextHopNetwork", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"next-hop-peering" => Some(("nextHopPeering", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"next-hop-vpn-tunnel" => Some(("nextHopVpnTunnel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"route-type" => Some(("routeType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tags" => Some(("tags", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "dest-range", "id", "kind", "name", "network", "next-hop-gateway", "next-hop-ilb", "next-hop-instance", "next-hop-ip", "next-hop-network", "next-hop-peering", "next-hop-vpn-tunnel", "priority", "route-type", "self-link", "tags"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Route = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.routes().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _routes_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.routes().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_add_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"action" => Some(("action", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.config.src-ip-ranges" => Some(("match.config.srcIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"match.expr.description" => Some(("match.expr.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.expr.expression" => Some(("match.expr.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.expr.location" => Some(("match.expr.location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.expr.title" => Some(("match.expr.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.versioned-expr" => Some(("match.versionedExpr", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"preview" => Some(("preview", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.ban-duration-sec" => Some(("rateLimitOptions.banDurationSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.ban-threshold.count" => Some(("rateLimitOptions.banThreshold.count", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.ban-threshold.interval-sec" => Some(("rateLimitOptions.banThreshold.intervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.conform-action" => Some(("rateLimitOptions.conformAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.enforce-on-key" => Some(("rateLimitOptions.enforceOnKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.enforce-on-key-name" => Some(("rateLimitOptions.enforceOnKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.exceed-action" => Some(("rateLimitOptions.exceedAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.exceed-redirect-options.target" => Some(("rateLimitOptions.exceedRedirectOptions.target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.exceed-redirect-options.type" => Some(("rateLimitOptions.exceedRedirectOptions.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.rate-limit-threshold.count" => Some(("rateLimitOptions.rateLimitThreshold.count", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.rate-limit-threshold.interval-sec" => Some(("rateLimitOptions.rateLimitThreshold.intervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"redirect-options.target" => Some(("redirectOptions.target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"redirect-options.type" => Some(("redirectOptions.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "ban-duration-sec", "ban-threshold", "config", "conform-action", "count", "description", "enforce-on-key", "enforce-on-key-name", "exceed-action", "exceed-redirect-options", "expr", "expression", "interval-sec", "kind", "location", "match", "preview", "priority", "rate-limit-options", "rate-limit-threshold", "redirect-options", "src-ip-ranges", "target", "title", "type", "versioned-expr"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SecurityPolicyRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.security_policies().add_rule(request, opt.value_of("project").unwrap_or(""), opt.value_of("security-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.security_policies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("security-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.security_policies().get(opt.value_of("project").unwrap_or(""), opt.value_of("security-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_get_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.security_policies().get_rule(opt.value_of("project").unwrap_or(""), opt.value_of("security-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"adaptive-protection-config.layer7-ddos-defense-config.enable" => Some(("adaptiveProtectionConfig.layer7DdosDefenseConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"adaptive-protection-config.layer7-ddos-defense-config.rule-visibility" => Some(("adaptiveProtectionConfig.layer7DdosDefenseConfig.ruleVisibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"advanced-options-config.json-parsing" => Some(("advancedOptionsConfig.jsonParsing", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"advanced-options-config.log-level" => Some(("advancedOptionsConfig.logLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"recaptcha-options-config.redirect-site-key" => Some(("recaptchaOptionsConfig.redirectSiteKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["adaptive-protection-config", "advanced-options-config", "creation-timestamp", "description", "enable", "fingerprint", "id", "json-parsing", "kind", "layer7-ddos-defense-config", "log-level", "name", "recaptcha-options-config", "redirect-site-key", "rule-visibility", "self-link", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SecurityPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.security_policies().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.security_policies().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_list_preconfigured_expression_sets(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.security_policies().list_preconfigured_expression_sets(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"adaptive-protection-config.layer7-ddos-defense-config.enable" => Some(("adaptiveProtectionConfig.layer7DdosDefenseConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"adaptive-protection-config.layer7-ddos-defense-config.rule-visibility" => Some(("adaptiveProtectionConfig.layer7DdosDefenseConfig.ruleVisibility", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"advanced-options-config.json-parsing" => Some(("advancedOptionsConfig.jsonParsing", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"advanced-options-config.log-level" => Some(("advancedOptionsConfig.logLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"recaptcha-options-config.redirect-site-key" => Some(("recaptchaOptionsConfig.redirectSiteKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["adaptive-protection-config", "advanced-options-config", "creation-timestamp", "description", "enable", "fingerprint", "id", "json-parsing", "kind", "layer7-ddos-defense-config", "log-level", "name", "recaptcha-options-config", "redirect-site-key", "rule-visibility", "self-link", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SecurityPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.security_policies().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("security-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_patch_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"action" => Some(("action", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.config.src-ip-ranges" => Some(("match.config.srcIpRanges", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"match.expr.description" => Some(("match.expr.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.expr.expression" => Some(("match.expr.expression", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.expr.location" => Some(("match.expr.location", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.expr.title" => Some(("match.expr.title", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"match.versioned-expr" => Some(("match.versionedExpr", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"preview" => Some(("preview", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"priority" => Some(("priority", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.ban-duration-sec" => Some(("rateLimitOptions.banDurationSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.ban-threshold.count" => Some(("rateLimitOptions.banThreshold.count", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.ban-threshold.interval-sec" => Some(("rateLimitOptions.banThreshold.intervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.conform-action" => Some(("rateLimitOptions.conformAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.enforce-on-key" => Some(("rateLimitOptions.enforceOnKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.enforce-on-key-name" => Some(("rateLimitOptions.enforceOnKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.exceed-action" => Some(("rateLimitOptions.exceedAction", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.exceed-redirect-options.target" => Some(("rateLimitOptions.exceedRedirectOptions.target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.exceed-redirect-options.type" => Some(("rateLimitOptions.exceedRedirectOptions.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.rate-limit-threshold.count" => Some(("rateLimitOptions.rateLimitThreshold.count", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"rate-limit-options.rate-limit-threshold.interval-sec" => Some(("rateLimitOptions.rateLimitThreshold.intervalSec", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"redirect-options.target" => Some(("redirectOptions.target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"redirect-options.type" => Some(("redirectOptions.type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["action", "ban-duration-sec", "ban-threshold", "config", "conform-action", "count", "description", "enforce-on-key", "enforce-on-key-name", "exceed-action", "exceed-redirect-options", "expr", "expression", "interval-sec", "kind", "location", "match", "preview", "priority", "rate-limit-options", "rate-limit-threshold", "redirect-options", "src-ip-ranges", "target", "title", "type", "versioned-expr"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SecurityPolicyRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.security_policies().patch_rule(request, opt.value_of("project").unwrap_or(""), opt.value_of("security-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _security_policies_remove_rule(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.security_policies().remove_rule(opt.value_of("project").unwrap_or(""), opt.value_of("security-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"priority" => {
|
|
call = call.priority(arg_from_str(value.unwrap_or("-0"), err, "priority", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["priority"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.service_attachments().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.service_attachments().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("service-attachment").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.service_attachments().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("service-attachment").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.service_attachments().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"connection-preference" => Some(("connectionPreference", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consumer-reject-lists" => Some(("consumerRejectLists", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"domain-names" => Some(("domainNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"enable-proxy-protocol" => Some(("enableProxyProtocol", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"nat-subnets" => Some(("natSubnets", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"producer-forwarding-rule" => Some(("producerForwardingRule", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-service-attachment-id.high" => Some(("pscServiceAttachmentId.high", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-service-attachment-id.low" => Some(("pscServiceAttachmentId.low", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target-service" => Some(("targetService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["connection-preference", "consumer-reject-lists", "creation-timestamp", "description", "domain-names", "enable-proxy-protocol", "fingerprint", "high", "id", "kind", "low", "name", "nat-subnets", "producer-forwarding-rule", "psc-service-attachment-id", "region", "self-link", "target-service"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ServiceAttachment = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.service_attachments().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.service_attachments().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"connection-preference" => Some(("connectionPreference", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"consumer-reject-lists" => Some(("consumerRejectLists", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"domain-names" => Some(("domainNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"enable-proxy-protocol" => Some(("enableProxyProtocol", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"nat-subnets" => Some(("natSubnets", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"producer-forwarding-rule" => Some(("producerForwardingRule", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-service-attachment-id.high" => Some(("pscServiceAttachmentId.high", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"psc-service-attachment-id.low" => Some(("pscServiceAttachmentId.low", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target-service" => Some(("targetService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["connection-preference", "consumer-reject-lists", "creation-timestamp", "description", "domain-names", "enable-proxy-protocol", "fingerprint", "high", "id", "kind", "low", "name", "nat-subnets", "producer-forwarding-rule", "psc-service-attachment-id", "region", "self-link", "target-service"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::ServiceAttachment = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.service_attachments().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("service-attachment").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.service_attachments().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _service_attachments_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.service_attachments().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _snapshots_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.snapshots().delete(opt.value_of("project").unwrap_or(""), opt.value_of("snapshot").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _snapshots_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.snapshots().get(opt.value_of("project").unwrap_or(""), opt.value_of("snapshot").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _snapshots_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.snapshots().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _snapshots_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"auto-created" => Some(("autoCreated", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"chain-name" => Some(("chainName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"disk-size-gb" => Some(("diskSizeGb", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"download-bytes" => Some(("downloadBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"license-codes" => Some(("licenseCodes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"licenses" => Some(("licenses", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"location-hint" => Some(("locationHint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"satisfies-pzs" => Some(("satisfiesPzs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.kms-key-name" => Some(("snapshotEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.kms-key-service-account" => Some(("snapshotEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.raw-key" => Some(("snapshotEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.rsa-encrypted-key" => Some(("snapshotEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"snapshot-encryption-key.sha256" => Some(("snapshotEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk" => Some(("sourceDisk", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-name" => Some(("sourceDiskEncryptionKey.kmsKeyName", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.kms-key-service-account" => Some(("sourceDiskEncryptionKey.kmsKeyServiceAccount", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.raw-key" => Some(("sourceDiskEncryptionKey.rawKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.rsa-encrypted-key" => Some(("sourceDiskEncryptionKey.rsaEncryptedKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-encryption-key.sha256" => Some(("sourceDiskEncryptionKey.sha256", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"source-disk-id" => Some(("sourceDiskId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-bytes" => Some(("storageBytes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-bytes-status" => Some(("storageBytesStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"storage-locations" => Some(("storageLocations", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["auto-created", "chain-name", "creation-timestamp", "description", "disk-size-gb", "download-bytes", "id", "kind", "kms-key-name", "kms-key-service-account", "label-fingerprint", "labels", "license-codes", "licenses", "location-hint", "name", "raw-key", "rsa-encrypted-key", "satisfies-pzs", "self-link", "sha256", "snapshot-encryption-key", "source-disk", "source-disk-encryption-key", "source-disk-id", "status", "storage-bytes", "storage-bytes-status", "storage-locations"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Snapshot = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.snapshots().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _snapshots_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.snapshots().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _snapshots_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.snapshots().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _snapshots_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::GlobalSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.snapshots().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _snapshots_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.snapshots().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_certificates_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.ssl_certificates().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_certificates_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.ssl_certificates().delete(opt.value_of("project").unwrap_or(""), opt.value_of("ssl-certificate").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_certificates_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.ssl_certificates().get(opt.value_of("project").unwrap_or(""), opt.value_of("ssl-certificate").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_certificates_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"certificate" => Some(("certificate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"expire-time" => Some(("expireTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"managed.domain-status" => Some(("managed.domainStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"managed.domains" => Some(("managed.domains", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"managed.status" => Some(("managed.status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"private-key" => Some(("privateKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-managed.certificate" => Some(("selfManaged.certificate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-managed.private-key" => Some(("selfManaged.privateKey", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"subject-alternative-names" => Some(("subjectAlternativeNames", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"type" => Some(("type", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["certificate", "creation-timestamp", "description", "domain-status", "domains", "expire-time", "id", "kind", "managed", "name", "private-key", "region", "self-link", "self-managed", "status", "subject-alternative-names", "type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SslCertificate = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.ssl_certificates().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_certificates_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.ssl_certificates().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_policies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.ssl_policies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("ssl-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_policies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.ssl_policies().get(opt.value_of("project").unwrap_or(""), opt.value_of("ssl-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_policies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-features" => Some(("customFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enabled-features" => Some(("enabledFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"min-tls-version" => Some(("minTlsVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"profile" => Some(("profile", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "custom-features", "description", "enabled-features", "fingerprint", "id", "kind", "min-tls-version", "name", "profile", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SslPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.ssl_policies().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_policies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.ssl_policies().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_policies_list_available_features(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.ssl_policies().list_available_features(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _ssl_policies_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"custom-features" => Some(("customFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enabled-features" => Some(("enabledFeatures", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"min-tls-version" => Some(("minTlsVersion", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"profile" => Some(("profile", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "custom-features", "description", "enabled-features", "fingerprint", "id", "kind", "min-tls-version", "name", "profile", "self-link"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SslPolicy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.ssl_policies().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("ssl-policy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.subnetworks().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.subnetworks().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("subnetwork").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_expand_ip_cidr_range(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ip-cidr-range"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SubnetworksExpandIpCidrRangeRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.subnetworks().expand_ip_cidr_range(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("subnetwork").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.subnetworks().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("subnetwork").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.subnetworks().get_iam_policy(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"options-requested-policy-version" => {
|
|
call = call.options_requested_policy_version(arg_from_str(value.unwrap_or("-0"), err, "options-requested-policy-version", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["options-requested-policy-version"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-flow-logs" => Some(("enableFlowLogs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"external-ipv6-prefix" => Some(("externalIpv6Prefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"gateway-address" => Some(("gatewayAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"internal-ipv6-prefix" => Some(("internalIpv6Prefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ipv6-access-type" => Some(("ipv6AccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ipv6-cidr-range" => Some(("ipv6CidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.aggregation-interval" => Some(("logConfig.aggregationInterval", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.filter-expr" => Some(("logConfig.filterExpr", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.flow-sampling" => Some(("logConfig.flowSampling", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"log-config.metadata" => Some(("logConfig.metadata", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.metadata-fields" => Some(("logConfig.metadataFields", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"private-ip-google-access" => Some(("privateIpGoogleAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"private-ipv6-google-access" => Some(("privateIpv6GoogleAccess", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"purpose" => Some(("purpose", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"role" => Some(("role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"stack-type" => Some(("stackType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["aggregation-interval", "creation-timestamp", "description", "enable", "enable-flow-logs", "external-ipv6-prefix", "filter-expr", "fingerprint", "flow-sampling", "gateway-address", "id", "internal-ipv6-prefix", "ip-cidr-range", "ipv6-access-type", "ipv6-cidr-range", "kind", "log-config", "metadata", "metadata-fields", "name", "network", "private-ip-google-access", "private-ipv6-google-access", "purpose", "region", "role", "self-link", "stack-type", "state"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Subnetwork = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.subnetworks().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.subnetworks().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_list_usable(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.subnetworks().list_usable(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"enable-flow-logs" => Some(("enableFlowLogs", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"external-ipv6-prefix" => Some(("externalIpv6Prefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"gateway-address" => Some(("gatewayAddress", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"internal-ipv6-prefix" => Some(("internalIpv6Prefix", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ip-cidr-range" => Some(("ipCidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ipv6-access-type" => Some(("ipv6AccessType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ipv6-cidr-range" => Some(("ipv6CidrRange", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.aggregation-interval" => Some(("logConfig.aggregationInterval", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.enable" => Some(("logConfig.enable", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"log-config.filter-expr" => Some(("logConfig.filterExpr", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.flow-sampling" => Some(("logConfig.flowSampling", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"log-config.metadata" => Some(("logConfig.metadata", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"log-config.metadata-fields" => Some(("logConfig.metadataFields", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"private-ip-google-access" => Some(("privateIpGoogleAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"private-ipv6-google-access" => Some(("privateIpv6GoogleAccess", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"purpose" => Some(("purpose", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"role" => Some(("role", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"stack-type" => Some(("stackType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"state" => Some(("state", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["aggregation-interval", "creation-timestamp", "description", "enable", "enable-flow-logs", "external-ipv6-prefix", "filter-expr", "fingerprint", "flow-sampling", "gateway-address", "id", "internal-ipv6-prefix", "ip-cidr-range", "ipv6-access-type", "ipv6-cidr-range", "kind", "log-config", "metadata", "metadata-fields", "name", "network", "private-ip-google-access", "private-ipv6-google-access", "purpose", "region", "role", "self-link", "stack-type", "state"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::Subnetwork = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.subnetworks().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("subnetwork").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"drain-timeout-seconds" => {
|
|
call = call.drain_timeout_seconds(arg_from_str(value.unwrap_or("-0"), err, "drain-timeout-seconds", "integer"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["drain-timeout-seconds", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_set_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"etag" => Some(("etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.etag" => Some(("policy.etag", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"policy.version" => Some(("policy.version", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["etag", "policy", "version"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetPolicyRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.subnetworks().set_iam_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_set_private_ip_google_access(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"private-ip-google-access" => Some(("privateIpGoogleAccess", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["private-ip-google-access"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SubnetworksSetPrivateIpGoogleAccessRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.subnetworks().set_private_ip_google_access(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("subnetwork").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _subnetworks_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.subnetworks().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_grpc_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_grpc_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("target-grpc-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_grpc_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_grpc_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("target-grpc-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_grpc_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"validate-for-proxyless" => Some(("validateForProxyless", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "kind", "name", "self-link", "self-link-with-id", "url-map", "validate-for-proxyless"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetGrpcProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_grpc_proxies().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_grpc_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_grpc_proxies().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_grpc_proxies_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link-with-id" => Some(("selfLinkWithId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"validate-for-proxyless" => Some(("validateForProxyless", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "kind", "name", "self-link", "self-link-with-id", "url-map", "validate-for-proxyless"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetGrpcProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_grpc_proxies().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-grpc-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_http_proxies_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_http_proxies().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_http_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_http_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_http_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_http_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_http_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"proxy-bind" => Some(("proxyBind", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "kind", "name", "proxy-bind", "region", "self-link", "url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetHttpProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_http_proxies().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_http_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_http_proxies().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_http_proxies_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"proxy-bind" => Some(("proxyBind", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "fingerprint", "id", "kind", "name", "proxy-bind", "region", "self-link", "url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetHttpProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_http_proxies().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_http_proxies_set_url_map(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMapReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_http_proxies().set_url_map(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-http-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_https_proxies().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_https_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_https_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"authorization-policy" => Some(("authorizationPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"proxy-bind" => Some(("proxyBind", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"quic-override" => Some(("quicOverride", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"server-tls-policy" => Some(("serverTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"ssl-policy" => Some(("sslPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["authorization-policy", "creation-timestamp", "description", "fingerprint", "id", "kind", "name", "proxy-bind", "quic-override", "region", "self-link", "server-tls-policy", "ssl-certificates", "ssl-policy", "url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetHttpsProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_https_proxies().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_https_proxies().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"authorization-policy" => Some(("authorizationPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"proxy-bind" => Some(("proxyBind", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"quic-override" => Some(("quicOverride", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"server-tls-policy" => Some(("serverTlsPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"ssl-policy" => Some(("sslPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["authorization-policy", "creation-timestamp", "description", "fingerprint", "id", "kind", "name", "proxy-bind", "quic-override", "region", "self-link", "server-tls-policy", "ssl-certificates", "ssl-policy", "url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetHttpsProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_https_proxies().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_set_quic_override(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"quic-override" => Some(("quicOverride", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["quic-override"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetHttpsProxiesSetQuicOverrideRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_https_proxies().set_quic_override(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_set_ssl_certificates(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ssl-certificates"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetHttpsProxiesSetSslCertificatesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_https_proxies().set_ssl_certificates(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_set_ssl_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ssl-policy" => Some(("sslPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ssl-policy"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SslPolicyReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_https_proxies().set_ssl_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_https_proxies_set_url_map(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"url-map" => Some(("urlMap", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["url-map"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMapReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_https_proxies().set_url_map(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-https-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_instances_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_instances().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_instances_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_instances().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("target-instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_instances_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_instances().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("target-instance").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_instances_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instance" => Some(("instance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"nat-policy" => Some(("natPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"zone" => Some(("zone", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "instance", "kind", "name", "nat-policy", "network", "self-link", "zone"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetInstance = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_instances().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_instances_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_instances().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_add_health_check(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetPoolsAddHealthCheckRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_pools().add_health_check(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_add_instance(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetPoolsAddInstanceRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_pools().add_instance(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_pools().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_pools().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_pools().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_get_health(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"instance" => Some(("instance", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["instance"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::InstanceReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_pools().get_health(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"backup-pool" => Some(("backupPool", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"failover-ratio" => Some(("failoverRatio", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"health-checks" => Some(("healthChecks", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"instances" => Some(("instances", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"session-affinity" => Some(("sessionAffinity", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["backup-pool", "creation-timestamp", "description", "failover-ratio", "health-checks", "id", "instances", "kind", "name", "region", "self-link", "session-affinity"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetPool = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_pools().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_pools().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_remove_health_check(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetPoolsRemoveHealthCheckRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_pools().remove_health_check(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_remove_instance(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec![]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetPoolsRemoveInstanceRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_pools().remove_instance(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_pools_set_backup(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"target" => Some(("target", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["target"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_pools().set_backup(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-pool").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
"failover-ratio" => {
|
|
call = call.failover_ratio(arg_from_str(value.unwrap_or("0.0"), err, "failover-ratio", "number"));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["failover-ratio", "request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_ssl_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_ssl_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_ssl_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_ssl_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_ssl_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"proxy-header" => Some(("proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service" => Some(("service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"ssl-policy" => Some(("sslPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "name", "proxy-header", "self-link", "service", "ssl-certificates", "ssl-policy"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetSslProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_ssl_proxies().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_ssl_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_ssl_proxies().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_ssl_proxies_set_backend_service(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"service" => Some(("service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["service"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetSslProxiesSetBackendServiceRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_ssl_proxies().set_backend_service(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_ssl_proxies_set_proxy_header(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"proxy-header" => Some(("proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["proxy-header"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetSslProxiesSetProxyHeaderRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_ssl_proxies().set_proxy_header(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_ssl_proxies_set_ssl_certificates(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ssl-certificates" => Some(("sslCertificates", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ssl-certificates"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetSslProxiesSetSslCertificatesRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_ssl_proxies().set_ssl_certificates(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_ssl_proxies_set_ssl_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"ssl-policy" => Some(("sslPolicy", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["ssl-policy"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::SslPolicyReference = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_ssl_proxies().set_ssl_policy(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-ssl-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_tcp_proxies_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_tcp_proxies().delete(opt.value_of("project").unwrap_or(""), opt.value_of("target-tcp-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_tcp_proxies_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_tcp_proxies().get(opt.value_of("project").unwrap_or(""), opt.value_of("target-tcp-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_tcp_proxies_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"proxy-bind" => Some(("proxyBind", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"proxy-header" => Some(("proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"service" => Some(("service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "name", "proxy-bind", "proxy-header", "self-link", "service"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetTcpProxy = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_tcp_proxies().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_tcp_proxies_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_tcp_proxies().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_tcp_proxies_set_backend_service(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"service" => Some(("service", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["service"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetTcpProxiesSetBackendServiceRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_tcp_proxies().set_backend_service(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-tcp-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_tcp_proxies_set_proxy_header(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"proxy-header" => Some(("proxyHeader", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["proxy-header"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetTcpProxiesSetProxyHeaderRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_tcp_proxies().set_proxy_header(request, opt.value_of("project").unwrap_or(""), opt.value_of("target-tcp-proxy").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_vpn_gateways_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_vpn_gateways().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_vpn_gateways_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_vpn_gateways().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-vpn-gateway").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_vpn_gateways_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_vpn_gateways().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("target-vpn-gateway").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_vpn_gateways_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"forwarding-rules" => Some(("forwardingRules", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"tunnels" => Some(("tunnels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "forwarding-rules", "id", "kind", "name", "network", "region", "self-link", "status", "tunnels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TargetVpnGateway = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.target_vpn_gateways().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _target_vpn_gateways_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.target_vpn_gateways().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.url_maps().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.url_maps().delete(opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.url_maps().get(opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-credentials" => Some(("defaultRouteAction.corsPolicy.allowCredentials", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-headers" => Some(("defaultRouteAction.corsPolicy.allowHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-methods" => Some(("defaultRouteAction.corsPolicy.allowMethods", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origin-regexes" => Some(("defaultRouteAction.corsPolicy.allowOriginRegexes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origins" => Some(("defaultRouteAction.corsPolicy.allowOrigins", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.disabled" => Some(("defaultRouteAction.corsPolicy.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.expose-headers" => Some(("defaultRouteAction.corsPolicy.exposeHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.max-age" => Some(("defaultRouteAction.corsPolicy.maxAge", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.http-status" => Some(("defaultRouteAction.faultInjectionPolicy.abort.httpStatus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.abort.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.nanos" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.seconds" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.delay.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.nanos" => Some(("defaultRouteAction.maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.seconds" => Some(("defaultRouteAction.maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.request-mirror-policy.backend-service" => Some(("defaultRouteAction.requestMirrorPolicy.backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.num-retries" => Some(("defaultRouteAction.retryPolicy.numRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.nanos" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.seconds" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.retry-conditions" => Some(("defaultRouteAction.retryPolicy.retryConditions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.timeout.nanos" => Some(("defaultRouteAction.timeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.timeout.seconds" => Some(("defaultRouteAction.timeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.host-rewrite" => Some(("defaultRouteAction.urlRewrite.hostRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.path-prefix-rewrite" => Some(("defaultRouteAction.urlRewrite.pathPrefixRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.host-redirect" => Some(("defaultUrlRedirect.hostRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.https-redirect" => Some(("defaultUrlRedirect.httpsRedirect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.path-redirect" => Some(("defaultUrlRedirect.pathRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.prefix-redirect" => Some(("defaultUrlRedirect.prefixRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.redirect-response-code" => Some(("defaultUrlRedirect.redirectResponseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.strip-query" => Some(("defaultUrlRedirect.stripQuery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"header-action.request-headers-to-remove" => Some(("headerAction.requestHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"header-action.response-headers-to-remove" => Some(("headerAction.responseHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abort", "allow-credentials", "allow-headers", "allow-methods", "allow-origin-regexes", "allow-origins", "backend-service", "cors-policy", "creation-timestamp", "default-route-action", "default-service", "default-url-redirect", "delay", "description", "disabled", "expose-headers", "fault-injection-policy", "fingerprint", "fixed-delay", "header-action", "host-redirect", "host-rewrite", "http-status", "https-redirect", "id", "kind", "max-age", "max-stream-duration", "name", "nanos", "num-retries", "path-prefix-rewrite", "path-redirect", "per-try-timeout", "percentage", "prefix-redirect", "redirect-response-code", "region", "request-headers-to-remove", "request-mirror-policy", "response-headers-to-remove", "retry-conditions", "retry-policy", "seconds", "self-link", "strip-query", "timeout", "url-rewrite"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMap = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.url_maps().insert(request, opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_invalidate_cache(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"host" => Some(("host", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"path" => Some(("path", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["host", "path"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::CacheInvalidationRule = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.url_maps().invalidate_cache(request, opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.url_maps().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-credentials" => Some(("defaultRouteAction.corsPolicy.allowCredentials", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-headers" => Some(("defaultRouteAction.corsPolicy.allowHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-methods" => Some(("defaultRouteAction.corsPolicy.allowMethods", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origin-regexes" => Some(("defaultRouteAction.corsPolicy.allowOriginRegexes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origins" => Some(("defaultRouteAction.corsPolicy.allowOrigins", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.disabled" => Some(("defaultRouteAction.corsPolicy.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.expose-headers" => Some(("defaultRouteAction.corsPolicy.exposeHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.max-age" => Some(("defaultRouteAction.corsPolicy.maxAge", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.http-status" => Some(("defaultRouteAction.faultInjectionPolicy.abort.httpStatus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.abort.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.nanos" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.seconds" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.delay.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.nanos" => Some(("defaultRouteAction.maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.seconds" => Some(("defaultRouteAction.maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.request-mirror-policy.backend-service" => Some(("defaultRouteAction.requestMirrorPolicy.backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.num-retries" => Some(("defaultRouteAction.retryPolicy.numRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.nanos" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.seconds" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.retry-conditions" => Some(("defaultRouteAction.retryPolicy.retryConditions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.timeout.nanos" => Some(("defaultRouteAction.timeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.timeout.seconds" => Some(("defaultRouteAction.timeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.host-rewrite" => Some(("defaultRouteAction.urlRewrite.hostRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.path-prefix-rewrite" => Some(("defaultRouteAction.urlRewrite.pathPrefixRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.host-redirect" => Some(("defaultUrlRedirect.hostRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.https-redirect" => Some(("defaultUrlRedirect.httpsRedirect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.path-redirect" => Some(("defaultUrlRedirect.pathRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.prefix-redirect" => Some(("defaultUrlRedirect.prefixRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.redirect-response-code" => Some(("defaultUrlRedirect.redirectResponseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.strip-query" => Some(("defaultUrlRedirect.stripQuery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"header-action.request-headers-to-remove" => Some(("headerAction.requestHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"header-action.response-headers-to-remove" => Some(("headerAction.responseHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abort", "allow-credentials", "allow-headers", "allow-methods", "allow-origin-regexes", "allow-origins", "backend-service", "cors-policy", "creation-timestamp", "default-route-action", "default-service", "default-url-redirect", "delay", "description", "disabled", "expose-headers", "fault-injection-policy", "fingerprint", "fixed-delay", "header-action", "host-redirect", "host-rewrite", "http-status", "https-redirect", "id", "kind", "max-age", "max-stream-duration", "name", "nanos", "num-retries", "path-prefix-rewrite", "path-redirect", "per-try-timeout", "percentage", "prefix-redirect", "redirect-response-code", "region", "request-headers-to-remove", "request-mirror-policy", "response-headers-to-remove", "retry-conditions", "retry-policy", "seconds", "self-link", "strip-query", "timeout", "url-rewrite"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMap = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.url_maps().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-credentials" => Some(("defaultRouteAction.corsPolicy.allowCredentials", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.allow-headers" => Some(("defaultRouteAction.corsPolicy.allowHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-methods" => Some(("defaultRouteAction.corsPolicy.allowMethods", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origin-regexes" => Some(("defaultRouteAction.corsPolicy.allowOriginRegexes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.allow-origins" => Some(("defaultRouteAction.corsPolicy.allowOrigins", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.disabled" => Some(("defaultRouteAction.corsPolicy.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-route-action.cors-policy.expose-headers" => Some(("defaultRouteAction.corsPolicy.exposeHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.cors-policy.max-age" => Some(("defaultRouteAction.corsPolicy.maxAge", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.http-status" => Some(("defaultRouteAction.faultInjectionPolicy.abort.httpStatus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.abort.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.abort.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.nanos" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.fixed-delay.seconds" => Some(("defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.fault-injection-policy.delay.percentage" => Some(("defaultRouteAction.faultInjectionPolicy.delay.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.nanos" => Some(("defaultRouteAction.maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.max-stream-duration.seconds" => Some(("defaultRouteAction.maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.request-mirror-policy.backend-service" => Some(("defaultRouteAction.requestMirrorPolicy.backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.num-retries" => Some(("defaultRouteAction.retryPolicy.numRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.nanos" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.per-try-timeout.seconds" => Some(("defaultRouteAction.retryPolicy.perTryTimeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.retry-policy.retry-conditions" => Some(("defaultRouteAction.retryPolicy.retryConditions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"default-route-action.timeout.nanos" => Some(("defaultRouteAction.timeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"default-route-action.timeout.seconds" => Some(("defaultRouteAction.timeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.host-rewrite" => Some(("defaultRouteAction.urlRewrite.hostRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-route-action.url-rewrite.path-prefix-rewrite" => Some(("defaultRouteAction.urlRewrite.pathPrefixRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-service" => Some(("defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.host-redirect" => Some(("defaultUrlRedirect.hostRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.https-redirect" => Some(("defaultUrlRedirect.httpsRedirect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.path-redirect" => Some(("defaultUrlRedirect.pathRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.prefix-redirect" => Some(("defaultUrlRedirect.prefixRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.redirect-response-code" => Some(("defaultUrlRedirect.redirectResponseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"default-url-redirect.strip-query" => Some(("defaultUrlRedirect.stripQuery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"fingerprint" => Some(("fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"header-action.request-headers-to-remove" => Some(("headerAction.requestHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"header-action.response-headers-to-remove" => Some(("headerAction.responseHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abort", "allow-credentials", "allow-headers", "allow-methods", "allow-origin-regexes", "allow-origins", "backend-service", "cors-policy", "creation-timestamp", "default-route-action", "default-service", "default-url-redirect", "delay", "description", "disabled", "expose-headers", "fault-injection-policy", "fingerprint", "fixed-delay", "header-action", "host-redirect", "host-rewrite", "http-status", "https-redirect", "id", "kind", "max-age", "max-stream-duration", "name", "nanos", "num-retries", "path-prefix-rewrite", "path-redirect", "per-try-timeout", "percentage", "prefix-redirect", "redirect-response-code", "region", "request-headers-to-remove", "request-mirror-policy", "response-headers-to-remove", "retry-conditions", "retry-policy", "seconds", "self-link", "strip-query", "timeout", "url-rewrite"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMap = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.url_maps().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _url_maps_validate(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"load-balancing-schemes" => Some(("loadBalancingSchemes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.creation-timestamp" => Some(("resource.creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.cors-policy.allow-credentials" => Some(("resource.defaultRouteAction.corsPolicy.allowCredentials", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.cors-policy.allow-headers" => Some(("resource.defaultRouteAction.corsPolicy.allowHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.allow-methods" => Some(("resource.defaultRouteAction.corsPolicy.allowMethods", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.allow-origin-regexes" => Some(("resource.defaultRouteAction.corsPolicy.allowOriginRegexes", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.allow-origins" => Some(("resource.defaultRouteAction.corsPolicy.allowOrigins", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.disabled" => Some(("resource.defaultRouteAction.corsPolicy.disabled", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.cors-policy.expose-headers" => Some(("resource.defaultRouteAction.corsPolicy.exposeHeaders", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.cors-policy.max-age" => Some(("resource.defaultRouteAction.corsPolicy.maxAge", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.abort.http-status" => Some(("resource.defaultRouteAction.faultInjectionPolicy.abort.httpStatus", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.abort.percentage" => Some(("resource.defaultRouteAction.faultInjectionPolicy.abort.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.delay.fixed-delay.nanos" => Some(("resource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.delay.fixed-delay.seconds" => Some(("resource.defaultRouteAction.faultInjectionPolicy.delay.fixedDelay.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.fault-injection-policy.delay.percentage" => Some(("resource.defaultRouteAction.faultInjectionPolicy.delay.percentage", JsonTypeInfo { jtype: JsonType::Float, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.max-stream-duration.nanos" => Some(("resource.defaultRouteAction.maxStreamDuration.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.max-stream-duration.seconds" => Some(("resource.defaultRouteAction.maxStreamDuration.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.request-mirror-policy.backend-service" => Some(("resource.defaultRouteAction.requestMirrorPolicy.backendService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.retry-policy.num-retries" => Some(("resource.defaultRouteAction.retryPolicy.numRetries", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.retry-policy.per-try-timeout.nanos" => Some(("resource.defaultRouteAction.retryPolicy.perTryTimeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.retry-policy.per-try-timeout.seconds" => Some(("resource.defaultRouteAction.retryPolicy.perTryTimeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.retry-policy.retry-conditions" => Some(("resource.defaultRouteAction.retryPolicy.retryConditions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.default-route-action.timeout.nanos" => Some(("resource.defaultRouteAction.timeout.nanos", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.timeout.seconds" => Some(("resource.defaultRouteAction.timeout.seconds", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.url-rewrite.host-rewrite" => Some(("resource.defaultRouteAction.urlRewrite.hostRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-route-action.url-rewrite.path-prefix-rewrite" => Some(("resource.defaultRouteAction.urlRewrite.pathPrefixRewrite", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-service" => Some(("resource.defaultService", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.host-redirect" => Some(("resource.defaultUrlRedirect.hostRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.https-redirect" => Some(("resource.defaultUrlRedirect.httpsRedirect", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.path-redirect" => Some(("resource.defaultUrlRedirect.pathRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.prefix-redirect" => Some(("resource.defaultUrlRedirect.prefixRedirect", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.redirect-response-code" => Some(("resource.defaultUrlRedirect.redirectResponseCode", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.default-url-redirect.strip-query" => Some(("resource.defaultUrlRedirect.stripQuery", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
|
|
"resource.description" => Some(("resource.description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.fingerprint" => Some(("resource.fingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.header-action.request-headers-to-remove" => Some(("resource.headerAction.requestHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.header-action.response-headers-to-remove" => Some(("resource.headerAction.responseHeadersToRemove", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"resource.id" => Some(("resource.id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.kind" => Some(("resource.kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.name" => Some(("resource.name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.region" => Some(("resource.region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"resource.self-link" => Some(("resource.selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["abort", "allow-credentials", "allow-headers", "allow-methods", "allow-origin-regexes", "allow-origins", "backend-service", "cors-policy", "creation-timestamp", "default-route-action", "default-service", "default-url-redirect", "delay", "description", "disabled", "expose-headers", "fault-injection-policy", "fingerprint", "fixed-delay", "header-action", "host-redirect", "host-rewrite", "http-status", "https-redirect", "id", "kind", "load-balancing-schemes", "max-age", "max-stream-duration", "name", "nanos", "num-retries", "path-prefix-rewrite", "path-redirect", "per-try-timeout", "percentage", "prefix-redirect", "redirect-response-code", "region", "request-headers-to-remove", "request-mirror-policy", "resource", "response-headers-to-remove", "retry-conditions", "retry-policy", "seconds", "self-link", "strip-query", "timeout", "url-rewrite"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::UrlMapsValidateRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.url_maps().validate(request, opt.value_of("project").unwrap_or(""), opt.value_of("url-map").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_gateways_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_gateways().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_gateways_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_gateways().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("vpn-gateway").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_gateways_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_gateways().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("vpn-gateway").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_gateways_get_status(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_gateways().get_status(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("vpn-gateway").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_gateways_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"network" => Some(("network", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"stack-type" => Some(("stackType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "id", "kind", "label-fingerprint", "labels", "name", "network", "region", "self-link", "stack-type"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::VpnGateway = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.vpn_gateways().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_gateways_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_gateways().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_gateways_set_labels(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"label-fingerprint" => Some(("labelFingerprint", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"labels" => Some(("labels", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["label-fingerprint", "labels"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::RegionSetLabelsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.vpn_gateways().set_labels(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_gateways_test_iam_permissions(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"permissions" => Some(("permissions", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["permissions"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::TestPermissionsRequest = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.vpn_gateways().test_iam_permissions(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_tunnels_aggregated_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_tunnels().aggregated_list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"include-all-scopes" => {
|
|
call = call.include_all_scopes(arg_from_str(value.unwrap_or("false"), err, "include-all-scopes", "boolean"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "include-all-scopes", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_tunnels_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_tunnels().delete(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("vpn-tunnel").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_tunnels_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_tunnels().get(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""), opt.value_of("vpn-tunnel").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_tunnels_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.push(field_err);
|
|
}
|
|
if value.is_none() {
|
|
field_cursor = temp_cursor.clone();
|
|
if err.issues.len() > last_errc {
|
|
err.issues.remove(last_errc);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
match &temp_cursor.to_string()[..] {
|
|
"creation-timestamp" => Some(("creationTimestamp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"detailed-status" => Some(("detailedStatus", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"ike-version" => Some(("ikeVersion", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"kind" => Some(("kind", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"local-traffic-selector" => Some(("localTrafficSelector", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"peer-external-gateway" => Some(("peerExternalGateway", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"peer-external-gateway-interface" => Some(("peerExternalGatewayInterface", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
"peer-gcp-gateway" => Some(("peerGcpGateway", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"peer-ip" => Some(("peerIp", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"region" => Some(("region", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"remote-traffic-selector" => Some(("remoteTrafficSelector", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Vec })),
|
|
"router" => Some(("router", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"self-link" => Some(("selfLink", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shared-secret" => Some(("sharedSecret", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"shared-secret-hash" => Some(("sharedSecretHash", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"status" => Some(("status", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"target-vpn-gateway" => Some(("targetVpnGateway", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"vpn-gateway" => Some(("vpnGateway", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
"vpn-gateway-interface" => Some(("vpnGatewayInterface", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
|
|
_ => {
|
|
let suggestion = FieldCursor::did_you_mean(key, &vec!["creation-timestamp", "description", "detailed-status", "id", "ike-version", "kind", "local-traffic-selector", "name", "peer-external-gateway", "peer-external-gateway-interface", "peer-gcp-gateway", "peer-ip", "region", "remote-traffic-selector", "router", "self-link", "shared-secret", "shared-secret-hash", "status", "target-vpn-gateway", "vpn-gateway", "vpn-gateway-interface"]);
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
|
|
None
|
|
}
|
|
};
|
|
if let Some((field_cursor_str, type_info)) = type_info {
|
|
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
|
|
}
|
|
}
|
|
let mut request: api::VpnTunnel = json::value::from_value(object).unwrap();
|
|
let mut call = self.hub.vpn_tunnels().insert(request, opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"request-id" => {
|
|
call = call.request_id(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["request-id"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _vpn_tunnels_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.vpn_tunnels().list(opt.value_of("project").unwrap_or(""), opt.value_of("region").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _zone_operations_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.zone_operations().delete(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok(mut response) => {
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _zone_operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.zone_operations().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _zone_operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.zone_operations().list(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _zone_operations_wait(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.zone_operations().wait(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _zones_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.zones().get(opt.value_of("project").unwrap_or(""), opt.value_of("zone").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _zones_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Result<(), DoitError> {
|
|
let mut call = self.hub.zones().list(opt.value_of("project").unwrap_or(""));
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"return-partial-success" => {
|
|
call = call.return_partial_success(arg_from_str(value.unwrap_or("false"), err, "return-partial-success", "boolean"));
|
|
},
|
|
"page-token" => {
|
|
call = call.page_token(value.unwrap_or(""));
|
|
},
|
|
"order-by" => {
|
|
call = call.order_by(value.unwrap_or(""));
|
|
},
|
|
"max-results" => {
|
|
call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer"));
|
|
},
|
|
"filter" => {
|
|
call = call.filter(value.unwrap_or(""));
|
|
},
|
|
_ => {
|
|
let mut found = false;
|
|
for param in &self.gp {
|
|
if key == *param {
|
|
found = true;
|
|
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
|
|
break;
|
|
}
|
|
}
|
|
if !found {
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
{let mut v = Vec::new();
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
v.extend(["filter", "max-results", "order-by", "page-token", "return-partial-success"].iter().map(|v|*v));
|
|
v } ));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let protocol = CallType::Standard;
|
|
if dry_run {
|
|
Ok(())
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
call = call.add_scope(scope);
|
|
}
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
Ok(mut f) => f,
|
|
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
|
|
};
|
|
match match protocol {
|
|
CallType::Standard => call.doit().await,
|
|
_ => unreachable!()
|
|
} {
|
|
Err(api_err) => Err(DoitError::ApiError(api_err)),
|
|
Ok((mut response, output_schema)) => {
|
|
let mut value = json::value::to_value(&output_schema).expect("serde to work");
|
|
remove_json_null_values(&mut value);
|
|
json::to_writer_pretty(&mut ostream, &value).unwrap();
|
|
ostream.flush().unwrap();
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async fn _doit(&self, dry_run: bool) -> Result<Result<(), DoitError>, Option<InvalidOptionsError>> {
|
|
let mut err = InvalidOptionsError::new();
|
|
let mut call_result: Result<(), DoitError> = Ok(());
|
|
let mut err_opt: Option<InvalidOptionsError> = None;
|
|
match self.opt.subcommand() {
|
|
("accelerator-types", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._accelerator_types_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._accelerator_types_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._accelerator_types_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("accelerator-types".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("addresses", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._addresses_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._addresses_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._addresses_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._addresses_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._addresses_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("addresses".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("autoscalers", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._autoscalers_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._autoscalers_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._autoscalers_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._autoscalers_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._autoscalers_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._autoscalers_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._autoscalers_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("autoscalers".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("backend-buckets", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-signed-url-key", Some(opt)) => {
|
|
call_result = self._backend_buckets_add_signed_url_key(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._backend_buckets_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete-signed-url-key", Some(opt)) => {
|
|
call_result = self._backend_buckets_delete_signed_url_key(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._backend_buckets_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._backend_buckets_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._backend_buckets_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._backend_buckets_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-edge-security-policy", Some(opt)) => {
|
|
call_result = self._backend_buckets_set_edge_security_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._backend_buckets_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("backend-buckets".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("backend-services", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-signed-url-key", Some(opt)) => {
|
|
call_result = self._backend_services_add_signed_url_key(opt, dry_run, &mut err).await;
|
|
},
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._backend_services_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._backend_services_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete-signed-url-key", Some(opt)) => {
|
|
call_result = self._backend_services_delete_signed_url_key(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._backend_services_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-health", Some(opt)) => {
|
|
call_result = self._backend_services_get_health(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._backend_services_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._backend_services_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._backend_services_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-edge-security-policy", Some(opt)) => {
|
|
call_result = self._backend_services_set_edge_security_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-security-policy", Some(opt)) => {
|
|
call_result = self._backend_services_set_security_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._backend_services_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("backend-services".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("disk-types", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._disk_types_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._disk_types_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._disk_types_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("disk-types".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("disks", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-resource-policies", Some(opt)) => {
|
|
call_result = self._disks_add_resource_policies(opt, dry_run, &mut err).await;
|
|
},
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._disks_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("create-snapshot", Some(opt)) => {
|
|
call_result = self._disks_create_snapshot(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._disks_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._disks_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._disks_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._disks_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._disks_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-resource-policies", Some(opt)) => {
|
|
call_result = self._disks_remove_resource_policies(opt, dry_run, &mut err).await;
|
|
},
|
|
("resize", Some(opt)) => {
|
|
call_result = self._disks_resize(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._disks_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._disks_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._disks_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("disks".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("external-vpn-gateways", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._external_vpn_gateways_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._external_vpn_gateways_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._external_vpn_gateways_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._external_vpn_gateways_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._external_vpn_gateways_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._external_vpn_gateways_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("external-vpn-gateways".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("firewall-policies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-association", Some(opt)) => {
|
|
call_result = self._firewall_policies_add_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("add-rule", Some(opt)) => {
|
|
call_result = self._firewall_policies_add_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("clone-rules", Some(opt)) => {
|
|
call_result = self._firewall_policies_clone_rules(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._firewall_policies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._firewall_policies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-association", Some(opt)) => {
|
|
call_result = self._firewall_policies_get_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._firewall_policies_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-rule", Some(opt)) => {
|
|
call_result = self._firewall_policies_get_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._firewall_policies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._firewall_policies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-associations", Some(opt)) => {
|
|
call_result = self._firewall_policies_list_associations(opt, dry_run, &mut err).await;
|
|
},
|
|
("move", Some(opt)) => {
|
|
call_result = self._firewall_policies_move(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._firewall_policies_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch-rule", Some(opt)) => {
|
|
call_result = self._firewall_policies_patch_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-association", Some(opt)) => {
|
|
call_result = self._firewall_policies_remove_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-rule", Some(opt)) => {
|
|
call_result = self._firewall_policies_remove_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._firewall_policies_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._firewall_policies_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("firewall-policies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("firewalls", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._firewalls_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._firewalls_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._firewalls_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._firewalls_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._firewalls_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._firewalls_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("firewalls".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("forwarding-rules", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._forwarding_rules_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._forwarding_rules_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._forwarding_rules_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._forwarding_rules_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._forwarding_rules_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._forwarding_rules_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._forwarding_rules_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-target", Some(opt)) => {
|
|
call_result = self._forwarding_rules_set_target(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("forwarding-rules".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("global-addresses", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._global_addresses_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._global_addresses_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._global_addresses_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._global_addresses_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("global-addresses".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("global-forwarding-rules", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._global_forwarding_rules_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._global_forwarding_rules_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._global_forwarding_rules_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._global_forwarding_rules_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._global_forwarding_rules_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._global_forwarding_rules_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-target", Some(opt)) => {
|
|
call_result = self._global_forwarding_rules_set_target(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("global-forwarding-rules".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("global-network-endpoint-groups", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("attach-network-endpoints", Some(opt)) => {
|
|
call_result = self._global_network_endpoint_groups_attach_network_endpoints(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._global_network_endpoint_groups_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("detach-network-endpoints", Some(opt)) => {
|
|
call_result = self._global_network_endpoint_groups_detach_network_endpoints(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._global_network_endpoint_groups_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._global_network_endpoint_groups_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._global_network_endpoint_groups_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-network-endpoints", Some(opt)) => {
|
|
call_result = self._global_network_endpoint_groups_list_network_endpoints(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("global-network-endpoint-groups".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("global-operations", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._global_operations_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._global_operations_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._global_operations_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._global_operations_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("wait", Some(opt)) => {
|
|
call_result = self._global_operations_wait(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("global-operations".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("global-organization-operations", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._global_organization_operations_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._global_organization_operations_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._global_organization_operations_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("global-organization-operations".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("global-public-delegated-prefixes", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._global_public_delegated_prefixes_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._global_public_delegated_prefixes_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._global_public_delegated_prefixes_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._global_public_delegated_prefixes_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._global_public_delegated_prefixes_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("global-public-delegated-prefixes".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("health-checks", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._health_checks_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._health_checks_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._health_checks_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._health_checks_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._health_checks_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._health_checks_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._health_checks_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("health-checks".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("http-health-checks", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._http_health_checks_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._http_health_checks_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._http_health_checks_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._http_health_checks_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._http_health_checks_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._http_health_checks_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("http-health-checks".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("https-health-checks", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._https_health_checks_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._https_health_checks_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._https_health_checks_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._https_health_checks_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._https_health_checks_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._https_health_checks_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("https-health-checks".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("image-family-views", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("get", Some(opt)) => {
|
|
call_result = self._image_family_views_get(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("image-family-views".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("images", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._images_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("deprecate", Some(opt)) => {
|
|
call_result = self._images_deprecate(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._images_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-from-family", Some(opt)) => {
|
|
call_result = self._images_get_from_family(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._images_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._images_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._images_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._images_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._images_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._images_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._images_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("images".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("instance-group-managers", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("abandon-instances", Some(opt)) => {
|
|
call_result = self._instance_group_managers_abandon_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._instance_group_managers_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("apply-updates-to-instances", Some(opt)) => {
|
|
call_result = self._instance_group_managers_apply_updates_to_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("create-instances", Some(opt)) => {
|
|
call_result = self._instance_group_managers_create_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._instance_group_managers_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete-instances", Some(opt)) => {
|
|
call_result = self._instance_group_managers_delete_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete-per-instance-configs", Some(opt)) => {
|
|
call_result = self._instance_group_managers_delete_per_instance_configs(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._instance_group_managers_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._instance_group_managers_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._instance_group_managers_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-errors", Some(opt)) => {
|
|
call_result = self._instance_group_managers_list_errors(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-managed-instances", Some(opt)) => {
|
|
call_result = self._instance_group_managers_list_managed_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-per-instance-configs", Some(opt)) => {
|
|
call_result = self._instance_group_managers_list_per_instance_configs(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._instance_group_managers_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch-per-instance-configs", Some(opt)) => {
|
|
call_result = self._instance_group_managers_patch_per_instance_configs(opt, dry_run, &mut err).await;
|
|
},
|
|
("recreate-instances", Some(opt)) => {
|
|
call_result = self._instance_group_managers_recreate_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("resize", Some(opt)) => {
|
|
call_result = self._instance_group_managers_resize(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-instance-template", Some(opt)) => {
|
|
call_result = self._instance_group_managers_set_instance_template(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-target-pools", Some(opt)) => {
|
|
call_result = self._instance_group_managers_set_target_pools(opt, dry_run, &mut err).await;
|
|
},
|
|
("update-per-instance-configs", Some(opt)) => {
|
|
call_result = self._instance_group_managers_update_per_instance_configs(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("instance-group-managers".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("instance-groups", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-instances", Some(opt)) => {
|
|
call_result = self._instance_groups_add_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._instance_groups_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._instance_groups_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._instance_groups_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._instance_groups_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._instance_groups_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-instances", Some(opt)) => {
|
|
call_result = self._instance_groups_list_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-instances", Some(opt)) => {
|
|
call_result = self._instance_groups_remove_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-named-ports", Some(opt)) => {
|
|
call_result = self._instance_groups_set_named_ports(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("instance-groups".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("instance-templates", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._instance_templates_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._instance_templates_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._instance_templates_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._instance_templates_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._instance_templates_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._instance_templates_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._instance_templates_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("instance-templates".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("instances", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-access-config", Some(opt)) => {
|
|
call_result = self._instances_add_access_config(opt, dry_run, &mut err).await;
|
|
},
|
|
("add-resource-policies", Some(opt)) => {
|
|
call_result = self._instances_add_resource_policies(opt, dry_run, &mut err).await;
|
|
},
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._instances_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("attach-disk", Some(opt)) => {
|
|
call_result = self._instances_attach_disk(opt, dry_run, &mut err).await;
|
|
},
|
|
("bulk-insert", Some(opt)) => {
|
|
call_result = self._instances_bulk_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._instances_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete-access-config", Some(opt)) => {
|
|
call_result = self._instances_delete_access_config(opt, dry_run, &mut err).await;
|
|
},
|
|
("detach-disk", Some(opt)) => {
|
|
call_result = self._instances_detach_disk(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._instances_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-effective-firewalls", Some(opt)) => {
|
|
call_result = self._instances_get_effective_firewalls(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-guest-attributes", Some(opt)) => {
|
|
call_result = self._instances_get_guest_attributes(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._instances_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-screenshot", Some(opt)) => {
|
|
call_result = self._instances_get_screenshot(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-serial-port-output", Some(opt)) => {
|
|
call_result = self._instances_get_serial_port_output(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-shielded-instance-identity", Some(opt)) => {
|
|
call_result = self._instances_get_shielded_instance_identity(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._instances_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._instances_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-referrers", Some(opt)) => {
|
|
call_result = self._instances_list_referrers(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-resource-policies", Some(opt)) => {
|
|
call_result = self._instances_remove_resource_policies(opt, dry_run, &mut err).await;
|
|
},
|
|
("reset", Some(opt)) => {
|
|
call_result = self._instances_reset(opt, dry_run, &mut err).await;
|
|
},
|
|
("resume", Some(opt)) => {
|
|
call_result = self._instances_resume(opt, dry_run, &mut err).await;
|
|
},
|
|
("send-diagnostic-interrupt", Some(opt)) => {
|
|
call_result = self._instances_send_diagnostic_interrupt(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-deletion-protection", Some(opt)) => {
|
|
call_result = self._instances_set_deletion_protection(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-disk-auto-delete", Some(opt)) => {
|
|
call_result = self._instances_set_disk_auto_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._instances_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._instances_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-machine-resources", Some(opt)) => {
|
|
call_result = self._instances_set_machine_resources(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-machine-type", Some(opt)) => {
|
|
call_result = self._instances_set_machine_type(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-metadata", Some(opt)) => {
|
|
call_result = self._instances_set_metadata(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-min-cpu-platform", Some(opt)) => {
|
|
call_result = self._instances_set_min_cpu_platform(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-scheduling", Some(opt)) => {
|
|
call_result = self._instances_set_scheduling(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-service-account", Some(opt)) => {
|
|
call_result = self._instances_set_service_account(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-shielded-instance-integrity-policy", Some(opt)) => {
|
|
call_result = self._instances_set_shielded_instance_integrity_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-tags", Some(opt)) => {
|
|
call_result = self._instances_set_tags(opt, dry_run, &mut err).await;
|
|
},
|
|
("simulate-maintenance-event", Some(opt)) => {
|
|
call_result = self._instances_simulate_maintenance_event(opt, dry_run, &mut err).await;
|
|
},
|
|
("start", Some(opt)) => {
|
|
call_result = self._instances_start(opt, dry_run, &mut err).await;
|
|
},
|
|
("start-with-encryption-key", Some(opt)) => {
|
|
call_result = self._instances_start_with_encryption_key(opt, dry_run, &mut err).await;
|
|
},
|
|
("stop", Some(opt)) => {
|
|
call_result = self._instances_stop(opt, dry_run, &mut err).await;
|
|
},
|
|
("suspend", Some(opt)) => {
|
|
call_result = self._instances_suspend(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._instances_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._instances_update(opt, dry_run, &mut err).await;
|
|
},
|
|
("update-access-config", Some(opt)) => {
|
|
call_result = self._instances_update_access_config(opt, dry_run, &mut err).await;
|
|
},
|
|
("update-display-device", Some(opt)) => {
|
|
call_result = self._instances_update_display_device(opt, dry_run, &mut err).await;
|
|
},
|
|
("update-network-interface", Some(opt)) => {
|
|
call_result = self._instances_update_network_interface(opt, dry_run, &mut err).await;
|
|
},
|
|
("update-shielded-instance-config", Some(opt)) => {
|
|
call_result = self._instances_update_shielded_instance_config(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("instances".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("interconnect-attachments", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._interconnect_attachments_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._interconnect_attachments_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._interconnect_attachments_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._interconnect_attachments_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._interconnect_attachments_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._interconnect_attachments_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("interconnect-attachments".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("interconnect-locations", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("get", Some(opt)) => {
|
|
call_result = self._interconnect_locations_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._interconnect_locations_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("interconnect-locations".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("interconnects", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._interconnects_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._interconnects_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-diagnostics", Some(opt)) => {
|
|
call_result = self._interconnects_get_diagnostics(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._interconnects_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._interconnects_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._interconnects_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("interconnects".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("license-codes", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("get", Some(opt)) => {
|
|
call_result = self._license_codes_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._license_codes_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("license-codes".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("licenses", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._licenses_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._licenses_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._licenses_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._licenses_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._licenses_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._licenses_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._licenses_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("licenses".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("machine-images", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._machine_images_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._machine_images_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._machine_images_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._machine_images_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._machine_images_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._machine_images_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._machine_images_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("machine-images".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("machine-types", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._machine_types_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._machine_types_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._machine_types_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("machine-types".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("network-endpoint-groups", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("attach-network-endpoints", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_attach_network_endpoints(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("detach-network-endpoints", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_detach_network_endpoints(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-network-endpoints", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_list_network_endpoints(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._network_endpoint_groups_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("network-endpoint-groups".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("network-firewall-policies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-association", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_add_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("add-rule", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_add_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("clone-rules", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_clone_rules(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-association", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_get_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-rule", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_get_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch-rule", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_patch_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-association", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_remove_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-rule", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_remove_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._network_firewall_policies_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("network-firewall-policies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("networks", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-peering", Some(opt)) => {
|
|
call_result = self._networks_add_peering(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._networks_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._networks_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-effective-firewalls", Some(opt)) => {
|
|
call_result = self._networks_get_effective_firewalls(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._networks_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._networks_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-peering-routes", Some(opt)) => {
|
|
call_result = self._networks_list_peering_routes(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._networks_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-peering", Some(opt)) => {
|
|
call_result = self._networks_remove_peering(opt, dry_run, &mut err).await;
|
|
},
|
|
("switch-to-custom-mode", Some(opt)) => {
|
|
call_result = self._networks_switch_to_custom_mode(opt, dry_run, &mut err).await;
|
|
},
|
|
("update-peering", Some(opt)) => {
|
|
call_result = self._networks_update_peering(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("networks".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("node-groups", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-nodes", Some(opt)) => {
|
|
call_result = self._node_groups_add_nodes(opt, dry_run, &mut err).await;
|
|
},
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._node_groups_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._node_groups_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete-nodes", Some(opt)) => {
|
|
call_result = self._node_groups_delete_nodes(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._node_groups_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._node_groups_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._node_groups_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._node_groups_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-nodes", Some(opt)) => {
|
|
call_result = self._node_groups_list_nodes(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._node_groups_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._node_groups_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-node-template", Some(opt)) => {
|
|
call_result = self._node_groups_set_node_template(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._node_groups_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("node-groups".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("node-templates", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._node_templates_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._node_templates_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._node_templates_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._node_templates_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._node_templates_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._node_templates_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._node_templates_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._node_templates_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("node-templates".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("node-types", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._node_types_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._node_types_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._node_types_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("node-types".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("packet-mirrorings", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._packet_mirrorings_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._packet_mirrorings_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._packet_mirrorings_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._packet_mirrorings_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._packet_mirrorings_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._packet_mirrorings_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._packet_mirrorings_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("packet-mirrorings".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("projects", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("disable-xpn-host", Some(opt)) => {
|
|
call_result = self._projects_disable_xpn_host(opt, dry_run, &mut err).await;
|
|
},
|
|
("disable-xpn-resource", Some(opt)) => {
|
|
call_result = self._projects_disable_xpn_resource(opt, dry_run, &mut err).await;
|
|
},
|
|
("enable-xpn-host", Some(opt)) => {
|
|
call_result = self._projects_enable_xpn_host(opt, dry_run, &mut err).await;
|
|
},
|
|
("enable-xpn-resource", Some(opt)) => {
|
|
call_result = self._projects_enable_xpn_resource(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._projects_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-xpn-host", Some(opt)) => {
|
|
call_result = self._projects_get_xpn_host(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-xpn-resources", Some(opt)) => {
|
|
call_result = self._projects_get_xpn_resources(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-xpn-hosts", Some(opt)) => {
|
|
call_result = self._projects_list_xpn_hosts(opt, dry_run, &mut err).await;
|
|
},
|
|
("move-disk", Some(opt)) => {
|
|
call_result = self._projects_move_disk(opt, dry_run, &mut err).await;
|
|
},
|
|
("move-instance", Some(opt)) => {
|
|
call_result = self._projects_move_instance(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-common-instance-metadata", Some(opt)) => {
|
|
call_result = self._projects_set_common_instance_metadata(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-default-network-tier", Some(opt)) => {
|
|
call_result = self._projects_set_default_network_tier(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-usage-export-bucket", Some(opt)) => {
|
|
call_result = self._projects_set_usage_export_bucket(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("projects".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("public-advertised-prefixes", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._public_advertised_prefixes_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._public_advertised_prefixes_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._public_advertised_prefixes_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._public_advertised_prefixes_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._public_advertised_prefixes_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("public-advertised-prefixes".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("public-delegated-prefixes", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._public_delegated_prefixes_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._public_delegated_prefixes_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._public_delegated_prefixes_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._public_delegated_prefixes_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._public_delegated_prefixes_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._public_delegated_prefixes_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("public-delegated-prefixes".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-autoscalers", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_autoscalers_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_autoscalers_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_autoscalers_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_autoscalers_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._region_autoscalers_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._region_autoscalers_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-autoscalers".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-backend-services", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_backend_services_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_backend_services_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-health", Some(opt)) => {
|
|
call_result = self._region_backend_services_get_health(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_backend_services_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_backend_services_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._region_backend_services_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._region_backend_services_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-backend-services".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-commitments", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._region_commitments_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_commitments_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_commitments_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_commitments_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._region_commitments_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-commitments".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-disk-types", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_disk_types_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_disk_types_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-disk-types".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-disks", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-resource-policies", Some(opt)) => {
|
|
call_result = self._region_disks_add_resource_policies(opt, dry_run, &mut err).await;
|
|
},
|
|
("create-snapshot", Some(opt)) => {
|
|
call_result = self._region_disks_create_snapshot(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_disks_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_disks_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._region_disks_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_disks_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_disks_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-resource-policies", Some(opt)) => {
|
|
call_result = self._region_disks_remove_resource_policies(opt, dry_run, &mut err).await;
|
|
},
|
|
("resize", Some(opt)) => {
|
|
call_result = self._region_disks_resize(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._region_disks_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._region_disks_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._region_disks_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-disks".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-health-check-services", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_health_check_services_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_health_check_services_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_health_check_services_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_health_check_services_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._region_health_check_services_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-health-check-services".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-health-checks", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_health_checks_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_health_checks_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_health_checks_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_health_checks_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._region_health_checks_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._region_health_checks_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-health-checks".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-instance-group-managers", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("abandon-instances", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_abandon_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("apply-updates-to-instances", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_apply_updates_to_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("create-instances", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_create_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete-instances", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_delete_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete-per-instance-configs", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_delete_per_instance_configs(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-errors", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_list_errors(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-managed-instances", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_list_managed_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-per-instance-configs", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_list_per_instance_configs(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch-per-instance-configs", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_patch_per_instance_configs(opt, dry_run, &mut err).await;
|
|
},
|
|
("recreate-instances", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_recreate_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("resize", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_resize(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-instance-template", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_set_instance_template(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-target-pools", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_set_target_pools(opt, dry_run, &mut err).await;
|
|
},
|
|
("update-per-instance-configs", Some(opt)) => {
|
|
call_result = self._region_instance_group_managers_update_per_instance_configs(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-instance-group-managers".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-instance-groups", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_instance_groups_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_instance_groups_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-instances", Some(opt)) => {
|
|
call_result = self._region_instance_groups_list_instances(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-named-ports", Some(opt)) => {
|
|
call_result = self._region_instance_groups_set_named_ports(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-instance-groups".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-instances", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("bulk-insert", Some(opt)) => {
|
|
call_result = self._region_instances_bulk_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-instances".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-network-endpoint-groups", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_network_endpoint_groups_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_network_endpoint_groups_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_network_endpoint_groups_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_network_endpoint_groups_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-network-endpoint-groups".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-network-firewall-policies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-association", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_add_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("add-rule", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_add_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("clone-rules", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_clone_rules(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-association", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_get_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-effective-firewalls", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_get_effective_firewalls(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-rule", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_get_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch-rule", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_patch_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-association", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_remove_association(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-rule", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_remove_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._region_network_firewall_policies_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-network-firewall-policies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-notification-endpoints", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_notification_endpoints_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_notification_endpoints_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_notification_endpoints_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_notification_endpoints_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-notification-endpoints".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-operations", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_operations_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_operations_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_operations_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("wait", Some(opt)) => {
|
|
call_result = self._region_operations_wait(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-operations".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-ssl-certificates", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_ssl_certificates_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_ssl_certificates_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_ssl_certificates_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_ssl_certificates_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-ssl-certificates".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-target-http-proxies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_target_http_proxies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_target_http_proxies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_target_http_proxies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_target_http_proxies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-url-map", Some(opt)) => {
|
|
call_result = self._region_target_http_proxies_set_url_map(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-target-http-proxies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-target-https-proxies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_target_https_proxies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_target_https_proxies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_target_https_proxies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_target_https_proxies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-ssl-certificates", Some(opt)) => {
|
|
call_result = self._region_target_https_proxies_set_ssl_certificates(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-url-map", Some(opt)) => {
|
|
call_result = self._region_target_https_proxies_set_url_map(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-target-https-proxies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("region-url-maps", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._region_url_maps_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._region_url_maps_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._region_url_maps_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._region_url_maps_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._region_url_maps_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._region_url_maps_update(opt, dry_run, &mut err).await;
|
|
},
|
|
("validate", Some(opt)) => {
|
|
call_result = self._region_url_maps_validate(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("region-url-maps".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("regions", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("get", Some(opt)) => {
|
|
call_result = self._regions_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._regions_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("regions".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("reservations", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._reservations_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._reservations_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._reservations_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._reservations_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._reservations_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._reservations_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("resize", Some(opt)) => {
|
|
call_result = self._reservations_resize(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._reservations_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._reservations_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._reservations_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("reservations".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("resource-policies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._resource_policies_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._resource_policies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._resource_policies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._resource_policies_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._resource_policies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._resource_policies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._resource_policies_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._resource_policies_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("resource-policies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("routers", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._routers_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._routers_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._routers_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-nat-mapping-info", Some(opt)) => {
|
|
call_result = self._routers_get_nat_mapping_info(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-router-status", Some(opt)) => {
|
|
call_result = self._routers_get_router_status(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._routers_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._routers_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._routers_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("preview", Some(opt)) => {
|
|
call_result = self._routers_preview(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._routers_update(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("routers".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("routes", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._routes_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._routes_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._routes_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._routes_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("routes".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("security-policies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-rule", Some(opt)) => {
|
|
call_result = self._security_policies_add_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._security_policies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._security_policies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-rule", Some(opt)) => {
|
|
call_result = self._security_policies_get_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._security_policies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._security_policies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-preconfigured-expression-sets", Some(opt)) => {
|
|
call_result = self._security_policies_list_preconfigured_expression_sets(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._security_policies_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch-rule", Some(opt)) => {
|
|
call_result = self._security_policies_patch_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-rule", Some(opt)) => {
|
|
call_result = self._security_policies_remove_rule(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("security-policies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("service-attachments", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._service_attachments_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._service_attachments_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._service_attachments_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._service_attachments_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._service_attachments_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._service_attachments_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._service_attachments_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._service_attachments_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._service_attachments_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("service-attachments".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("snapshots", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._snapshots_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._snapshots_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._snapshots_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._snapshots_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._snapshots_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._snapshots_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._snapshots_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._snapshots_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("snapshots".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("ssl-certificates", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._ssl_certificates_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._ssl_certificates_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._ssl_certificates_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._ssl_certificates_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._ssl_certificates_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("ssl-certificates".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("ssl-policies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._ssl_policies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._ssl_policies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._ssl_policies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._ssl_policies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-available-features", Some(opt)) => {
|
|
call_result = self._ssl_policies_list_available_features(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._ssl_policies_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("ssl-policies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("subnetworks", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._subnetworks_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._subnetworks_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("expand-ip-cidr-range", Some(opt)) => {
|
|
call_result = self._subnetworks_expand_ip_cidr_range(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._subnetworks_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-iam-policy", Some(opt)) => {
|
|
call_result = self._subnetworks_get_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._subnetworks_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._subnetworks_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("list-usable", Some(opt)) => {
|
|
call_result = self._subnetworks_list_usable(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._subnetworks_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-iam-policy", Some(opt)) => {
|
|
call_result = self._subnetworks_set_iam_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-private-ip-google-access", Some(opt)) => {
|
|
call_result = self._subnetworks_set_private_ip_google_access(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._subnetworks_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("subnetworks".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("target-grpc-proxies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._target_grpc_proxies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._target_grpc_proxies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._target_grpc_proxies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._target_grpc_proxies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._target_grpc_proxies_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("target-grpc-proxies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("target-http-proxies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._target_http_proxies_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._target_http_proxies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._target_http_proxies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._target_http_proxies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._target_http_proxies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._target_http_proxies_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-url-map", Some(opt)) => {
|
|
call_result = self._target_http_proxies_set_url_map(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("target-http-proxies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("target-https-proxies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._target_https_proxies_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._target_https_proxies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._target_https_proxies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._target_https_proxies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._target_https_proxies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._target_https_proxies_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-quic-override", Some(opt)) => {
|
|
call_result = self._target_https_proxies_set_quic_override(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-ssl-certificates", Some(opt)) => {
|
|
call_result = self._target_https_proxies_set_ssl_certificates(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-ssl-policy", Some(opt)) => {
|
|
call_result = self._target_https_proxies_set_ssl_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-url-map", Some(opt)) => {
|
|
call_result = self._target_https_proxies_set_url_map(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("target-https-proxies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("target-instances", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._target_instances_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._target_instances_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._target_instances_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._target_instances_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._target_instances_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("target-instances".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("target-pools", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("add-health-check", Some(opt)) => {
|
|
call_result = self._target_pools_add_health_check(opt, dry_run, &mut err).await;
|
|
},
|
|
("add-instance", Some(opt)) => {
|
|
call_result = self._target_pools_add_instance(opt, dry_run, &mut err).await;
|
|
},
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._target_pools_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._target_pools_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._target_pools_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-health", Some(opt)) => {
|
|
call_result = self._target_pools_get_health(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._target_pools_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._target_pools_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-health-check", Some(opt)) => {
|
|
call_result = self._target_pools_remove_health_check(opt, dry_run, &mut err).await;
|
|
},
|
|
("remove-instance", Some(opt)) => {
|
|
call_result = self._target_pools_remove_instance(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-backup", Some(opt)) => {
|
|
call_result = self._target_pools_set_backup(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("target-pools".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("target-ssl-proxies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._target_ssl_proxies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._target_ssl_proxies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._target_ssl_proxies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._target_ssl_proxies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-backend-service", Some(opt)) => {
|
|
call_result = self._target_ssl_proxies_set_backend_service(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-proxy-header", Some(opt)) => {
|
|
call_result = self._target_ssl_proxies_set_proxy_header(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-ssl-certificates", Some(opt)) => {
|
|
call_result = self._target_ssl_proxies_set_ssl_certificates(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-ssl-policy", Some(opt)) => {
|
|
call_result = self._target_ssl_proxies_set_ssl_policy(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("target-ssl-proxies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("target-tcp-proxies", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._target_tcp_proxies_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._target_tcp_proxies_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._target_tcp_proxies_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._target_tcp_proxies_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-backend-service", Some(opt)) => {
|
|
call_result = self._target_tcp_proxies_set_backend_service(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-proxy-header", Some(opt)) => {
|
|
call_result = self._target_tcp_proxies_set_proxy_header(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("target-tcp-proxies".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("target-vpn-gateways", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._target_vpn_gateways_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._target_vpn_gateways_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._target_vpn_gateways_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._target_vpn_gateways_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._target_vpn_gateways_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("target-vpn-gateways".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("url-maps", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._url_maps_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._url_maps_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._url_maps_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._url_maps_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("invalidate-cache", Some(opt)) => {
|
|
call_result = self._url_maps_invalidate_cache(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._url_maps_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("patch", Some(opt)) => {
|
|
call_result = self._url_maps_patch(opt, dry_run, &mut err).await;
|
|
},
|
|
("update", Some(opt)) => {
|
|
call_result = self._url_maps_update(opt, dry_run, &mut err).await;
|
|
},
|
|
("validate", Some(opt)) => {
|
|
call_result = self._url_maps_validate(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("url-maps".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("vpn-gateways", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._vpn_gateways_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._vpn_gateways_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._vpn_gateways_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("get-status", Some(opt)) => {
|
|
call_result = self._vpn_gateways_get_status(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._vpn_gateways_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._vpn_gateways_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("set-labels", Some(opt)) => {
|
|
call_result = self._vpn_gateways_set_labels(opt, dry_run, &mut err).await;
|
|
},
|
|
("test-iam-permissions", Some(opt)) => {
|
|
call_result = self._vpn_gateways_test_iam_permissions(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("vpn-gateways".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("vpn-tunnels", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("aggregated-list", Some(opt)) => {
|
|
call_result = self._vpn_tunnels_aggregated_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("delete", Some(opt)) => {
|
|
call_result = self._vpn_tunnels_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._vpn_tunnels_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("insert", Some(opt)) => {
|
|
call_result = self._vpn_tunnels_insert(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._vpn_tunnels_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("vpn-tunnels".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("zone-operations", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("delete", Some(opt)) => {
|
|
call_result = self._zone_operations_delete(opt, dry_run, &mut err).await;
|
|
},
|
|
("get", Some(opt)) => {
|
|
call_result = self._zone_operations_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._zone_operations_list(opt, dry_run, &mut err).await;
|
|
},
|
|
("wait", Some(opt)) => {
|
|
call_result = self._zone_operations_wait(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("zone-operations".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
("zones", Some(opt)) => {
|
|
match opt.subcommand() {
|
|
("get", Some(opt)) => {
|
|
call_result = self._zones_get(opt, dry_run, &mut err).await;
|
|
},
|
|
("list", Some(opt)) => {
|
|
call_result = self._zones_list(opt, dry_run, &mut err).await;
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingMethodError("zones".to_string()));
|
|
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
|
|
}
|
|
}
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::MissingCommandError);
|
|
writeln!(io::stderr(), "{}\n", self.opt.usage()).ok();
|
|
}
|
|
}
|
|
|
|
if dry_run {
|
|
if err.issues.len() > 0 {
|
|
err_opt = Some(err);
|
|
}
|
|
Err(err_opt)
|
|
} else {
|
|
Ok(call_result)
|
|
}
|
|
}
|
|
|
|
// Please note that this call will fail if any part of the opt can't be handled
|
|
async fn new(opt: ArgMatches<'n>, connector: S) -> Result<Engine<'n, S>, InvalidOptionsError> {
|
|
let (config_dir, secret) = {
|
|
let config_dir = match client::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) {
|
|
Err(e) => return Err(InvalidOptionsError::single(e, 3)),
|
|
Ok(p) => p,
|
|
};
|
|
|
|
match client::application_secret_from_directory(&config_dir, "compute1-secret.json",
|
|
"{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") {
|
|
Ok(secret) => (config_dir, secret),
|
|
Err(e) => return Err(InvalidOptionsError::single(e, 4))
|
|
}
|
|
};
|
|
|
|
let client = hyper::Client::builder().build(connector);
|
|
|
|
let auth = oauth2::InstalledFlowAuthenticator::with_client(
|
|
secret,
|
|
oauth2::InstalledFlowReturnMethod::HTTPRedirect,
|
|
client.clone(),
|
|
).persist_tokens_to_disk(format!("{}/compute1", config_dir)).build().await.unwrap();
|
|
|
|
let engine = Engine {
|
|
opt: opt,
|
|
hub: api::Compute::new(client, auth),
|
|
gp: vec!["$-xgafv", "access-token", "alt", "callback", "fields", "key", "oauth-token", "pretty-print", "quota-user", "upload-type", "upload-protocol", "user-ip"],
|
|
gpm: vec![
|
|
("$-xgafv", "$.xgafv"),
|
|
("access-token", "access_token"),
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("upload-type", "uploadType"),
|
|
("upload-protocol", "upload_protocol"),
|
|
("user-ip", "userIp"),
|
|
]
|
|
};
|
|
|
|
match engine._doit(true).await {
|
|
Err(Some(err)) => Err(err),
|
|
Err(None) => Ok(engine),
|
|
Ok(_) => unreachable!(),
|
|
}
|
|
}
|
|
|
|
async fn doit(&self) -> Result<(), DoitError> {
|
|
match self._doit(false).await {
|
|
Ok(res) => res,
|
|
Err(_) => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let mut exit_status = 0i32;
|
|
let arg_data = [
|
|
("accelerator-types", "methods: 'aggregated-list', 'get' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of accelerator types."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/accelerator-types_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified accelerator type."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/accelerator-types_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"accelerator-type"##),
|
|
None,
|
|
Some(r##"Name of the accelerator type to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of accelerator types that are available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/accelerator-types_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("addresses", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of addresses."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified address resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"address"##),
|
|
None,
|
|
Some(r##"Name of the address resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified address resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"address"##),
|
|
None,
|
|
Some(r##"Name of the address resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an address resource in the specified project by using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of addresses contained within the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/addresses_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("autoscalers", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of autoscalers."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified autoscaler."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"autoscaler"##),
|
|
None,
|
|
Some(r##"Name of the autoscaler to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified autoscaler resource. Gets a list of available autoscalers by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"autoscaler"##),
|
|
None,
|
|
Some(r##"Name of the autoscaler to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an autoscaler in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of autoscalers contained within the specified zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates an autoscaler in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/autoscalers_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("backend-buckets", "methods: 'add-signed-url-key', 'delete', 'delete-signed-url-key', 'get', 'insert', 'list', 'patch', 'set-edge-security-policy' and 'update'", vec![
|
|
("add-signed-url-key",
|
|
Some(r##"Adds a key for validating requests with signed URLs for this backend bucket."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_add-signed-url-key",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-bucket"##),
|
|
None,
|
|
Some(r##"Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified BackendBucket resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-bucket"##),
|
|
None,
|
|
Some(r##"Name of the BackendBucket resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete-signed-url-key",
|
|
Some(r##"Deletes a key for validating requests with signed URLs for this backend bucket."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_delete-signed-url-key",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-bucket"##),
|
|
None,
|
|
Some(r##"Name of the BackendBucket resource to which the Signed URL Key should be added. The name should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"key-name"##),
|
|
None,
|
|
Some(r##"The name of the Signed URL Key to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified BackendBucket resource. Gets a list of available backend buckets by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-bucket"##),
|
|
None,
|
|
Some(r##"Name of the BackendBucket resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a BackendBucket resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of BackendBucket resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified BackendBucket resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-bucket"##),
|
|
None,
|
|
Some(r##"Name of the BackendBucket resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-edge-security-policy",
|
|
Some(r##"Sets the edge security policy for the specified backend bucket."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_set-edge-security-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-bucket"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates the specified BackendBucket resource with the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-buckets_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-bucket"##),
|
|
None,
|
|
Some(r##"Name of the BackendBucket resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("backend-services", "methods: 'add-signed-url-key', 'aggregated-list', 'delete', 'delete-signed-url-key', 'get', 'get-health', 'insert', 'list', 'patch', 'set-edge-security-policy', 'set-security-policy' and 'update'", vec![
|
|
("add-signed-url-key",
|
|
Some(r##"Adds a key for validating requests with signed URLs for this backend service."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_add-signed-url-key",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to which the Signed URL Key should be added. The name should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of all BackendService resources, regional and global, available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Name of the project scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified BackendService resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete-signed-url-key",
|
|
Some(r##"Deletes a key for validating requests with signed URLs for this backend service."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_delete-signed-url-key",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to which the Signed URL Key should be added. The name should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"key-name"##),
|
|
None,
|
|
Some(r##"The name of the Signed URL Key to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified BackendService resource. Gets a list of available backend services."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-health",
|
|
Some(r##"Gets the most recent health check results for this BackendService. Example request body: { "group": "/zones/us-east1-b/instanceGroups/lb-backend-example" }"##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_get-health",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
None,
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to which the queried instance belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview ."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of BackendService resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified BackendService resource with the data included in the request. For more information, see Backend services overview. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-edge-security-policy",
|
|
Some(r##"Sets the edge security policy for the specified backend service."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_set-edge-security-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to which the edge security policy should be set. The name should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-security-policy",
|
|
Some(r##"Sets the Google Cloud Armor security policy for the specified backend service. For more information, see Google Cloud Armor Overview"##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_set-security-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates the specified BackendService resource with the data included in the request. For more information, see Backend services overview."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/backend-services_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("disk-types", "methods: 'aggregated-list', 'get' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of disk types."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disk-types_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified disk type. Gets a list of available disk types by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disk-types_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk-type"##),
|
|
None,
|
|
Some(r##"Name of the disk type to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of disk types available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disk-types_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("disks", "methods: 'add-resource-policies', 'aggregated-list', 'create-snapshot', 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'remove-resource-policies', 'resize', 'set-iam-policy', 'set-labels' and 'test-iam-permissions'", vec![
|
|
("add-resource-policies",
|
|
Some(r##"Adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_add-resource-policies",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"The disk name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of persistent disks."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("create-snapshot",
|
|
Some(r##"Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_create-snapshot",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"Name of the persistent disk to snapshot."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"Name of the persistent disk to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns a specified persistent disk. Gets a list of available persistent disks by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"Name of the persistent disk to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a persistent disk in the specified project using the data in the request. You can create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of persistent disks contained within the specified zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-resource-policies",
|
|
Some(r##"Removes resource policies from a disk."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_remove-resource-policies",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"The disk name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("resize",
|
|
Some(r##"Resizes the specified persistent disk. You can only increase the size of the disk."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_resize",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"The name of the persistent disk."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/disks_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("external-vpn-gateways", "methods: 'delete', 'get', 'insert', 'list', 'set-labels' and 'test-iam-permissions'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified externalVpnGateway."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/external-vpn-gateways_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"external-vpn-gateway"##),
|
|
None,
|
|
Some(r##"Name of the externalVpnGateways to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified externalVpnGateway. Get a list of available externalVpnGateways by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/external-vpn-gateways_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"external-vpn-gateway"##),
|
|
None,
|
|
Some(r##"Name of the externalVpnGateway to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a ExternalVpnGateway in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/external-vpn-gateways_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of ExternalVpnGateway available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/external-vpn-gateways_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources documentation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/external-vpn-gateways_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/external-vpn-gateways_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("firewall-policies", "methods: 'add-association', 'add-rule', 'clone-rules', 'delete', 'get', 'get-association', 'get-iam-policy', 'get-rule', 'insert', 'list', 'list-associations', 'move', 'patch', 'patch-rule', 'remove-association', 'remove-rule', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("add-association",
|
|
Some(r##"Inserts an association for the specified firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_add-association",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("add-rule",
|
|
Some(r##"Inserts a rule into a firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_add-rule",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("clone-rules",
|
|
Some(r##"Copies rules to the specified firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_clone-rules",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_delete",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_get",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to get."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-association",
|
|
Some(r##"Gets an association with the specified name."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_get-association",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to which the queried rule belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_get-iam-policy",
|
|
vec![
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-rule",
|
|
Some(r##"Gets a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_get-rule",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to which the queried rule belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a new policy in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_insert",
|
|
vec![
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists all the policies that have been configured for the specified folder or organization."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_list",
|
|
vec![
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-associations",
|
|
Some(r##"Lists associations of a specified target, i.e., organization or folder."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_list-associations",
|
|
vec![
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("move",
|
|
Some(r##"Moves the specified firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_move",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified policy with the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_patch",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch-rule",
|
|
Some(r##"Patches a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_patch-rule",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-association",
|
|
Some(r##"Removes an association for the specified firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_remove-association",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-rule",
|
|
Some(r##"Deletes a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_remove-rule",
|
|
vec![
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_set-iam-policy",
|
|
vec![
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewall-policies_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("firewalls", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified firewall."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall"##),
|
|
None,
|
|
Some(r##"Name of the firewall rule to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified firewall."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall"##),
|
|
None,
|
|
Some(r##"Name of the firewall rule to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a firewall rule in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of firewall rules available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified firewall rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall"##),
|
|
None,
|
|
Some(r##"Name of the firewall rule to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates the specified firewall rule with the data included in the request. Note that all fields will be updated if using PUT, even fields that are not specified. To update individual fields, please use PATCH instead."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/firewalls_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall"##),
|
|
None,
|
|
Some(r##"Name of the firewall rule to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("forwarding-rules", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list', 'patch', 'set-labels' and 'set-target'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of forwarding rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified ForwardingRule resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"forwarding-rule"##),
|
|
None,
|
|
Some(r##"Name of the ForwardingRule resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified ForwardingRule resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"forwarding-rule"##),
|
|
None,
|
|
Some(r##"Name of the ForwardingRule resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a ForwardingRule resource in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of ForwardingRule resources available to the specified project and region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"forwarding-rule"##),
|
|
None,
|
|
Some(r##"Name of the ForwardingRule resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets the labels on the specified resource. To learn more about labels, read the Labeling Resources documentation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-target",
|
|
Some(r##"Changes target URL for forwarding rule. The new target should be of the same type as the old target."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/forwarding-rules_set-target",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"forwarding-rule"##),
|
|
None,
|
|
Some(r##"Name of the ForwardingRule resource in which target is to be set."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("global-addresses", "methods: 'delete', 'get', 'insert' and 'list'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified address resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-addresses_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"address"##),
|
|
None,
|
|
Some(r##"Name of the address resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified address resource. Gets a list of available addresses by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-addresses_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"address"##),
|
|
None,
|
|
Some(r##"Name of the address resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an address resource in the specified project by using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-addresses_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of global addresses."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-addresses_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("global-forwarding-rules", "methods: 'delete', 'get', 'insert', 'list', 'patch', 'set-labels' and 'set-target'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified GlobalForwardingRule resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"forwarding-rule"##),
|
|
None,
|
|
Some(r##"Name of the ForwardingRule resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified GlobalForwardingRule resource. Gets a list of available forwarding rules by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"forwarding-rule"##),
|
|
None,
|
|
Some(r##"Name of the ForwardingRule resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a GlobalForwardingRule resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of GlobalForwardingRule resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"forwarding-rule"##),
|
|
None,
|
|
Some(r##"Name of the ForwardingRule resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets the labels on the specified resource. To learn more about labels, read the Labeling resources documentation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-target",
|
|
Some(r##"Changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as the old target."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-forwarding-rules_set-target",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"forwarding-rule"##),
|
|
None,
|
|
Some(r##"Name of the ForwardingRule resource in which target is to be set."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("global-network-endpoint-groups", "methods: 'attach-network-endpoints', 'delete', 'detach-network-endpoints', 'get', 'insert', 'list' and 'list-network-endpoints'", vec![
|
|
("attach-network-endpoints",
|
|
Some(r##"Attach a network endpoint to the specified network endpoint group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-network-endpoint-groups_attach-network-endpoints",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group where you are attaching network endpoints to. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend services referencing it."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-network-endpoint-groups_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group to delete. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("detach-network-endpoints",
|
|
Some(r##"Detach the network endpoint from the specified network endpoint group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-network-endpoint-groups_detach-network-endpoints",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group where you are removing network endpoints. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified network endpoint group. Gets a list of available network endpoint groups by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-network-endpoint-groups_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a network endpoint group in the specified project using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-network-endpoint-groups_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of network endpoint groups that are located in the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-network-endpoint-groups_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-network-endpoints",
|
|
Some(r##"Lists the network endpoints in the specified network endpoint group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-network-endpoint-groups_list-network-endpoints",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("global-operations", "methods: 'aggregated-list', 'delete', 'get', 'list' and 'wait'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of all operations."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified Operations resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
]),
|
|
("get",
|
|
Some(r##"Retrieves the specified Operations resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of Operation resources contained within the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("wait",
|
|
Some(r##"Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-operations_wait",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("global-organization-operations", "methods: 'delete', 'get' and 'list'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified Operations resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-organization-operations_delete",
|
|
vec![
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
]),
|
|
("get",
|
|
Some(r##"Retrieves the specified Operations resource. Gets a list of operations by making a `list()` request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-organization-operations_get",
|
|
vec![
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of Operation resources contained within the specified organization."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-organization-operations_list",
|
|
vec![
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("global-public-delegated-prefixes", "methods: 'delete', 'get', 'insert', 'list' and 'patch'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified global PublicDelegatedPrefix."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-public-delegated-prefixes_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-delegated-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicDelegatedPrefix resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified global PublicDelegatedPrefix resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-public-delegated-prefixes_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-delegated-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicDelegatedPrefix resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a global PublicDelegatedPrefix in the specified project using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-public-delegated-prefixes_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists the global PublicDelegatedPrefixes for a project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-public-delegated-prefixes_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified global PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/global-public-delegated-prefixes_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-delegated-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicDelegatedPrefix resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("health-checks", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of all HealthCheck resources, regional and global, available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Name of the project scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified HealthCheck resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheck resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified HealthCheck resource. Gets a list of available health checks by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheck resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a HealthCheck resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of HealthCheck resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheck resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates a HealthCheck resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/health-checks_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheck resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("http-health-checks", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified HttpHealthCheck resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"http-health-check"##),
|
|
None,
|
|
Some(r##"Name of the HttpHealthCheck resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified HttpHealthCheck resource. Gets a list of available HTTP health checks by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"http-health-check"##),
|
|
None,
|
|
Some(r##"Name of the HttpHealthCheck resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a HttpHealthCheck resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of HttpHealthCheck resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates a HttpHealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"http-health-check"##),
|
|
None,
|
|
Some(r##"Name of the HttpHealthCheck resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates a HttpHealthCheck resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/http-health-checks_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"http-health-check"##),
|
|
None,
|
|
Some(r##"Name of the HttpHealthCheck resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("https-health-checks", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified HttpsHealthCheck resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"https-health-check"##),
|
|
None,
|
|
Some(r##"Name of the HttpsHealthCheck resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified HttpsHealthCheck resource. Gets a list of available HTTPS health checks by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"https-health-check"##),
|
|
None,
|
|
Some(r##"Name of the HttpsHealthCheck resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a HttpsHealthCheck resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of HttpsHealthCheck resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates a HttpsHealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"https-health-check"##),
|
|
None,
|
|
Some(r##"Name of the HttpsHealthCheck resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates a HttpsHealthCheck resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/https-health-checks_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"https-health-check"##),
|
|
None,
|
|
Some(r##"Name of the HttpsHealthCheck resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("image-family-views", "methods: 'get'", vec![
|
|
("get",
|
|
Some(r##"Returns the latest image that is part of an image family, is not deprecated and is rolled out in the specified zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/image-family-views_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"family"##),
|
|
None,
|
|
Some(r##"Name of the image family to search for."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("images", "methods: 'delete', 'deprecate', 'get', 'get-from-family', 'get-iam-policy', 'insert', 'list', 'patch', 'set-iam-policy', 'set-labels' and 'test-iam-permissions'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified image."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"image"##),
|
|
None,
|
|
Some(r##"Name of the image resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("deprecate",
|
|
Some(r##"Sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_deprecate",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"image"##),
|
|
None,
|
|
Some(r##"Image name."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified image. Gets a list of available images by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"image"##),
|
|
None,
|
|
Some(r##"Name of the image resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-from-family",
|
|
Some(r##"Returns the latest image that is part of an image family and is not deprecated."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_get-from-family",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"family"##),
|
|
None,
|
|
Some(r##"Name of the image family to search for."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an image in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"image"##),
|
|
None,
|
|
Some(r##"Name of the image resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets the labels on an image. To learn more about labels, read the Labeling Resources documentation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/images_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("instance-group-managers", "methods: 'abandon-instances', 'aggregated-list', 'apply-updates-to-instances', 'create-instances', 'delete', 'delete-instances', 'delete-per-instance-configs', 'get', 'insert', 'list', 'list-errors', 'list-managed-instances', 'list-per-instance-configs', 'patch', 'patch-per-instance-configs', 'recreate-instances', 'resize', 'set-instance-template', 'set-target-pools' and 'update-per-instance-configs'", vec![
|
|
("abandon-instances",
|
|
Some(r##"Flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_abandon-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of managed instance groups and groups them by zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("apply-updates-to-instances",
|
|
Some(r##"Applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_apply-updates-to-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located. Should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group, should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("create-instances",
|
|
Some(r##"Creates instances with per-instance configs in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_create-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete-instances",
|
|
Some(r##"Flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_delete-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete-per-instance-configs",
|
|
Some(r##"Deletes selected per-instance configs for the managed instance group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_delete-per-instance-configs",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns all of the details about the specified managed instance group. Gets a list of available managed instance groups by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where you want to create the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of managed instance groups that are contained within the specified project and zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-errors",
|
|
Some(r##"Lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_list-errors",
|
|
vec?)|1-9{0,19}."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-managed-instances",
|
|
Some(r##"Lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_list-managed-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-per-instance-configs",
|
|
Some(r##"Lists all of the per-instance configs defined for the managed instance group. The orderBy query parameter is not supported."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_list-per-instance-configs",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where you want to create the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the instance group manager."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch-per-instance-configs",
|
|
Some(r##"Inserts or patches per-instance configs for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_patch-per-instance-configs",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("recreate-instances",
|
|
Some(r##"Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_recreate-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("resize",
|
|
Some(r##"Resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_resize",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"size"##),
|
|
None,
|
|
Some(r##"The number of running instances that the managed instance group should maintain at any given time. The group automatically adds or removes instances to maintain the number of instances specified by this parameter."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-instance-template",
|
|
Some(r##"Specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group's updatePolicy.type to PROACTIVE."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_set-instance-template",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-target-pools",
|
|
Some(r##"Modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_set-target-pools",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update-per-instance-configs",
|
|
Some(r##"Inserts or updates per-instance configs for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-group-managers_update-per-instance-configs",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the managed instance group is located. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("instance-groups", "methods: 'add-instances', 'aggregated-list', 'delete', 'get', 'insert', 'list', 'list-instances', 'remove-instances' and 'set-named-ports'", vec![
|
|
("add-instances",
|
|
Some(r##"Adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_add-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"The name of the instance group where you are adding instances."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of instance groups and sorts them by zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"The name of the instance group to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified zonal instance group. Get a list of available zonal instance groups by making a list() request. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"The name of the instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an instance group in the specified project using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where you want to create the instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of zonal instance group resources contained within the specified zone. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-instances",
|
|
Some(r##"Lists the instances in the specified instance group. The orderBy query parameter is not supported."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_list-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"The name of the instance group from which you want to generate a list of included instances."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-instances",
|
|
Some(r##"Removes one or more instances from the specified instance group, but does not delete those instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_remove-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"The name of the instance group where the specified instances will be removed."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-named-ports",
|
|
Some(r##"Sets the named ports for the specified instance group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-groups_set-named-ports",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the instance group is located."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"The name of the instance group where the named ports are updated."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("instance-templates", "methods: 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It is not possible to delete templates that are already in use by a managed instance group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-template"##),
|
|
None,
|
|
Some(r##"The name of the instance template to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified instance template. Gets a list of available instance templates by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-template"##),
|
|
None,
|
|
Some(r##"The name of the instance template."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of instance templates that are contained within the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instance-templates_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("instances", "methods: 'add-access-config', 'add-resource-policies', 'aggregated-list', 'attach-disk', 'bulk-insert', 'delete', 'delete-access-config', 'detach-disk', 'get', 'get-effective-firewalls', 'get-guest-attributes', 'get-iam-policy', 'get-screenshot', 'get-serial-port-output', 'get-shielded-instance-identity', 'insert', 'list', 'list-referrers', 'remove-resource-policies', 'reset', 'resume', 'send-diagnostic-interrupt', 'set-deletion-protection', 'set-disk-auto-delete', 'set-iam-policy', 'set-labels', 'set-machine-resources', 'set-machine-type', 'set-metadata', 'set-min-cpu-platform', 'set-scheduling', 'set-service-account', 'set-shielded-instance-integrity-policy', 'set-tags', 'simulate-maintenance-event', 'start', 'start-with-encryption-key', 'stop', 'suspend', 'test-iam-permissions', 'update', 'update-access-config', 'update-display-device', 'update-network-interface' and 'update-shielded-instance-config'", vec![
|
|
("add-access-config",
|
|
Some(r##"Adds an access config to an instance's network interface."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_add-access-config",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"The instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-interface"##),
|
|
None,
|
|
Some(r##"The name of the network interface to add to this instance."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("add-resource-policies",
|
|
Some(r##"Adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_add-resource-policies",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"The instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("attach-disk",
|
|
Some(r##"Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_attach-disk",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"The instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("bulk-insert",
|
|
Some(r##"Creates multiple instances. Count specifies the number of instances to create."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_bulk-insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified Instance resource. For more information, see Deleting an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete-access-config",
|
|
Some(r##"Deletes an access config from an instance's network interface."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_delete-access-config",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"The instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"access-config"##),
|
|
None,
|
|
Some(r##"The name of the access config to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-interface"##),
|
|
None,
|
|
Some(r##"The name of the network interface."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("detach-disk",
|
|
Some(r##"Detaches a disk from an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_detach-disk",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"device-name"##),
|
|
None,
|
|
Some(r##"The device name of the disk to detach. Make a get() request on the instance to view currently attached disks and device names."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified Instance resource. Gets a list of available instances by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-effective-firewalls",
|
|
Some(r##"Returns effective firewalls applied to an interface of the instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get-effective-firewalls",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-interface"##),
|
|
None,
|
|
Some(r##"The name of the network interface to get the effective firewalls."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-guest-attributes",
|
|
Some(r##"Returns the specified guest attributes entry."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get-guest-attributes",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-screenshot",
|
|
Some(r##"Returns the screenshot from the specified instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get-screenshot",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-serial-port-output",
|
|
Some(r##"Returns the last 1 MB of serial port output from the specified instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get-serial-port-output",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-shielded-instance-identity",
|
|
Some(r##"Returns the Shielded Instance Identity of an instance"##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_get-shielded-instance-identity",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name or id of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an instance resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of instances contained within the specified zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-referrers",
|
|
Some(r##"Retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_list-referrers",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the target instance scoping this request, or '-' if the request should span over all instances in the container."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-resource-policies",
|
|
Some(r##"Removes resource policies from an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_remove-resource-policies",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"The instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("reset",
|
|
Some(r##"Performs a reset on the instance. This is a hard reset the VM does not do a graceful shutdown. For more information, see Resetting an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_reset",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("resume",
|
|
Some(r##"Resumes an instance that was suspended using the instances().suspend method."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_resume",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to resume."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("send-diagnostic-interrupt",
|
|
Some(r##"Sends diagnostic interrupt to the instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_send-diagnostic-interrupt",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
]),
|
|
("set-deletion-protection",
|
|
Some(r##"Sets deletion protection on the instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-deletion-protection",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-disk-auto-delete",
|
|
Some(r##"Sets the auto-delete flag for a disk attached to an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-disk-auto-delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"The instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"auto-delete"##),
|
|
None,
|
|
Some(r##"Whether to auto-delete the disk when the instance is deleted."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"device-name"##),
|
|
None,
|
|
Some(r##"The device name of the disk to modify. Make a get() request on the instance to view currently attached disks and device names."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets labels on an instance. To learn more about labels, read the Labeling Resources documentation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-machine-resources",
|
|
Some(r##"Changes the number and/or type of accelerator for a stopped instance to the values specified in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-machine-resources",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-machine-type",
|
|
Some(r##"Changes the machine type for a stopped instance to the machine type specified in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-machine-type",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-metadata",
|
|
Some(r##"Sets metadata for the specified instance to the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-metadata",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-min-cpu-platform",
|
|
Some(r##"Changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-min-cpu-platform",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-scheduling",
|
|
Some(r##"Sets an instance's scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a `TERMINATED` state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM availability policies."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-scheduling",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-service-account",
|
|
Some(r##"Sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-service-account",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to start."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-shielded-instance-integrity-policy",
|
|
Some(r##"Sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-shielded-instance-integrity-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name or id of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-tags",
|
|
Some(r##"Sets network tags for the specified instance to the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_set-tags",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("simulate-maintenance-event",
|
|
Some(r##"Simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_simulate-maintenance-event",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("start",
|
|
Some(r##"Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_start",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to start."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("start-with-encryption-key",
|
|
Some(r##"Starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_start-with-encryption-key",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to start."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("stop",
|
|
Some(r##"Stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_stop",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to stop."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("suspend",
|
|
Some(r##"This method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_suspend",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to suspend."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update-access-config",
|
|
Some(r##"Updates the specified access config from an instance's network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_update-access-config",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"The instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-interface"##),
|
|
None,
|
|
Some(r##"The name of the network interface where the access config is attached."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update-display-device",
|
|
Some(r##"Updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_update-display-device",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update-network-interface",
|
|
Some(r##"Updates an instance's network interface. This method can only update an interface's alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_update-network-interface",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"The instance name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-interface"##),
|
|
None,
|
|
Some(r##"The name of the network interface to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update-shielded-instance-config",
|
|
Some(r##"Updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/instances_update-shielded-instance-config",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance"##),
|
|
None,
|
|
Some(r##"Name or id of the instance scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("interconnect-attachments", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list' and 'patch'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of interconnect attachments."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnect-attachments_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified interconnect attachment."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnect-attachments_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"interconnect-attachment"##),
|
|
None,
|
|
Some(r##"Name of the interconnect attachment to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified interconnect attachment."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnect-attachments_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"interconnect-attachment"##),
|
|
None,
|
|
Some(r##"Name of the interconnect attachment to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an InterconnectAttachment in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnect-attachments_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of interconnect attachments contained within the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnect-attachments_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified interconnect attachment with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnect-attachments_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"interconnect-attachment"##),
|
|
None,
|
|
Some(r##"Name of the interconnect attachment to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("interconnect-locations", "methods: 'get' and 'list'", vec![
|
|
("get",
|
|
Some(r##"Returns the details for the specified interconnect location. Gets a list of available interconnect locations by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnect-locations_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"interconnect-location"##),
|
|
None,
|
|
Some(r##"Name of the interconnect location to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of interconnect locations available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnect-locations_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("interconnects", "methods: 'delete', 'get', 'get-diagnostics', 'insert', 'list' and 'patch'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified interconnect."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnects_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"interconnect"##),
|
|
None,
|
|
Some(r##"Name of the interconnect to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified interconnect. Get a list of available interconnects by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnects_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"interconnect"##),
|
|
None,
|
|
Some(r##"Name of the interconnect to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-diagnostics",
|
|
Some(r##"Returns the interconnectDiagnostics for the specified interconnect."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnects_get-diagnostics",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"interconnect"##),
|
|
None,
|
|
Some(r##"Name of the interconnect resource to query."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a Interconnect in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnects_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of interconnect available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnects_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified interconnect with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/interconnects_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"interconnect"##),
|
|
None,
|
|
Some(r##"Name of the interconnect to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("license-codes", "methods: 'get' and 'test-iam-permissions'", vec![
|
|
("get",
|
|
Some(r##"Return a specified license code. License codes are mirrored across all projects that have permissions to read the License Code. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/license-codes_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"license-code"##),
|
|
None,
|
|
Some(r##"Number corresponding to the License code resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/license-codes_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("licenses", "methods: 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified license. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/licenses_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"license"##),
|
|
None,
|
|
Some(r##"Name of the license resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified License resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/licenses_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"license"##),
|
|
None,
|
|
Some(r##"Name of the License resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/licenses_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Create a License resource in the specified project. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/licenses_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of licenses available in the specified project. This method does not get any licenses that belong to other projects, including licenses attached to publicly-available images, like Debian 9. If you want to get a list of publicly-available licenses, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/licenses_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/licenses_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource. *Caution* This resource is intended for use only by third-party partners who are creating Cloud Marketplace images. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/licenses_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("machine-images", "methods: 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified machine image. Deleting a machine image is permanent and cannot be undone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-images_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"machine-image"##),
|
|
None,
|
|
Some(r##"The name of the machine image to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified machine image. Gets a list of available machine images by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-images_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"machine-image"##),
|
|
None,
|
|
Some(r##"The name of the machine image."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-images_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-images_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of machine images that are contained within the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-images_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-images_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-images_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("machine-types", "methods: 'aggregated-list', 'get' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of machine types."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-types_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified machine type. Gets a list of available machine types by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-types_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"machine-type"##),
|
|
None,
|
|
Some(r##"Name of the machine type to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of machine types available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/machine-types_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("network-endpoint-groups", "methods: 'aggregated-list', 'attach-network-endpoints', 'delete', 'detach-network-endpoints', 'get', 'insert', 'list', 'list-network-endpoints' and 'test-iam-permissions'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of network endpoint groups and sorts them by zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("attach-network-endpoints",
|
|
Some(r##"Attach a list of network endpoints to the specified network endpoint group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_attach-network-endpoints",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group where you are attaching network endpoints to. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they belong to are not terminated when the NEG is deleted. Note that the NEG cannot be deleted if there are backend services referencing it."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group to delete. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("detach-network-endpoints",
|
|
Some(r##"Detach a list of network endpoints from the specified network endpoint group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_detach-network-endpoints",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group where you are removing network endpoints. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified network endpoint group. Gets a list of available network endpoint groups by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a network endpoint group in the specified project using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where you want to create the network endpoint group. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of network endpoint groups that are located in the specified project and zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-network-endpoints",
|
|
Some(r##"Lists the network endpoints in the specified network endpoint group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_list-network-endpoints",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group from which you want to generate a list of included network endpoints. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-endpoint-groups_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("network-firewall-policies", "methods: 'add-association', 'add-rule', 'clone-rules', 'delete', 'get', 'get-association', 'get-iam-policy', 'get-rule', 'insert', 'list', 'patch', 'patch-rule', 'remove-association', 'remove-rule', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("add-association",
|
|
Some(r##"Inserts an association for the specified firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_add-association",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("add-rule",
|
|
Some(r##"Inserts a rule into a firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_add-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("clone-rules",
|
|
Some(r##"Copies rules to the specified firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_clone-rules",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified network firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to get."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-association",
|
|
Some(r##"Gets an association with the specified name."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_get-association",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to which the queried association belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-rule",
|
|
Some(r##"Gets a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_get-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to which the queried rule belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a new policy in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists all the policies that have been configured for the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified policy with the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch-rule",
|
|
Some(r##"Patches a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_patch-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-association",
|
|
Some(r##"Removes an association for the specified firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_remove-association",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-rule",
|
|
Some(r##"Deletes a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_remove-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/network-firewall-policies_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("networks", "methods: 'add-peering', 'delete', 'get', 'get-effective-firewalls', 'insert', 'list', 'list-peering-routes', 'patch', 'remove-peering', 'switch-to-custom-mode' and 'update-peering'", vec![
|
|
("add-peering",
|
|
Some(r##"Adds a peering to the specified network."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_add-peering",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network resource to add peering to."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified network."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified network. Gets a list of available networks by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-effective-firewalls",
|
|
Some(r##"Returns the effective firewalls on a given network."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_get-effective-firewalls",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a network in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of networks available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-peering-routes",
|
|
Some(r##"Lists the peering routes exchanged over peering connection."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_list-peering-routes",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified network with the data included in the request. Only the following fields can be modified: routingConfig.routingMode."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-peering",
|
|
Some(r##"Removes a peering from the specified network."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_remove-peering",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network resource to remove peering from."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("switch-to-custom-mode",
|
|
Some(r##"Switches the network mode from auto subnet mode to custom subnet mode."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_switch-to-custom-mode",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network to be updated."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update-peering",
|
|
Some(r##"Updates the specified network peering with the data included in the request. You can only modify the NetworkPeering.export_custom_routes field and the NetworkPeering.import_custom_routes field."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/networks_update-peering",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Name of the network resource which the updated peering is belonging to."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("node-groups", "methods: 'add-nodes', 'aggregated-list', 'delete', 'delete-nodes', 'get', 'get-iam-policy', 'insert', 'list', 'list-nodes', 'patch', 'set-iam-policy', 'set-node-template' and 'test-iam-permissions'", vec![
|
|
("add-nodes",
|
|
Some(r##"Adds specified number of nodes to the node group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_add-nodes",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-group"##),
|
|
None,
|
|
Some(r##"Name of the NodeGroup resource."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of node groups. Note: use nodeGroups.listNodes for more details about each group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified NodeGroup resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-group"##),
|
|
None,
|
|
Some(r##"Name of the NodeGroup resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete-nodes",
|
|
Some(r##"Deletes specified nodes from the node group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_delete-nodes",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-group"##),
|
|
None,
|
|
Some(r##"Name of the NodeGroup resource whose nodes will be deleted."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified NodeGroup. Get a list of available NodeGroups by making a list() request. Note: the "nodes" field should not be used. Use nodeGroups.listNodes instead."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-group"##),
|
|
None,
|
|
Some(r##"Name of the node group to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a NodeGroup resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"initial-node-count"##),
|
|
None,
|
|
Some(r##"Initial count of nodes in the node group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of node groups available to the specified project. Note: use nodeGroups.listNodes for more details about each group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-nodes",
|
|
Some(r##"Lists nodes in the node group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_list-nodes",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-group"##),
|
|
None,
|
|
Some(r##"Name of the NodeGroup resource whose nodes you want to list."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified node group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-group"##),
|
|
None,
|
|
Some(r##"Name of the NodeGroup resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-node-template",
|
|
Some(r##"Updates the node template of the node group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_set-node-template",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-group"##),
|
|
None,
|
|
Some(r##"Name of the NodeGroup resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-groups_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("node-templates", "methods: 'aggregated-list', 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of node templates."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-templates_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified NodeTemplate resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-templates_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-template"##),
|
|
None,
|
|
Some(r##"Name of the NodeTemplate resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified node template. Gets a list of available node templates by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-templates_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-template"##),
|
|
None,
|
|
Some(r##"Name of the node template to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-templates_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a NodeTemplate resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-templates_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of node templates available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-templates_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-templates_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-templates_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("node-types", "methods: 'aggregated-list', 'get' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of node types."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-types_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified node type. Gets a list of available node types by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-types_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"node-type"##),
|
|
None,
|
|
Some(r##"Name of the node type to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of node types available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/node-types_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("packet-mirrorings", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list', 'patch' and 'test-iam-permissions'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of packetMirrorings."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/packet-mirrorings_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified PacketMirroring resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/packet-mirrorings_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"packet-mirroring"##),
|
|
None,
|
|
Some(r##"Name of the PacketMirroring resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified PacketMirroring resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/packet-mirrorings_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"packet-mirroring"##),
|
|
None,
|
|
Some(r##"Name of the PacketMirroring resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a PacketMirroring resource in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/packet-mirrorings_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of PacketMirroring resources available to the specified project and region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/packet-mirrorings_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified PacketMirroring resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/packet-mirrorings_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"packet-mirroring"##),
|
|
None,
|
|
Some(r##"Name of the PacketMirroring resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/packet-mirrorings_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("projects", "methods: 'disable-xpn-host', 'disable-xpn-resource', 'enable-xpn-host', 'enable-xpn-resource', 'get', 'get-xpn-host', 'get-xpn-resources', 'list-xpn-hosts', 'move-disk', 'move-instance', 'set-common-instance-metadata', 'set-default-network-tier' and 'set-usage-export-bucket'", vec![
|
|
("disable-xpn-host",
|
|
Some(r##"Disable this project as a shared VPC host project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_disable-xpn-host",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("disable-xpn-resource",
|
|
Some(r##"Disable a service resource (also known as service project) associated with this host project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_disable-xpn-resource",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("enable-xpn-host",
|
|
Some(r##"Enable this project as a shared VPC host project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_enable-xpn-host",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("enable-xpn-resource",
|
|
Some(r##"Enable service resource (a.k.a service project) for a host project, so that subnets in the host project can be used by instances in the service project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_enable-xpn-resource",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified Project resource. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-xpn-host",
|
|
Some(r##"Gets the shared VPC host project that this project links to. May be empty if no link exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_get-xpn-host",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-xpn-resources",
|
|
Some(r##"Gets service resources (a.k.a service project) associated with this host project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_get-xpn-resources",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-xpn-hosts",
|
|
Some(r##"Lists all shared VPC host projects visible to the user in an organization."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_list-xpn-hosts",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("move-disk",
|
|
Some(r##"Moves a persistent disk from one zone to another."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_move-disk",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("move-instance",
|
|
Some(r##"Moves an instance and its attached persistent disks from one zone to another. *Note*: Moving VMs or disks by using this method might cause unexpected behavior. For more information, see the [known issue](/compute/docs/troubleshooting/known-issues#moving_vms_or_disks_using_the_moveinstance_api_or_the_causes_unexpected_behavior)."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_move-instance",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-common-instance-metadata",
|
|
Some(r##"Sets metadata common to all instances within the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_set-common-instance-metadata",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-default-network-tier",
|
|
Some(r##"Sets the default network tier of the project. The default network tier is used when an address/forwardingRule/instance is created without specifying the network tier field."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_set-default-network-tier",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-usage-export-bucket",
|
|
Some(r##"Enables the usage export feature and sets the usage export bucket where reports are stored. If you provide an empty request body using this method, the usage export feature will be disabled."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/projects_set-usage-export-bucket",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("public-advertised-prefixes", "methods: 'delete', 'get', 'insert', 'list' and 'patch'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified PublicAdvertisedPrefix"##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-advertised-prefixes_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-advertised-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicAdvertisedPrefix resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified PublicAdvertisedPrefix resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-advertised-prefixes_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-advertised-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicAdvertisedPrefix resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a PublicAdvertisedPrefix in the specified project using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-advertised-prefixes_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists the PublicAdvertisedPrefixes for a project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-advertised-prefixes_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-advertised-prefixes_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-advertised-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicAdvertisedPrefix resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("public-delegated-prefixes", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list' and 'patch'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Lists all PublicDelegatedPrefix resources owned by the specific project across all scopes."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-delegated-prefixes_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Name of the project scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified PublicDelegatedPrefix in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-delegated-prefixes_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region of this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-delegated-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicDelegatedPrefix resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified PublicDelegatedPrefix resource in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-delegated-prefixes_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region of this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-delegated-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicDelegatedPrefix resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a PublicDelegatedPrefix in the specified project in the given region using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-delegated-prefixes_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region of this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists the PublicDelegatedPrefixes for a project in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-delegated-prefixes_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region of this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/public-delegated-prefixes_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"public-delegated-prefix"##),
|
|
None,
|
|
Some(r##"Name of the PublicDelegatedPrefix resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-autoscalers", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified autoscaler."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-autoscalers_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"autoscaler"##),
|
|
None,
|
|
Some(r##"Name of the autoscaler to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified autoscaler."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-autoscalers_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"autoscaler"##),
|
|
None,
|
|
Some(r##"Name of the autoscaler to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates an autoscaler in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-autoscalers_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of autoscalers contained within the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-autoscalers_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-autoscalers_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates an autoscaler in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-autoscalers_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-backend-services", "methods: 'delete', 'get', 'get-health', 'insert', 'list', 'patch' and 'update'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified regional BackendService resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-backend-services_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified regional BackendService resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-backend-services_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-health",
|
|
Some(r##"Gets the most recent health check results for this regional BackendService."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-backend-services_get-health",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
None,
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource for which to get health."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a regional BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-backend-services_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of regional BackendService resources available to the specified project in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-backend-services_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified regional BackendService resource with the data included in the request. For more information, see Understanding backend services This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-backend-services_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates the specified regional BackendService resource with the data included in the request. For more information, see Backend services overview ."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-backend-services_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"backend-service"##),
|
|
None,
|
|
Some(r##"Name of the BackendService resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-commitments", "methods: 'aggregated-list', 'get', 'insert', 'list' and 'update'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of commitments by region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-commitments_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified commitment resource. Gets a list of available commitments by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-commitments_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"commitment"##),
|
|
None,
|
|
Some(r##"Name of the commitment to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a commitment in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-commitments_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of commitments contained within the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-commitments_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates the specified commitment with the data included in the request. Update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: auto_renew."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-commitments_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"commitment"##),
|
|
None,
|
|
Some(r##"Name of the commitment for which auto renew is being updated."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-disk-types", "methods: 'get' and 'list'", vec![
|
|
("get",
|
|
Some(r##"Returns the specified regional disk type. Gets a list of available disk types by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disk-types_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk-type"##),
|
|
None,
|
|
Some(r##"Name of the disk type to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of regional disk types available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disk-types_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-disks", "methods: 'add-resource-policies', 'create-snapshot', 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'remove-resource-policies', 'resize', 'set-iam-policy', 'set-labels' and 'test-iam-permissions'", vec![
|
|
("add-resource-policies",
|
|
Some(r##"Adds existing resource policies to a regional disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_add-resource-policies",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"The disk name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("create-snapshot",
|
|
Some(r##"Creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_create-snapshot",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"Name of the regional persistent disk to snapshot."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified regional persistent disk. Deleting a regional disk removes all the replicas of its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"Name of the regional persistent disk to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns a specified regional persistent disk."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"Name of the regional persistent disk to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a persistent regional disk in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of persistent disks contained within the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-resource-policies",
|
|
Some(r##"Removes resource policies from a regional disk."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_remove-resource-policies",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"The disk name for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("resize",
|
|
Some(r##"Resizes the specified regional persistent disk."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_resize",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"The project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"disk"##),
|
|
None,
|
|
Some(r##"Name of the regional persistent disk."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets the labels on the target regional disk."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-disks_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-health-check-services", "methods: 'delete', 'get', 'insert', 'list' and 'patch'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified regional HealthCheckService."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-check-services_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check-service"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheckService to delete. The name must be 1-63 characters long, and comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified regional HealthCheckService resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-check-services_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check-service"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheckService to update. The name must be 1-63 characters long, and comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a regional HealthCheckService resource in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-check-services_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists all the HealthCheckService resources that have been configured for the specified project in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-check-services_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates the specified regional HealthCheckService resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-check-services_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check-service"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheckService to update. The name must be 1-63 characters long, and comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-health-checks", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified HealthCheck resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-checks_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheck resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified HealthCheck resource. Gets a list of available health checks by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-checks_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheck resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a HealthCheck resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-checks_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of HealthCheck resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-checks_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-checks_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheck resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates a HealthCheck resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-health-checks_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"health-check"##),
|
|
None,
|
|
Some(r##"Name of the HealthCheck resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-instance-group-managers", "methods: 'abandon-instances', 'apply-updates-to-instances', 'create-instances', 'delete', 'delete-instances', 'delete-per-instance-configs', 'get', 'insert', 'list', 'list-errors', 'list-managed-instances', 'list-per-instance-configs', 'patch', 'patch-per-instance-configs', 'recreate-instances', 'resize', 'set-instance-template', 'set-target-pools' and 'update-per-instance-configs'", vec![
|
|
("abandon-instances",
|
|
Some(r##"Flags the specified instances to be immediately removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_abandon-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"Name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("apply-updates-to-instances",
|
|
Some(r##"Apply updates to selected instances the managed instance group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_apply-updates-to-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request, should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group, should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("create-instances",
|
|
Some(r##"Creates instances with per-instance configs in this regional managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_create-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region where the managed instance group is located. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified managed instance group and all of the instances in that group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"Name of the managed instance group to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete-instances",
|
|
Some(r##"Flags the specified instances in the managed instance group to be immediately deleted. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. The deleteInstances operation is marked DONE if the deleteInstances request is successful. The underlying actions take additional time. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_delete-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"Name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete-per-instance-configs",
|
|
Some(r##"Deletes selected per-instance configs for the managed instance group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_delete-per-instance-configs",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request, should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns all of the details about the specified managed instance group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"Name of the managed instance group to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A regional managed instance group can contain up to 2000 instances."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of managed instance groups that are contained within the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-errors",
|
|
Some(r##"Lists all errors thrown by actions on instances for a given regional managed instance group. The filter and orderBy query parameters are not supported."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_list-errors",
|
|
vec?)|1-9{0,19}."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-managed-instances",
|
|
Some(r##"Lists the instances in the managed instance group and instances that are scheduled to be created. The list includes any current actions that the group has scheduled for its instances. The orderBy query parameter is not supported."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_list-managed-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-per-instance-configs",
|
|
Some(r##"Lists all of the per-instance configs defined for the managed instance group. The orderBy query parameter is not supported."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_list-per-instance-configs",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request, should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listmanagedinstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it's possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the instance group manager."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch-per-instance-configs",
|
|
Some(r##"Inserts or patches per-instance configs for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_patch-per-instance-configs",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request, should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("recreate-instances",
|
|
Some(r##"Flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group's current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_recreate-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"Name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("resize",
|
|
Some(r##"Changes the intended size of the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes one or more instances. The resize operation is marked DONE if the resize request is successful. The underlying actions take additional time. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_resize",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"Name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"size"##),
|
|
None,
|
|
Some(r##"Number of instances that should exist in this instance group manager."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-instance-template",
|
|
Some(r##"Sets the instance template to use when creating new instances or recreating instances in this group. Existing instances are not affected."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_set-instance-template",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-target-pools",
|
|
Some(r##"Modifies the target pools to which all new instances in this group are assigned. Existing instances in the group are not affected."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_set-target-pools",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"Name of the managed instance group."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update-per-instance-configs",
|
|
Some(r##"Inserts or updates per-instance configs for the managed instance group. perInstanceConfig.name serves as a key used to distinguish whether to perform insert or patch."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-group-managers_update-per-instance-configs",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request, should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group-manager"##),
|
|
None,
|
|
Some(r##"The name of the managed instance group. It should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-instance-groups", "methods: 'get', 'list', 'list-instances' and 'set-named-ports'", vec![
|
|
("get",
|
|
Some(r##"Returns the specified instance group resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-groups_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"Name of the instance group resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of instance group resources contained within the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-groups_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-instances",
|
|
Some(r##"Lists the instances in the specified instance group and displays information about the named ports. Depending on the specified options, this method can list all instances or only the instances that are running. The orderBy query parameter is not supported."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-groups_list-instances",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"Name of the regional instance group for which we want to list the instances."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-named-ports",
|
|
Some(r##"Sets the named ports for the specified regional instance group."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instance-groups_set-named-ports",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"instance-group"##),
|
|
None,
|
|
Some(r##"The name of the regional instance group where the named ports are updated."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-instances", "methods: 'bulk-insert'", vec![
|
|
("bulk-insert",
|
|
Some(r##"Creates multiple instances in a given region. Count specifies the number of instances to create."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-instances_bulk-insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-network-endpoint-groups", "methods: 'delete', 'get', 'insert' and 'list'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified network endpoint group. Note that the NEG cannot be deleted if it is configured as a backend of a backend service."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-endpoint-groups_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group to delete. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified network endpoint group. Gets a list of available network endpoint groups by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-endpoint-groups_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network-endpoint-group"##),
|
|
None,
|
|
Some(r##"The name of the network endpoint group. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a network endpoint group in the specified project using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-endpoint-groups_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region where you want to create the network endpoint group. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of regional network endpoint groups available to the specified project in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-endpoint-groups_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region where the network endpoint group is located. It should comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-network-firewall-policies", "methods: 'add-association', 'add-rule', 'clone-rules', 'delete', 'get', 'get-association', 'get-effective-firewalls', 'get-iam-policy', 'get-rule', 'insert', 'list', 'patch', 'patch-rule', 'remove-association', 'remove-rule', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("add-association",
|
|
Some(r##"Inserts an association for the specified network firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_add-association",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("add-rule",
|
|
Some(r##"Inserts a rule into a network firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_add-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("clone-rules",
|
|
Some(r##"Copies rules to the specified network firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_clone-rules",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified network firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified network firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to get."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-association",
|
|
Some(r##"Gets an association with the specified name."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_get-association",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to which the queried association belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-effective-firewalls",
|
|
Some(r##"Returns the effective firewalls on a given network."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_get-effective-firewalls",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"network"##),
|
|
None,
|
|
Some(r##"Network reference"##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-rule",
|
|
Some(r##"Gets a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_get-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to which the queried rule belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a new network firewall policy in the specified project and region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists all the network firewall policies that have been configured for the specified project in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified network firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch-rule",
|
|
Some(r##"Patches a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_patch-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-association",
|
|
Some(r##"Removes an association for the specified network firewall policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_remove-association",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-rule",
|
|
Some(r##"Deletes a rule of the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_remove-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"firewall-policy"##),
|
|
None,
|
|
Some(r##"Name of the firewall policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-network-firewall-policies_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-notification-endpoints", "methods: 'delete', 'get', 'insert' and 'list'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified NotificationEndpoint in the given region"##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-notification-endpoints_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"notification-endpoint"##),
|
|
None,
|
|
Some(r##"Name of the NotificationEndpoint resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified NotificationEndpoint resource in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-notification-endpoints_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"notification-endpoint"##),
|
|
None,
|
|
Some(r##"Name of the NotificationEndpoint resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Create a NotificationEndpoint in the specified project in the given region using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-notification-endpoints_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists the NotificationEndpoints for a project in the given region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-notification-endpoints_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-operations", "methods: 'delete', 'get', 'list' and 'wait'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified region-specific Operations resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-operations_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
]),
|
|
("get",
|
|
Some(r##"Retrieves the specified region-specific Operations resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-operations_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of Operation resources contained within the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-operations_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("wait",
|
|
Some(r##"Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the `GET` method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-operations_wait",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-ssl-certificates", "methods: 'delete', 'get', 'insert' and 'list'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified SslCertificate resource in the region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-ssl-certificates_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"ssl-certificate"##),
|
|
None,
|
|
Some(r##"Name of the SslCertificate resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified SslCertificate resource in the specified region. Get a list of available SSL certificates by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-ssl-certificates_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"ssl-certificate"##),
|
|
None,
|
|
Some(r##"Name of the SslCertificate resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a SslCertificate resource in the specified project and region using the data included in the request"##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-ssl-certificates_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of SslCertificate resources available to the specified project in the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-ssl-certificates_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-target-http-proxies", "methods: 'delete', 'get', 'insert', 'list' and 'set-url-map'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified TargetHttpProxy resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-http-proxies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-http-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpProxy resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified TargetHttpProxy resource in the specified region. Gets a list of available target HTTP proxies by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-http-proxies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-http-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpProxy resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a TargetHttpProxy resource in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-http-proxies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of TargetHttpProxy resources available to the specified project in the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-http-proxies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-url-map",
|
|
Some(r##"Changes the URL map for TargetHttpProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-http-proxies_set-url-map",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-http-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpProxy to set a URL map for."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-target-https-proxies", "methods: 'delete', 'get', 'insert', 'list', 'set-ssl-certificates' and 'set-url-map'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified TargetHttpsProxy resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-https-proxies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified TargetHttpsProxy resource in the specified region. Gets a list of available target HTTP proxies by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-https-proxies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a TargetHttpsProxy resource in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-https-proxies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of TargetHttpsProxy resources available to the specified project in the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-https-proxies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-ssl-certificates",
|
|
Some(r##"Replaces SslCertificates for TargetHttpsProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-https-proxies_set-ssl-certificates",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource to set an SslCertificates resource for."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-url-map",
|
|
Some(r##"Changes the URL map for TargetHttpsProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-target-https-proxies_set-url-map",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy to set a URL map for."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("region-url-maps", "methods: 'delete', 'get', 'insert', 'list', 'patch', 'update' and 'validate'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified UrlMap resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-url-maps_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified UrlMap resource. Gets a list of available URL maps by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-url-maps_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a UrlMap resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-url-maps_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of UrlMap resources available to the specified project in the specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-url-maps_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-url-maps_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates the specified UrlMap resource with the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-url-maps_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("validate",
|
|
Some(r##"Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/region-url-maps_validate",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to be validated as."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("regions", "methods: 'get' and 'list'", vec![
|
|
("get",
|
|
Some(r##"Returns the specified Region resource. Gets a list of available regions by making a list() request. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/regions_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of region resources available to the specified project. To decrease latency for this method, you can optionally omit any unneeded information from the response by using a field mask. This practice is especially recommended for unused quota information (the `items.quotas` field). To exclude one or more fields, set your request's `fields` query parameter to only include the fields you need. For example, to only include the `id` and `selfLink` fields, add the query parameter `?fields=id,selfLink` to your request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/regions_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("reservations", "methods: 'aggregated-list', 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'resize', 'set-iam-policy', 'test-iam-permissions' and 'update'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of reservations."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified reservation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"reservation"##),
|
|
None,
|
|
Some(r##"Name of the reservation to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Retrieves information about the specified reservation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"reservation"##),
|
|
None,
|
|
Some(r##"Name of the reservation to retrieve."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a new reservation. For more information, read Reserving zonal resources."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"A list of all the reservations that have been configured for the specified project in specified zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("resize",
|
|
Some(r##"Resizes the reservation (applicable to standalone reservations only). For more information, read Modifying reservations."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_resize",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"reservation"##),
|
|
None,
|
|
Some(r##"Name of the reservation to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"The name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Update share settings of the reservation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/reservations_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"reservation"##),
|
|
None,
|
|
Some(r##"Name of the reservation to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("resource-policies", "methods: 'aggregated-list', 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of resource policies."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/resource-policies_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified resource policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/resource-policies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource-policy"##),
|
|
None,
|
|
Some(r##"Name of the resource policy to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Retrieves all information of the specified resource policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/resource-policies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource-policy"##),
|
|
None,
|
|
Some(r##"Name of the resource policy to retrieve."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/resource-policies_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a new resource policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/resource-policies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"A list all the resource policies that have been configured for the specified project in specified region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/resource-policies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/resource-policies_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/resource-policies_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("routers", "methods: 'aggregated-list', 'delete', 'get', 'get-nat-mapping-info', 'get-router-status', 'insert', 'list', 'patch', 'preview' and 'update'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of routers."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified Router resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"router"##),
|
|
None,
|
|
Some(r##"Name of the Router resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified Router resource. Gets a list of available routers by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"router"##),
|
|
None,
|
|
Some(r##"Name of the Router resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-nat-mapping-info",
|
|
Some(r##"Retrieves runtime Nat mapping information of VM endpoints."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_get-nat-mapping-info",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"router"##),
|
|
None,
|
|
Some(r##"Name of the Router resource to query for Nat Mapping information of VM endpoints."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-router-status",
|
|
Some(r##"Retrieves runtime information of the specified router."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_get-router-status",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"router"##),
|
|
None,
|
|
Some(r##"Name of the Router resource to query."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a Router resource in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of Router resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified Router resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"router"##),
|
|
None,
|
|
Some(r##"Name of the Router resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("preview",
|
|
Some(r##"Preview fields auto-generated during router create and update operations. Calling this method does NOT create or update the router."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_preview",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"router"##),
|
|
None,
|
|
Some(r##"Name of the Router resource to query."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates the specified Router resource with the data included in the request. This method conforms to PUT semantics, which requests that the state of the target resource be created or replaced with the state defined by the representation enclosed in the request message payload."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routers_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"router"##),
|
|
None,
|
|
Some(r##"Name of the Router resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("routes", "methods: 'delete', 'get', 'insert' and 'list'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified Route resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routes_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"route"##),
|
|
None,
|
|
Some(r##"Name of the Route resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified Route resource. Gets a list of available routes by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routes_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"route"##),
|
|
None,
|
|
Some(r##"Name of the Route resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a Route resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routes_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of Route resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/routes_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("security-policies", "methods: 'add-rule', 'delete', 'get', 'get-rule', 'insert', 'list', 'list-preconfigured-expression-sets', 'patch', 'patch-rule' and 'remove-rule'", vec![
|
|
("add-rule",
|
|
Some(r##"Inserts a rule into a security policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_add-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"security-policy"##),
|
|
None,
|
|
Some(r##"Name of the security policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"security-policy"##),
|
|
None,
|
|
Some(r##"Name of the security policy to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"List all of the ordered rules present in a single specified policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"security-policy"##),
|
|
None,
|
|
Some(r##"Name of the security policy to get."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-rule",
|
|
Some(r##"Gets a rule at the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_get-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"security-policy"##),
|
|
None,
|
|
Some(r##"Name of the security policy to which the queried rule belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a new policy in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"List all the policies that have been configured for the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-preconfigured-expression-sets",
|
|
Some(r##"Gets the current list of preconfigured Web Application Firewall (WAF) expressions."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_list-preconfigured-expression-sets",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified policy with the data included in the request. This cannot be used to be update the rules in the policy. Please use the per rule methods like addRule, patchRule, and removeRule instead."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"security-policy"##),
|
|
None,
|
|
Some(r##"Name of the security policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch-rule",
|
|
Some(r##"Patches a rule at the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_patch-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"security-policy"##),
|
|
None,
|
|
Some(r##"Name of the security policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-rule",
|
|
Some(r##"Deletes a rule at the specified priority."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/security-policies_remove-rule",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"security-policy"##),
|
|
None,
|
|
Some(r##"Name of the security policy to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("service-attachments", "methods: 'aggregated-list', 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'patch', 'set-iam-policy' and 'test-iam-permissions'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of all ServiceAttachment resources, regional and global, available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Name of the project scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified ServiceAttachment in the given scope"##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region of this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"service-attachment"##),
|
|
None,
|
|
Some(r##"Name of the ServiceAttachment resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified ServiceAttachment resource in the given scope."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region of this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"service-attachment"##),
|
|
None,
|
|
Some(r##"Name of the ServiceAttachment resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a ServiceAttachment in the specified project in the given scope using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region of this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists the ServiceAttachments for a project in the given scope."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region of this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified ServiceAttachment resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The region scoping this request and should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"service-attachment"##),
|
|
None,
|
|
Some(r##"The resource id of the ServiceAttachment to patch. It should conform to RFC1035 resource name or be a string form on an unsigned long number."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/service-attachments_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("snapshots", "methods: 'delete', 'get', 'get-iam-policy', 'insert', 'list', 'set-iam-policy', 'set-labels' and 'test-iam-permissions'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. For more information, see Deleting snapshots."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"snapshot"##),
|
|
None,
|
|
Some(r##"Name of the Snapshot resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified Snapshot resource. Gets a list of available snapshots by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"snapshot"##),
|
|
None,
|
|
Some(r##"Name of the Snapshot resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of Snapshot resources contained within the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets the labels on a snapshot. To learn more about labels, read the Labeling Resources documentation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/snapshots_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("ssl-certificates", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of all SslCertificate resources, regional and global, available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Name of the project scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified SslCertificate resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"ssl-certificate"##),
|
|
None,
|
|
Some(r##"Name of the SslCertificate resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified SslCertificate resource. Gets a list of available SSL certificates by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"ssl-certificate"##),
|
|
None,
|
|
Some(r##"Name of the SslCertificate resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a SslCertificate resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of SslCertificate resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-certificates_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("ssl-policies", "methods: 'delete', 'get', 'insert', 'list', 'list-available-features' and 'patch'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified SSL policy. The SSL policy resource can be deleted only if it is not in use by any TargetHttpsProxy or TargetSslProxy resources."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-policies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"ssl-policy"##),
|
|
None,
|
|
Some(r##"Name of the SSL policy to delete. The name must be 1-63 characters long, and comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Lists all of the ordered rules present in a single specified policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-policies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"ssl-policy"##),
|
|
None,
|
|
Some(r##"Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Returns the specified SSL policy resource. Gets a list of available SSL policies by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-policies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists all the SSL policies that have been configured for the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-policies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-available-features",
|
|
Some(r##"Lists all features that can be specified in the SSL policy when using custom profile."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-policies_list-available-features",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified SSL policy with the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/ssl-policies_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"ssl-policy"##),
|
|
None,
|
|
Some(r##"Name of the SSL policy to update. The name must be 1-63 characters long, and comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("subnetworks", "methods: 'aggregated-list', 'delete', 'expand-ip-cidr-range', 'get', 'get-iam-policy', 'insert', 'list', 'list-usable', 'patch', 'set-iam-policy', 'set-private-ip-google-access' and 'test-iam-permissions'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of subnetworks."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified subnetwork."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"subnetwork"##),
|
|
None,
|
|
Some(r##"Name of the Subnetwork resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("expand-ip-cidr-range",
|
|
Some(r##"Expands the IP CIDR range of the subnetwork to a specified value."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_expand-ip-cidr-range",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"subnetwork"##),
|
|
None,
|
|
Some(r##"Name of the Subnetwork resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified subnetwork. Gets a list of available subnetworks list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"subnetwork"##),
|
|
None,
|
|
Some(r##"Name of the Subnetwork resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-iam-policy",
|
|
Some(r##"Gets the access control policy for a resource. May be empty if no such policy or resource exists."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_get-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a subnetwork in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of subnetworks available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list-usable",
|
|
Some(r##"Retrieves an aggregated list of all usable subnetworks in the project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_list-usable",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified subnetwork with the data included in the request. Only certain fields can be updated with a patch request as indicated in the field descriptions. You must specify the current fingerprint of the subnetwork resource being patched."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"subnetwork"##),
|
|
None,
|
|
Some(r##"Name of the Subnetwork resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-iam-policy",
|
|
Some(r##"Sets the access control policy on the specified resource. Replaces any existing policy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_set-iam-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-private-ip-google-access",
|
|
Some(r##"Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_set-private-ip-google-access",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"subnetwork"##),
|
|
None,
|
|
Some(r##"Name of the Subnetwork resource."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/subnetworks_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("target-grpc-proxies", "methods: 'delete', 'get', 'insert', 'list' and 'patch'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified TargetGrpcProxy in the given scope"##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-grpc-proxies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-grpc-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetGrpcProxy resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified TargetGrpcProxy resource in the given scope."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-grpc-proxies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-grpc-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetGrpcProxy resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a TargetGrpcProxy in the specified project in the given scope using the parameters that are included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-grpc-proxies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Lists the TargetGrpcProxies for a project in the given scope."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-grpc-proxies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified TargetGrpcProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-grpc-proxies_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-grpc-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetGrpcProxy resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("target-http-proxies", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list', 'patch' and 'set-url-map'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of all TargetHttpProxy resources, regional and global, available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Name of the project scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified TargetHttpProxy resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-http-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpProxy resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified TargetHttpProxy resource. Gets a list of available target HTTP proxies by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-http-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpProxy resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a TargetHttpProxy resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of TargetHttpProxy resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified TargetHttpProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-http-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpProxy resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-url-map",
|
|
Some(r##"Changes the URL map for TargetHttpProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-http-proxies_set-url-map",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-http-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpProxy to set a URL map for."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("target-https-proxies", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'list', 'patch', 'set-quic-override', 'set-ssl-certificates', 'set-ssl-policy' and 'set-url-map'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of all TargetHttpsProxy resources, regional and global, available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Name of the project scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified TargetHttpsProxy resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified TargetHttpsProxy resource. Gets a list of available target HTTPS proxies by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a TargetHttpsProxy resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of TargetHttpsProxy resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified TargetHttpsProxy resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-quic-override",
|
|
Some(r##"Sets the QUIC override policy for TargetHttpsProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_set-quic-override",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource to set the QUIC override policy for. The name should conform to RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-ssl-certificates",
|
|
Some(r##"Replaces SslCertificates for TargetHttpsProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_set-ssl-certificates",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource to set an SslCertificates resource for."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-ssl-policy",
|
|
Some(r##"Sets the SSL policy for TargetHttpsProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the HTTPS proxy load balancer. They do not affect the connection between the load balancer and the backends."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_set-ssl-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource whose SSL policy is to be set. The name must be 1-63 characters long, and comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-url-map",
|
|
Some(r##"Changes the URL map for TargetHttpsProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-https-proxies_set-url-map",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-https-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetHttpsProxy resource whose URL map is to be set."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("target-instances", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of target instances."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified TargetInstance resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-instance"##),
|
|
None,
|
|
Some(r##"Name of the TargetInstance resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified TargetInstance resource. Gets a list of available target instances by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-instance"##),
|
|
None,
|
|
Some(r##"Name of the TargetInstance resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a TargetInstance resource in the specified project and zone using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of TargetInstance resources available to the specified project and zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-instances_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("target-pools", "methods: 'add-health-check', 'add-instance', 'aggregated-list', 'delete', 'get', 'get-health', 'insert', 'list', 'remove-health-check', 'remove-instance' and 'set-backup'", vec![
|
|
("add-health-check",
|
|
Some(r##"Adds health check URLs to a target pool."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_add-health-check",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-pool"##),
|
|
None,
|
|
Some(r##"Name of the target pool to add a health check to."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("add-instance",
|
|
Some(r##"Adds an instance to a target pool."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_add-instance",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-pool"##),
|
|
None,
|
|
Some(r##"Name of the TargetPool resource to add instances to."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of target pools."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified target pool."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-pool"##),
|
|
None,
|
|
Some(r##"Name of the TargetPool resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified target pool. Gets a list of available target pools by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-pool"##),
|
|
None,
|
|
Some(r##"Name of the TargetPool resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-health",
|
|
Some(r##"Gets the most recent health check results for each IP for the instance that is referenced by the given target pool."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_get-health",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-pool"##),
|
|
None,
|
|
Some(r##"Name of the TargetPool resource to which the queried instance belongs."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a target pool in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of target pools available to the specified project and region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-health-check",
|
|
Some(r##"Removes health check URL from a target pool."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_remove-health-check",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-pool"##),
|
|
None,
|
|
Some(r##"Name of the target pool to remove health checks from."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("remove-instance",
|
|
Some(r##"Removes instance URL from a target pool."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_remove-instance",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-pool"##),
|
|
None,
|
|
Some(r##"Name of the TargetPool resource to remove instances from."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-backup",
|
|
Some(r##"Changes a backup target pool's configurations."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-pools_set-backup",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-pool"##),
|
|
None,
|
|
Some(r##"Name of the TargetPool resource to set a backup pool for."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("target-ssl-proxies", "methods: 'delete', 'get', 'insert', 'list', 'set-backend-service', 'set-proxy-header', 'set-ssl-certificates' and 'set-ssl-policy'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified TargetSslProxy resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-ssl-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetSslProxy resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified TargetSslProxy resource. Gets a list of available target SSL proxies by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-ssl-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetSslProxy resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a TargetSslProxy resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of TargetSslProxy resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-backend-service",
|
|
Some(r##"Changes the BackendService for TargetSslProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_set-backend-service",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-ssl-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetSslProxy resource whose BackendService resource is to be set."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-proxy-header",
|
|
Some(r##"Changes the ProxyHeaderType for TargetSslProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_set-proxy-header",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-ssl-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetSslProxy resource whose ProxyHeader is to be set."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-ssl-certificates",
|
|
Some(r##"Changes SslCertificates for TargetSslProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_set-ssl-certificates",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-ssl-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetSslProxy resource whose SslCertificate resource is to be set."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-ssl-policy",
|
|
Some(r##"Sets the SSL policy for TargetSslProxy. The SSL policy specifies the server-side support for SSL features. This affects connections between clients and the SSL proxy load balancer. They do not affect the connection between the load balancer and the backends."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-ssl-proxies_set-ssl-policy",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-ssl-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetSslProxy resource whose SSL policy is to be set. The name must be 1-63 characters long, and comply with RFC1035."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("target-tcp-proxies", "methods: 'delete', 'get', 'insert', 'list', 'set-backend-service' and 'set-proxy-header'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified TargetTcpProxy resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-tcp-proxies_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-tcp-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetTcpProxy resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified TargetTcpProxy resource. Gets a list of available target TCP proxies by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-tcp-proxies_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-tcp-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetTcpProxy resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a TargetTcpProxy resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-tcp-proxies_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of TargetTcpProxy resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-tcp-proxies_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-backend-service",
|
|
Some(r##"Changes the BackendService for TargetTcpProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-tcp-proxies_set-backend-service",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-tcp-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetTcpProxy resource whose BackendService resource is to be set."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-proxy-header",
|
|
Some(r##"Changes the ProxyHeaderType for TargetTcpProxy."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-tcp-proxies_set-proxy-header",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-tcp-proxy"##),
|
|
None,
|
|
Some(r##"Name of the TargetTcpProxy resource whose ProxyHeader is to be set."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("target-vpn-gateways", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of target VPN gateways."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified target VPN gateway."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-vpn-gateway"##),
|
|
None,
|
|
Some(r##"Name of the target VPN gateway to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified target VPN gateway. Gets a list of available target VPN gateways by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"target-vpn-gateway"##),
|
|
None,
|
|
Some(r##"Name of the target VPN gateway to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a target VPN gateway in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of target VPN gateways available to the specified project and region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/target-vpn-gateways_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("url-maps", "methods: 'aggregated-list', 'delete', 'get', 'insert', 'invalidate-cache', 'list', 'patch', 'update' and 'validate'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves the list of all UrlMap resources, regional and global, available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Name of the project scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified UrlMap resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified UrlMap resource. Gets a list of available URL maps by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a UrlMap resource in the specified project using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("invalidate-cache",
|
|
Some(r##"Initiates a cache invalidation operation, invalidating the specified path, scoped to the specified UrlMap. For more information, see [Invalidating cached content](/cdn/docs/invalidating-cached-content)."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_invalidate-cache",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap scoping this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of UrlMap resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("patch",
|
|
Some(r##"Patches the specified UrlMap resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_patch",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to patch."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("update",
|
|
Some(r##"Updates the specified UrlMap resource with the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_update",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to update."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("validate",
|
|
Some(r##"Runs static validation for the UrlMap. In particular, the tests of the provided UrlMap will be run. Calling this method does NOT create the UrlMap."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/url-maps_validate",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"url-map"##),
|
|
None,
|
|
Some(r##"Name of the UrlMap resource to be validated as."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("vpn-gateways", "methods: 'aggregated-list', 'delete', 'get', 'get-status', 'insert', 'list', 'set-labels' and 'test-iam-permissions'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of VPN gateways."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-gateways_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified VPN gateway."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-gateways_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"vpn-gateway"##),
|
|
None,
|
|
Some(r##"Name of the VPN gateway to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified VPN gateway. Gets a list of available VPN gateways by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-gateways_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"vpn-gateway"##),
|
|
None,
|
|
Some(r##"Name of the VPN gateway to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get-status",
|
|
Some(r##"Returns the status for the specified VPN gateway."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-gateways_get-status",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"vpn-gateway"##),
|
|
None,
|
|
Some(r##"Name of the VPN gateway to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a VPN gateway in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-gateways_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of VPN gateways available to the specified project and region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-gateways_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("set-labels",
|
|
Some(r##"Sets the labels on a VpnGateway. To learn more about labels, read the Labeling Resources documentation."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-gateways_set-labels",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("test-iam-permissions",
|
|
Some(r##"Returns permissions that a caller has on the specified resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-gateways_test-iam-permissions",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"The name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"resource"##),
|
|
None,
|
|
Some(r##"Name or id of the resource for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("vpn-tunnels", "methods: 'aggregated-list', 'delete', 'get', 'insert' and 'list'", vec![
|
|
("aggregated-list",
|
|
Some(r##"Retrieves an aggregated list of VPN tunnels."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_aggregated-list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("delete",
|
|
Some(r##"Deletes the specified VpnTunnel resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"vpn-tunnel"##),
|
|
None,
|
|
Some(r##"Name of the VpnTunnel resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("get",
|
|
Some(r##"Returns the specified VpnTunnel resource. Gets a list of available VPN tunnels by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"vpn-tunnel"##),
|
|
None,
|
|
Some(r##"Name of the VpnTunnel resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("insert",
|
|
Some(r##"Creates a VpnTunnel resource in the specified project and region using the data included in the request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_insert",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"kv"##),
|
|
Some(r##"r"##),
|
|
Some(r##"Set various fields of the request structure, matching the key=value form"##),
|
|
Some(true),
|
|
Some(true)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of VpnTunnel resources contained in the specified project and region."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/vpn-tunnels_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"region"##),
|
|
None,
|
|
Some(r##"Name of the region for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("zone-operations", "methods: 'delete', 'get', 'list' and 'wait'", vec![
|
|
("delete",
|
|
Some(r##"Deletes the specified zone-specific Operations resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zone-operations_delete",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to delete."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
]),
|
|
("get",
|
|
Some(r##"Retrieves the specified zone-specific Operations resource."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zone-operations_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves a list of Operation resources contained within the specified zone."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zone-operations_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("wait",
|
|
Some(r##"Waits for the specified Operation resource to return as `DONE` or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method waits for no more than the 2 minutes and then returns the current state of the operation, which might be `DONE` or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not `DONE`. "##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zone-operations_wait",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"operation"##),
|
|
None,
|
|
Some(r##"Name of the Operations resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
("zones", "methods: 'get' and 'list'", vec![
|
|
("get",
|
|
Some(r##"Returns the specified Zone resource. Gets a list of available zones by making a list() request."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zones_get",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"zone"##),
|
|
None,
|
|
Some(r##"Name of the zone resource to return."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
("list",
|
|
Some(r##"Retrieves the list of Zone resources available to the specified project."##),
|
|
"Details at http://byron.github.io/google-apis-rs/google_compute1_cli/zones_list",
|
|
vec![
|
|
(Some(r##"project"##),
|
|
None,
|
|
Some(r##"Project ID for this request."##),
|
|
Some(true),
|
|
Some(false)),
|
|
|
|
(Some(r##"v"##),
|
|
Some(r##"p"##),
|
|
Some(r##"Set various optional parameters, matching the key=value form"##),
|
|
Some(false),
|
|
Some(true)),
|
|
|
|
(Some(r##"out"##),
|
|
Some(r##"o"##),
|
|
Some(r##"Specify the file into which to write the program's output"##),
|
|
Some(false),
|
|
Some(false)),
|
|
]),
|
|
]),
|
|
|
|
];
|
|
|
|
let mut app = App::new("compute1")
|
|
.author("Sebastian Thiel <byronimo@gmail.com>")
|
|
.version("4.0.1+20220224")
|
|
.about("Creates and runs virtual machines on Google Cloud Platform. ")
|
|
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_compute1_cli")
|
|
.arg(Arg::with_name("url")
|
|
.long("scope")
|
|
.help("Specify the authentication a method should be executed in. Each scope requires the user to grant this application permission to use it.If unset, it defaults to the shortest scope url for a particular method.")
|
|
.multiple(true)
|
|
.takes_value(true))
|
|
.arg(Arg::with_name("folder")
|
|
.long("config-dir")
|
|
.help("A directory into which we will store our persistent data. Defaults to a user-writable directory that we will create during the first invocation.[default: ~/.google-service-cli")
|
|
.multiple(false)
|
|
.takes_value(true))
|
|
.arg(Arg::with_name("debug")
|
|
.long("debug")
|
|
.help("Debug print all errors")
|
|
.multiple(false)
|
|
.takes_value(false));
|
|
|
|
for &(main_command_name, about, ref subcommands) in arg_data.iter() {
|
|
let mut mcmd = SubCommand::with_name(main_command_name).about(about);
|
|
|
|
for &(sub_command_name, ref desc, url_info, ref args) in subcommands {
|
|
let mut scmd = SubCommand::with_name(sub_command_name);
|
|
if let &Some(desc) = desc {
|
|
scmd = scmd.about(desc);
|
|
}
|
|
scmd = scmd.after_help(url_info);
|
|
|
|
for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args {
|
|
let arg_name_str =
|
|
match (arg_name, flag) {
|
|
(&Some(an), _ ) => an,
|
|
(_ , &Some(f)) => f,
|
|
_ => unreachable!(),
|
|
};
|
|
let mut arg = Arg::with_name(arg_name_str)
|
|
.empty_values(false);
|
|
if let &Some(short_flag) = flag {
|
|
arg = arg.short(short_flag);
|
|
}
|
|
if let &Some(desc) = desc {
|
|
arg = arg.help(desc);
|
|
}
|
|
if arg_name.is_some() && flag.is_some() {
|
|
arg = arg.takes_value(true);
|
|
}
|
|
if let &Some(required) = required {
|
|
arg = arg.required(required);
|
|
}
|
|
if let &Some(multi) = multi {
|
|
arg = arg.multiple(multi);
|
|
}
|
|
scmd = scmd.arg(arg);
|
|
}
|
|
mcmd = mcmd.subcommand(scmd);
|
|
}
|
|
app = app.subcommand(mcmd);
|
|
}
|
|
|
|
let matches = app.get_matches();
|
|
|
|
let debug = matches.is_present("adebug");
|
|
let connector = hyper_rustls::HttpsConnectorBuilder::new().with_native_roots()
|
|
.https_or_http()
|
|
.enable_http1()
|
|
.enable_http2()
|
|
.build();
|
|
|
|
match Engine::new(matches, connector).await {
|
|
Err(err) => {
|
|
exit_status = err.exit_code;
|
|
writeln!(io::stderr(), "{}", err).ok();
|
|
},
|
|
Ok(engine) => {
|
|
if let Err(doit_err) = engine.doit().await {
|
|
exit_status = 1;
|
|
match doit_err {
|
|
DoitError::IoError(path, err) => {
|
|
writeln!(io::stderr(), "Failed to open output file '{}': {}", path, err).ok();
|
|
},
|
|
DoitError::ApiError(err) => {
|
|
if debug {
|
|
writeln!(io::stderr(), "{:#?}", err).ok();
|
|
} else {
|
|
writeln!(io::stderr(), "{}", err).ok();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
std::process::exit(exit_status);
|
|
}
|