// DO NOT EDIT ! // This file was generated automatically from 'src/mako/cli/main.rs.mako' // DO NOT EDIT ! #![feature(plugin, exit_status)] #![allow(unused_variables, unused_imports, dead_code, unused_mut)] #[macro_use] extern crate clap; extern crate yup_oauth2 as oauth2; extern crate yup_hyper_mock as mock; extern crate serde; extern crate hyper; extern crate mime; extern crate strsim; extern crate google_mapsengine1 as api; use std::env; use std::io::{self, Write}; use clap::{App, SubCommand, Arg}; mod cmn; use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, 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}; use std::default::Default; use std::str::FromStr; use oauth2::{Authenticator, DefaultAuthenticatorDelegate}; use serde::json; use clap::ArgMatches; enum DoitError { IoError(String, io::Error), ApiError(api::Error), } struct Engine<'n, 'a> { opt: ArgMatches<'n, 'a>, hub: api::MapsEngine>, gp: Vec<&'static str>, gpm: Vec<(&'static str, &'static str)>, } impl<'n, 'a> Engine<'n, 'a> { fn _assets_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.assets().get(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _assets_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.assets().list(); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "type" => { call = call.type_(value.unwrap_or("")); }, "tags" => { call = call.tags(value.unwrap_or("")); }, "search" => { call = call.search(value.unwrap_or("")); }, "role" => { call = call.role(value.unwrap_or("")); }, "project-id" => { call = call.project_id(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "modified-before" => { call = call.modified_before(value.unwrap_or("")); }, "modified-after" => { call = call.modified_after(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, "creator-email" => { call = call.creator_email(value.unwrap_or("")); }, "created-before" => { call = call.created_before(value.unwrap_or("")); }, "created-after" => { call = call.created_after(value.unwrap_or("")); }, "bbox" => { call = call.bbox(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["modified-after", "search", "tags", "project-id", "created-after", "max-results", "page-token", "created-before", "role", "bbox", "modified-before", "creator-email", "type"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _assets_parents_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.assets().parents_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "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(), Vec::new() + &self.gp + &["page-token", "max-results"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _assets_permissions_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.assets().permissions_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_cancel_processing(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().cancel_processing(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_create(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Layer::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } fn request_style_feature_info_init(request: &mut api::Layer) { request_style_init(request); if request.style.as_mut().unwrap().feature_info.is_none() { request.style.as_mut().unwrap().feature_info = Some(Default::default()); } } fn request_style_init(request: &mut api::Layer) { if request.style.is_none() { request.style = Some(Default::default()); } } match &temp_cursor.to_string()[..] { "style.feature-info.content" => { request_style_feature_info_init(&mut request); request.style.as_mut().unwrap().feature_info.as_mut().unwrap().content = Some(value.unwrap_or("").to_string()); }, "style.type" => { request_style_feature_info_init(&mut request); request.style.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "description" => { request_style_init(&mut request); request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request_style_init(&mut request); request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request_style_init(&mut request); request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "datasource-type" => { request_style_init(&mut request); request.datasource_type = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_style_init(&mut request); request.creation_time = Some(value.unwrap_or("").to_string()); }, "publishing-status" => { request_style_init(&mut request); request.publishing_status = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request_style_init(&mut request); request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "etag" => { request_style_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request_style_init(&mut request); request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { request_style_init(&mut request); if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "layer-type" => { request_style_init(&mut request); request.layer_type = Some(value.unwrap_or("").to_string()); }, "project-id" => { request_style_init(&mut request); request.project_id = Some(value.unwrap_or("").to_string()); }, "last-modifier-email" => { request_style_init(&mut request); request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request_style_init(&mut request); request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "published-access-list" => { request_style_init(&mut request); request.published_access_list = Some(value.unwrap_or("").to_string()); }, "id" => { request_style_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request_style_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["bbox", "content", "creation-time", "creator-email", "datasource-type", "description", "draft-access-list", "etag", "feature-info", "id", "last-modified-time", "last-modifier-email", "layer-type", "name", "processing-status", "project-id", "published-access-list", "publishing-status", "style", "type", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.layers().create(request); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "process" => { call = call.process(arg_from_str(value.unwrap_or("false"), err, "process", "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(), Vec::new() + &self.gp + &["process"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().delete(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _layers_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().get(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "version" => { call = call.version(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["version"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_get_published(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().get_published(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().list(); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); }, "search" => { call = call.search(value.unwrap_or("")); }, "role" => { call = call.role(value.unwrap_or("")); }, "project-id" => { call = call.project_id(value.unwrap_or("")); }, "processing-status" => { call = call.processing_status(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "modified-before" => { call = call.modified_before(value.unwrap_or("")); }, "modified-after" => { call = call.modified_after(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, "creator-email" => { call = call.creator_email(value.unwrap_or("")); }, "created-before" => { call = call.created_before(value.unwrap_or("")); }, "created-after" => { call = call.created_after(value.unwrap_or("")); }, "bbox" => { call = call.bbox(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["modified-after", "search", "processing-status", "project-id", "tags", "created-after", "max-results", "page-token", "created-before", "role", "bbox", "modified-before", "creator-email"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_list_published(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().list_published(); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "project-id" => { call = call.project_id(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "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(), Vec::new() + &self.gp + &["project-id", "max-results", "page-token"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_parents_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().parents_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "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(), Vec::new() + &self.gp + &["page-token", "max-results"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Layer::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } fn request_style_feature_info_init(request: &mut api::Layer) { request_style_init(request); if request.style.as_mut().unwrap().feature_info.is_none() { request.style.as_mut().unwrap().feature_info = Some(Default::default()); } } fn request_style_init(request: &mut api::Layer) { if request.style.is_none() { request.style = Some(Default::default()); } } match &temp_cursor.to_string()[..] { "style.feature-info.content" => { request_style_feature_info_init(&mut request); request.style.as_mut().unwrap().feature_info.as_mut().unwrap().content = Some(value.unwrap_or("").to_string()); }, "style.type" => { request_style_feature_info_init(&mut request); request.style.as_mut().unwrap().type_ = Some(value.unwrap_or("").to_string()); }, "description" => { request_style_init(&mut request); request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request_style_init(&mut request); request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request_style_init(&mut request); request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "datasource-type" => { request_style_init(&mut request); request.datasource_type = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_style_init(&mut request); request.creation_time = Some(value.unwrap_or("").to_string()); }, "publishing-status" => { request_style_init(&mut request); request.publishing_status = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request_style_init(&mut request); request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "etag" => { request_style_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request_style_init(&mut request); request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { request_style_init(&mut request); if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "layer-type" => { request_style_init(&mut request); request.layer_type = Some(value.unwrap_or("").to_string()); }, "project-id" => { request_style_init(&mut request); request.project_id = Some(value.unwrap_or("").to_string()); }, "last-modifier-email" => { request_style_init(&mut request); request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request_style_init(&mut request); request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "published-access-list" => { request_style_init(&mut request); request.published_access_list = Some(value.unwrap_or("").to_string()); }, "id" => { request_style_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request_style_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["bbox", "content", "creation-time", "creator-email", "datasource-type", "description", "draft-access-list", "etag", "feature-info", "id", "last-modified-time", "last-modifier-email", "layer-type", "name", "processing-status", "project-id", "published-access-list", "publishing-status", "style", "type", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.layers().patch(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _layers_permissions_batch_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchDeleteRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); } request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["ids"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.layers().permissions_batch_delete(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_permissions_batch_update(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchUpdateRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } 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())))); } } } let mut call = self.hub.layers().permissions_batch_update(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_permissions_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().permissions_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_process(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().process(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_publish(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().publish(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "force" => { call = call.force(arg_from_str(value.unwrap_or("false"), err, "force", "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(), Vec::new() + &self.gp + &["force"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _layers_unpublish(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.layers().unpublish(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_create(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Map::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "description" => { request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request.project_id = Some(value.unwrap_or("").to_string()); }, "versions" => { if request.versions.is_none() { request.versions = Some(Default::default()); } request.versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-time" => { request.creation_time = Some(value.unwrap_or("").to_string()); }, "publishing-status" => { request.publishing_status = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "etag" => { request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "published-access-list" => { request.published_access_list = Some(value.unwrap_or("").to_string()); }, "id" => { request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["bbox", "creation-time", "creator-email", "description", "draft-access-list", "etag", "id", "last-modified-time", "last-modifier-email", "name", "processing-status", "project-id", "published-access-list", "publishing-status", "versions", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.maps().create(request); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.maps().delete(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _maps_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.maps().get(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "version" => { call = call.version(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["version"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_get_published(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.maps().get_published(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.maps().list(); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); }, "search" => { call = call.search(value.unwrap_or("")); }, "role" => { call = call.role(value.unwrap_or("")); }, "project-id" => { call = call.project_id(value.unwrap_or("")); }, "processing-status" => { call = call.processing_status(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "modified-before" => { call = call.modified_before(value.unwrap_or("")); }, "modified-after" => { call = call.modified_after(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, "creator-email" => { call = call.creator_email(value.unwrap_or("")); }, "created-before" => { call = call.created_before(value.unwrap_or("")); }, "created-after" => { call = call.created_after(value.unwrap_or("")); }, "bbox" => { call = call.bbox(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["modified-after", "search", "processing-status", "project-id", "tags", "created-after", "max-results", "page-token", "created-before", "role", "bbox", "modified-before", "creator-email"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_list_published(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.maps().list_published(); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "project-id" => { call = call.project_id(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "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(), Vec::new() + &self.gp + &["project-id", "max-results", "page-token"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Map::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "description" => { request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request.project_id = Some(value.unwrap_or("").to_string()); }, "versions" => { if request.versions.is_none() { request.versions = Some(Default::default()); } request.versions.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "creation-time" => { request.creation_time = Some(value.unwrap_or("").to_string()); }, "publishing-status" => { request.publishing_status = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "etag" => { request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "published-access-list" => { request.published_access_list = Some(value.unwrap_or("").to_string()); }, "id" => { request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["bbox", "creation-time", "creator-email", "description", "draft-access-list", "etag", "id", "last-modified-time", "last-modifier-email", "name", "processing-status", "project-id", "published-access-list", "publishing-status", "versions", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.maps().patch(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _maps_permissions_batch_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchDeleteRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); } request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["ids"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.maps().permissions_batch_delete(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_permissions_batch_update(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchUpdateRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } 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())))); } } } let mut call = self.hub.maps().permissions_batch_update(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_permissions_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.maps().permissions_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_publish(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.maps().publish(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "force" => { call = call.force(arg_from_str(value.unwrap_or("false"), err, "force", "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(), Vec::new() + &self.gp + &["force"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _maps_unpublish(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.maps().unpublish(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _projects_icons_create(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Icon::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "description" => { request.description = Some(value.unwrap_or("").to_string()); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); }, "id" => { request.id = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["description", "id", "name"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.projects().icons_create(request, opt.value_of("project-id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let vals = opt.values_of("mode").unwrap(); let protocol = calltype_from_str(vals[0], ["simple", "resumable"].iter().map(|&v| v.to_string()).collect(), err); let mut input_file = input_file_from_opts(vals[1], err); let mime_type = input_mime_from_opts(opt.value_of("mime").unwrap_or("application/octet-stream"), err); if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Upload(UploadProtocol::Simple) => call.upload(input_file.unwrap(), mime_type.unwrap()), CallType::Upload(UploadProtocol::Resumable) => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), CallType::Standard => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _projects_icons_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut download_mode = false; let mut call = self.hub.projects().icons_get(opt.value_of("project-id").unwrap_or(""), opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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 { if key == "alt" && value.unwrap_or("unset") == "media" { download_mode = true; } found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { if !download_mode { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); } else { io::copy(&mut response, &mut ostream).unwrap(); } Ok(()) } } } } fn _projects_icons_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.projects().icons_list(opt.value_of("project-id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "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(), Vec::new() + &self.gp + &["page-token", "max-results"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _projects_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.projects().list(); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_cancel_processing(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.raster_collections().cancel_processing(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_create(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::RasterCollection::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "attribution" => { request.attribution = Some(value.unwrap_or("").to_string()); }, "description" => { request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request.project_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request.creation_time = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "raster-type" => { request.raster_type = Some(value.unwrap_or("").to_string()); }, "etag" => { request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "id" => { request.id = Some(value.unwrap_or("").to_string()); }, "mosaic" => { request.mosaic = Some(arg_from_str(value.unwrap_or("false"), err, "mosaic", "boolean")); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["attribution", "bbox", "creation-time", "creator-email", "description", "draft-access-list", "etag", "id", "last-modified-time", "last-modifier-email", "mosaic", "name", "processing-status", "project-id", "raster-type", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.raster_collections().create(request); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.raster_collections().delete(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _raster_collections_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.raster_collections().get(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.raster_collections().list(); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); }, "search" => { call = call.search(value.unwrap_or("")); }, "role" => { call = call.role(value.unwrap_or("")); }, "project-id" => { call = call.project_id(value.unwrap_or("")); }, "processing-status" => { call = call.processing_status(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "modified-before" => { call = call.modified_before(value.unwrap_or("")); }, "modified-after" => { call = call.modified_after(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, "creator-email" => { call = call.creator_email(value.unwrap_or("")); }, "created-before" => { call = call.created_before(value.unwrap_or("")); }, "created-after" => { call = call.created_after(value.unwrap_or("")); }, "bbox" => { call = call.bbox(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["modified-after", "search", "processing-status", "project-id", "tags", "created-after", "max-results", "page-token", "created-before", "role", "bbox", "modified-before", "creator-email"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_parents_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.raster_collections().parents_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "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(), Vec::new() + &self.gp + &["page-token", "max-results"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::RasterCollection::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "attribution" => { request.attribution = Some(value.unwrap_or("").to_string()); }, "description" => { request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request.project_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request.creation_time = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "raster-type" => { request.raster_type = Some(value.unwrap_or("").to_string()); }, "etag" => { request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "id" => { request.id = Some(value.unwrap_or("").to_string()); }, "mosaic" => { request.mosaic = Some(arg_from_str(value.unwrap_or("false"), err, "mosaic", "boolean")); }, "name" => { request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["attribution", "bbox", "creation-time", "creator-email", "description", "draft-access-list", "etag", "id", "last-modified-time", "last-modifier-email", "mosaic", "name", "processing-status", "project-id", "raster-type", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.raster_collections().patch(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _raster_collections_permissions_batch_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchDeleteRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); } request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["ids"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.raster_collections().permissions_batch_delete(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_permissions_batch_update(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchUpdateRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } 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())))); } } } let mut call = self.hub.raster_collections().permissions_batch_update(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_permissions_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.raster_collections().permissions_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_process(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.raster_collections().process(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_rasters_batch_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::RasterCollectionsRasterBatchDeleteRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); } request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["ids"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.raster_collections().rasters_batch_delete(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_rasters_batch_insert(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::RasterCollectionsRastersBatchInsertRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); } request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["ids"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.raster_collections().rasters_batch_insert(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _raster_collections_rasters_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.raster_collections().rasters_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); }, "search" => { call = call.search(value.unwrap_or("")); }, "role" => { call = call.role(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "modified-before" => { call = call.modified_before(value.unwrap_or("")); }, "modified-after" => { call = call.modified_after(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, "creator-email" => { call = call.creator_email(value.unwrap_or("")); }, "created-before" => { call = call.created_before(value.unwrap_or("")); }, "created-after" => { call = call.created_after(value.unwrap_or("")); }, "bbox" => { call = call.bbox(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["modified-after", "search", "tags", "created-after", "max-results", "page-token", "created-before", "role", "bbox", "modified-before", "creator-email"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _rasters_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.rasters().delete(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _rasters_files_insert(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.rasters().files_insert(opt.value_of("id").unwrap_or(""), opt.value_of("filename").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let vals = opt.values_of("mode").unwrap(); let protocol = calltype_from_str(vals[0], ["simple", "resumable"].iter().map(|&v| v.to_string()).collect(), err); let mut input_file = input_file_from_opts(vals[1], err); let mime_type = input_mime_from_opts(opt.value_of("mime").unwrap_or("application/octet-stream"), err); if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Upload(UploadProtocol::Simple) => call.upload(input_file.unwrap(), mime_type.unwrap()), CallType::Upload(UploadProtocol::Resumable) => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), CallType::Standard => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _rasters_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.rasters().get(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _rasters_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.rasters().list(opt.value_of("project-id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); }, "search" => { call = call.search(value.unwrap_or("")); }, "role" => { call = call.role(value.unwrap_or("")); }, "processing-status" => { call = call.processing_status(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "modified-before" => { call = call.modified_before(value.unwrap_or("")); }, "modified-after" => { call = call.modified_after(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, "creator-email" => { call = call.creator_email(value.unwrap_or("")); }, "created-before" => { call = call.created_before(value.unwrap_or("")); }, "created-after" => { call = call.created_after(value.unwrap_or("")); }, "bbox" => { call = call.bbox(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["modified-after", "search", "processing-status", "tags", "created-after", "max-results", "page-token", "created-before", "role", "bbox", "modified-before", "creator-email"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _rasters_parents_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.rasters().parents_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "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(), Vec::new() + &self.gp + &["page-token", "max-results"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _rasters_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Raster::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } fn request_acquisition_time_init(request: &mut api::Raster) { if request.acquisition_time.is_none() { request.acquisition_time = Some(Default::default()); } } match &temp_cursor.to_string()[..] { "acquisition-time.start" => { request_acquisition_time_init(&mut request); request.acquisition_time.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "acquisition-time.end" => { request_acquisition_time_init(&mut request); request.acquisition_time.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "acquisition-time.precision" => { request_acquisition_time_init(&mut request); request.acquisition_time.as_mut().unwrap().precision = Some(value.unwrap_or("").to_string()); }, "attribution" => { request_acquisition_time_init(&mut request); request.attribution = Some(value.unwrap_or("").to_string()); }, "description" => { request_acquisition_time_init(&mut request); request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request_acquisition_time_init(&mut request); request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request_acquisition_time_init(&mut request); request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request_acquisition_time_init(&mut request); request.project_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_acquisition_time_init(&mut request); request.creation_time = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request_acquisition_time_init(&mut request); request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "mask-type" => { request_acquisition_time_init(&mut request); request.mask_type = Some(value.unwrap_or("").to_string()); }, "etag" => { request_acquisition_time_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request_acquisition_time_init(&mut request); request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { request_acquisition_time_init(&mut request); if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_acquisition_time_init(&mut request); request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request_acquisition_time_init(&mut request); request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "id" => { request_acquisition_time_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, "raster-type" => { request_acquisition_time_init(&mut request); request.raster_type = Some(value.unwrap_or("").to_string()); }, "name" => { request_acquisition_time_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["acquisition-time", "attribution", "bbox", "creation-time", "creator-email", "description", "draft-access-list", "end", "etag", "id", "last-modified-time", "last-modifier-email", "mask-type", "name", "precision", "processing-status", "project-id", "raster-type", "start", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.rasters().patch(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _rasters_permissions_batch_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchDeleteRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); } request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["ids"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.rasters().permissions_batch_delete(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _rasters_permissions_batch_update(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchUpdateRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } 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())))); } } } let mut call = self.hub.rasters().permissions_batch_update(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _rasters_permissions_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.rasters().permissions_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _rasters_process(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.rasters().process(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _rasters_upload(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Raster::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } fn request_acquisition_time_init(request: &mut api::Raster) { if request.acquisition_time.is_none() { request.acquisition_time = Some(Default::default()); } } match &temp_cursor.to_string()[..] { "acquisition-time.start" => { request_acquisition_time_init(&mut request); request.acquisition_time.as_mut().unwrap().start = Some(value.unwrap_or("").to_string()); }, "acquisition-time.end" => { request_acquisition_time_init(&mut request); request.acquisition_time.as_mut().unwrap().end = Some(value.unwrap_or("").to_string()); }, "acquisition-time.precision" => { request_acquisition_time_init(&mut request); request.acquisition_time.as_mut().unwrap().precision = Some(value.unwrap_or("").to_string()); }, "attribution" => { request_acquisition_time_init(&mut request); request.attribution = Some(value.unwrap_or("").to_string()); }, "description" => { request_acquisition_time_init(&mut request); request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request_acquisition_time_init(&mut request); request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request_acquisition_time_init(&mut request); request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request_acquisition_time_init(&mut request); request.project_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_acquisition_time_init(&mut request); request.creation_time = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request_acquisition_time_init(&mut request); request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "mask-type" => { request_acquisition_time_init(&mut request); request.mask_type = Some(value.unwrap_or("").to_string()); }, "etag" => { request_acquisition_time_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request_acquisition_time_init(&mut request); request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { request_acquisition_time_init(&mut request); if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_acquisition_time_init(&mut request); request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request_acquisition_time_init(&mut request); request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "id" => { request_acquisition_time_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, "raster-type" => { request_acquisition_time_init(&mut request); request.raster_type = Some(value.unwrap_or("").to_string()); }, "name" => { request_acquisition_time_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["acquisition-time", "attribution", "bbox", "creation-time", "creator-email", "description", "draft-access-list", "end", "etag", "id", "last-modified-time", "last-modifier-email", "mask-type", "name", "precision", "processing-status", "project-id", "raster-type", "start", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.rasters().upload(request); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_create(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Table::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } fn request_schema_init(request: &mut api::Table) { if request.schema.is_none() { request.schema = Some(Default::default()); } } match &temp_cursor.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); }, "schema.primary-key" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_key = Some(value.unwrap_or("").to_string()); }, "description" => { request_schema_init(&mut request); request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request_schema_init(&mut request); request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request_schema_init(&mut request); request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request_schema_init(&mut request); request.project_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_schema_init(&mut request); request.creation_time = Some(value.unwrap_or("").to_string()); }, "source-encoding" => { request_schema_init(&mut request); request.source_encoding = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request_schema_init(&mut request); request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "etag" => { request_schema_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request_schema_init(&mut request); request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { request_schema_init(&mut request); if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_schema_init(&mut request); request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request_schema_init(&mut request); request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "published-access-list" => { request_schema_init(&mut request); request.published_access_list = Some(value.unwrap_or("").to_string()); }, "id" => { request_schema_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request_schema_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["bbox", "creation-time", "creator-email", "description", "draft-access-list", "etag", "id", "last-modified-time", "last-modifier-email", "name", "primary-geometry", "primary-key", "processing-status", "project-id", "published-access-list", "schema", "source-encoding", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.tables().create(request); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().delete(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _tables_features_batch_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::FeaturesBatchDeleteRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "gx-ids" => { if request.gx_ids.is_none() { request.gx_ids = Some(Default::default()); } request.gx_ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, "primary-keys" => { if request.primary_keys.is_none() { request.primary_keys = Some(Default::default()); } request.primary_keys.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["gx-ids", "primary-keys"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.tables().features_batch_delete(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _tables_features_batch_insert(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::FeaturesBatchInsertRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "normalize-geometries" => { request.normalize_geometries = Some(arg_from_str(value.unwrap_or("false"), err, "normalize-geometries", "boolean")); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["normalize-geometries"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.tables().features_batch_insert(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _tables_features_batch_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::FeaturesBatchPatchRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "normalize-geometries" => { request.normalize_geometries = Some(arg_from_str(value.unwrap_or("false"), err, "normalize-geometries", "boolean")); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["normalize-geometries"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.tables().features_batch_patch(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _tables_features_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().features_get(opt.value_of("table-id").unwrap_or(""), opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "version" => { call = call.version(value.unwrap_or("")); }, "select" => { call = call.select(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["version", "select"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_features_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().features_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "where" => { call = call.where_(value.unwrap_or("")); }, "version" => { call = call.version(value.unwrap_or("")); }, "select" => { call = call.select(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")); }, "limit" => { call = call.limit(arg_from_str(value.unwrap_or("-0"), err, "limit", "integer")); }, "intersects" => { call = call.intersects(value.unwrap_or("")); }, "include" => { call = call.include(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["order-by", "intersects", "max-results", "page-token", "version", "limit", "include", "where", "select"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_files_insert(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().files_insert(opt.value_of("id").unwrap_or(""), opt.value_of("filename").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let vals = opt.values_of("mode").unwrap(); let protocol = calltype_from_str(vals[0], ["simple", "resumable"].iter().map(|&v| v.to_string()).collect(), err); let mut input_file = input_file_from_opts(vals[1], err); let mime_type = input_mime_from_opts(opt.value_of("mime").unwrap_or("application/octet-stream"), err); if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Upload(UploadProtocol::Simple) => call.upload(input_file.unwrap(), mime_type.unwrap()), CallType::Upload(UploadProtocol::Resumable) => call.upload_resumable(input_file.unwrap(), mime_type.unwrap()), CallType::Standard => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _tables_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().get(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "version" => { call = call.version(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["version"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().list(); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "tags" => { call = call.tags(value.unwrap_or("")); }, "search" => { call = call.search(value.unwrap_or("")); }, "role" => { call = call.role(value.unwrap_or("")); }, "project-id" => { call = call.project_id(value.unwrap_or("")); }, "processing-status" => { call = call.processing_status(value.unwrap_or("")); }, "page-token" => { call = call.page_token(value.unwrap_or("")); }, "modified-before" => { call = call.modified_before(value.unwrap_or("")); }, "modified-after" => { call = call.modified_after(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "integer")); }, "creator-email" => { call = call.creator_email(value.unwrap_or("")); }, "created-before" => { call = call.created_before(value.unwrap_or("")); }, "created-after" => { call = call.created_after(value.unwrap_or("")); }, "bbox" => { call = call.bbox(value.unwrap_or("")); }, _ => { let mut found = false; for param in &self.gp { if key == *param { found = true; call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset")); break; } } if !found { err.issues.push(CLIError::UnknownParameter(key.to_string(), Vec::new() + &self.gp + &["modified-after", "search", "processing-status", "project-id", "tags", "created-after", "max-results", "page-token", "created-before", "role", "bbox", "modified-before", "creator-email"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_parents_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().parents_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() { let (key, value) = parse_kv_arg(&*parg, err, false); match key { "page-token" => { call = call.page_token(value.unwrap_or("")); }, "max-results" => { call = call.max_results(arg_from_str(value.unwrap_or("-0"), err, "max-results", "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(), Vec::new() + &self.gp + &["page-token", "max-results"] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Table::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } fn request_schema_init(request: &mut api::Table) { if request.schema.is_none() { request.schema = Some(Default::default()); } } match &temp_cursor.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); }, "schema.primary-key" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_key = Some(value.unwrap_or("").to_string()); }, "description" => { request_schema_init(&mut request); request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request_schema_init(&mut request); request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request_schema_init(&mut request); request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request_schema_init(&mut request); request.project_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_schema_init(&mut request); request.creation_time = Some(value.unwrap_or("").to_string()); }, "source-encoding" => { request_schema_init(&mut request); request.source_encoding = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request_schema_init(&mut request); request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "etag" => { request_schema_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request_schema_init(&mut request); request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { request_schema_init(&mut request); if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_schema_init(&mut request); request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request_schema_init(&mut request); request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "published-access-list" => { request_schema_init(&mut request); request.published_access_list = Some(value.unwrap_or("").to_string()); }, "id" => { request_schema_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request_schema_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["bbox", "creation-time", "creator-email", "description", "draft-access-list", "etag", "id", "last-modified-time", "last-modifier-email", "name", "primary-geometry", "primary-key", "processing-status", "project-id", "published-access-list", "schema", "source-encoding", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.tables().patch(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok(mut response) => { Ok(()) } } } } fn _tables_permissions_batch_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchDeleteRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } match &temp_cursor.to_string()[..] { "ids" => { if request.ids.is_none() { request.ids = Some(Default::default()); } request.ids.as_mut().unwrap().push(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["ids"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.tables().permissions_batch_delete(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_permissions_batch_update(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::PermissionsBatchUpdateRequest::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } 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())))); } } } let mut call = self.hub.tables().permissions_batch_update(request, opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_permissions_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().permissions_list(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_process(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut call = self.hub.tables().process(opt.value_of("id").unwrap_or("")); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _tables_upload(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError) -> Result<(), DoitError> { let mut request = api::Table::default(); let mut field_cursor = FieldCursor::default(); for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() { let last_errc = err.issues.len(); let (key, value) = parse_kv_arg(&*kvarg, err, false); let mut temp_cursor = field_cursor.clone(); if let Err(field_err) = temp_cursor.set(&*key) { err.issues.push(field_err); } if value.is_none() { field_cursor = temp_cursor.clone(); if err.issues.len() > last_errc { err.issues.remove(last_errc); } continue; } fn request_schema_init(request: &mut api::Table) { if request.schema.is_none() { request.schema = Some(Default::default()); } } match &temp_cursor.to_string()[..] { "schema.primary-geometry" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_geometry = Some(value.unwrap_or("").to_string()); }, "schema.primary-key" => { request_schema_init(&mut request); request.schema.as_mut().unwrap().primary_key = Some(value.unwrap_or("").to_string()); }, "description" => { request_schema_init(&mut request); request.description = Some(value.unwrap_or("").to_string()); }, "processing-status" => { request_schema_init(&mut request); request.processing_status = Some(value.unwrap_or("").to_string()); }, "draft-access-list" => { request_schema_init(&mut request); request.draft_access_list = Some(value.unwrap_or("").to_string()); }, "project-id" => { request_schema_init(&mut request); request.project_id = Some(value.unwrap_or("").to_string()); }, "creation-time" => { request_schema_init(&mut request); request.creation_time = Some(value.unwrap_or("").to_string()); }, "source-encoding" => { request_schema_init(&mut request); request.source_encoding = Some(value.unwrap_or("").to_string()); }, "writers-can-edit-permissions" => { request_schema_init(&mut request); request.writers_can_edit_permissions = Some(arg_from_str(value.unwrap_or("false"), err, "writers-can-edit-permissions", "boolean")); }, "etag" => { request_schema_init(&mut request); request.etag = Some(value.unwrap_or("").to_string()); }, "creator-email" => { request_schema_init(&mut request); request.creator_email = Some(value.unwrap_or("").to_string()); }, "bbox" => { request_schema_init(&mut request); if request.bbox.is_none() { request.bbox = Some(Default::default()); } request.bbox.as_mut().unwrap().push(arg_from_str(value.unwrap_or("0.0"), err, "bbox", "number")); }, "last-modifier-email" => { request_schema_init(&mut request); request.last_modifier_email = Some(value.unwrap_or("").to_string()); }, "last-modified-time" => { request_schema_init(&mut request); request.last_modified_time = Some(value.unwrap_or("").to_string()); }, "published-access-list" => { request_schema_init(&mut request); request.published_access_list = Some(value.unwrap_or("").to_string()); }, "id" => { request_schema_init(&mut request); request.id = Some(value.unwrap_or("").to_string()); }, "name" => { request_schema_init(&mut request); request.name = Some(value.unwrap_or("").to_string()); }, _ => { let suggestion = FieldCursor::did_you_mean(key, &vec!["bbox", "creation-time", "creator-email", "description", "draft-access-list", "etag", "id", "last-modified-time", "last-modifier-email", "name", "primary-geometry", "primary-key", "processing-status", "project-id", "published-access-list", "schema", "source-encoding", "writers-can-edit-permissions"]); err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string())))); } } } let mut call = self.hub.tables().upload(request); for parg in opt.values_of("v").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(), Vec::new() + &self.gp + &[] )); } } } } let protocol = CallType::Standard; if dry_run { Ok(()) } else { assert!(err.issues.len() == 0); for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() { call = call.add_scope(scope); } let mut ostream = match writer_from_opts(opt.value_of("out")) { Ok(mut f) => f, Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)), }; match match protocol { CallType::Standard => call.doit(), _ => unreachable!() } { Err(api_err) => Err(DoitError::ApiError(api_err)), Ok((mut response, output_schema)) => { let mut value = json::value::to_value(&output_schema); remove_json_null_values(&mut value); serde::json::to_writer_pretty(&mut ostream, &value).unwrap(); Ok(()) } } } } fn _doit(&self, dry_run: bool) -> Result, Option> { let mut err = InvalidOptionsError::new(); let mut call_result: Result<(), DoitError> = Ok(()); let mut err_opt: Option = None; match self.opt.subcommand() { ("assets", Some(opt)) => { match opt.subcommand() { ("get", Some(opt)) => { call_result = self._assets_get(opt, dry_run, &mut err); }, ("list", Some(opt)) => { call_result = self._assets_list(opt, dry_run, &mut err); }, ("parents-list", Some(opt)) => { call_result = self._assets_parents_list(opt, dry_run, &mut err); }, ("permissions-list", Some(opt)) => { call_result = self._assets_permissions_list(opt, dry_run, &mut err); }, _ => { err.issues.push(CLIError::MissingMethodError("assets".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); } } }, ("layers", Some(opt)) => { match opt.subcommand() { ("cancel-processing", Some(opt)) => { call_result = self._layers_cancel_processing(opt, dry_run, &mut err); }, ("create", Some(opt)) => { call_result = self._layers_create(opt, dry_run, &mut err); }, ("delete", Some(opt)) => { call_result = self._layers_delete(opt, dry_run, &mut err); }, ("get", Some(opt)) => { call_result = self._layers_get(opt, dry_run, &mut err); }, ("get-published", Some(opt)) => { call_result = self._layers_get_published(opt, dry_run, &mut err); }, ("list", Some(opt)) => { call_result = self._layers_list(opt, dry_run, &mut err); }, ("list-published", Some(opt)) => { call_result = self._layers_list_published(opt, dry_run, &mut err); }, ("parents-list", Some(opt)) => { call_result = self._layers_parents_list(opt, dry_run, &mut err); }, ("patch", Some(opt)) => { call_result = self._layers_patch(opt, dry_run, &mut err); }, ("permissions-batch-delete", Some(opt)) => { call_result = self._layers_permissions_batch_delete(opt, dry_run, &mut err); }, ("permissions-batch-update", Some(opt)) => { call_result = self._layers_permissions_batch_update(opt, dry_run, &mut err); }, ("permissions-list", Some(opt)) => { call_result = self._layers_permissions_list(opt, dry_run, &mut err); }, ("process", Some(opt)) => { call_result = self._layers_process(opt, dry_run, &mut err); }, ("publish", Some(opt)) => { call_result = self._layers_publish(opt, dry_run, &mut err); }, ("unpublish", Some(opt)) => { call_result = self._layers_unpublish(opt, dry_run, &mut err); }, _ => { err.issues.push(CLIError::MissingMethodError("layers".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); } } }, ("maps", Some(opt)) => { match opt.subcommand() { ("create", Some(opt)) => { call_result = self._maps_create(opt, dry_run, &mut err); }, ("delete", Some(opt)) => { call_result = self._maps_delete(opt, dry_run, &mut err); }, ("get", Some(opt)) => { call_result = self._maps_get(opt, dry_run, &mut err); }, ("get-published", Some(opt)) => { call_result = self._maps_get_published(opt, dry_run, &mut err); }, ("list", Some(opt)) => { call_result = self._maps_list(opt, dry_run, &mut err); }, ("list-published", Some(opt)) => { call_result = self._maps_list_published(opt, dry_run, &mut err); }, ("patch", Some(opt)) => { call_result = self._maps_patch(opt, dry_run, &mut err); }, ("permissions-batch-delete", Some(opt)) => { call_result = self._maps_permissions_batch_delete(opt, dry_run, &mut err); }, ("permissions-batch-update", Some(opt)) => { call_result = self._maps_permissions_batch_update(opt, dry_run, &mut err); }, ("permissions-list", Some(opt)) => { call_result = self._maps_permissions_list(opt, dry_run, &mut err); }, ("publish", Some(opt)) => { call_result = self._maps_publish(opt, dry_run, &mut err); }, ("unpublish", Some(opt)) => { call_result = self._maps_unpublish(opt, dry_run, &mut err); }, _ => { err.issues.push(CLIError::MissingMethodError("maps".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); } } }, ("projects", Some(opt)) => { match opt.subcommand() { ("icons-create", Some(opt)) => { call_result = self._projects_icons_create(opt, dry_run, &mut err); }, ("icons-get", Some(opt)) => { call_result = self._projects_icons_get(opt, dry_run, &mut err); }, ("icons-list", Some(opt)) => { call_result = self._projects_icons_list(opt, dry_run, &mut err); }, ("list", Some(opt)) => { call_result = self._projects_list(opt, dry_run, &mut err); }, _ => { err.issues.push(CLIError::MissingMethodError("projects".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); } } }, ("raster-collections", Some(opt)) => { match opt.subcommand() { ("cancel-processing", Some(opt)) => { call_result = self._raster_collections_cancel_processing(opt, dry_run, &mut err); }, ("create", Some(opt)) => { call_result = self._raster_collections_create(opt, dry_run, &mut err); }, ("delete", Some(opt)) => { call_result = self._raster_collections_delete(opt, dry_run, &mut err); }, ("get", Some(opt)) => { call_result = self._raster_collections_get(opt, dry_run, &mut err); }, ("list", Some(opt)) => { call_result = self._raster_collections_list(opt, dry_run, &mut err); }, ("parents-list", Some(opt)) => { call_result = self._raster_collections_parents_list(opt, dry_run, &mut err); }, ("patch", Some(opt)) => { call_result = self._raster_collections_patch(opt, dry_run, &mut err); }, ("permissions-batch-delete", Some(opt)) => { call_result = self._raster_collections_permissions_batch_delete(opt, dry_run, &mut err); }, ("permissions-batch-update", Some(opt)) => { call_result = self._raster_collections_permissions_batch_update(opt, dry_run, &mut err); }, ("permissions-list", Some(opt)) => { call_result = self._raster_collections_permissions_list(opt, dry_run, &mut err); }, ("process", Some(opt)) => { call_result = self._raster_collections_process(opt, dry_run, &mut err); }, ("rasters-batch-delete", Some(opt)) => { call_result = self._raster_collections_rasters_batch_delete(opt, dry_run, &mut err); }, ("rasters-batch-insert", Some(opt)) => { call_result = self._raster_collections_rasters_batch_insert(opt, dry_run, &mut err); }, ("rasters-list", Some(opt)) => { call_result = self._raster_collections_rasters_list(opt, dry_run, &mut err); }, _ => { err.issues.push(CLIError::MissingMethodError("raster-collections".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); } } }, ("rasters", Some(opt)) => { match opt.subcommand() { ("delete", Some(opt)) => { call_result = self._rasters_delete(opt, dry_run, &mut err); }, ("files-insert", Some(opt)) => { call_result = self._rasters_files_insert(opt, dry_run, &mut err); }, ("get", Some(opt)) => { call_result = self._rasters_get(opt, dry_run, &mut err); }, ("list", Some(opt)) => { call_result = self._rasters_list(opt, dry_run, &mut err); }, ("parents-list", Some(opt)) => { call_result = self._rasters_parents_list(opt, dry_run, &mut err); }, ("patch", Some(opt)) => { call_result = self._rasters_patch(opt, dry_run, &mut err); }, ("permissions-batch-delete", Some(opt)) => { call_result = self._rasters_permissions_batch_delete(opt, dry_run, &mut err); }, ("permissions-batch-update", Some(opt)) => { call_result = self._rasters_permissions_batch_update(opt, dry_run, &mut err); }, ("permissions-list", Some(opt)) => { call_result = self._rasters_permissions_list(opt, dry_run, &mut err); }, ("process", Some(opt)) => { call_result = self._rasters_process(opt, dry_run, &mut err); }, ("upload", Some(opt)) => { call_result = self._rasters_upload(opt, dry_run, &mut err); }, _ => { err.issues.push(CLIError::MissingMethodError("rasters".to_string())); writeln!(io::stderr(), "{}\n", opt.usage()).ok(); } } }, ("tables", Some(opt)) => { match opt.subcommand() { ("create", Some(opt)) => { call_result = self._tables_create(opt, dry_run, &mut err); }, ("delete", Some(opt)) => { call_result = self._tables_delete(opt, dry_run, &mut err); }, ("features-batch-delete", Some(opt)) => { call_result = self._tables_features_batch_delete(opt, dry_run, &mut err); }, ("features-batch-insert", Some(opt)) => { call_result = self._tables_features_batch_insert(opt, dry_run, &mut err); }, ("features-batch-patch", Some(opt)) => { call_result = self._tables_features_batch_patch(opt, dry_run, &mut err); }, ("features-get", Some(opt)) => { call_result = self._tables_features_get(opt, dry_run, &mut err); }, ("features-list", Some(opt)) => { call_result = self._tables_features_list(opt, dry_run, &mut err); }, ("files-insert", Some(opt)) => { call_result = self._tables_files_insert(opt, dry_run, &mut err); }, ("get", Some(opt)) => { call_result = self._tables_get(opt, dry_run, &mut err); }, ("list", Some(opt)) => { call_result = self._tables_list(opt, dry_run, &mut err); }, ("parents-list", Some(opt)) => { call_result = self._tables_parents_list(opt, dry_run, &mut err); }, ("patch", Some(opt)) => { call_result = self._tables_patch(opt, dry_run, &mut err); }, ("permissions-batch-delete", Some(opt)) => { call_result = self._tables_permissions_batch_delete(opt, dry_run, &mut err); }, ("permissions-batch-update", Some(opt)) => { call_result = self._tables_permissions_batch_update(opt, dry_run, &mut err); }, ("permissions-list", Some(opt)) => { call_result = self._tables_permissions_list(opt, dry_run, &mut err); }, ("process", Some(opt)) => { call_result = self._tables_process(opt, dry_run, &mut err); }, ("upload", Some(opt)) => { call_result = self._tables_upload(opt, dry_run, &mut err); }, _ => { err.issues.push(CLIError::MissingMethodError("tables".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 fn new(opt: ArgMatches<'a, 'n>) -> Result, InvalidOptionsError> { let (config_dir, secret) = { let config_dir = match cmn::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 cmn::application_secret_from_directory(&config_dir, "mapsengine1-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 auth = Authenticator::new( &secret, DefaultAuthenticatorDelegate, if opt.is_present("debug-auth") { hyper::Client::with_connector(mock::TeeConnector { connector: hyper::net::HttpConnector(None) }) } else { hyper::Client::new() }, JsonTokenStorage { program_name: "mapsengine1", db_dir: config_dir.clone(), }, None); let client = if opt.is_present("debug") { hyper::Client::with_connector(mock::TeeConnector { connector: hyper::net::HttpConnector(None) }) } else { hyper::Client::new() }; let engine = Engine { opt: opt, hub: api::MapsEngine::new(client, auth), gp: vec!["alt", "fields", "key", "oauth-token", "pretty-print", "quota-user", "user-ip"], gpm: vec![ ("oauth-token", "oauth_token"), ("pretty-print", "prettyPrint"), ("quota-user", "quotaUser"), ("user-ip", "userIp"), ] }; match engine._doit(true) { Err(Some(err)) => Err(err), Err(None) => Ok(engine), Ok(_) => unreachable!(), } } fn doit(&self) -> Result<(), DoitError> { match self._doit(false) { Ok(res) => res, Err(_) => unreachable!(), } } } fn main() { let upload_value_names = ["mode", "file"]; let arg_data = [ ("assets", "methods: 'get', 'list', 'parents-list' and 'permissions-list'", vec![ ("get", Some(r##"Return metadata for a particular asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/assets_get", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Return all assets readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/assets_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)), ]), ("parents-list", Some(r##"Return all parent ids of the specified asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/assets_parents-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset whose parents will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("permissions-list", Some(r##"Return all of the permissions for the specified asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/assets_permissions-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset whose permissions will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ]), ("layers", "methods: 'cancel-processing', 'create', 'delete', 'get', 'get-published', 'list', 'list-published', 'parents-list', 'patch', 'permissions-batch-delete', 'permissions-batch-update', 'permissions-list', 'process', 'publish' and 'unpublish'", vec![ ("cancel-processing", Some(r##"Cancel processing on a layer asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_cancel-processing", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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", Some(r##"Create a layer asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_create", 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)), ]), ("delete", Some(r##"Delete a layer."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer. Only the layer creator or project owner are permitted to delete. If the layer is published, or included in a map, the request will fail. Unpublish the layer, and remove it from all maps prior to deleting."##), Some(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##"Return metadata for a particular layer."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_get", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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-published", Some(r##"Return the published metadata for a particular layer."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_get-published", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Return all layers readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_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-published", Some(r##"Return all published layers readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_list-published", 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)), ]), ("parents-list", Some(r##"Return all parent ids of the specified layer."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_parents-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer whose parents will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Mutate a layer asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_patch", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("permissions-batch-delete", Some(r##"Remove permission entries from an already existing asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_permissions-batch-delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset from which permissions 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)), ]), ("permissions-batch-update", Some(r##"Add or update permission entries to an already existing asset. An asset can hold up to 20 different permission entries. Each batchInsert request is atomic."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_permissions-batch-update", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset to which permissions will be added."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("permissions-list", Some(r##"Return all of the permissions for the specified asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_permissions-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset whose permissions will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("process", Some(r##"Process a layer asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_process", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("publish", Some(r##"Publish a layer asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_publish", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("unpublish", Some(r##"Unpublish a layer asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/layers_unpublish", vec![ (Some(r##"id"##), None, Some(r##"The ID of the layer."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ]), ("maps", "methods: 'create', 'delete', 'get', 'get-published', 'list', 'list-published', 'patch', 'permissions-batch-delete', 'permissions-batch-update', 'permissions-list', 'publish' and 'unpublish'", vec![ ("create", Some(r##"Create a map asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_create", 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)), ]), ("delete", Some(r##"Delete a map."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the map. Only the map creator or project owner are permitted to delete. If the map is published the request will fail. Unpublish the map prior to deleting."##), Some(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##"Return metadata for a particular map."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_get", vec![ (Some(r##"id"##), None, Some(r##"The ID of the map."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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-published", Some(r##"Return the published metadata for a particular map."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_get-published", vec![ (Some(r##"id"##), None, Some(r##"The ID of the map."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Return all maps readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_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-published", Some(r##"Return all published maps readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_list-published", 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)), ]), ("patch", Some(r##"Mutate a map asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_patch", vec![ (Some(r##"id"##), None, Some(r##"The ID of the map."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("permissions-batch-delete", Some(r##"Remove permission entries from an already existing asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_permissions-batch-delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset from which permissions 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)), ]), ("permissions-batch-update", Some(r##"Add or update permission entries to an already existing asset. An asset can hold up to 20 different permission entries. Each batchInsert request is atomic."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_permissions-batch-update", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset to which permissions will be added."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("permissions-list", Some(r##"Return all of the permissions for the specified asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_permissions-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset whose permissions will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("publish", Some(r##"Publish a map asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_publish", vec![ (Some(r##"id"##), None, Some(r##"The ID of the map."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("unpublish", Some(r##"Unpublish a map asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/maps_unpublish", vec![ (Some(r##"id"##), None, Some(r##"The ID of the map."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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: 'icons-create', 'icons-get', 'icons-list' and 'list'", vec![ ("icons-create", Some(r##"Create an icon."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/projects_icons-create", vec![ (Some(r##"project-id"##), None, Some(r##"The ID of the project."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"mode"##), Some(r##"u"##), Some(r##"Specify the upload protocol (simple|resumable) and the file to upload"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("icons-get", Some(r##"Return an icon or its associated metadata"##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/projects_icons-get", vec![ (Some(r##"project-id"##), None, Some(r##"The ID of the project."##), Some(true), Some(false)), (Some(r##"id"##), None, Some(r##"The ID of the icon."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("icons-list", Some(r##"Return all icons in the current project"##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/projects_icons-list", vec![ (Some(r##"project-id"##), None, Some(r##"The ID of the project."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Return all projects readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/projects_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)), ]), ]), ("raster-collections", "methods: 'cancel-processing', 'create', 'delete', 'get', 'list', 'parents-list', 'patch', 'permissions-batch-delete', 'permissions-batch-update', 'permissions-list', 'process', 'rasters-batch-delete', 'rasters-batch-insert' and 'rasters-list'", vec![ ("cancel-processing", Some(r##"Cancel processing on a raster collection asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_cancel-processing", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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", Some(r##"Create a raster collection asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_create", 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)), ]), ("delete", Some(r##"Delete a raster collection."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection. Only the raster collection creator or project owner are permitted to delete. If the rastor collection is included in a layer, the request will fail. Remove the raster collection from all layers prior to deleting."##), Some(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##"Return metadata for a particular raster collection."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_get", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Return all raster collections readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_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)), ]), ("parents-list", Some(r##"Return all parent ids of the specified raster collection."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_parents-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection whose parents will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Mutate a raster collection asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_patch", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("permissions-batch-delete", Some(r##"Remove permission entries from an already existing asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_permissions-batch-delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset from which permissions 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)), ]), ("permissions-batch-update", Some(r##"Add or update permission entries to an already existing asset. An asset can hold up to 20 different permission entries. Each batchInsert request is atomic."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_permissions-batch-update", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset to which permissions will be added."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("permissions-list", Some(r##"Return all of the permissions for the specified asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_permissions-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset whose permissions will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("process", Some(r##"Process a raster collection asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_process", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("rasters-batch-delete", Some(r##"Remove rasters from an existing raster collection. Up to 50 rasters can be included in a single batchDelete request. Each batchDelete request is atomic."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_rasters-batch-delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection to which these rasters belong."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("rasters-batch-insert", Some(r##"Add rasters to an existing raster collection. Rasters must be successfully processed in order to be added to a raster collection. Up to 50 rasters can be included in a single batchInsert request. Each batchInsert request is atomic."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_rasters-batch-insert", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection to which these rasters belong."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("rasters-list", Some(r##"Return all rasters within a raster collection."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/raster-collections_rasters-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster collection to which these rasters belong."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ]), ("rasters", "methods: 'delete', 'files-insert', 'get', 'list', 'parents-list', 'patch', 'permissions-batch-delete', 'permissions-batch-update', 'permissions-list', 'process' and 'upload'", vec![ ("delete", Some(r##"Delete a raster."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster. Only the raster creator or project owner are permitted to delete. If the raster is included in a layer or mosaic, the request will fail. Remove it from all parents prior to deleting."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("files-insert", Some(r##"Upload a file to a raster asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_files-insert", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster asset."##), Some(true), Some(false)), (Some(r##"filename"##), None, Some(r##"The file name of this uploaded file."##), Some(true), Some(false)), (Some(r##"mode"##), Some(r##"u"##), Some(r##"Specify the upload protocol (simple|resumable) and the file to upload"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("get", Some(r##"Return metadata for a single raster."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_get", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Return all rasters readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_list", vec![ (Some(r##"project-id"##), None, Some(r##"The ID of a Maps Engine project, used to filter the response. To list all available projects with their IDs, send a Projects: list request. You can also find your project ID as the value of the DashboardPlace:cid URL parameter when signed in to mapsengine.google.com."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("parents-list", Some(r##"Return all parent ids of the specified rasters."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_parents-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the rasters whose parents will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Mutate a raster asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_patch", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("permissions-batch-delete", Some(r##"Remove permission entries from an already existing asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_permissions-batch-delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset from which permissions 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)), ]), ("permissions-batch-update", Some(r##"Add or update permission entries to an already existing asset. An asset can hold up to 20 different permission entries. Each batchInsert request is atomic."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_permissions-batch-update", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset to which permissions will be added."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("permissions-list", Some(r##"Return all of the permissions for the specified asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_permissions-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset whose permissions will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("process", Some(r##"Process a raster asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_process", vec![ (Some(r##"id"##), None, Some(r##"The ID of the raster."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("upload", Some(r##"Create a skeleton raster asset for upload."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/rasters_upload", 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)), ]), ]), ("tables", "methods: 'create', 'delete', 'features-batch-delete', 'features-batch-insert', 'features-batch-patch', 'features-get', 'features-list', 'files-insert', 'get', 'list', 'parents-list', 'patch', 'permissions-batch-delete', 'permissions-batch-update', 'permissions-list', 'process' and 'upload'", vec![ ("create", Some(r##"Create a table asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_create", 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)), ]), ("delete", Some(r##"Delete a table."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table. Only the table creator or project owner are permitted to delete. If the table is included in a layer, the request will fail. Remove it from all layers prior to deleting."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("features-batch-delete", Some(r##"Delete all features matching the given IDs."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_features-batch-delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table that contains the features to 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)), ]), ("features-batch-insert", Some(r##"Append features to an existing table. A single batchInsert request can create: - Up to 50 features. - A combined total of 10 000 vertices. Feature limits are documented in the Supported data formats and limits article of the Google Maps Engine help center. Note that free and paid accounts have different limits. For more information about inserting features, read Creating features in the Google Maps Engine developer's guide."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_features-batch-insert", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table to append the features 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)), ]), ("features-batch-patch", Some(r##"Update the supplied features. A single batchPatch request can update: - Up to 50 features. - A combined total of 10 000 vertices. Feature limits are documented in the Supported data formats and limits article of the Google Maps Engine help center. Note that free and paid accounts have different limits. Feature updates use HTTP PATCH semantics: - A supplied value replaces an existing value (if any) in that field. - Omitted fields remain unchanged. - Complex values in geometries and properties must be replaced as atomic units. For example, providing just the coordinates of a geometry is not allowed; the complete geometry, including type, must be supplied. - Setting a property's value to null deletes that property. For more information about updating features, read Updating features in the Google Maps Engine developer's guide."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_features-batch-patch", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table containing the features to be patched."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("features-get", Some(r##"Return a single feature, given its ID."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_features-get", vec![ (Some(r##"table-id"##), None, Some(r##"The ID of the table."##), Some(true), Some(false)), (Some(r##"id"##), None, Some(r##"The ID of the feature 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)), ]), ("features-list", Some(r##"Return all features readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_features-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table to which these features belong."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("files-insert", Some(r##"Upload a file to a placeholder table asset. See Table Upload in the Developer's Guide for more information. Supported file types are listed in the Supported data formats and limits article of the Google Maps Engine help center."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_files-insert", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table asset."##), Some(true), Some(false)), (Some(r##"filename"##), None, Some(r##"The file name of this uploaded file."##), Some(true), Some(false)), (Some(r##"mode"##), Some(r##"u"##), Some(r##"Specify the upload protocol (simple|resumable) and the file to upload"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("get", Some(r##"Return metadata for a particular table, including the schema."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_get", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Return all tables readable by the current user."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_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)), ]), ("parents-list", Some(r##"Return all parent ids of the specified table."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_parents-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table whose parents will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(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##"Mutate a table asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_patch", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), ]), ("permissions-batch-delete", Some(r##"Remove permission entries from an already existing asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_permissions-batch-delete", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset from which permissions 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)), ]), ("permissions-batch-update", Some(r##"Add or update permission entries to an already existing asset. An asset can hold up to 20 different permission entries. Each batchInsert request is atomic."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_permissions-batch-update", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset to which permissions will be added."##), Some(true), Some(false)), (Some(r##"kv"##), Some(r##"r"##), Some(r##"Set various fields of the request structure, matching the key=value form"##), Some(true), Some(true)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("permissions-list", Some(r##"Return all of the permissions for the specified asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_permissions-list", vec![ (Some(r##"id"##), None, Some(r##"The ID of the asset whose permissions will be listed."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("process", Some(r##"Process a table asset."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_process", vec![ (Some(r##"id"##), None, Some(r##"The ID of the table."##), Some(true), Some(false)), (Some(r##"v"##), Some(r##"p"##), Some(r##"Set various optional parameters, matching the key=value form"##), Some(false), Some(true)), (Some(r##"out"##), Some(r##"o"##), Some(r##"Specify the file into which to write the program's output"##), Some(false), Some(false)), ]), ("upload", Some(r##"Create a placeholder table asset to which table files can be uploaded. Once the placeholder has been created, files are uploaded to the https://www.googleapis.com/upload/mapsengine/v1/tables/table_id/files endpoint. See Table Upload in the Developer's Guide or Table.files: insert in the reference documentation for more information."##), "Details at http://byron.github.io/google-apis-rs/google_mapsengine1_cli/tables_upload", 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)), ]), ]), ]; let mut app = App::new("mapsengine1") .author("Sebastian Thiel ") .version("0.2.0+20150414") .about("The Google Maps Engine API allows developers to store and query geospatial vector and raster data.") .after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_mapsengine1_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("Output all server communication to standard error. `tx` and `rx` are placed into the same stream.") .multiple(false) .takes_value(false)) .arg(Arg::with_name("debug-auth") .long("debug-auth") .help("Output all communication related to authentication to standard error. `tx` and `rx` are placed into the same stream.") .multiple(false) .takes_value(false)); for &(main_command_name, ref about, ref subcommands) in arg_data.iter() { let mut mcmd = SubCommand::new(main_command_name).about(about); for &(sub_command_name, ref desc, url_info, ref args) in subcommands { let mut scmd = SubCommand::new(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); 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); } if arg_name_str == "mode" { arg = arg.number_of_values(2); arg = arg.value_names(&upload_value_names); scmd = scmd.arg(Arg::with_name("mime") .short("m") .requires("mode") .required(false) .help("The file's mime time, like 'application/octet-stream'") .takes_value(true)); } scmd = scmd.arg(arg); } mcmd = mcmd.subcommand(scmd); } app = app.subcommand(mcmd); } let matches = app.get_matches(); let debug = matches.is_present("debug"); match Engine::new(matches) { Err(err) => { env::set_exit_status(err.exit_code); writeln!(io::stderr(), "{}", err).ok(); }, Ok(engine) => { if let Err(doit_err) = engine.doit() { env::set_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(); } } } } } } }