mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-21 10:38:25 +01:00
2840 lines
116 KiB
Rust
2840 lines
116 KiB
Rust
// DO NOT EDIT !
|
|
// This file was generated automatically from 'src/mako/cli/main.rs.mako'
|
|
// DO NOT EDIT !
|
|
#![feature(plugin, exit_status)]
|
|
#![plugin(docopt_macros)]
|
|
#![allow(unused_variables, unused_imports, dead_code, unused_mut)]
|
|
|
|
extern crate docopt;
|
|
extern crate yup_oauth2 as oauth2;
|
|
extern crate yup_hyper_mock as mock;
|
|
extern crate rustc_serialize;
|
|
extern crate serde;
|
|
extern crate hyper;
|
|
extern crate mime;
|
|
extern crate google_androidenterprise1 as api;
|
|
|
|
use std::env;
|
|
use std::io::{self, Write};
|
|
|
|
docopt!(Options derive Debug, "
|
|
Usage:
|
|
androidenterprise1 [options] collections delete <enterprise-id> <collection-id> [-p <v>...]
|
|
androidenterprise1 [options] collections get <enterprise-id> <collection-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] collections insert <enterprise-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] collections list <enterprise-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] collections patch <enterprise-id> <collection-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] collections update <enterprise-id> <collection-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] collectionviewers delete <enterprise-id> <collection-id> <user-id> [-p <v>...]
|
|
androidenterprise1 [options] collectionviewers get <enterprise-id> <collection-id> <user-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] collectionviewers list <enterprise-id> <collection-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] collectionviewers patch <enterprise-id> <collection-id> <user-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] collectionviewers update <enterprise-id> <collection-id> <user-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] devices get <enterprise-id> <user-id> <device-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] devices get-state <enterprise-id> <user-id> <device-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] devices list <enterprise-id> <user-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] devices set-state <enterprise-id> <user-id> <device-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] enterprises delete <enterprise-id> [-p <v>...]
|
|
androidenterprise1 [options] enterprises enroll <token> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] enterprises get <enterprise-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] enterprises insert <token> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] enterprises list <domain> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] enterprises set-account <enterprise-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] enterprises unenroll <enterprise-id> [-p <v>...]
|
|
androidenterprise1 [options] entitlements delete <enterprise-id> <user-id> <entitlement-id> [-p <v>...]
|
|
androidenterprise1 [options] entitlements get <enterprise-id> <user-id> <entitlement-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] entitlements list <enterprise-id> <user-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] entitlements patch <enterprise-id> <user-id> <entitlement-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] entitlements update <enterprise-id> <user-id> <entitlement-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] grouplicenses get <enterprise-id> <group-license-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] grouplicenses list <enterprise-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] grouplicenseusers list <enterprise-id> <group-license-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] installs delete <enterprise-id> <user-id> <device-id> <install-id> [-p <v>...]
|
|
androidenterprise1 [options] installs get <enterprise-id> <user-id> <device-id> <install-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] installs list <enterprise-id> <user-id> <device-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] installs patch <enterprise-id> <user-id> <device-id> <install-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] installs update <enterprise-id> <user-id> <device-id> <install-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] permissions get <permission-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] products get <enterprise-id> <product-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] products get-app-restrictions-schema <enterprise-id> <product-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] products get-permissions <enterprise-id> <product-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] products update-permissions <enterprise-id> <product-id> -r <kv>... [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] users generate-token <enterprise-id> <user-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] users get <enterprise-id> <user-id> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] users list <enterprise-id> <email> [-p <v>...] [-o <out>]
|
|
androidenterprise1 [options] users revoke-token <enterprise-id> <user-id> [-p <v>...]
|
|
androidenterprise1 --help
|
|
|
|
All documentation details can be found at
|
|
http://byron.github.io/google-apis-rs/google_androidenterprise1_cli/index.html
|
|
|
|
Configuration:
|
|
--scope <url>
|
|
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.
|
|
--config-dir <folder>
|
|
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]
|
|
--debug
|
|
Output all server communication to standard error. `tx` and `rx` are placed
|
|
into the same stream.
|
|
--debug-auth
|
|
Output all communication related to authentication to standard error. `tx`
|
|
and `rx` are placed into the same stream.
|
|
");
|
|
|
|
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};
|
|
|
|
use std::default::Default;
|
|
use std::str::FromStr;
|
|
|
|
use oauth2::{Authenticator, DefaultAuthenticatorDelegate};
|
|
use rustc_serialize::json;
|
|
|
|
struct Engine {
|
|
opt: Options,
|
|
hub: api::AndroidEnterprise<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>,
|
|
}
|
|
|
|
|
|
impl Engine {
|
|
fn _collections_delete(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.collections().delete(&self.opt.arg_enterprise_id, &self.opt.arg_collection_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok(mut response) => {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collections_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.collections().get(&self.opt.arg_enterprise_id, &self.opt.arg_collection_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collections_insert(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Collection::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"product-id" => {
|
|
if request.product_id.is_none() {
|
|
request.product_id = Some(Default::default());
|
|
}
|
|
request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
|
},
|
|
"name" => {
|
|
request.name = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"visibility" => {
|
|
request.visibility = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"collection-id" => {
|
|
request.collection_id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.collections().insert(request, &self.opt.arg_enterprise_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collections_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.collections().list(&self.opt.arg_enterprise_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collections_patch(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Collection::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"product-id" => {
|
|
if request.product_id.is_none() {
|
|
request.product_id = Some(Default::default());
|
|
}
|
|
request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
|
},
|
|
"name" => {
|
|
request.name = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"visibility" => {
|
|
request.visibility = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"collection-id" => {
|
|
request.collection_id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.collections().patch(request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collections_update(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Collection::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"product-id" => {
|
|
if request.product_id.is_none() {
|
|
request.product_id = Some(Default::default());
|
|
}
|
|
request.product_id.as_mut().unwrap().push(value.unwrap_or("").to_string());
|
|
},
|
|
"name" => {
|
|
request.name = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"visibility" => {
|
|
request.visibility = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"collection-id" => {
|
|
request.collection_id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.collections().update(request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collectionviewers_delete(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.collectionviewers().delete(&self.opt.arg_enterprise_id, &self.opt.arg_collection_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok(mut response) => {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collectionviewers_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.collectionviewers().get(&self.opt.arg_enterprise_id, &self.opt.arg_collection_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collectionviewers_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.collectionviewers().list(&self.opt.arg_enterprise_id, &self.opt.arg_collection_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collectionviewers_patch(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::User::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"primary-email" => {
|
|
request.primary_email = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"id" => {
|
|
request.id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.collectionviewers().patch(request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _collectionviewers_update(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::User::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"primary-email" => {
|
|
request.primary_email = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"id" => {
|
|
request.id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.collectionviewers().update(request, &self.opt.arg_enterprise_id, &self.opt.arg_collection_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _devices_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.devices().get(&self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _devices_get_state(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.devices().get_state(&self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _devices_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.devices().list(&self.opt.arg_enterprise_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _devices_set_state(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::DeviceState::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"account-state" => {
|
|
request.account_state = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.devices().set_state(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _enterprises_delete(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.enterprises().delete(&self.opt.arg_enterprise_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok(mut response) => {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _enterprises_enroll(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Enterprise::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"primary-domain" => {
|
|
request.primary_domain = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"id" => {
|
|
request.id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"name" => {
|
|
request.name = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.enterprises().enroll(request, &self.opt.arg_token);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _enterprises_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.enterprises().get(&self.opt.arg_enterprise_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _enterprises_insert(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Enterprise::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"primary-domain" => {
|
|
request.primary_domain = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"id" => {
|
|
request.id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"name" => {
|
|
request.name = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.enterprises().insert(request, &self.opt.arg_token);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _enterprises_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.enterprises().list(&self.opt.arg_domain);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _enterprises_set_account(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::EnterpriseAccount::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"account-email" => {
|
|
request.account_email = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.enterprises().set_account(request, &self.opt.arg_enterprise_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _enterprises_unenroll(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.enterprises().unenroll(&self.opt.arg_enterprise_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok(mut response) => {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _entitlements_delete(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.entitlements().delete(&self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_entitlement_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok(mut response) => {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _entitlements_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.entitlements().get(&self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_entitlement_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _entitlements_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.entitlements().list(&self.opt.arg_enterprise_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _entitlements_patch(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Entitlement::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"reason" => {
|
|
request.reason = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"product-id" => {
|
|
request.product_id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.entitlements().patch(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_entitlement_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"install" => {
|
|
call = call.install(arg_from_str(value.unwrap_or("false"), err, "install", "boolean"));
|
|
},
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _entitlements_update(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Entitlement::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"reason" => {
|
|
request.reason = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"product-id" => {
|
|
request.product_id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.entitlements().update(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_entitlement_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"install" => {
|
|
call = call.install(arg_from_str(value.unwrap_or("false"), err, "install", "boolean"));
|
|
},
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _grouplicenses_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.grouplicenses().get(&self.opt.arg_enterprise_id, &self.opt.arg_group_license_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _grouplicenses_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.grouplicenses().list(&self.opt.arg_enterprise_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _grouplicenseusers_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.grouplicenseusers().list(&self.opt.arg_enterprise_id, &self.opt.arg_group_license_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _installs_delete(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.installs().delete(&self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id, &self.opt.arg_install_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok(mut response) => {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _installs_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.installs().get(&self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id, &self.opt.arg_install_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _installs_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.installs().list(&self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _installs_patch(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Install::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"install-state" => {
|
|
request.install_state = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"version-code" => {
|
|
request.version_code = Some(arg_from_str(value.unwrap_or("-0"), err, "version-code", "integer"));
|
|
},
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"product-id" => {
|
|
request.product_id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.installs().patch(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id, &self.opt.arg_install_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _installs_update(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::Install::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"install-state" => {
|
|
request.install_state = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"version-code" => {
|
|
request.version_code = Some(arg_from_str(value.unwrap_or("-0"), err, "version-code", "integer"));
|
|
},
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"product-id" => {
|
|
request.product_id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.installs().update(request, &self.opt.arg_enterprise_id, &self.opt.arg_user_id, &self.opt.arg_device_id, &self.opt.arg_install_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _permissions_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.permissions().get(&self.opt.arg_permission_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"language" => {
|
|
call = call.language(value.unwrap_or(""));
|
|
},
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _products_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.products().get(&self.opt.arg_enterprise_id, &self.opt.arg_product_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"language" => {
|
|
call = call.language(value.unwrap_or(""));
|
|
},
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _products_get_app_restrictions_schema(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.products().get_app_restrictions_schema(&self.opt.arg_enterprise_id, &self.opt.arg_product_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"language" => {
|
|
call = call.language(value.unwrap_or(""));
|
|
},
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _products_get_permissions(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.products().get_permissions(&self.opt.arg_enterprise_id, &self.opt.arg_product_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _products_update_permissions(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
|
|
let mut request = api::ProductPermissions::default();
|
|
let mut field_cursor = FieldCursor::default();
|
|
for kvarg in self.opt.arg_kv.iter() {
|
|
let last_errc = err.issues.len();
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
let mut temp_cursor = field_cursor.clone();
|
|
if let Err(field_err) = temp_cursor.set(&*key) {
|
|
err.issues.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()[..] {
|
|
"kind" => {
|
|
request.kind = Some(value.unwrap_or("").to_string());
|
|
},
|
|
"product-id" => {
|
|
request.product_id = Some(value.unwrap_or("").to_string());
|
|
},
|
|
_ => {
|
|
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string())));
|
|
}
|
|
}
|
|
}
|
|
let mut call = self.hub.products().update_permissions(request, &self.opt.arg_enterprise_id, &self.opt.arg_product_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _users_generate_token(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.users().generate_token(&self.opt.arg_enterprise_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _users_get(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.users().get(&self.opt.arg_enterprise_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _users_list(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.users().list(&self.opt.arg_enterprise_id, &self.opt.arg_email);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
let mut ostream = writer_from_opts(self.opt.flag_o, &self.opt.arg_out);
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok((mut response, output_schema)) => {
|
|
serde::json::to_writer_pretty(&mut ostream, &output_schema).unwrap();
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _users_revoke_token(&self, dry_run: bool, err: &mut InvalidOptionsError)
|
|
-> Option<api::Error> {
|
|
let mut call = self.hub.users().revoke_token(&self.opt.arg_enterprise_id, &self.opt.arg_user_id);
|
|
for parg in self.opt.arg_v.iter() {
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
match key {
|
|
"alt"
|
|
|"fields"
|
|
|"key"
|
|
|"oauth-token"
|
|
|"pretty-print"
|
|
|"quota-user"
|
|
|"user-ip" => {
|
|
let map = [
|
|
("oauth-token", "oauth_token"),
|
|
("pretty-print", "prettyPrint"),
|
|
("quota-user", "quotaUser"),
|
|
("user-ip", "userIp"),
|
|
];
|
|
call = call.param(map.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"))
|
|
},
|
|
_ => err.issues.push(CLIError::UnknownParameter(key.to_string())),
|
|
}
|
|
}
|
|
let protocol = "standard-request";
|
|
if dry_run {
|
|
None
|
|
} else {
|
|
assert!(err.issues.len() == 0);
|
|
if self.opt.flag_scope.len() > 0 {
|
|
call = call.add_scope(&self.opt.flag_scope);
|
|
}
|
|
match match protocol {
|
|
"standard-request" => call.doit(),
|
|
_ => unreachable!(),
|
|
} {
|
|
Err(api_err) => Some(api_err),
|
|
Ok(mut response) => {
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn _doit(&self, dry_run: bool) -> (Option<api::Error>, Option<InvalidOptionsError>) {
|
|
let mut err = InvalidOptionsError::new();
|
|
let mut call_result: Option<api::Error>;
|
|
let mut err_opt: Option<InvalidOptionsError> = None;
|
|
|
|
if self.opt.cmd_collections {
|
|
if self.opt.cmd_delete {
|
|
call_result = self._collections_delete(dry_run, &mut err);
|
|
} else if self.opt.cmd_get {
|
|
call_result = self._collections_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_insert {
|
|
call_result = self._collections_insert(dry_run, &mut err);
|
|
} else if self.opt.cmd_list {
|
|
call_result = self._collections_list(dry_run, &mut err);
|
|
} else if self.opt.cmd_patch {
|
|
call_result = self._collections_patch(dry_run, &mut err);
|
|
} else if self.opt.cmd_update {
|
|
call_result = self._collections_update(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_collectionviewers {
|
|
if self.opt.cmd_delete {
|
|
call_result = self._collectionviewers_delete(dry_run, &mut err);
|
|
} else if self.opt.cmd_get {
|
|
call_result = self._collectionviewers_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_list {
|
|
call_result = self._collectionviewers_list(dry_run, &mut err);
|
|
} else if self.opt.cmd_patch {
|
|
call_result = self._collectionviewers_patch(dry_run, &mut err);
|
|
} else if self.opt.cmd_update {
|
|
call_result = self._collectionviewers_update(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_devices {
|
|
if self.opt.cmd_get {
|
|
call_result = self._devices_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_get_state {
|
|
call_result = self._devices_get_state(dry_run, &mut err);
|
|
} else if self.opt.cmd_list {
|
|
call_result = self._devices_list(dry_run, &mut err);
|
|
} else if self.opt.cmd_set_state {
|
|
call_result = self._devices_set_state(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_enterprises {
|
|
if self.opt.cmd_delete {
|
|
call_result = self._enterprises_delete(dry_run, &mut err);
|
|
} else if self.opt.cmd_enroll {
|
|
call_result = self._enterprises_enroll(dry_run, &mut err);
|
|
} else if self.opt.cmd_get {
|
|
call_result = self._enterprises_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_insert {
|
|
call_result = self._enterprises_insert(dry_run, &mut err);
|
|
} else if self.opt.cmd_list {
|
|
call_result = self._enterprises_list(dry_run, &mut err);
|
|
} else if self.opt.cmd_set_account {
|
|
call_result = self._enterprises_set_account(dry_run, &mut err);
|
|
} else if self.opt.cmd_unenroll {
|
|
call_result = self._enterprises_unenroll(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_entitlements {
|
|
if self.opt.cmd_delete {
|
|
call_result = self._entitlements_delete(dry_run, &mut err);
|
|
} else if self.opt.cmd_get {
|
|
call_result = self._entitlements_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_list {
|
|
call_result = self._entitlements_list(dry_run, &mut err);
|
|
} else if self.opt.cmd_patch {
|
|
call_result = self._entitlements_patch(dry_run, &mut err);
|
|
} else if self.opt.cmd_update {
|
|
call_result = self._entitlements_update(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_grouplicenses {
|
|
if self.opt.cmd_get {
|
|
call_result = self._grouplicenses_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_list {
|
|
call_result = self._grouplicenses_list(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_grouplicenseusers {
|
|
if self.opt.cmd_list {
|
|
call_result = self._grouplicenseusers_list(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_installs {
|
|
if self.opt.cmd_delete {
|
|
call_result = self._installs_delete(dry_run, &mut err);
|
|
} else if self.opt.cmd_get {
|
|
call_result = self._installs_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_list {
|
|
call_result = self._installs_list(dry_run, &mut err);
|
|
} else if self.opt.cmd_patch {
|
|
call_result = self._installs_patch(dry_run, &mut err);
|
|
} else if self.opt.cmd_update {
|
|
call_result = self._installs_update(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_permissions {
|
|
if self.opt.cmd_get {
|
|
call_result = self._permissions_get(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_products {
|
|
if self.opt.cmd_get {
|
|
call_result = self._products_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_get_app_restrictions_schema {
|
|
call_result = self._products_get_app_restrictions_schema(dry_run, &mut err);
|
|
} else if self.opt.cmd_get_permissions {
|
|
call_result = self._products_get_permissions(dry_run, &mut err);
|
|
} else if self.opt.cmd_update_permissions {
|
|
call_result = self._products_update_permissions(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
}
|
|
else if self.opt.cmd_users {
|
|
if self.opt.cmd_generate_token {
|
|
call_result = self._users_generate_token(dry_run, &mut err);
|
|
} else if self.opt.cmd_get {
|
|
call_result = self._users_get(dry_run, &mut err);
|
|
} else if self.opt.cmd_list {
|
|
call_result = self._users_list(dry_run, &mut err);
|
|
} else if self.opt.cmd_revoke_token {
|
|
call_result = self._users_revoke_token(dry_run, &mut err);
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
} else {
|
|
unreachable!();
|
|
}
|
|
|
|
if dry_run {
|
|
if err.issues.len() > 0 {
|
|
err_opt = Some(err);
|
|
}
|
|
}
|
|
(call_result, err_opt)
|
|
}
|
|
|
|
// Please note that this call will fail if any part of the opt can't be handled
|
|
fn new(opt: Options) -> Result<Engine, InvalidOptionsError> {
|
|
let (config_dir, secret) = {
|
|
let config_dir = match cmn::assure_config_dir_exists(&opt.flag_config_dir) {
|
|
Err(e) => return Err(InvalidOptionsError::single(e, 3)),
|
|
Ok(p) => p,
|
|
};
|
|
|
|
match cmn::application_secret_from_directory(&config_dir, "androidenterprise1-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.flag_debug_auth {
|
|
hyper::Client::with_connector(mock::TeeConnector {
|
|
connector: hyper::net::HttpConnector(None)
|
|
})
|
|
} else {
|
|
hyper::Client::new()
|
|
},
|
|
JsonTokenStorage {
|
|
program_name: "androidenterprise1",
|
|
db_dir: config_dir.clone(),
|
|
}, None);
|
|
|
|
let client =
|
|
if opt.flag_debug {
|
|
hyper::Client::with_connector(mock::TeeConnector {
|
|
connector: hyper::net::HttpConnector(None)
|
|
})
|
|
} else {
|
|
hyper::Client::new()
|
|
};
|
|
let engine = Engine {
|
|
opt: opt,
|
|
hub: api::AndroidEnterprise::new(client, auth),
|
|
};
|
|
|
|
match engine._doit(true) {
|
|
(_, Some(err)) => Err(err),
|
|
_ => Ok(engine),
|
|
}
|
|
}
|
|
|
|
// Execute the call with all the bells and whistles, informing the caller only if there was an error.
|
|
// The absense of one indicates success.
|
|
fn doit(&self) -> Option<api::Error> {
|
|
self._doit(false).0
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let opts: Options = Options::docopt().decode().unwrap_or_else(|e| e.exit());
|
|
let debug = opts.flag_debug;
|
|
match Engine::new(opts) {
|
|
Err(err) => {
|
|
writeln!(io::stderr(), "{}", err).ok();
|
|
env::set_exit_status(err.exit_code);
|
|
},
|
|
Ok(engine) => {
|
|
if let Some(err) = engine.doit() {
|
|
if debug {
|
|
writeln!(io::stderr(), "{:?}", err).ok();
|
|
} else {
|
|
writeln!(io::stderr(), "{}", err).ok();
|
|
}
|
|
env::set_exit_status(1);
|
|
}
|
|
}
|
|
}
|
|
} |