From eb0d9d207a8b690d00e436804fa96e2511e6107b Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Fri, 14 Jul 2023 17:37:54 -0700 Subject: [PATCH] Restructure argument processing (#523) Restructure argument processing to close up some corner cases where we didn't properly identify when the json body was required and to make it more extensible to other types of parameters such as those derived from enum variants. --- progenitor-impl/src/cli.rs | 604 ++-- .../tests/output/buildomat-cli.out | 156 +- progenitor-impl/tests/output/keeper-cli.out | 44 +- progenitor-impl/tests/output/nexus-cli.out | 2860 ++++++++--------- .../tests/output/propolis-server-cli.out | 26 +- 5 files changed, 1869 insertions(+), 1821 deletions(-) diff --git a/progenitor-impl/src/cli.rs b/progenitor-impl/src/cli.rs index 0d58bfd..08507a2 100644 --- a/progenitor-impl/src/cli.rs +++ b/progenitor-impl/src/cli.rs @@ -1,5 +1,7 @@ // Copyright 2023 Oxide Computer Company +use std::collections::BTreeMap; + use heck::ToKebabCase; use openapiv3::OpenAPI; use proc_macro2::TokenStream; @@ -177,200 +179,10 @@ impl Generator { &mut self, method: &crate::method::OperationMethod, ) -> CliOperation { - let maybe_body_arg = method.params.iter().find(|param| { - matches!(¶m.kind, OperationParameterKind::Body(_)) - // TODO not sure how to deal with raw bodies right now - && matches!(¶m.typ, OperationParameterType::Type(_)) - }); - - let mut full_body = true; - - // Preprocess the body parameter (if there is one) to create an - // iterator of top-level properties that can be represented as scalar - // values. We use these to create `clap::Arg` structures and then to - // build up the body parameter in the actual API call. - let body_params = maybe_body_arg - .into_iter() - .flat_map(|param| { - let OperationParameterType::Type(type_id) = ¶m.typ else { - unreachable!(); - }; - - let body_arg_type = self.type_space.get_type(type_id).unwrap(); - let details = body_arg_type.details(); - - match details { - typify::TypeDetails::Struct(struct_info) => { - struct_info - .properties_info() - .filter_map(|prop_info| { - let TypeStructPropInfo { - name: prop_name, - description, - required, - type_id: prop_type_id, - } = prop_info; - let prop_type = self - .type_space - .get_type(&prop_type_id) - .unwrap(); - - // TODO this is maybe a kludge--not completely sure - // of the right way to handle option types. On one - // hand, we could want types from this interface to - // never show us Option types--we could let the - // `required` field give us that information. On - // the other hand, there might be Option types that - // are required ... at least in the JSON sense, - // meaning that we need to include `"foo": null` - // rather than omitting the field. Back to the - // first hand: is that last point just a serde - // issue rather than an interface one? - let maybe_inner_type = - if let typify::TypeDetails::Option( - inner_type_id, - ) = prop_type.details() - { - let inner_type = self - .type_space - .get_type(&inner_type_id) - .unwrap(); - Some(inner_type) - } else { - None - }; - - let prop_type = if let Some(inner_type) = - maybe_inner_type - { - inner_type - } else { - prop_type - }; - - let scalar = - prop_type.has_impl(TypeSpaceImpl::FromStr); - let prop_name = prop_name.to_kebab_case(); - - // If there's a required property that we can't - // represent as a scalar (and therefore as a - // CLI parameter), the user will be unable to - // specify the full body without a json file. - if required && !scalar { - full_body = false; - } - - // println!( - // "{}::{}: {}; scalar: {}; required: {}", - // body_args.name(), - // prop_name, - // prop_type.name(), - // scalar, - // required, - // ); - - scalar.then(|| { - ( - prop_name.clone(), - required, - description.map(str::to_string), - prop_type, - ) - }) - }) - .collect::>() - } - _ => Vec::new(), - } - }) - .collect::>(); - let fn_name = format_ident!("cli_{}", &method.operation_id); - - let first_page_required_set = method - .dropshot_paginated - .as_ref() - .map(|d| &d.first_page_params); - - let args = method - .params - .iter() - .filter(|param| { - !matches!(¶m.kind, OperationParameterKind::Body(_)) - && (method.dropshot_paginated.is_none() - || param.name.as_str() != "page_token") - }) - .map(|param| { - let arg_name = param.name.to_kebab_case(); - - let first_page_required = first_page_required_set - .map_or(false, |required| { - required.contains(¶m.api_name) - }); - - let required = if first_page_required { - Volitionality::Required - } else { - match ¶m.kind { - OperationParameterKind::Path => Volitionality::Required, - OperationParameterKind::Query(true) - | OperationParameterKind::Header(true) => { - Volitionality::Required - } - OperationParameterKind::Query(false) - | OperationParameterKind::Header(false) => { - Volitionality::Optional - } - OperationParameterKind::Body(_) => unreachable!(), - } - }; - - let OperationParameterType::Type(arg_type_id) = ¶m.typ - else { - panic!() - }; - let arg_type = self.type_space.get_type(arg_type_id).unwrap(); - - clap_arg(&arg_name, required, ¶m.description, &arg_type) - }); - - let body_args = body_params.iter().map( - |(prop_name, required, description, prop_type)| { - let volitionality = if *required { - Volitionality::RequiredIfNoBody - } else { - Volitionality::Optional - }; - clap_arg(prop_name, volitionality, description, prop_type) - }, - ); - - // TODO parameter for body as input json (--body-input?) - // TODO parameter to output a body template (--body-template?) - // TODO deal with all parameters? - - let body_json_args = maybe_body_arg.map(|_| { - let help = "Path to a file that contains the full json body."; - let required = !full_body; - - quote! { - .arg( - clap::Arg::new("json-body") - .long("json-body") - .value_name("JSON-FILE") - // Required if we can't turn the body into individual - // parameters. - .required(#required) - .value_parser(clap::value_parser!(std::path::PathBuf)) - .help(#help) - ) - .arg( - clap::Arg::new("json-body-template") - .long("json-body-template") - .action(clap::ArgAction::SetTrue) - .help("XXX") - ) - } - }); + let CliArg { + parser: parser_args, + consumer: consumer_args, + } = self.cli_method_args(method); let about = method.summary.as_ref().map(|summary| { quote! { @@ -384,75 +196,20 @@ impl Generator { } }); + let fn_name = format_ident!("cli_{}", &method.operation_id); + let cli_fn = quote! { pub fn #fn_name() -> clap::Command { clap::Command::new("") - #( - .arg(#args) - )* - #( - .arg(#body_args) - )* - #body_json_args + #parser_args #about #long_about } }; - let op_name = format_ident!("{}", &method.operation_id); let fn_name = format_ident!("execute_{}", &method.operation_id); - - // Build up the iterator processing each top-level parameter. - let args = method - .params - .iter() - .filter(|param| { - !matches!(¶m.kind, OperationParameterKind::Body(_)) - && (method.dropshot_paginated.is_none() - || (param.name.as_str() != "page_token")) - }) - .map(|param| { - let arg_name = param.name.to_kebab_case(); - let arg_fn_name = sanitize(¶m.name, Case::Snake); - let arg_fn = format_ident!("{}", arg_fn_name); - let OperationParameterType::Type(arg_type_id) = ¶m.typ else { - panic!() - }; - let arg_type = self.type_space.get_type(arg_type_id).unwrap(); - let arg_type_name = arg_type.ident(); - - quote! { - if let Some(value) = - matches.get_one::<#arg_type_name>(#arg_name) - { - // clone here in case the arg type doesn't impl - // From<&T> - request = request.#arg_fn(value.clone()); - } - } - }); - - // Build up the iterator processing each body property we can handle. - let body_args = - body_params.iter().map(|(prop_name, _, _, prop_type)| { - let prop_fn = - format_ident!("{}", sanitize(prop_name, Case::Snake)); - let prop_type_ident = prop_type.ident(); - quote! { - if let Some(value) = - matches.get_one::<#prop_type_ident>( - #prop_name, - ) - { - // clone here in case the arg type - // doesn't impl TryFrom<&T> - request = request.body_map(|body| { - body.#prop_fn(value.clone()) - }) - } - } - }); + let op_name = format_ident!("{}", &method.operation_id); let (_, success_type) = self.extract_responses( method, @@ -522,37 +279,13 @@ impl Generator { } }; - let body_json_args = maybe_body_arg.map(|body_param| { - let OperationParameterType::Type(body_type_id) = &body_param.typ - else { - unreachable!(); - }; - let body_type = self.type_space.get_type(body_type_id).unwrap(); - let body_type_ident = body_type.ident(); - quote! { - if let Some(value) = - matches.get_one::("json-body") - { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::<#body_type_ident>( - &body_txt, - ) - .unwrap(); - request = request.body(body_value); - } - } - }); - let execute_fn = quote! { pub async fn #fn_name(&self, matches: &clap::ArgMatches) // -> // Result, Error<#error_type>> { let mut request = self.client.#op_name(); - #body_json_args - #( #args )* - #( #body_args )* + #consumer_args // Call the override function. // TODO don't want to unwrap. @@ -584,6 +317,276 @@ impl Generator { execute_trait, } } + + fn cli_method_args( + &self, + method: &crate::method::OperationMethod, + ) -> CliArg { + let mut args = CliOperationArgs::default(); + + let first_page_required_set = method + .dropshot_paginated + .as_ref() + .map(|d| &d.first_page_params); + + for param in &method.params { + let innately_required = match ¶m.kind { + // We're not interetested in the body parameter yet. + OperationParameterKind::Body(_) => continue, + + OperationParameterKind::Path => true, + OperationParameterKind::Query(required) => *required, + OperationParameterKind::Header(required) => *required, + }; + + // For paginated endpoints, we don't generate 'page_token' args. + if method.dropshot_paginated.is_some() + && param.name.as_str() == "page_token" + { + continue; + } + + let first_page_required = first_page_required_set + .map_or(false, |required| required.contains(¶m.api_name)); + + let volitionality = if innately_required || first_page_required { + Volitionality::Required + } else { + Volitionality::Optional + }; + + let OperationParameterType::Type(arg_type_id) = ¶m.typ + else { + unreachable!("query and path parameters must be typed") + }; + let arg_type = self.type_space.get_type(arg_type_id).unwrap(); + + let arg_name = param.name.to_kebab_case(); + + // There should be no conflicting path or query parameters. + assert!(!args.has_arg(&arg_name)); + + let parser = clap_arg( + &arg_name, + volitionality, + ¶m.description, + &arg_type, + ); + + let arg_fn_name = sanitize(¶m.name, Case::Snake); + let arg_fn = format_ident!("{}", arg_fn_name); + let OperationParameterType::Type(arg_type_id) = ¶m.typ else { + panic!() + }; + let arg_type = self.type_space.get_type(arg_type_id).unwrap(); + let arg_type_name = arg_type.ident(); + + let consumer = quote! { + if let Some(value) = + matches.get_one::<#arg_type_name>(#arg_name) + { + // clone here in case the arg type doesn't impl + // From<&T> + request = request.#arg_fn(value.clone()); + } + }; + + args.add_arg(arg_name, CliArg { parser, consumer }) + } + + let maybe_body_type_id = method + .params + .iter() + .find(|param| { + matches!(¶m.kind, OperationParameterKind::Body(_)) + }) + .and_then(|param| match ¶m.typ { + // TODO not sure how to deal with raw bodies, but we definitely + // need **some** input so we shouldn't just ignore it... as we + // are currently... + OperationParameterType::RawBody => None, + + OperationParameterType::Type(body_type_id) => { + Some(body_type_id) + } + }); + + if let Some(body_type_id) = maybe_body_type_id { + args.body_present(); + let body_type = self.type_space.get_type(body_type_id).unwrap(); + let details = body_type.details(); + + match details { + typify::TypeDetails::Struct(struct_info) => { + for prop_info in struct_info.properties_info() { + self.cli_method_body_arg(&mut args, prop_info) + } + } + + _ => { + // If the body is not a struct, we don't know what's + // required or how to generate it + args.body_required() + } + } + } + + let parser_args = + args.args.values().map(|CliArg { parser, .. }| parser); + + // TODO do this as args we add in. + let body_json_args = (match args.body { + CliBodyArg::None => None, + CliBodyArg::Required => Some(true), + CliBodyArg::Optional => Some(false), + }) + .map(|required| { + let help = "Path to a file that contains the full json body."; + + quote! { + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + // Required if we can't turn the body into individual + // parameters. + .required(#required) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help(#help) + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX") + ) + } + }); + + let parser = quote! { + #( + .arg(#parser_args) + )* + #body_json_args + }; + + let consumer_args = + args.args.values().map(|CliArg { consumer, .. }| consumer); + + let body_json_consumer = maybe_body_type_id.map(|body_type_id| { + let body_type = self.type_space.get_type(body_type_id).unwrap(); + let body_type_ident = body_type.ident(); + quote! { + if let Some(value) = + matches.get_one::("json-body") + { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::<#body_type_ident>( + &body_txt, + ) + .unwrap(); + request = request.body(body_value); + } + } + }); + + let consumer = quote! { + #( + #consumer_args + )* + #body_json_consumer + }; + + CliArg { parser, consumer } + } + + fn cli_method_body_arg( + &self, + args: &mut CliOperationArgs, + prop_info: TypeStructPropInfo<'_>, + ) { + let TypeStructPropInfo { + name, + description, + required, + type_id, + } = prop_info; + + let prop_type = self.type_space.get_type(&type_id).unwrap(); + + // TODO this is maybe a kludge--not completely sure of the right way to + // handle option types. On one hand, we could want types from this + // interface to never show us Option types--we could let the + // `required` field give us that information. On the other hand, there + // might be Option types that are required ... at least in the JSON + // sense, meaning that we need to include `"foo": null` rather than + // omitting the field. Back to the first hand: is that last point just + // a serde issue rather than an interface one? + let maybe_inner_type = + if let typify::TypeDetails::Option(inner_type_id) = + prop_type.details() + { + let inner_type = + self.type_space.get_type(&inner_type_id).unwrap(); + Some(inner_type) + } else { + None + }; + + let prop_type = if let Some(inner_type) = maybe_inner_type { + inner_type + } else { + prop_type + }; + + let scalar = prop_type.has_impl(TypeSpaceImpl::FromStr); + + if scalar { + let volitionality = if required { + Volitionality::RequiredIfNoBody + } else { + Volitionality::Optional + }; + let prop_name = name.to_kebab_case(); + let parser = clap_arg( + &prop_name, + volitionality, + &description.map(str::to_string), + &prop_type, + ); + + let prop_fn = format_ident!("{}", sanitize(name, Case::Snake)); + let prop_type_ident = prop_type.ident(); + let consumer = quote! { + if let Some(value) = + matches.get_one::<#prop_type_ident>( + #prop_name, + ) + { + // clone here in case the arg type + // doesn't impl TryFrom<&T> + request = request.body_map(|body| { + body.#prop_fn(value.clone()) + }) + } + }; + args.add_arg(prop_name, CliArg { parser, consumer }) + } else if required { + args.body_required() + } + + // Cases + // 1. If the type can be represented as a string, great + // + // 2. If it's a substruct then we can try to glue the names together + // and hope? + // + // 3. enums + // 3.1 simple enums (should be covered by 1 above) + // e.g. enum { A, B } + // args for --a and --b that are in a group + } } enum Volitionality { @@ -664,3 +667,48 @@ fn clap_arg( #help } } + +#[derive(Debug)] +struct CliArg { + /// Code to parse the argument + parser: TokenStream, + + /// Code to consume the argument + consumer: TokenStream, +} + +#[derive(Debug, Default, PartialEq, Eq)] +enum CliBodyArg { + #[default] + None, + Required, + Optional, +} + +#[derive(Default, Debug)] +struct CliOperationArgs { + args: BTreeMap, + body: CliBodyArg, +} + +impl CliOperationArgs { + fn has_arg(&self, name: &String) -> bool { + self.args.contains_key(name) + } + fn add_arg(&mut self, name: String, arg: CliArg) { + self.args.insert(name, arg); + } + + fn body_present(&mut self) { + assert_eq!(self.body, CliBodyArg::None); + self.body = CliBodyArg::Optional; + } + + fn body_required(&mut self) { + assert!( + self.body == CliBodyArg::Optional + || self.body == CliBodyArg::Required + ); + self.body = CliBodyArg::Required; + } +} diff --git a/progenitor-impl/tests/output/buildomat-cli.out b/progenitor-impl/tests/output/buildomat-cli.out index 1f09219..317eab7 100644 --- a/progenitor-impl/tests/output/buildomat-cli.out +++ b/progenitor-impl/tests/output/buildomat-cli.out @@ -84,18 +84,18 @@ impl Cli { pub fn cli_task_events_get() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("task") - .long("task") - .value_parser(clap::value_parser!(String)) - .required(true), - ) .arg( clap::Arg::new("minseq") .long("minseq") .value_parser(clap::value_parser!(u32)) .required(false), ) + .arg( + clap::Arg::new("task") + .long("task") + .value_parser(clap::value_parser!(String)) + .required(true), + ) } pub fn cli_task_outputs_get() -> clap::Command { @@ -110,14 +110,14 @@ impl Cli { pub fn cli_task_output_download() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("task") - .long("task") + clap::Arg::new("output") + .long("output") .value_parser(clap::value_parser!(String)) .required(true), ) .arg( - clap::Arg::new("output") - .long("output") + clap::Arg::new("task") + .long("task") .value_parser(clap::value_parser!(String)) .required(true), ) @@ -187,12 +187,6 @@ impl Cli { pub fn cli_worker_task_append() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("task") - .long("task") - .value_parser(clap::value_parser!(String)) - .required(true), - ) .arg( clap::Arg::new("payload") .long("payload") @@ -205,6 +199,12 @@ impl Cli { .value_parser(clap::value_parser!(String)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("task") + .long("task") + .value_parser(clap::value_parser!(String)) + .required(true), + ) .arg( clap::Arg::new("time") .long("time") @@ -238,18 +238,18 @@ impl Cli { pub fn cli_worker_task_complete() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("task") - .long("task") - .value_parser(clap::value_parser!(String)) - .required(true), - ) .arg( clap::Arg::new("failed") .long("failed") .value_parser(clap::value_parser!(bool)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("task") + .long("task") + .value_parser(clap::value_parser!(String)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -268,12 +268,6 @@ impl Cli { pub fn cli_worker_task_add_output() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("task") - .long("task") - .value_parser(clap::value_parser!(String)) - .required(true), - ) .arg( clap::Arg::new("path") .long("path") @@ -286,6 +280,12 @@ impl Cli { .value_parser(clap::value_parser!(i64)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("task") + .long("task") + .value_parser(clap::value_parser!(String)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -441,12 +441,6 @@ impl Cli { pub async fn execute_task_submit(&self, matches: &clap::ArgMatches) { let mut request = self.client.task_submit(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("name") { request = request.body_map(|body| body.name(value.clone())) } @@ -455,6 +449,12 @@ impl Cli { request = request.body_map(|body| body.script(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_task_submit(matches, &mut request) .unwrap(); @@ -471,14 +471,14 @@ impl Cli { pub async fn execute_task_events_get(&self, matches: &clap::ArgMatches) { let mut request = self.client.task_events_get(); - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } - if let Some(value) = matches.get_one::("minseq") { request = request.minseq(value.clone()); } + if let Some(value) = matches.get_one::("task") { + request = request.task(value.clone()); + } + self.over .execute_task_events_get(matches, &mut request) .unwrap(); @@ -515,14 +515,14 @@ impl Cli { pub async fn execute_task_output_download(&self, matches: &clap::ArgMatches) { let mut request = self.client.task_output_download(); - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } - if let Some(value) = matches.get_one::("output") { request = request.output(value.clone()); } + if let Some(value) = matches.get_one::("task") { + request = request.task(value.clone()); + } + self.over .execute_task_output_download(matches, &mut request) .unwrap(); @@ -539,16 +539,16 @@ impl Cli { pub async fn execute_user_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.user_create(); + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) - } - self.over .execute_user_create(matches, &mut request) .unwrap(); @@ -579,12 +579,6 @@ impl Cli { pub async fn execute_worker_bootstrap(&self, matches: &clap::ArgMatches) { let mut request = self.client.worker_bootstrap(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("bootstrap") { request = request.body_map(|body| body.bootstrap(value.clone())) } @@ -593,6 +587,12 @@ impl Cli { request = request.body_map(|body| body.token(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_worker_bootstrap(matches, &mut request) .unwrap(); @@ -625,16 +625,6 @@ impl Cli { pub async fn execute_worker_task_append(&self, matches: &clap::ArgMatches) { let mut request = self.client.worker_task_append(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } - if let Some(value) = matches.get_one::("payload") { request = request.body_map(|body| body.payload(value.clone())) } @@ -643,10 +633,20 @@ impl Cli { request = request.body_map(|body| body.stream(value.clone())) } + if let Some(value) = matches.get_one::("task") { + request = request.task(value.clone()); + } + if let Some(value) = matches.get_one::>("time") { request = request.body_map(|body| body.time(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_worker_task_append(matches, &mut request) .unwrap(); @@ -683,18 +683,18 @@ impl Cli { pub async fn execute_worker_task_complete(&self, matches: &clap::ArgMatches) { let mut request = self.client.worker_task_complete(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("failed") { + request = request.body_map(|body| body.failed(value.clone())) } if let Some(value) = matches.get_one::("task") { request = request.task(value.clone()); } - if let Some(value) = matches.get_one::("failed") { - request = request.body_map(|body| body.failed(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -713,16 +713,6 @@ impl Cli { pub async fn execute_worker_task_add_output(&self, matches: &clap::ArgMatches) { let mut request = self.client.worker_task_add_output(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } - if let Some(value) = matches.get_one::("path") { request = request.body_map(|body| body.path(value.clone())) } @@ -731,6 +721,16 @@ impl Cli { request = request.body_map(|body| body.size(value.clone())) } + if let Some(value) = matches.get_one::("task") { + request = request.task(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_worker_task_add_output(matches, &mut request) .unwrap(); diff --git a/progenitor-impl/tests/output/keeper-cli.out b/progenitor-impl/tests/output/keeper-cli.out index ba3405e..fc3e41b 100644 --- a/progenitor-impl/tests/output/keeper-cli.out +++ b/progenitor-impl/tests/output/keeper-cli.out @@ -212,12 +212,6 @@ impl Cli { pub async fn execute_enrol(&self, matches: &clap::ArgMatches) { let mut request = self.client.enrol(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("authorization") { request = request.authorization(value.clone()); } @@ -230,6 +224,12 @@ impl Cli { request = request.body_map(|body| body.key(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over.execute_enrol(matches, &mut request).unwrap(); let result = request.send().await; match result { @@ -282,12 +282,6 @@ impl Cli { pub async fn execute_report_finish(&self, matches: &clap::ArgMatches) { let mut request = self.client.report_finish(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("authorization") { request = request.authorization(value.clone()); } @@ -304,6 +298,12 @@ impl Cli { request = request.body_map(|body| body.exit_status(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_report_finish(matches, &mut request) .unwrap(); @@ -320,16 +320,16 @@ impl Cli { pub async fn execute_report_output(&self, matches: &clap::ArgMatches) { let mut request = self.client.report_output(); + if let Some(value) = matches.get_one::("authorization") { + request = request.authorization(value.clone()); + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("authorization") { - request = request.authorization(value.clone()); - } - self.over .execute_report_output(matches, &mut request) .unwrap(); @@ -346,12 +346,6 @@ impl Cli { pub async fn execute_report_start(&self, matches: &clap::ArgMatches) { let mut request = self.client.report_start(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("authorization") { request = request.authorization(value.clone()); } @@ -365,6 +359,12 @@ impl Cli { request = request.body_map(|body| body.start_time(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_report_start(matches, &mut request) .unwrap(); diff --git a/progenitor-impl/tests/output/nexus-cli.out b/progenitor-impl/tests/output/nexus-cli.out index ce2207f..3d94453 100644 --- a/progenitor-impl/tests/output/nexus-cli.out +++ b/progenitor-impl/tests/output/nexus-cli.out @@ -491,18 +491,18 @@ impl Cli { pub fn cli_login_local() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("silo-name") - .long("silo-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("password") .long("password") .value_parser(clap::value_parser!(types::Password)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("username") .long("username") @@ -529,14 +529,14 @@ impl Cli { pub fn cli_login_saml_begin() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("silo-name") - .long("silo-name") + clap::Arg::new("provider-name") + .long("provider-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) .arg( - clap::Arg::new("provider-name") - .long("provider-name") + clap::Arg::new("silo-name") + .long("silo-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -550,14 +550,14 @@ impl Cli { pub fn cli_login_saml() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("silo-name") - .long("silo-name") + clap::Arg::new("provider-name") + .long("provider-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) .arg( - clap::Arg::new("provider-name") - .long("provider-name") + clap::Arg::new("silo-name") + .long("silo-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -641,13 +641,6 @@ impl Cli { pub fn cli_organization_update() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The organization's unique name."), - ) .arg( clap::Arg::new("description") .long("description") @@ -660,6 +653,13 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(false), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The organization's unique name."), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -733,13 +733,6 @@ impl Cli { pub fn cli_project_list() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The organization's unique name."), - ) .arg( clap::Arg::new("limit") .long("limit") @@ -747,6 +740,13 @@ impl Cli { .required(false) .help("Maximum number of items returned by a single call"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The organization's unique name."), + ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -766,13 +766,6 @@ impl Cli { pub fn cli_project_create() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The organization's unique name."), - ) .arg( clap::Arg::new("description") .long("description") @@ -785,6 +778,13 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The organization's unique name."), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -825,6 +825,18 @@ impl Cli { pub fn cli_project_update() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required(false), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(types::Name)) + .required(false), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -839,18 +851,6 @@ impl Cli { .required(true) .help("The project's unique name within the organization."), ) - .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required(false), - ) - .arg( - clap::Arg::new("name") - .long("name") - .value_parser(clap::value_parser!(types::Name)) - .required(false), - ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -891,6 +891,13 @@ impl Cli { pub fn cli_disk_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -905,13 +912,6 @@ impl Cli { .required(true) .help("The project's unique name within the organization."), ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -929,6 +929,18 @@ impl Cli { pub fn cli_disk_create() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(types::Name)) + .required_unless_present("json-body"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -943,18 +955,6 @@ impl Cli { .required(true) .help("The project's unique name within the organization."), ) - .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), - ) - .arg( - clap::Arg::new("name") - .long("name") - .value_parser(clap::value_parser!(types::Name)) - .required_unless_present("json-body"), - ) .arg( clap::Arg::new("size") .long("size") @@ -981,6 +981,12 @@ impl Cli { pub fn cli_disk_view() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("disk-name") + .long("disk-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -993,18 +999,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("disk-name") - .long("disk-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Fetch a disk") .long_about("Use `GET /v1/disks/{disk}` instead") } pub fn cli_disk_delete() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("disk-name") + .long("disk-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1017,35 +1023,31 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("disk-name") - .long("disk-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Use `DELETE /v1/disks/{disk}` instead") } pub fn cli_disk_metrics_list() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("disk-name") .long("disk-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) + .arg( + clap::Arg::new("end-time") + .long("end-time") + .value_parser(clap::value_parser!(chrono::DateTime)) + .required(true) + .help("An exclusive end time of metrics."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("metric-name") .long("metric-name") @@ -1063,18 +1065,16 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("end-time") - .long("end-time") - .value_parser(clap::value_parser!(chrono::DateTime)) - .required(true) - .help("An exclusive end time of metrics."), + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), ) .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), ) .arg( clap::Arg::new("start-time") @@ -1088,6 +1088,13 @@ impl Cli { pub fn cli_image_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1102,13 +1109,6 @@ impl Cli { .required(true) .help("The project's unique name within the organization."), ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -1129,6 +1129,18 @@ impl Cli { pub fn cli_image_create() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(types::Name)) + .required_unless_present("json-body"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1143,18 +1155,6 @@ impl Cli { .required(true) .help("The project's unique name within the organization."), ) - .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), - ) - .arg( - clap::Arg::new("name") - .long("name") - .value_parser(clap::value_parser!(types::Name)) - .required_unless_present("json-body"), - ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -1175,6 +1175,12 @@ impl Cli { pub fn cli_image_view() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("image-name") + .long("image-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1187,18 +1193,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("image-name") - .long("image-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Fetch an image") .long_about("Fetch the details for a specific image in a project.") } pub fn cli_image_delete() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("image-name") + .long("image-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1211,12 +1217,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("image-name") - .long("image-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Delete an image") .long_about( "Permanently delete an image from a project. This operation cannot be undone. Any \ @@ -1227,6 +1227,13 @@ impl Cli { pub fn cli_instance_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1241,13 +1248,6 @@ impl Cli { .required(true) .help("The project's unique name within the organization."), ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -1264,20 +1264,6 @@ impl Cli { pub fn cli_instance_create() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The organization's unique name."), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The project's unique name within the organization."), - ) .arg( clap::Arg::new("description") .long("description") @@ -1308,6 +1294,20 @@ impl Cli { .value_parser(clap::value_parser!(types::InstanceCpuCount)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The project's unique name within the organization."), + ) .arg( clap::Arg::new("start") .long("start") @@ -1346,6 +1346,12 @@ impl Cli { pub fn cli_instance_view() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1358,18 +1364,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("instance-name") - .long("instance-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Fetch an instance") .long_about("Use `GET /v1/instances/{instance}` instead") } pub fn cli_instance_delete() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1382,29 +1388,11 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("instance-name") - .long("instance-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Delete an instance") } pub fn cli_instance_disk_list() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("instance-name") .long("instance-name") @@ -1418,6 +1406,18 @@ impl Cli { .required(false) .help("Maximum number of items returned by a single call"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -1435,18 +1435,6 @@ impl Cli { pub fn cli_instance_disk_attach() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("instance-name") .long("instance-name") @@ -1459,6 +1447,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -1479,18 +1479,6 @@ impl Cli { pub fn cli_instance_disk_detach() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("instance-name") .long("instance-name") @@ -1503,6 +1491,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -1523,6 +1523,12 @@ impl Cli { pub fn cli_instance_external_ip_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1535,17 +1541,23 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("instance-name") - .long("instance-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("List external IP addresses") } pub fn cli_instance_migrate() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("dst-sled-id") + .long("dst-sled-id") + .value_parser(clap::value_parser!(uuid::Uuid)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1558,18 +1570,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("instance-name") - .long("instance-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("dst-sled-id") - .long("dst-sled-id") - .value_parser(clap::value_parser!(uuid::Uuid)) - .required_unless_present("json-body"), - ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -1590,18 +1590,6 @@ impl Cli { pub fn cli_instance_network_interface_list() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("instance-name") .long("instance-name") @@ -1615,6 +1603,18 @@ impl Cli { .required(false) .help("Maximum number of items returned by a single call"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -1632,16 +1632,10 @@ impl Cli { pub fn cli_instance_network_interface_create() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), ) .arg( clap::Arg::new("instance-name") @@ -1649,12 +1643,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), - ) .arg( clap::Arg::new("ip") .long("ip") @@ -1671,6 +1659,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("subnet-name") .long("subnet-name") @@ -1704,18 +1704,6 @@ impl Cli { pub fn cli_instance_network_interface_view() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("instance-name") .long("instance-name") @@ -1728,22 +1716,28 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .about("Fetch a network interface") } pub fn cli_instance_network_interface_update() -> clap::Command { clap::Command::new("") .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required(false), ) .arg( clap::Arg::new("instance-name") @@ -1757,18 +1751,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required(false), - ) .arg( clap::Arg::new("name") .long("name") .value_parser(clap::value_parser!(types::Name)) .required(false), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("primary") .long("primary") @@ -1785,6 +1779,12 @@ impl Cli { error.", ), ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -1804,18 +1804,6 @@ impl Cli { pub fn cli_instance_network_interface_delete() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("instance-name") .long("instance-name") @@ -1828,6 +1816,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .about("Delete a network interface") .long_about( "Note that the primary interface for an instance cannot be deleted if there are \ @@ -1838,6 +1838,12 @@ impl Cli { pub fn cli_instance_reboot() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1850,36 +1856,12 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("instance-name") - .long("instance-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Reboot an instance") .long_about("Use `POST /v1/instances/{instance}/reboot` instead") } pub fn cli_instance_serial_console() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("instance-name") - .long("instance-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("from-start") .long("from-start") @@ -1892,6 +1874,12 @@ impl Cli { must *not* be provided.", ), ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("max-bytes") .long("max-bytes") @@ -1914,12 +1902,6 @@ impl Cli { instance. (See note on `from_start` about mutual exclusivity)", ), ) - .about("Fetch an instance's serial console") - .long_about("Use `GET /v1/instances/{instance}/serial-console` instead") - } - - pub fn cli_instance_serial_console_stream() -> clap::Command { - clap::Command::new("") .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1932,18 +1914,42 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) + .about("Fetch an instance's serial console") + .long_about("Use `GET /v1/instances/{instance}/serial-console` instead") + } + + pub fn cli_instance_serial_console_stream() -> clap::Command { + clap::Command::new("") .arg( clap::Arg::new("instance-name") .long("instance-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .about("Connect to an instance's serial console") .long_about("Use `GET /v1/instances/{instance}/serial-console/stream` instead") } pub fn cli_instance_start() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1956,18 +1962,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("instance-name") - .long("instance-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Boot an instance") .long_about("Use `POST /v1/instances/{instance}/start` instead") } pub fn cli_instance_stop() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -1980,12 +1986,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("instance-name") - .long("instance-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .about("Halt an instance") .long_about("Use `POST /v1/instances/{instance}/stop` instead") } @@ -2045,6 +2045,13 @@ impl Cli { pub fn cli_snapshot_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2059,13 +2066,6 @@ impl Cli { .required(true) .help("The project's unique name within the organization."), ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -2082,20 +2082,6 @@ impl Cli { pub fn cli_snapshot_create() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The organization's unique name."), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The project's unique name within the organization."), - ) .arg( clap::Arg::new("description") .long("description") @@ -2115,6 +2101,20 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The project's unique name within the organization."), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -2181,6 +2181,13 @@ impl Cli { pub fn cli_vpc_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2195,13 +2202,6 @@ impl Cli { .required(true) .help("The project's unique name within the organization."), ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -2218,20 +2218,6 @@ impl Cli { pub fn cli_vpc_create() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The organization's unique name."), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The project's unique name within the organization."), - ) .arg( clap::Arg::new("description") .long("description") @@ -2262,6 +2248,20 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The project's unique name within the organization."), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -2304,24 +2304,6 @@ impl Cli { pub fn cli_vpc_update() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("description") .long("description") @@ -2340,6 +2322,24 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(false), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -2442,6 +2442,13 @@ impl Cli { pub fn cli_vpc_router_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2454,19 +2461,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -2478,11 +2472,29 @@ impl Cli { )) .required(false), ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .about("List routers") } pub fn cli_vpc_router_create() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(types::Name)) + .required_unless_present("json-body"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2501,18 +2513,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), - ) - .arg( - clap::Arg::new("name") - .long("name") - .value_parser(clap::value_parser!(types::Name)) - .required_unless_present("json-body"), - ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -2545,14 +2545,14 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") + clap::Arg::new("router-name") + .long("router-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) .arg( - clap::Arg::new("router-name") - .long("router-name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -2561,6 +2561,18 @@ impl Cli { pub fn cli_vpc_router_update() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required(false), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(types::Name)) + .required(false), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2573,12 +2585,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("router-name") .long("router-name") @@ -2586,16 +2592,10 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required(false), - ) - .arg( - clap::Arg::new("name") - .long("name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) - .required(false), + .required(true), ) .arg( clap::Arg::new("json-body") @@ -2629,14 +2629,14 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") + clap::Arg::new("router-name") + .long("router-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) .arg( - clap::Arg::new("router-name") - .long("router-name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -2645,6 +2645,13 @@ impl Cli { pub fn cli_vpc_router_route_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2657,25 +2664,12 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("router-name") .long("router-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -2687,12 +2681,30 @@ impl Cli { )) .required(false), ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .about("List routes") .long_about("List the routes associated with a router in a particular VPC.") } pub fn cli_vpc_router_route_create() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body"), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(types::Name)) + .required_unless_present("json-body"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2705,12 +2717,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("router-name") .long("router-name") @@ -2718,16 +2724,10 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body"), - ) - .arg( - clap::Arg::new("name") - .long("name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) - .required_unless_present("json-body"), + .required(true), ) .arg( clap::Arg::new("json-body") @@ -2761,8 +2761,8 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") + clap::Arg::new("route-name") + .long("route-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -2773,8 +2773,8 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("route-name") - .long("route-name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -2783,6 +2783,18 @@ impl Cli { pub fn cli_vpc_router_route_update() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required(false), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(types::Name)) + .required(false), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2796,8 +2808,8 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") + clap::Arg::new("route-name") + .long("route-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -2808,23 +2820,11 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("route-name") - .long("route-name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required(false), - ) - .arg( - clap::Arg::new("name") - .long("name") - .value_parser(clap::value_parser!(types::Name)) - .required(false), - ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -2857,8 +2857,8 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") + clap::Arg::new("route-name") + .long("route-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -2869,8 +2869,8 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("route-name") - .long("route-name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -2879,6 +2879,13 @@ impl Cli { pub fn cli_vpc_subnet_list() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -2891,19 +2898,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -2915,29 +2909,17 @@ impl Cli { )) .required(false), ) - .about("List subnets") - } - - pub fn cli_vpc_subnet_create() -> clap::Command { - clap::Command::new("") - .arg( - clap::Arg::new("organization-name") - .long("organization-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("project-name") - .long("project-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("vpc-name") .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) + .about("List subnets") + } + + pub fn cli_vpc_subnet_create() -> clap::Command { + clap::Command::new("") .arg( clap::Arg::new("description") .long("description") @@ -2973,6 +2955,24 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -3005,14 +3005,14 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") + clap::Arg::new("subnet-name") + .long("subnet-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) .arg( - clap::Arg::new("subnet-name") - .long("subnet-name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -3021,6 +3021,18 @@ impl Cli { pub fn cli_vpc_subnet_update() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .value_parser(clap::value_parser!(String)) + .required(false), + ) + .arg( + clap::Arg::new("name") + .long("name") + .value_parser(clap::value_parser!(types::Name)) + .required(false), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -3033,12 +3045,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("subnet-name") .long("subnet-name") @@ -3046,16 +3052,10 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("description") - .long("description") - .value_parser(clap::value_parser!(String)) - .required(false), - ) - .arg( - clap::Arg::new("name") - .long("name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) - .required(false), + .required(true), ) .arg( clap::Arg::new("json-body") @@ -3089,14 +3089,14 @@ impl Cli { .required(true), ) .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") + clap::Arg::new("subnet-name") + .long("subnet-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) .arg( - clap::Arg::new("subnet-name") - .long("subnet-name") + clap::Arg::new("vpc-name") + .long("vpc-name") .value_parser(clap::value_parser!(types::Name)) .required(true), ) @@ -3105,6 +3105,13 @@ impl Cli { pub fn cli_vpc_subnet_list_network_interfaces() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) .arg( clap::Arg::new("organization-name") .long("organization-name") @@ -3117,25 +3124,6 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(true), ) - .arg( - clap::Arg::new("vpc-name") - .long("vpc-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("subnet-name") - .long("subnet-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -3147,6 +3135,18 @@ impl Cli { )) .required(false), ) + .arg( + clap::Arg::new("subnet-name") + .long("subnet-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .about("List network interfaces") } @@ -3540,13 +3540,6 @@ impl Cli { pub fn cli_sled_physical_disk_list() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("sled-id") - .long("sled-id") - .value_parser(clap::value_parser!(uuid::Uuid)) - .required(true) - .help("The sled's unique ID."), - ) .arg( clap::Arg::new("limit") .long("limit") @@ -3554,6 +3547,13 @@ impl Cli { .required(false) .help("Maximum number of items returned by a single call"), ) + .arg( + clap::Arg::new("sled-id") + .long("sled-id") + .value_parser(clap::value_parser!(uuid::Uuid)) + .required(true) + .help("The sled's unique ID."), + ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -3727,12 +3727,6 @@ impl Cli { pub fn cli_ip_pool_update() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("pool-name") - .long("pool-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("description") .long("description") @@ -3745,6 +3739,12 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(false), ) + .arg( + clap::Arg::new("pool-name") + .long("pool-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -3775,12 +3775,6 @@ impl Cli { pub fn cli_ip_pool_range_list() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("pool-name") - .long("pool-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true), - ) .arg( clap::Arg::new("limit") .long("limit") @@ -3788,6 +3782,12 @@ impl Cli { .required(false) .help("Maximum number of items returned by a single call"), ) + .arg( + clap::Arg::new("pool-name") + .long("pool-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true), + ) .about("List ranges for an IP pool") .long_about("Ranges are ordered by their first address.") } @@ -3804,7 +3804,7 @@ impl Cli { clap::Arg::new("json-body") .long("json-body") .value_name("JSON-FILE") - .required(false) + .required(true) .value_parser(clap::value_parser!(std::path::PathBuf)) .help("Path to a file that contains the full json body."), ) @@ -3829,7 +3829,7 @@ impl Cli { clap::Arg::new("json-body") .long("json-body") .value_name("JSON-FILE") - .required(false) + .required(true) .value_parser(clap::value_parser!(std::path::PathBuf)) .help("Path to a file that contains the full json body."), ) @@ -3865,7 +3865,7 @@ impl Cli { clap::Arg::new("json-body") .long("json-body") .value_name("JSON-FILE") - .required(false) + .required(true) .value_parser(clap::value_parser!(std::path::PathBuf)) .help("Path to a file that contains the full json body."), ) @@ -3884,7 +3884,7 @@ impl Cli { clap::Arg::new("json-body") .long("json-body") .value_name("JSON-FILE") - .required(false) + .required(true) .value_parser(clap::value_parser!(std::path::PathBuf)) .help("Path to a file that contains the full json body."), ) @@ -3899,19 +3899,6 @@ impl Cli { pub fn cli_system_metric() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("metric-name") - .long("metric-name") - .value_parser(clap::builder::TypedValueParser::map( - clap::builder::PossibleValuesParser::new([ - types::SystemMetricName::VirtualDiskSpaceProvisioned.to_string(), - types::SystemMetricName::CpusProvisioned.to_string(), - types::SystemMetricName::RamProvisioned.to_string(), - ]), - |s| types::SystemMetricName::try_from(s).unwrap(), - )) - .required(true), - ) .arg( clap::Arg::new("end-time") .long("end-time") @@ -3933,6 +3920,19 @@ impl Cli { .required(false) .help("Maximum number of items returned by a single call"), ) + .arg( + clap::Arg::new("metric-name") + .long("metric-name") + .value_parser(clap::builder::TypedValueParser::map( + clap::builder::PossibleValuesParser::new([ + types::SystemMetricName::VirtualDiskSpaceProvisioned.to_string(), + types::SystemMetricName::CpusProvisioned.to_string(), + types::SystemMetricName::RamProvisioned.to_string(), + ]), + |s| types::SystemMetricName::try_from(s).unwrap(), + )) + .required(true), + ) .arg( clap::Arg::new("page-token") .long("page-token") @@ -4124,13 +4124,6 @@ impl Cli { pub fn cli_silo_identity_provider_list() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("silo-name") - .long("silo-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The silo's unique name."), - ) .arg( clap::Arg::new("limit") .long("limit") @@ -4138,6 +4131,13 @@ impl Cli { .required(false) .help("Maximum number of items returned by a single call"), ) + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The silo's unique name."), + ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -4154,13 +4154,6 @@ impl Cli { pub fn cli_local_idp_user_create() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("silo-name") - .long("silo-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The silo's unique name."), - ) .arg( clap::Arg::new("external-id") .long("external-id") @@ -4168,6 +4161,13 @@ impl Cli { .required_unless_present("json-body") .help("username used to log in"), ) + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The silo's unique name."), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -4229,7 +4229,7 @@ impl Cli { clap::Arg::new("json-body") .long("json-body") .value_name("JSON-FILE") - .required(false) + .required(true) .value_parser(clap::value_parser!(std::path::PathBuf)) .help("Path to a file that contains the full json body."), ) @@ -4247,13 +4247,6 @@ impl Cli { pub fn cli_saml_identity_provider_create() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("silo-name") - .long("silo-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The silo's unique name."), - ) .arg( clap::Arg::new("acs-url") .long("acs-url") @@ -4291,6 +4284,13 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The silo's unique name."), + ) .arg( clap::Arg::new("slo-url") .long("slo-url") @@ -4331,13 +4331,6 @@ impl Cli { pub fn cli_saml_identity_provider_view() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("silo-name") - .long("silo-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The silo's unique name."), - ) .arg( clap::Arg::new("provider-name") .long("provider-name") @@ -4345,6 +4338,13 @@ impl Cli { .required(true) .help("The SAML identity provider's name"), ) + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The silo's unique name."), + ) .about("Fetch a SAML IDP") } @@ -4388,13 +4388,6 @@ impl Cli { pub fn cli_silo_users_list() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("silo-name") - .long("silo-name") - .value_parser(clap::value_parser!(types::Name)) - .required(true) - .help("The silo's unique name."), - ) .arg( clap::Arg::new("limit") .long("limit") @@ -4402,6 +4395,13 @@ impl Cli { .required(false) .help("Maximum number of items returned by a single call"), ) + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .value_parser(clap::value_parser!(types::Name)) + .required(true) + .help("The silo's unique name."), + ) .arg( clap::Arg::new("sort-by") .long("sort-by") @@ -4544,18 +4544,6 @@ impl Cli { pub fn cli_disk_create_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization") - .long("organization") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(false), - ) - .arg( - clap::Arg::new("project") - .long("project") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("description") .long("description") @@ -4568,6 +4556,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization") + .long("organization") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(false), + ) + .arg( + clap::Arg::new("project") + .long("project") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .arg( clap::Arg::new("size") .long("size") @@ -4677,18 +4677,6 @@ impl Cli { pub fn cli_instance_create_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization") - .long("organization") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(false), - ) - .arg( - clap::Arg::new("project") - .long("project") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("description") .long("description") @@ -4719,6 +4707,18 @@ impl Cli { .value_parser(clap::value_parser!(types::InstanceCpuCount)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization") + .long("organization") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(false), + ) + .arg( + clap::Arg::new("project") + .long("project") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .arg( clap::Arg::new("start") .long("start") @@ -4845,6 +4845,12 @@ impl Cli { pub fn cli_instance_disk_attach_v1() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("disk") + .long("disk") + .value_parser(clap::value_parser!(types::NameOrId)) + .required_unless_present("json-body"), + ) .arg( clap::Arg::new("instance") .long("instance") @@ -4863,12 +4869,6 @@ impl Cli { .value_parser(clap::value_parser!(types::NameOrId)) .required(false), ) - .arg( - clap::Arg::new("disk") - .long("disk") - .value_parser(clap::value_parser!(types::NameOrId)) - .required_unless_present("json-body"), - ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -4888,6 +4888,12 @@ impl Cli { pub fn cli_instance_disk_detach_v1() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("disk") + .long("disk") + .value_parser(clap::value_parser!(types::NameOrId)) + .required_unless_present("json-body"), + ) .arg( clap::Arg::new("instance") .long("instance") @@ -4906,12 +4912,6 @@ impl Cli { .value_parser(clap::value_parser!(types::NameOrId)) .required(false), ) - .arg( - clap::Arg::new("disk") - .long("disk") - .value_parser(clap::value_parser!(types::NameOrId)) - .required_unless_present("json-body"), - ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -4931,6 +4931,12 @@ impl Cli { pub fn cli_instance_migrate_v1() -> clap::Command { clap::Command::new("") + .arg( + clap::Arg::new("dst-sled-id") + .long("dst-sled-id") + .value_parser(clap::value_parser!(uuid::Uuid)) + .required_unless_present("json-body"), + ) .arg( clap::Arg::new("instance") .long("instance") @@ -4949,12 +4955,6 @@ impl Cli { .value_parser(clap::value_parser!(types::NameOrId)) .required(false), ) - .arg( - clap::Arg::new("dst-sled-id") - .long("dst-sled-id") - .value_parser(clap::value_parser!(uuid::Uuid)) - .required_unless_present("json-body"), - ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -4997,12 +4997,6 @@ impl Cli { pub fn cli_instance_serial_console_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("instance") - .long("instance") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("from-start") .long("from-start") @@ -5015,6 +5009,12 @@ impl Cli { must *not* be provided.", ), ) + .arg( + clap::Arg::new("instance") + .long("instance") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .arg( clap::Arg::new("max-bytes") .long("max-bytes") @@ -5190,12 +5190,6 @@ impl Cli { pub fn cli_organization_update_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization") - .long("organization") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("description") .long("description") @@ -5208,6 +5202,12 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(false), ) + .arg( + clap::Arg::new("organization") + .long("organization") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -5305,12 +5305,6 @@ impl Cli { pub fn cli_project_create_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("organization") - .long("organization") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("description") .long("description") @@ -5323,6 +5317,12 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required_unless_present("json-body"), ) + .arg( + clap::Arg::new("organization") + .long("organization") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -5342,35 +5342,23 @@ impl Cli { pub fn cli_project_view_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("project") - .long("project") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("organization") .long("organization") .value_parser(clap::value_parser!(types::NameOrId)) .required(false), ) + .arg( + clap::Arg::new("project") + .long("project") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .about("Fetch a project") } pub fn cli_project_update_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("project") - .long("project") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) - .arg( - clap::Arg::new("organization") - .long("organization") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(false), - ) .arg( clap::Arg::new("description") .long("description") @@ -5383,6 +5371,18 @@ impl Cli { .value_parser(clap::value_parser!(types::Name)) .required(false), ) + .arg( + clap::Arg::new("organization") + .long("organization") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(false), + ) + .arg( + clap::Arg::new("project") + .long("project") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -5402,52 +5402,52 @@ impl Cli { pub fn cli_project_delete_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("project") - .long("project") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("organization") .long("organization") .value_parser(clap::value_parser!(types::NameOrId)) .required(false), ) + .arg( + clap::Arg::new("project") + .long("project") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .about("Delete a project") } pub fn cli_project_policy_view_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("project") - .long("project") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("organization") .long("organization") .value_parser(clap::value_parser!(types::NameOrId)) .required(false), ) + .arg( + clap::Arg::new("project") + .long("project") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .about("Fetch a project's IAM policy") } pub fn cli_project_policy_update_v1() -> clap::Command { clap::Command::new("") - .arg( - clap::Arg::new("project") - .long("project") - .value_parser(clap::value_parser!(types::NameOrId)) - .required(true), - ) .arg( clap::Arg::new("organization") .long("organization") .value_parser(clap::value_parser!(types::NameOrId)) .required(false), ) + .arg( + clap::Arg::new("project") + .long("project") + .value_parser(clap::value_parser!(types::NameOrId)) + .required(true), + ) .arg( clap::Arg::new("json-body") .long("json-body") @@ -6421,16 +6421,16 @@ impl Cli { pub async fn execute_device_auth_request(&self, matches: &clap::ArgMatches) { let mut request = self.client.device_auth_request(); + if let Some(value) = matches.get_one::("client-id") { + request = request.body_map(|body| body.client_id(value.clone())) + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("client-id") { - request = request.body_map(|body| body.client_id(value.clone())) - } - self.over .execute_device_auth_request(matches, &mut request) .unwrap(); @@ -6447,16 +6447,16 @@ impl Cli { pub async fn execute_device_auth_confirm(&self, matches: &clap::ArgMatches) { let mut request = self.client.device_auth_confirm(); + if let Some(value) = matches.get_one::("user-code") { + request = request.body_map(|body| body.user_code(value.clone())) + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("user-code") { - request = request.body_map(|body| body.user_code(value.clone())) - } - self.over .execute_device_auth_confirm(matches, &mut request) .unwrap(); @@ -6473,13 +6473,6 @@ impl Cli { pub async fn execute_device_access_token(&self, matches: &clap::ArgMatches) { let mut request = self.client.device_access_token(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("client-id") { request = request.body_map(|body| body.client_id(value.clone())) } @@ -6492,6 +6485,13 @@ impl Cli { request = request.body_map(|body| body.grant_type(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_device_access_token(matches, &mut request) .unwrap(); @@ -6536,16 +6536,16 @@ impl Cli { pub async fn execute_login_spoof(&self, matches: &clap::ArgMatches) { let mut request = self.client.login_spoof(); + if let Some(value) = matches.get_one::("username") { + request = request.body_map(|body| body.username(value.clone())) + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("username") { - request = request.body_map(|body| body.username(value.clone())) - } - self.over .execute_login_spoof(matches, &mut request) .unwrap(); @@ -6562,25 +6562,25 @@ impl Cli { pub async fn execute_login_local(&self, matches: &clap::ArgMatches) { let mut request = self.client.login_local(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("password") { + request = request.body_map(|body| body.password(value.clone())) } if let Some(value) = matches.get_one::("silo-name") { request = request.silo_name(value.clone()); } - if let Some(value) = matches.get_one::("password") { - request = request.body_map(|body| body.password(value.clone())) - } - if let Some(value) = matches.get_one::("username") { request = request.body_map(|body| body.username(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_login_local(matches, &mut request) .unwrap(); @@ -6597,14 +6597,14 @@ impl Cli { pub async fn execute_login_saml_begin(&self, matches: &clap::ArgMatches) { let mut request = self.client.login_saml_begin(); - if let Some(value) = matches.get_one::("silo-name") { - request = request.silo_name(value.clone()); - } - if let Some(value) = matches.get_one::("provider-name") { request = request.provider_name(value.clone()); } + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + self.over .execute_login_saml_begin(matches, &mut request) .unwrap(); @@ -6621,14 +6621,14 @@ impl Cli { pub async fn execute_login_saml(&self, matches: &clap::ArgMatches) { let mut request = self.client.login_saml(); - if let Some(value) = matches.get_one::("silo-name") { - request = request.silo_name(value.clone()); - } - if let Some(value) = matches.get_one::("provider-name") { request = request.provider_name(value.clone()); } + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + self.over.execute_login_saml(matches, &mut request).unwrap(); let result = request.send().await; match result { @@ -6687,12 +6687,6 @@ impl Cli { pub async fn execute_organization_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.organization_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -6701,6 +6695,12 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_organization_create(matches, &mut request) .unwrap(); @@ -6737,16 +6737,6 @@ impl Cli { pub async fn execute_organization_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.organization_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -6755,6 +6745,16 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_organization_update(matches, &mut request) .unwrap(); @@ -6811,6 +6811,10 @@ impl Cli { pub async fn execute_organization_policy_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.organization_policy_update(); + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = @@ -6818,10 +6822,6 @@ impl Cli { request = request.body(body_value); } - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - self.over .execute_organization_policy_update(matches, &mut request) .unwrap(); @@ -6838,14 +6838,14 @@ impl Cli { pub async fn execute_project_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_list(); - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -6872,16 +6872,6 @@ impl Cli { pub async fn execute_project_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -6890,6 +6880,16 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_project_create(matches, &mut request) .unwrap(); @@ -6930,10 +6930,12 @@ impl Cli { pub async fn execute_project_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -6944,12 +6946,10 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -6992,6 +6992,10 @@ impl Cli { pub async fn execute_disk_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.disk_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7000,10 +7004,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -7028,10 +7028,12 @@ impl Cli { pub async fn execute_disk_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.disk_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -7042,18 +7044,16 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) - } - if let Some(value) = matches.get_one::("size") { request = request.body_map(|body| body.size(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_disk_create(matches, &mut request) .unwrap(); @@ -7070,6 +7070,10 @@ impl Cli { pub async fn execute_disk_view(&self, matches: &clap::ArgMatches) { let mut request = self.client.disk_view(); + if let Some(value) = matches.get_one::("disk-name") { + request = request.disk_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7078,10 +7082,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("disk-name") { - request = request.disk_name(value.clone()); - } - self.over.execute_disk_view(matches, &mut request).unwrap(); let result = request.send().await; match result { @@ -7096,6 +7096,10 @@ impl Cli { pub async fn execute_disk_delete(&self, matches: &clap::ArgMatches) { let mut request = self.client.disk_delete(); + if let Some(value) = matches.get_one::("disk-name") { + request = request.disk_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7104,10 +7108,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("disk-name") { - request = request.disk_name(value.clone()); - } - self.over .execute_disk_delete(matches, &mut request) .unwrap(); @@ -7124,22 +7124,10 @@ impl Cli { pub async fn execute_disk_metrics_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.disk_metrics_list(); - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - if let Some(value) = matches.get_one::("disk-name") { request = request.disk_name(value.clone()); } - if let Some(value) = matches.get_one::("metric-name") { - request = request.metric_name(value.clone()); - } - if let Some(value) = matches.get_one::>("end-time") { request = request.end_time(value.clone()); } @@ -7148,6 +7136,18 @@ impl Cli { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("metric-name") { + request = request.metric_name(value.clone()); + } + + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + if let Some(value) = matches.get_one::>("start-time") { request = request.start_time(value.clone()); @@ -7175,6 +7175,10 @@ impl Cli { pub async fn execute_image_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.image_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7183,10 +7187,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -7211,10 +7211,12 @@ impl Cli { pub async fn execute_image_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.image_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -7225,12 +7227,10 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -7249,6 +7249,10 @@ impl Cli { pub async fn execute_image_view(&self, matches: &clap::ArgMatches) { let mut request = self.client.image_view(); + if let Some(value) = matches.get_one::("image-name") { + request = request.image_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7257,10 +7261,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("image-name") { - request = request.image_name(value.clone()); - } - self.over.execute_image_view(matches, &mut request).unwrap(); let result = request.send().await; match result { @@ -7275,6 +7275,10 @@ impl Cli { pub async fn execute_image_delete(&self, matches: &clap::ArgMatches) { let mut request = self.client.image_delete(); + if let Some(value) = matches.get_one::("image-name") { + request = request.image_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7283,10 +7287,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("image-name") { - request = request.image_name(value.clone()); - } - self.over .execute_image_delete(matches, &mut request) .unwrap(); @@ -7303,6 +7303,10 @@ impl Cli { pub async fn execute_instance_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7311,10 +7315,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -7341,20 +7341,6 @@ impl Cli { pub async fn execute_instance_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -7375,6 +7361,14 @@ impl Cli { request = request.body_map(|body| body.ncpus(value.clone())) } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + if let Some(value) = matches.get_one::("start") { request = request.body_map(|body| body.start(value.clone())) } @@ -7383,6 +7377,12 @@ impl Cli { request = request.body_map(|body| body.user_data(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_instance_create(matches, &mut request) .unwrap(); @@ -7399,6 +7399,10 @@ impl Cli { pub async fn execute_instance_view(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_view(); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7407,10 +7411,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - self.over .execute_instance_view(matches, &mut request) .unwrap(); @@ -7427,6 +7427,10 @@ impl Cli { pub async fn execute_instance_delete(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_delete(); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7435,10 +7439,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - self.over .execute_instance_delete(matches, &mut request) .unwrap(); @@ -7455,14 +7455,6 @@ impl Cli { pub async fn execute_instance_disk_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_disk_list(); - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - if let Some(value) = matches.get_one::("instance-name") { request = request.instance_name(value.clone()); } @@ -7471,6 +7463,14 @@ impl Cli { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -7497,10 +7497,12 @@ impl Cli { pub async fn execute_instance_disk_attach(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_disk_attach(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -7511,12 +7513,10 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -7535,10 +7535,12 @@ impl Cli { pub async fn execute_instance_disk_detach(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_disk_detach(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -7549,12 +7551,10 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -7573,6 +7573,10 @@ impl Cli { pub async fn execute_instance_external_ip_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_external_ip_list(); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7581,10 +7585,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - self.over .execute_instance_external_ip_list(matches, &mut request) .unwrap(); @@ -7601,10 +7601,12 @@ impl Cli { pub async fn execute_instance_migrate(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_migrate(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("dst-sled-id") { + request = request.body_map(|body| body.dst_sled_id(value.clone())) + } + + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); } if let Some(value) = matches.get_one::("organization-name") { @@ -7615,12 +7617,10 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - - if let Some(value) = matches.get_one::("dst-sled-id") { - request = request.body_map(|body| body.dst_sled_id(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -7639,14 +7639,6 @@ impl Cli { pub async fn execute_instance_network_interface_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_network_interface_list(); - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - if let Some(value) = matches.get_one::("instance-name") { request = request.instance_name(value.clone()); } @@ -7655,6 +7647,14 @@ impl Cli { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -7681,29 +7681,14 @@ impl Cli { pub async fn execute_instance_network_interface_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_network_interface_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) } if let Some(value) = matches.get_one::("instance-name") { request = request.instance_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - if let Some(value) = matches.get_one::("ip") { request = request.body_map(|body| body.ip(value.clone())) } @@ -7712,6 +7697,14 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + if let Some(value) = matches.get_one::("subnet-name") { request = request.body_map(|body| body.subnet_name(value.clone())) } @@ -7720,6 +7713,13 @@ impl Cli { request = request.body_map(|body| body.vpc_name(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_instance_network_interface_create(matches, &mut request) .unwrap(); @@ -7736,14 +7736,6 @@ impl Cli { pub async fn execute_instance_network_interface_view(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_network_interface_view(); - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - if let Some(value) = matches.get_one::("instance-name") { request = request.instance_name(value.clone()); } @@ -7752,6 +7744,14 @@ impl Cli { request = request.interface_name(value.clone()); } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + self.over .execute_instance_network_interface_view(matches, &mut request) .unwrap(); @@ -7768,19 +7768,8 @@ impl Cli { pub async fn execute_instance_network_interface_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_network_interface_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) } if let Some(value) = matches.get_one::("instance-name") { @@ -7791,18 +7780,29 @@ impl Cli { request = request.interface_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - if let Some(value) = matches.get_one::("name") { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + if let Some(value) = matches.get_one::("primary") { request = request.body_map(|body| body.primary(value.clone())) } + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_instance_network_interface_update(matches, &mut request) .unwrap(); @@ -7819,14 +7819,6 @@ impl Cli { pub async fn execute_instance_network_interface_delete(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_network_interface_delete(); - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - if let Some(value) = matches.get_one::("instance-name") { request = request.instance_name(value.clone()); } @@ -7835,6 +7827,14 @@ impl Cli { request = request.interface_name(value.clone()); } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + self.over .execute_instance_network_interface_delete(matches, &mut request) .unwrap(); @@ -7851,6 +7851,10 @@ impl Cli { pub async fn execute_instance_reboot(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_reboot(); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7859,10 +7863,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - self.over .execute_instance_reboot(matches, &mut request) .unwrap(); @@ -7879,22 +7879,14 @@ impl Cli { pub async fn execute_instance_serial_console(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_serial_console(); - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); + if let Some(value) = matches.get_one::("from-start") { + request = request.from_start(value.clone()); } if let Some(value) = matches.get_one::("instance-name") { request = request.instance_name(value.clone()); } - if let Some(value) = matches.get_one::("from-start") { - request = request.from_start(value.clone()); - } - if let Some(value) = matches.get_one::("max-bytes") { request = request.max_bytes(value.clone()); } @@ -7903,6 +7895,14 @@ impl Cli { request = request.most_recent(value.clone()); } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + self.over .execute_instance_serial_console(matches, &mut request) .unwrap(); @@ -7919,6 +7919,10 @@ impl Cli { pub async fn execute_instance_serial_console_stream(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_serial_console_stream(); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7927,10 +7931,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - self.over .execute_instance_serial_console_stream(matches, &mut request) .unwrap(); @@ -7947,6 +7947,10 @@ impl Cli { pub async fn execute_instance_start(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_start(); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7955,10 +7959,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - self.over .execute_instance_start(matches, &mut request) .unwrap(); @@ -7975,6 +7975,10 @@ impl Cli { pub async fn execute_instance_stop(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_stop(); + if let Some(value) = matches.get_one::("instance-name") { + request = request.instance_name(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -7983,10 +7987,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("instance-name") { - request = request.instance_name(value.clone()); - } - self.over .execute_instance_stop(matches, &mut request) .unwrap(); @@ -8027,12 +8027,6 @@ impl Cli { pub async fn execute_project_policy_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_policy_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -8041,6 +8035,12 @@ impl Cli { request = request.project_name(value.clone()); } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_project_policy_update(matches, &mut request) .unwrap(); @@ -8057,6 +8057,10 @@ impl Cli { pub async fn execute_snapshot_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.snapshot_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -8065,10 +8069,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -8095,20 +8095,6 @@ impl Cli { pub async fn execute_snapshot_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.snapshot_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -8121,6 +8107,20 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_snapshot_create(matches, &mut request) .unwrap(); @@ -8193,6 +8193,10 @@ impl Cli { pub async fn execute_vpc_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -8201,10 +8205,6 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -8229,20 +8229,6 @@ impl Cli { pub async fn execute_vpc_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -8259,6 +8245,20 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over.execute_vpc_create(matches, &mut request).unwrap(); let result = request.send().await; match result { @@ -8299,10 +8299,16 @@ impl Cli { pub async fn execute_vpc_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("dns-name") { + request = request.body_map(|body| body.dns_name(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -8317,16 +8323,10 @@ impl Cli { request = request.vpc_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - - if let Some(value) = matches.get_one::("dns-name") { - request = request.body_map(|body| body.dns_name(value.clone())) - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over.execute_vpc_update(matches, &mut request).unwrap(); @@ -8397,13 +8397,6 @@ impl Cli { pub async fn execute_vpc_firewall_rules_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_firewall_rules_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -8416,6 +8409,13 @@ impl Cli { request = request.vpc_name(value.clone()); } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_vpc_firewall_rules_update(matches, &mut request) .unwrap(); @@ -8432,6 +8432,10 @@ impl Cli { pub async fn execute_vpc_router_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_router_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -8440,18 +8444,14 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); + } + self.over .execute_vpc_router_list(matches, &mut request) .unwrap(); @@ -8474,10 +8474,12 @@ impl Cli { pub async fn execute_vpc_router_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_router_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -8492,12 +8494,10 @@ impl Cli { request = request.vpc_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -8524,14 +8524,14 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("router-name") { request = request.router_name(value.clone()); } + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); + } + self.over .execute_vpc_router_view(matches, &mut request) .unwrap(); @@ -8548,10 +8548,12 @@ impl Cli { pub async fn execute_vpc_router_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_router_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -8562,20 +8564,18 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("router-name") { request = request.router_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); } - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -8602,14 +8602,14 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("router-name") { request = request.router_name(value.clone()); } + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); + } + self.over .execute_vpc_router_delete(matches, &mut request) .unwrap(); @@ -8626,6 +8626,10 @@ impl Cli { pub async fn execute_vpc_router_route_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_router_route_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -8634,22 +8638,18 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("router-name") { request = request.router_name(value.clone()); } - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); + } + self.over .execute_vpc_router_route_list(matches, &mut request) .unwrap(); @@ -8672,11 +8672,12 @@ impl Cli { pub async fn execute_vpc_router_route_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_router_route_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -8687,20 +8688,19 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("router-name") { request = request.router_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); } - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -8727,16 +8727,16 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); + if let Some(value) = matches.get_one::("route-name") { + request = request.route_name(value.clone()); } if let Some(value) = matches.get_one::("router-name") { request = request.router_name(value.clone()); } - if let Some(value) = matches.get_one::("route-name") { - request = request.route_name(value.clone()); + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); } self.over @@ -8755,11 +8755,12 @@ impl Cli { pub async fn execute_vpc_router_route_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_router_route_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -8770,24 +8771,23 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); + if let Some(value) = matches.get_one::("route-name") { + request = request.route_name(value.clone()); } if let Some(value) = matches.get_one::("router-name") { request = request.router_name(value.clone()); } - if let Some(value) = matches.get_one::("route-name") { - request = request.route_name(value.clone()); + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -8814,16 +8814,16 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); + if let Some(value) = matches.get_one::("route-name") { + request = request.route_name(value.clone()); } if let Some(value) = matches.get_one::("router-name") { request = request.router_name(value.clone()); } - if let Some(value) = matches.get_one::("route-name") { - request = request.route_name(value.clone()); + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); } self.over @@ -8842,6 +8842,10 @@ impl Cli { pub async fn execute_vpc_subnet_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_subnet_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -8850,18 +8854,14 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); + } + self.over .execute_vpc_subnet_list(matches, &mut request) .unwrap(); @@ -8884,24 +8884,6 @@ impl Cli { pub async fn execute_vpc_subnet_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_subnet_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization-name") { - request = request.organization_name(value.clone()); - } - - if let Some(value) = matches.get_one::("project-name") { - request = request.project_name(value.clone()); - } - - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -8918,6 +8900,24 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_vpc_subnet_create(matches, &mut request) .unwrap(); @@ -8942,14 +8942,14 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("subnet-name") { request = request.subnet_name(value.clone()); } + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); + } + self.over .execute_vpc_subnet_view(matches, &mut request) .unwrap(); @@ -8966,10 +8966,12 @@ impl Cli { pub async fn execute_vpc_subnet_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_subnet_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization-name") { @@ -8980,20 +8982,18 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("subnet-name") { request = request.subnet_name(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); } - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -9020,14 +9020,14 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); - } - if let Some(value) = matches.get_one::("subnet-name") { request = request.subnet_name(value.clone()); } + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); + } + self.over .execute_vpc_subnet_delete(matches, &mut request) .unwrap(); @@ -9044,6 +9044,10 @@ impl Cli { pub async fn execute_vpc_subnet_list_network_interfaces(&self, matches: &clap::ArgMatches) { let mut request = self.client.vpc_subnet_list_network_interfaces(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + if let Some(value) = matches.get_one::("organization-name") { request = request.organization_name(value.clone()); } @@ -9052,20 +9056,16 @@ impl Cli { request = request.project_name(value.clone()); } - if let Some(value) = matches.get_one::("vpc-name") { - request = request.vpc_name(value.clone()); + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); } if let Some(value) = matches.get_one::("subnet-name") { request = request.subnet_name(value.clone()); } - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - - if let Some(value) = matches.get_one::("sort-by") { - request = request.sort_by(value.clone()); + if let Some(value) = matches.get_one::("vpc-name") { + request = request.vpc_name(value.clone()); } self.over @@ -9244,12 +9244,6 @@ impl Cli { pub async fn execute_session_sshkey_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.session_sshkey_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -9262,6 +9256,12 @@ impl Cli { request = request.body_map(|body| body.public_key(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_session_sshkey_create(matches, &mut request) .unwrap(); @@ -9408,12 +9408,6 @@ impl Cli { pub async fn execute_certificate_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.certificate_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -9426,6 +9420,12 @@ impl Cli { request = request.body_map(|body| body.service(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_certificate_create(matches, &mut request) .unwrap(); @@ -9604,14 +9604,14 @@ impl Cli { pub async fn execute_sled_physical_disk_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.sled_physical_disk_list(); - if let Some(value) = matches.get_one::("sled-id") { - request = request.sled_id(value.clone()); - } - if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("sled-id") { + request = request.sled_id(value.clone()); + } + if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -9668,12 +9668,6 @@ impl Cli { pub async fn execute_system_image_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.system_image_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -9682,6 +9676,12 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_system_image_create(matches, &mut request) .unwrap(); @@ -9768,12 +9768,6 @@ impl Cli { pub async fn execute_ip_pool_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.ip_pool_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -9782,6 +9776,12 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_ip_pool_create(matches, &mut request) .unwrap(); @@ -9818,16 +9818,6 @@ impl Cli { pub async fn execute_ip_pool_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.ip_pool_update(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("pool-name") { - request = request.pool_name(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -9836,6 +9826,16 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("pool-name") { + request = request.pool_name(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_ip_pool_update(matches, &mut request) .unwrap(); @@ -9872,14 +9872,14 @@ impl Cli { pub async fn execute_ip_pool_range_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.ip_pool_range_list(); - if let Some(value) = matches.get_one::("pool-name") { - request = request.pool_name(value.clone()); - } - if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("pool-name") { + request = request.pool_name(value.clone()); + } + self.over .execute_ip_pool_range_list(matches, &mut request) .unwrap(); @@ -9902,16 +9902,16 @@ impl Cli { pub async fn execute_ip_pool_range_add(&self, matches: &clap::ArgMatches) { let mut request = self.client.ip_pool_range_add(); + if let Some(value) = matches.get_one::("pool-name") { + request = request.pool_name(value.clone()); + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("pool-name") { - request = request.pool_name(value.clone()); - } - self.over .execute_ip_pool_range_add(matches, &mut request) .unwrap(); @@ -9928,16 +9928,16 @@ impl Cli { pub async fn execute_ip_pool_range_remove(&self, matches: &clap::ArgMatches) { let mut request = self.client.ip_pool_range_remove(); + if let Some(value) = matches.get_one::("pool-name") { + request = request.pool_name(value.clone()); + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("pool-name") { - request = request.pool_name(value.clone()); - } - self.over .execute_ip_pool_range_remove(matches, &mut request) .unwrap(); @@ -10040,10 +10040,6 @@ impl Cli { pub async fn execute_system_metric(&self, matches: &clap::ArgMatches) { let mut request = self.client.system_metric(); - if let Some(value) = matches.get_one::("metric-name") { - request = request.metric_name(value.clone()); - } - if let Some(value) = matches.get_one::>("end-time") { request = request.end_time(value.clone()); } @@ -10056,6 +10052,10 @@ impl Cli { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("metric-name") { + request = request.metric_name(value.clone()); + } + if let Some(value) = matches.get_one::("page-token") { request = request.page_token(value.clone()); } @@ -10193,12 +10193,6 @@ impl Cli { pub async fn execute_silo_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.silo_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("admin-group-name") { request = request.body_map(|body| body.admin_group_name(value.clone())) } @@ -10219,6 +10213,12 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_silo_create(matches, &mut request) .unwrap(); @@ -10273,14 +10273,14 @@ impl Cli { pub async fn execute_silo_identity_provider_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.silo_identity_provider_list(); - if let Some(value) = matches.get_one::("silo-name") { - request = request.silo_name(value.clone()); - } - if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -10307,18 +10307,18 @@ impl Cli { pub async fn execute_local_idp_user_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.local_idp_user_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("external-id") { + request = request.body_map(|body| body.external_id(value.clone())) } if let Some(value) = matches.get_one::("silo-name") { request = request.silo_name(value.clone()); } - if let Some(value) = matches.get_one::("external-id") { - request = request.body_map(|body| body.external_id(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -10361,12 +10361,6 @@ impl Cli { pub async fn execute_local_idp_user_set_password(&self, matches: &clap::ArgMatches) { let mut request = self.client.local_idp_user_set_password(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("silo-name") { request = request.silo_name(value.clone()); } @@ -10375,6 +10369,12 @@ impl Cli { request = request.user_id(value.clone()); } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_local_idp_user_set_password(matches, &mut request) .unwrap(); @@ -10391,17 +10391,6 @@ impl Cli { pub async fn execute_saml_identity_provider_create(&self, matches: &clap::ArgMatches) { let mut request = self.client.saml_identity_provider_create(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = - serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("silo-name") { - request = request.silo_name(value.clone()); - } - if let Some(value) = matches.get_one::("acs-url") { request = request.body_map(|body| body.acs_url(value.clone())) } @@ -10422,6 +10411,10 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + if let Some(value) = matches.get_one::("slo-url") { request = request.body_map(|body| body.slo_url(value.clone())) } @@ -10434,6 +10427,13 @@ impl Cli { request = request.body_map(|body| body.technical_contact_email(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = + serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_saml_identity_provider_create(matches, &mut request) .unwrap(); @@ -10450,14 +10450,14 @@ impl Cli { pub async fn execute_saml_identity_provider_view(&self, matches: &clap::ArgMatches) { let mut request = self.client.saml_identity_provider_view(); - if let Some(value) = matches.get_one::("silo-name") { - request = request.silo_name(value.clone()); - } - if let Some(value) = matches.get_one::("provider-name") { request = request.provider_name(value.clone()); } + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + self.over .execute_saml_identity_provider_view(matches, &mut request) .unwrap(); @@ -10494,16 +10494,16 @@ impl Cli { pub async fn execute_silo_policy_update(&self, matches: &clap::ArgMatches) { let mut request = self.client.silo_policy_update(); + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("silo-name") { - request = request.silo_name(value.clone()); - } - self.over .execute_silo_policy_update(matches, &mut request) .unwrap(); @@ -10520,14 +10520,14 @@ impl Cli { pub async fn execute_silo_users_list(&self, matches: &clap::ArgMatches) { let mut request = self.client.silo_users_list(); - if let Some(value) = matches.get_one::("silo-name") { - request = request.silo_name(value.clone()); - } - if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); } + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + if let Some(value) = matches.get_one::("sort-by") { request = request.sort_by(value.clone()); } @@ -10720,10 +10720,12 @@ impl Cli { pub async fn execute_disk_create_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.disk_create_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) } if let Some(value) = matches.get_one::("organization") { @@ -10734,18 +10736,16 @@ impl Cli { request = request.project(value.clone()); } - if let Some(value) = matches.get_one::("description") { - request = request.body_map(|body| body.description(value.clone())) - } - - if let Some(value) = matches.get_one::("name") { - request = request.body_map(|body| body.name(value.clone())) - } - if let Some(value) = matches.get_one::("size") { request = request.body_map(|body| body.size(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_disk_create_v1(matches, &mut request) .unwrap(); @@ -10856,20 +10856,6 @@ impl Cli { pub async fn execute_instance_create_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_create_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization") { - request = request.organization(value.clone()); - } - - if let Some(value) = matches.get_one::("project") { - request = request.project(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -10890,6 +10876,14 @@ impl Cli { request = request.body_map(|body| body.ncpus(value.clone())) } + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + if let Some(value) = matches.get_one::("project") { + request = request.project(value.clone()); + } + if let Some(value) = matches.get_one::("start") { request = request.body_map(|body| body.start(value.clone())) } @@ -10898,6 +10892,12 @@ impl Cli { request = request.body_map(|body| body.user_data(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_instance_create_v1(matches, &mut request) .unwrap(); @@ -11012,10 +11012,8 @@ impl Cli { pub async fn execute_instance_disk_attach_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_disk_attach_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("disk") { + request = request.body_map(|body| body.disk(value.clone())) } if let Some(value) = matches.get_one::("instance") { @@ -11030,8 +11028,10 @@ impl Cli { request = request.project(value.clone()); } - if let Some(value) = matches.get_one::("disk") { - request = request.body_map(|body| body.disk(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -11050,10 +11050,8 @@ impl Cli { pub async fn execute_instance_disk_detach_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_disk_detach_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("disk") { + request = request.body_map(|body| body.disk(value.clone())) } if let Some(value) = matches.get_one::("instance") { @@ -11068,8 +11066,10 @@ impl Cli { request = request.project(value.clone()); } - if let Some(value) = matches.get_one::("disk") { - request = request.body_map(|body| body.disk(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -11088,10 +11088,8 @@ impl Cli { pub async fn execute_instance_migrate_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_migrate_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("dst-sled-id") { + request = request.body_map(|body| body.dst_sled_id(value.clone())) } if let Some(value) = matches.get_one::("instance") { @@ -11106,8 +11104,10 @@ impl Cli { request = request.project(value.clone()); } - if let Some(value) = matches.get_one::("dst-sled-id") { - request = request.body_map(|body| body.dst_sled_id(value.clone())) + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -11154,14 +11154,14 @@ impl Cli { pub async fn execute_instance_serial_console_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_serial_console_v1(); - if let Some(value) = matches.get_one::("instance") { - request = request.instance(value.clone()); - } - if let Some(value) = matches.get_one::("from-start") { request = request.from_start(value.clone()); } + if let Some(value) = matches.get_one::("instance") { + request = request.instance(value.clone()); + } + if let Some(value) = matches.get_one::("max-bytes") { request = request.max_bytes(value.clone()); } @@ -11308,12 +11308,6 @@ impl Cli { pub async fn execute_organization_create_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.organization_create_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -11322,6 +11316,12 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_organization_create_v1(matches, &mut request) .unwrap(); @@ -11358,16 +11358,6 @@ impl Cli { pub async fn execute_organization_update_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.organization_update_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization") { - request = request.organization(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -11376,6 +11366,16 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_organization_update_v1(matches, &mut request) .unwrap(); @@ -11432,6 +11432,10 @@ impl Cli { pub async fn execute_organization_policy_update_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.organization_policy_update_v1(); + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = @@ -11439,10 +11443,6 @@ impl Cli { request = request.body(body_value); } - if let Some(value) = matches.get_one::("organization") { - request = request.organization(value.clone()); - } - self.over .execute_organization_policy_update_v1(matches, &mut request) .unwrap(); @@ -11493,16 +11493,6 @@ impl Cli { pub async fn execute_project_create_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_create_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("organization") { - request = request.organization(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -11511,6 +11501,16 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_project_create_v1(matches, &mut request) .unwrap(); @@ -11527,14 +11527,14 @@ impl Cli { pub async fn execute_project_view_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_view_v1(); - if let Some(value) = matches.get_one::("project") { - request = request.project(value.clone()); - } - if let Some(value) = matches.get_one::("organization") { request = request.organization(value.clone()); } + if let Some(value) = matches.get_one::("project") { + request = request.project(value.clone()); + } + self.over .execute_project_view_v1(matches, &mut request) .unwrap(); @@ -11551,20 +11551,6 @@ impl Cli { pub async fn execute_project_update_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_update_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - if let Some(value) = matches.get_one::("project") { - request = request.project(value.clone()); - } - - if let Some(value) = matches.get_one::("organization") { - request = request.organization(value.clone()); - } - if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) } @@ -11573,6 +11559,20 @@ impl Cli { request = request.body_map(|body| body.name(value.clone())) } + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + if let Some(value) = matches.get_one::("project") { + request = request.project(value.clone()); + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + self.over .execute_project_update_v1(matches, &mut request) .unwrap(); @@ -11589,14 +11589,14 @@ impl Cli { pub async fn execute_project_delete_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_delete_v1(); - if let Some(value) = matches.get_one::("project") { - request = request.project(value.clone()); - } - if let Some(value) = matches.get_one::("organization") { request = request.organization(value.clone()); } + if let Some(value) = matches.get_one::("project") { + request = request.project(value.clone()); + } + self.over .execute_project_delete_v1(matches, &mut request) .unwrap(); @@ -11613,14 +11613,14 @@ impl Cli { pub async fn execute_project_policy_view_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_policy_view_v1(); - if let Some(value) = matches.get_one::("project") { - request = request.project(value.clone()); - } - if let Some(value) = matches.get_one::("organization") { request = request.organization(value.clone()); } + if let Some(value) = matches.get_one::("project") { + request = request.project(value.clone()); + } + self.over .execute_project_policy_view_v1(matches, &mut request) .unwrap(); @@ -11637,18 +11637,18 @@ impl Cli { pub async fn execute_project_policy_update_v1(&self, matches: &clap::ArgMatches) { let mut request = self.client.project_policy_update_v1(); - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); } if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); } - if let Some(value) = matches.get_one::("organization") { - request = request.organization(value.clone()); + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); } self.over @@ -11763,16 +11763,16 @@ impl Cli { pub async fn execute_system_update_start(&self, matches: &clap::ArgMatches) { let mut request = self.client.system_update_start(); + if let Some(value) = matches.get_one::("version") { + request = request.body_map(|body| body.version(value.clone())) + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = serde_json::from_str::(&body_txt).unwrap(); request = request.body(body_value); } - if let Some(value) = matches.get_one::("version") { - request = request.body_map(|body| body.version(value.clone())) - } - self.over .execute_system_update_start(matches, &mut request) .unwrap(); diff --git a/progenitor-impl/tests/output/propolis-server-cli.out b/progenitor-impl/tests/output/propolis-server-cli.out index 7d42f70..6cdb4c0 100644 --- a/progenitor-impl/tests/output/propolis-server-cli.out +++ b/progenitor-impl/tests/output/propolis-server-cli.out @@ -101,7 +101,7 @@ impl Cli { clap::Arg::new("json-body") .long("json-body") .value_name("JSON-FILE") - .required(false) + .required(true) .value_parser(clap::value_parser!(std::path::PathBuf)) .help("Path to a file that contains the full json body."), ) @@ -188,6 +188,10 @@ impl Cli { pub async fn execute_instance_ensure(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_ensure(); + if let Some(value) = matches.get_one::("cloud-init-bytes") { + request = request.body_map(|body| body.cloud_init_bytes(value.clone())) + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = @@ -195,10 +199,6 @@ impl Cli { request = request.body(body_value); } - if let Some(value) = matches.get_one::("cloud-init-bytes") { - request = request.body_map(|body| body.cloud_init_bytes(value.clone())) - } - self.over .execute_instance_ensure(matches, &mut request) .unwrap(); @@ -242,6 +242,10 @@ impl Cli { pub async fn execute_instance_migrate_status(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_migrate_status(); + if let Some(value) = matches.get_one::("migration-id") { + request = request.body_map(|body| body.migration_id(value.clone())) + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = @@ -249,10 +253,6 @@ impl Cli { request = request.body(body_value); } - if let Some(value) = matches.get_one::("migration-id") { - request = request.body_map(|body| body.migration_id(value.clone())) - } - self.over .execute_instance_migrate_status(matches, &mut request) .unwrap(); @@ -308,6 +308,10 @@ impl Cli { pub async fn execute_instance_state_monitor(&self, matches: &clap::ArgMatches) { let mut request = self.client.instance_state_monitor(); + if let Some(value) = matches.get_one::("gen") { + request = request.body_map(|body| body.gen(value.clone())) + } + if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); let body_value = @@ -315,10 +319,6 @@ impl Cli { request = request.body(body_value); } - if let Some(value) = matches.get_one::("gen") { - request = request.body_map(|body| body.gen(value.clone())) - } - self.over .execute_instance_state_monitor(matches, &mut request) .unwrap();