Bump version to 1.0.9; update JSON schemas; add new APIs

This commit is contained in:
Sebastian Thiel
2019-07-05 11:32:35 +08:00
parent 99e97ceece
commit e42ebc0c2b
2442 changed files with 190984 additions and 71186 deletions

View File

@@ -67,6 +67,17 @@ pub fn remove_json_null_values(value: &mut Value) {
map.remove(key);
}
}
json::value::Value::Array(ref mut arr) => {
let mut i = 0;
while i < arr.len() {
if arr[i].is_null() {
arr.remove(i);
} else {
remove_json_null_values(&mut arr[i]);
i += 1;
}
}
}
_ => {}
}
}

View File

@@ -1099,204 +1099,6 @@ impl<'n> Engine<'n> {
}
}
fn _projects_locations_registries_groups_bind_device_to_gateway(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
if let Err(field_err) = temp_cursor.set(&*key) {
err.issues.push(field_err);
}
if value.is_none() {
field_cursor = temp_cursor.clone();
if err.issues.len() > last_errc {
err.issues.remove(last_errc);
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"gateway-id" => Some(("gatewayId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"device-id" => Some(("deviceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["device-id", "gateway-id"]);
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
None
}
};
if let Some((field_cursor_str, type_info)) = type_info {
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
}
}
let mut request: api::BindDeviceToGatewayRequest = json::value::from_value(object).unwrap();
let mut call = self.hub.projects().locations_registries_groups_bind_device_to_gateway(request, opt.value_of("parent").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _projects_locations_registries_groups_devices_config_versions_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.projects().locations_registries_groups_devices_config_versions_list(opt.value_of("name").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"num-versions" => {
call = call.num_versions(arg_from_str(value.unwrap_or("-0"), err, "num-versions", "integer"));
},
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["num-versions"].iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
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).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _projects_locations_registries_groups_devices_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.projects().locations_registries_groups_devices_get(opt.value_of("name").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"field-mask" => {
call = call.field_mask(value.unwrap_or(""));
},
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["field-mask"].iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _projects_locations_registries_groups_devices_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.projects().locations_registries_groups_devices_list(opt.value_of("parent").unwrap_or(""));
@@ -1374,346 +1176,6 @@ impl<'n> Engine<'n> {
}
}
fn _projects_locations_registries_groups_devices_modify_cloud_to_device_config(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
if let Err(field_err) = temp_cursor.set(&*key) {
err.issues.push(field_err);
}
if value.is_none() {
field_cursor = temp_cursor.clone();
if err.issues.len() > last_errc {
err.issues.remove(last_errc);
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"version-to-update" => Some(("versionToUpdate", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"binary-data" => Some(("binaryData", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["binary-data", "version-to-update"]);
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
None
}
};
if let Some((field_cursor_str, type_info)) = type_info {
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
}
}
let mut request: api::ModifyCloudToDeviceConfigRequest = json::value::from_value(object).unwrap();
let mut call = self.hub.projects().locations_registries_groups_devices_modify_cloud_to_device_config(request, opt.value_of("name").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _projects_locations_registries_groups_devices_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
if let Err(field_err) = temp_cursor.set(&*key) {
err.issues.push(field_err);
}
if value.is_none() {
field_cursor = temp_cursor.clone();
if err.issues.len() > last_errc {
err.issues.remove(last_errc);
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"last-state-time" => Some(("lastStateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"gateway-config.gateway-type" => Some(("gatewayConfig.gatewayType", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"gateway-config.last-accessed-gateway-time" => Some(("gatewayConfig.lastAccessedGatewayTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"gateway-config.gateway-auth-method" => Some(("gatewayConfig.gatewayAuthMethod", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"gateway-config.last-accessed-gateway-id" => Some(("gatewayConfig.lastAccessedGatewayId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-event-time" => Some(("lastEventTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-error-time" => Some(("lastErrorTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"num-id" => Some(("numId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"state.update-time" => Some(("state.updateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"state.binary-data" => Some(("state.binaryData", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"name" => Some(("name", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"metadata" => Some(("metadata", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Map })),
"log-level" => Some(("logLevel", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-heartbeat-time" => Some(("lastHeartbeatTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-error-status.message" => Some(("lastErrorStatus.message", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-error-status.code" => Some(("lastErrorStatus.code", JsonTypeInfo { jtype: JsonType::Int, ctype: ComplexType::Pod })),
"last-config-ack-time" => Some(("lastConfigAckTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"blocked" => Some(("blocked", JsonTypeInfo { jtype: JsonType::Boolean, ctype: ComplexType::Pod })),
"config.version" => Some(("config.version", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"config.cloud-update-time" => Some(("config.cloudUpdateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"config.binary-data" => Some(("config.binaryData", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"config.device-ack-time" => Some(("config.deviceAckTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"id" => Some(("id", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-config-send-time" => Some(("lastConfigSendTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["binary-data", "blocked", "cloud-update-time", "code", "config", "device-ack-time", "gateway-auth-method", "gateway-config", "gateway-type", "id", "last-accessed-gateway-id", "last-accessed-gateway-time", "last-config-ack-time", "last-config-send-time", "last-error-status", "last-error-time", "last-event-time", "last-heartbeat-time", "last-state-time", "log-level", "message", "metadata", "name", "num-id", "state", "update-time", "version"]);
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
None
}
};
if let Some((field_cursor_str, type_info)) = type_info {
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
}
}
let mut request: api::Device = json::value::from_value(object).unwrap();
let mut call = self.hub.projects().locations_registries_groups_devices_patch(request, opt.value_of("name").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"update-mask" => {
call = call.update_mask(value.unwrap_or(""));
},
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["update-mask"].iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _projects_locations_registries_groups_devices_send_command_to_device(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
if let Err(field_err) = temp_cursor.set(&*key) {
err.issues.push(field_err);
}
if value.is_none() {
field_cursor = temp_cursor.clone();
if err.issues.len() > last_errc {
err.issues.remove(last_errc);
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"binary-data" => Some(("binaryData", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"subfolder" => Some(("subfolder", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["binary-data", "subfolder"]);
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
None
}
};
if let Some((field_cursor_str, type_info)) = type_info {
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
}
}
let mut request: api::SendCommandToDeviceRequest = json::value::from_value(object).unwrap();
let mut call = self.hub.projects().locations_registries_groups_devices_send_command_to_device(request, opt.value_of("name").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _projects_locations_registries_groups_devices_states_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.projects().locations_registries_groups_devices_states_list(opt.value_of("name").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
"num-states" => {
call = call.num_states(arg_from_str(value.unwrap_or("-0"), err, "num-states", "integer"));
},
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["num-states"].iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
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).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _projects_locations_registries_groups_get_iam_policy(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
@@ -1969,92 +1431,6 @@ impl<'n> Engine<'n> {
}
}
fn _projects_locations_registries_groups_unbind_device_from_gateway(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut field_cursor = FieldCursor::default();
let mut object = json::value::Value::Object(Default::default());
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let last_errc = err.issues.len();
let (key, value) = parse_kv_arg(&*kvarg, err, false);
let mut temp_cursor = field_cursor.clone();
if let Err(field_err) = temp_cursor.set(&*key) {
err.issues.push(field_err);
}
if value.is_none() {
field_cursor = temp_cursor.clone();
if err.issues.len() > last_errc {
err.issues.remove(last_errc);
}
continue;
}
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"gateway-id" => Some(("gatewayId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"device-id" => Some(("deviceId", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
_ => {
let suggestion = FieldCursor::did_you_mean(key, &vec!["device-id", "gateway-id"]);
err.issues.push(CLIError::Field(FieldError::Unknown(temp_cursor.to_string(), suggestion, value.map(|v| v.to_string()))));
None
}
};
if let Some((field_cursor_str, type_info)) = type_info {
FieldCursor::from(field_cursor_str).set_json_value(&mut object, value.unwrap(), type_info, err, &temp_cursor);
}
}
let mut request: api::UnbindDeviceFromGatewayRequest = json::value::from_value(object).unwrap();
let mut call = self.hub.projects().locations_registries_groups_unbind_device_from_gateway(request, opt.value_of("parent").unwrap_or(""));
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
let (key, value) = parse_kv_arg(&*parg, err, false);
match key {
_ => {
let mut found = false;
for param in &self.gp {
if key == *param {
found = true;
call = call.param(self.gpm.iter().find(|t| t.0 == key).unwrap_or(&("", key)).1, value.unwrap_or("unset"));
break;
}
}
if !found {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v } ));
}
}
}
}
let protocol = CallType::Standard;
if dry_run {
Ok(())
} else {
assert!(err.issues.len() == 0);
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
call = call.add_scope(scope);
}
let mut ostream = match writer_from_opts(opt.value_of("out")) {
Ok(mut f) => f,
Err(io_err) => return Err(DoitError::IoError(opt.value_of("out").unwrap_or("-").to_string(), io_err)),
};
match match protocol {
CallType::Standard => call.doit(),
_ => unreachable!()
} {
Err(api_err) => Err(DoitError::ApiError(api_err)),
Ok((mut response, output_schema)) => {
let mut value = json::value::to_value(&output_schema).expect("serde to work");
remove_json_null_values(&mut value);
json::to_writer_pretty(&mut ostream, &value).unwrap();
ostream.flush().unwrap();
Ok(())
}
}
}
}
fn _projects_locations_registries_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
let mut call = self.hub.projects().locations_registries_list(opt.value_of("parent").unwrap_or(""));
@@ -2514,30 +1890,9 @@ impl<'n> Engine<'n> {
("locations-registries-get-iam-policy", Some(opt)) => {
call_result = self._projects_locations_registries_get_iam_policy(opt, dry_run, &mut err);
},
("locations-registries-groups-bind-device-to-gateway", Some(opt)) => {
call_result = self._projects_locations_registries_groups_bind_device_to_gateway(opt, dry_run, &mut err);
},
("locations-registries-groups-devices-config-versions-list", Some(opt)) => {
call_result = self._projects_locations_registries_groups_devices_config_versions_list(opt, dry_run, &mut err);
},
("locations-registries-groups-devices-get", Some(opt)) => {
call_result = self._projects_locations_registries_groups_devices_get(opt, dry_run, &mut err);
},
("locations-registries-groups-devices-list", Some(opt)) => {
call_result = self._projects_locations_registries_groups_devices_list(opt, dry_run, &mut err);
},
("locations-registries-groups-devices-modify-cloud-to-device-config", Some(opt)) => {
call_result = self._projects_locations_registries_groups_devices_modify_cloud_to_device_config(opt, dry_run, &mut err);
},
("locations-registries-groups-devices-patch", Some(opt)) => {
call_result = self._projects_locations_registries_groups_devices_patch(opt, dry_run, &mut err);
},
("locations-registries-groups-devices-send-command-to-device", Some(opt)) => {
call_result = self._projects_locations_registries_groups_devices_send_command_to_device(opt, dry_run, &mut err);
},
("locations-registries-groups-devices-states-list", Some(opt)) => {
call_result = self._projects_locations_registries_groups_devices_states_list(opt, dry_run, &mut err);
},
("locations-registries-groups-get-iam-policy", Some(opt)) => {
call_result = self._projects_locations_registries_groups_get_iam_policy(opt, dry_run, &mut err);
},
@@ -2547,9 +1902,6 @@ impl<'n> Engine<'n> {
("locations-registries-groups-test-iam-permissions", Some(opt)) => {
call_result = self._projects_locations_registries_groups_test_iam_permissions(opt, dry_run, &mut err);
},
("locations-registries-groups-unbind-device-from-gateway", Some(opt)) => {
call_result = self._projects_locations_registries_groups_unbind_device_from_gateway(opt, dry_run, &mut err);
},
("locations-registries-list", Some(opt)) => {
call_result = self._projects_locations_registries_list(opt, dry_run, &mut err);
},
@@ -2656,7 +2008,7 @@ impl<'n> Engine<'n> {
fn main() {
let mut exit_status = 0i32;
let arg_data = [
("projects", "methods: 'locations-registries-bind-device-to-gateway', 'locations-registries-create', 'locations-registries-delete', 'locations-registries-devices-config-versions-list', 'locations-registries-devices-create', 'locations-registries-devices-delete', 'locations-registries-devices-get', 'locations-registries-devices-list', 'locations-registries-devices-modify-cloud-to-device-config', 'locations-registries-devices-patch', 'locations-registries-devices-send-command-to-device', 'locations-registries-devices-states-list', 'locations-registries-get', 'locations-registries-get-iam-policy', 'locations-registries-groups-bind-device-to-gateway', 'locations-registries-groups-devices-config-versions-list', 'locations-registries-groups-devices-get', 'locations-registries-groups-devices-list', 'locations-registries-groups-devices-modify-cloud-to-device-config', 'locations-registries-groups-devices-patch', 'locations-registries-groups-devices-send-command-to-device', 'locations-registries-groups-devices-states-list', 'locations-registries-groups-get-iam-policy', 'locations-registries-groups-set-iam-policy', 'locations-registries-groups-test-iam-permissions', 'locations-registries-groups-unbind-device-from-gateway', 'locations-registries-list', 'locations-registries-patch', 'locations-registries-set-iam-policy', 'locations-registries-test-iam-permissions' and 'locations-registries-unbind-device-from-gateway'", vec![
("projects", "methods: 'locations-registries-bind-device-to-gateway', 'locations-registries-create', 'locations-registries-delete', 'locations-registries-devices-config-versions-list', 'locations-registries-devices-create', 'locations-registries-devices-delete', 'locations-registries-devices-get', 'locations-registries-devices-list', 'locations-registries-devices-modify-cloud-to-device-config', 'locations-registries-devices-patch', 'locations-registries-devices-send-command-to-device', 'locations-registries-devices-states-list', 'locations-registries-get', 'locations-registries-get-iam-policy', 'locations-registries-groups-devices-list', 'locations-registries-groups-get-iam-policy', 'locations-registries-groups-set-iam-policy', 'locations-registries-groups-test-iam-permissions', 'locations-registries-list', 'locations-registries-patch', 'locations-registries-set-iam-policy', 'locations-registries-test-iam-permissions' and 'locations-registries-unbind-device-from-gateway'", vec![
("locations-registries-bind-device-to-gateway",
Some(r##"Associates the device with the gateway."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-bind-device-to-gateway",
@@ -3043,84 +2395,6 @@ fn main() {
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("locations-registries-groups-bind-device-to-gateway",
Some(r##"Associates the device with the gateway."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-groups-bind-device-to-gateway",
vec![
(Some(r##"parent"##),
None,
Some(r##"The name of the registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`."##),
Some(true),
Some(false)),
(Some(r##"kv"##),
Some(r##"r"##),
Some(r##"Set various fields of the request structure, matching the key=value form"##),
Some(true),
Some(true)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("locations-registries-groups-devices-config-versions-list",
Some(r##"Lists the last few versions of the device configuration in descending
order (i.e.: newest first)."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-groups-devices-config-versions-list",
vec![
(Some(r##"name"##),
None,
Some(r##"The name of the device. For example,
`projects/p0/locations/us-central1/registries/registry0/devices/device0` or
`projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`."##),
Some(true),
Some(false)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("locations-registries-groups-devices-get",
Some(r##"Gets details about a device."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-groups-devices-get",
vec![
(Some(r##"name"##),
None,
Some(r##"The name of the device. For example,
`projects/p0/locations/us-central1/registries/registry0/devices/device0` or
`projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`."##),
Some(true),
Some(false)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
@@ -3144,137 +2418,6 @@ fn main() {
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("locations-registries-groups-devices-modify-cloud-to-device-config",
Some(r##"Modifies the configuration for the device, which is eventually sent from
the Cloud IoT Core servers. Returns the modified configuration version and
its metadata."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-groups-devices-modify-cloud-to-device-config",
vec![
(Some(r##"name"##),
None,
Some(r##"The name of the device. For example,
`projects/p0/locations/us-central1/registries/registry0/devices/device0` or
`projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`."##),
Some(true),
Some(false)),
(Some(r##"kv"##),
Some(r##"r"##),
Some(r##"Set various fields of the request structure, matching the key=value form"##),
Some(true),
Some(true)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("locations-registries-groups-devices-patch",
Some(r##"Updates a device."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-groups-devices-patch",
vec![
(Some(r##"name"##),
None,
Some(r##"The resource path name. For example,
`projects/p1/locations/us-central1/registries/registry0/devices/dev0` or
`projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.
When `name` is populated as a response from the service, it always ends
in the device numeric ID."##),
Some(true),
Some(false)),
(Some(r##"kv"##),
Some(r##"r"##),
Some(r##"Set various fields of the request structure, matching the key=value form"##),
Some(true),
Some(true)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("locations-registries-groups-devices-send-command-to-device",
Some(r##"Sends a command to the specified device. In order for a device to be able
to receive commands, it must:
1) be connected to Cloud IoT Core using the MQTT protocol, and
2) be subscribed to the group of MQTT topics specified by
/devices/{device-id}/commands/#. This subscription will receive commands
at the top-level topic /devices/{device-id}/commands as well as commands
for subfolders, like /devices/{device-id}/commands/subfolder.
Note that subscribing to specific subfolders is not supported.
If the command could not be delivered to the device, this method will
return an error; in particular, if the device is not subscribed, this
method will return FAILED_PRECONDITION. Otherwise, this method will
return OK. If the subscription is QoS 1, at least once delivery will be
guaranteed; for QoS 0, no acknowledgment will be expected from the device."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-groups-devices-send-command-to-device",
vec![
(Some(r##"name"##),
None,
Some(r##"The name of the device. For example,
`projects/p0/locations/us-central1/registries/registry0/devices/device0` or
`projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`."##),
Some(true),
Some(false)),
(Some(r##"kv"##),
Some(r##"r"##),
Some(r##"Set various fields of the request structure, matching the key=value form"##),
Some(true),
Some(true)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("locations-registries-groups-devices-states-list",
Some(r##"Lists the last few versions of the device state in descending order (i.e.:
newest first)."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-groups-devices-states-list",
vec![
(Some(r##"name"##),
None,
Some(r##"The name of the device. For example,
`projects/p0/locations/us-central1/registries/registry0/devices/device0` or
`projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`."##),
Some(true),
Some(false)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
@@ -3367,35 +2510,6 @@ fn main() {
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
Some(false),
Some(false)),
]),
("locations-registries-groups-unbind-device-from-gateway",
Some(r##"Deletes the association between the device and the gateway."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-groups-unbind-device-from-gateway",
vec![
(Some(r##"parent"##),
None,
Some(r##"The name of the registry. For example,
`projects/example-project/locations/us-central1/registries/my-registry`."##),
Some(true),
Some(false)),
(Some(r##"kv"##),
Some(r##"r"##),
Some(r##"Set various fields of the request structure, matching the key=value form"##),
Some(true),
Some(true)),
(Some(r##"v"##),
Some(r##"p"##),
Some(r##"Set various optional parameters, matching the key=value form"##),
Some(false),
Some(true)),
(Some(r##"out"##),
Some(r##"o"##),
Some(r##"Specify the file into which to write the program's output"##),
@@ -3550,7 +2664,7 @@ fn main() {
let mut app = App::new("cloudiot1")
.author("Sebastian Thiel <byronimo@gmail.com>")
.version("1.0.8+20190321")
.version("1.0.9+20190618")
.about("Registers and manages IoT (Internet of Things) devices that connect to the Google Cloud Platform.
")
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_cloudiot1_cli")