Regen all APIs from new JSON

This commit is contained in:
Guy Taylor
2019-04-04 18:16:26 +01:00
committed by Sebastian Thiel
parent 86a884c48b
commit 2ad9f3781d
1212 changed files with 440610 additions and 142417 deletions

View File

@@ -46,6 +46,92 @@ struct Engine<'n> {
impl<'n> Engine<'n> {
fn _projects_locations_registries_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_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_create(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
-> Result<(), DoitError> {
@@ -268,7 +354,10 @@ impl<'n> Engine<'n> {
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"last-state-time" => Some(("lastStateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-config-send-time" => Some(("lastConfigSendTime", 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 })),
@@ -281,14 +370,15 @@ impl<'n> Engine<'n> {
"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 })),
"blocked" => Some(("blocked", JsonTypeInfo { jtype: JsonType::Boolean, 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", "id", "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"]);
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
}
@@ -468,6 +558,15 @@ impl<'n> Engine<'n> {
"page-size" => {
call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer"));
},
"gateway-list-options-gateway-type" => {
call = call.gateway_list_options_gateway_type(value.unwrap_or(""));
},
"gateway-list-options-associations-gateway-id" => {
call = call.gateway_list_options_associations_gateway_id(value.unwrap_or(""));
},
"gateway-list-options-associations-device-id" => {
call = call.gateway_list_options_associations_device_id(value.unwrap_or(""));
},
"field-mask" => {
call = call.field_mask(value.unwrap_or(""));
},
@@ -490,7 +589,7 @@ impl<'n> Engine<'n> {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["device-num-ids", "page-token", "field-mask", "page-size", "device-ids"].iter().map(|v|*v));
v.extend(["page-size", "gateway-list-options-associations-gateway-id", "field-mask", "device-ids", "device-num-ids", "page-token", "gateway-list-options-gateway-type", "gateway-list-options-associations-device-id"].iter().map(|v|*v));
v } ));
}
}
@@ -634,7 +733,10 @@ impl<'n> Engine<'n> {
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"last-state-time" => Some(("lastStateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-config-send-time" => Some(("lastConfigSendTime", 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 })),
@@ -647,14 +749,15 @@ impl<'n> Engine<'n> {
"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 })),
"blocked" => Some(("blocked", JsonTypeInfo { jtype: JsonType::Boolean, 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", "id", "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"]);
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
}
@@ -996,6 +1099,92 @@ 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(""));
@@ -1120,6 +1309,15 @@ impl<'n> Engine<'n> {
"page-size" => {
call = call.page_size(arg_from_str(value.unwrap_or("-0"), err, "page-size", "integer"));
},
"gateway-list-options-gateway-type" => {
call = call.gateway_list_options_gateway_type(value.unwrap_or(""));
},
"gateway-list-options-associations-gateway-id" => {
call = call.gateway_list_options_associations_gateway_id(value.unwrap_or(""));
},
"gateway-list-options-associations-device-id" => {
call = call.gateway_list_options_associations_device_id(value.unwrap_or(""));
},
"field-mask" => {
call = call.field_mask(value.unwrap_or(""));
},
@@ -1142,7 +1340,7 @@ impl<'n> Engine<'n> {
err.issues.push(CLIError::UnknownParameter(key.to_string(),
{let mut v = Vec::new();
v.extend(self.gp.iter().map(|v|*v));
v.extend(["device-num-ids", "page-token", "field-mask", "page-size", "device-ids"].iter().map(|v|*v));
v.extend(["page-size", "gateway-list-options-associations-gateway-id", "field-mask", "device-ids", "device-num-ids", "page-token", "gateway-list-options-gateway-type", "gateway-list-options-associations-device-id"].iter().map(|v|*v));
v } ));
}
}
@@ -1286,7 +1484,10 @@ impl<'n> Engine<'n> {
let type_info: Option<(&'static str, JsonTypeInfo)> =
match &temp_cursor.to_string()[..] {
"last-state-time" => Some(("lastStateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
"last-config-send-time" => Some(("lastConfigSendTime", 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 })),
@@ -1299,14 +1500,15 @@ impl<'n> Engine<'n> {
"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 })),
"blocked" => Some(("blocked", JsonTypeInfo { jtype: JsonType::Boolean, 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", "id", "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"]);
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
}
@@ -1767,6 +1969,92 @@ 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(""));
@@ -2091,6 +2379,92 @@ impl<'n> Engine<'n> {
}
}
fn _projects_locations_registries_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_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 _doit(&self, dry_run: bool) -> Result<Result<(), DoitError>, Option<InvalidOptionsError>> {
let mut err = InvalidOptionsError::new();
let mut call_result: Result<(), DoitError> = Ok(());
@@ -2098,6 +2472,9 @@ impl<'n> Engine<'n> {
match self.opt.subcommand() {
("projects", Some(opt)) => {
match opt.subcommand() {
("locations-registries-bind-device-to-gateway", Some(opt)) => {
call_result = self._projects_locations_registries_bind_device_to_gateway(opt, dry_run, &mut err);
},
("locations-registries-create", Some(opt)) => {
call_result = self._projects_locations_registries_create(opt, dry_run, &mut err);
},
@@ -2137,6 +2514,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);
},
@@ -2167,6 +2547,9 @@ 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);
},
@@ -2179,6 +2562,9 @@ impl<'n> Engine<'n> {
("locations-registries-test-iam-permissions", Some(opt)) => {
call_result = self._projects_locations_registries_test_iam_permissions(opt, dry_run, &mut err);
},
("locations-registries-unbind-device-from-gateway", Some(opt)) => {
call_result = self._projects_locations_registries_unbind_device_from_gateway(opt, dry_run, &mut err);
},
_ => {
err.issues.push(CLIError::MissingMethodError("projects".to_string()));
writeln!(io::stderr(), "{}\n", opt.usage()).ok();
@@ -2270,7 +2656,36 @@ impl<'n> Engine<'n> {
fn main() {
let mut exit_status = 0i32;
let arg_data = [
("projects", "methods: '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-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-list', 'locations-registries-patch', 'locations-registries-set-iam-policy' and 'locations-registries-test-iam-permissions'", 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-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![
("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",
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-create",
Some(r##"Creates a device registry that contains devices."##),
"Details at http://byron.github.io/google-apis-rs/google_cloudiot1_cli/projects_locations-registries-create",
@@ -2628,6 +3043,35 @@ 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"##),
@@ -2923,6 +3367,35 @@ 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"##),
@@ -3036,6 +3509,35 @@ 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-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-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"##),
@@ -3048,7 +3550,7 @@ fn main() {
let mut app = App::new("cloudiot1")
.author("Sebastian Thiel <byronimo@gmail.com>")
.version("1.0.8+20181002")
.version("1.0.8+20190321")
.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")