diff --git a/Cargo.lock b/Cargo.lock index 05518219..e81ce38d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2103,7 +2103,7 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "typify" version = "0.0.12-dev" -source = "git+https://github.com/oxidecomputer/typify#3cda314def8e95043f45c172cfb8851e391ef7ad" +source = "git+https://github.com/oxidecomputer/typify#6d77f63b3dc5312cd36549507f941cb5d783600e" dependencies = [ "typify-impl", "typify-macro", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "typify-impl" version = "0.0.12-dev" -source = "git+https://github.com/oxidecomputer/typify#3cda314def8e95043f45c172cfb8851e391ef7ad" +source = "git+https://github.com/oxidecomputer/typify#6d77f63b3dc5312cd36549507f941cb5d783600e" dependencies = [ "heck", "log", @@ -2129,7 +2129,7 @@ dependencies = [ [[package]] name = "typify-macro" version = "0.0.12-dev" -source = "git+https://github.com/oxidecomputer/typify#3cda314def8e95043f45c172cfb8851e391ef7ad" +source = "git+https://github.com/oxidecomputer/typify#6d77f63b3dc5312cd36549507f941cb5d783600e" dependencies = [ "proc-macro2", "quote", diff --git a/progenitor-impl/Cargo.toml b/progenitor-impl/Cargo.toml index 014d011d..3b2acbeb 100644 --- a/progenitor-impl/Cargo.toml +++ b/progenitor-impl/Cargo.toml @@ -32,3 +32,4 @@ expectorate = "1.0" http = "0.2.9" hyper = "0.14.25" serde_yaml = "0.9" +serde_json = "1.0.91" diff --git a/progenitor-impl/src/cli.rs b/progenitor-impl/src/cli.rs new file mode 100644 index 00000000..f79e807d --- /dev/null +++ b/progenitor-impl/src/cli.rs @@ -0,0 +1,538 @@ +// Copyright 2023 Oxide Computer Company + +use heck::ToKebabCase; +use openapiv3::OpenAPI; +use proc_macro2::TokenStream; +use quote::{format_ident, quote}; +use typify::{TypeSpaceImpl, TypeStructPropInfo}; + +use crate::{ + method::{ + OperationParameterKind, OperationParameterType, OperationResponseStatus, + }, + space_out_items, + to_schema::ToSchema, + util::{sanitize, Case}, + validate_openapi, Generator, Result, +}; + +struct CliOperation { + cli_fn: TokenStream, + execute_fn: TokenStream, + cli_trait: TokenStream, + execute_trait: TokenStream, +} + +impl Generator { + pub fn cli_text( + &mut self, + spec: &OpenAPI, + crate_name: &str, + ) -> Result { + let output = self.cli(spec, crate_name)?; + + let content = rustfmt_wrapper::rustfmt_config( + rustfmt_wrapper::config::Config { + format_strings: Some(true), + ..Default::default() + }, + output, + ) + .unwrap(); + + space_out_items(content) + } + + pub fn cli( + &mut self, + spec: &OpenAPI, + crate_name: &str, + ) -> Result { + validate_openapi(spec)?; + + // Convert our components dictionary to schemars + let schemas = spec.components.iter().flat_map(|components| { + components.schemas.iter().map(|(name, ref_or_schema)| { + (name.clone(), ref_or_schema.to_schema()) + }) + }); + + self.type_space.add_ref_types(schemas)?; + + let raw_methods = spec + .paths + .iter() + .flat_map(|(path, ref_or_item)| { + // Exclude externally defined path items. + let item = ref_or_item.as_item().unwrap(); + item.iter().map(move |(method, operation)| { + (path.as_str(), method, operation, &item.parameters) + }) + }) + .map(|(path, method, operation, path_parameters)| { + self.process_operation( + operation, + &spec.components, + path, + method, + path_parameters, + ) + }) + .collect::>>()?; + + let methods = raw_methods + .iter() + .map(|method| self.cli_method(method)) + .collect::>(); + + let ops = methods.iter().map( + |CliOperation { + cli_fn, + execute_fn, + cli_trait: _, + execute_trait: _, + }| { + quote! { + #cli_fn + #execute_fn + } + }, + ); + + let trait_ops = methods.iter().map( + |CliOperation { + cli_fn: _, + execute_fn: _, + cli_trait, + execute_trait, + }| { + quote! { + #cli_trait + #execute_trait + } + }, + ); + + let cli_fns = raw_methods + .iter() + .map(|method| { + format_ident!( + "cli_{}", + sanitize(&method.operation_id, Case::Snake) + ) + }) + .collect::>(); + let execute_fns = raw_methods + .iter() + .map(|method| { + format_ident!( + "execute_{}", + sanitize(&method.operation_id, Case::Snake) + ) + }) + .collect::>(); + + let cli_variants = raw_methods + .iter() + .map(|method| { + format_ident!( + "{}", + sanitize(&method.operation_id, Case::Pascal) + ) + }) + .collect::>(); + + let crate_ident = format_ident!("{}", crate_name); + + let code = quote! { + pub struct Cli { + client: #crate_ident::Client, + } + impl Cli { + pub fn new(client: #crate_ident::Client) -> Self { + Self { client } + } + + #(#ops)* + + pub fn get_command(cmd: CliCommand) -> clap::Command { + match cmd { + #( + CliCommand::#cli_variants => Self::#cli_fns(), + )* + } + } + + pub async fn execute( + &self, + cmd: CliCommand, + matches: &clap::ArgMatches, + ) { + let _ = match cmd { + #( + CliCommand::#cli_variants => { + // TODO ... do something with output + self.#execute_fns(matches).await; + } + )* + }; + } + } + + pub trait CliOverride { + #(#trait_ops)* + } + + #[derive(Copy, Clone, Debug)] + pub enum CliCommand { + #(#cli_variants,)* + } + + impl CliCommand { + pub fn iter() -> impl Iterator { + vec![ + #( + CliCommand::#cli_variants, + )* + ].into_iter() + } + } + + }; + + Ok(code) + } + + fn cli_method( + &mut self, + method: &crate::method::OperationMethod, + ) -> CliOperation { + let fn_name = format_ident!("cli_{}", &method.operation_id); + + 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 required = match ¶m.kind { + OperationParameterKind::Path => true, + OperationParameterKind::Query(required) => *required, + OperationParameterKind::Header(required) => *required, + 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(); + let arg_details = arg_type.details(); + let arg_type_name = match &arg_details{ + typify::TypeDetails::Option(opt_id) => { + let inner_type = self.type_space.get_type(opt_id).unwrap(); + inner_type.ident() + } + _ => { + arg_type.ident() + } + }; + + let help = param.description.as_ref().map(|description| { + quote! { + .help(#description) + } + }); + + quote! { + clap::Arg::new(#arg_name) + .long(#arg_name) + .required(#required) + .value_parser(clap::value_parser!(#arg_type_name)) + #help + } + }); + + let maybe_body_param = 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 body_arg = maybe_body_param.map(|param| { + let OperationParameterType::Type(type_id) = ¶m.typ else { + unreachable!(); + }; + + let body_args = self.type_space.get_type(type_id).unwrap(); + + let body_arg = match body_args.details() { + typify::TypeDetails::Struct(s) => { + s.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(); + let prop_type_ident = prop_type.ident(); + let good = + prop_type.has_impl(TypeSpaceImpl::FromStr); + let prop_name = prop_name.to_kebab_case(); + // assert!(good || !required); + + good.then(|| { + let help = + description.as_ref().map(|description| { + quote! { + .help(#description) + } + }); + quote! { + clap::Arg::new(#prop_name) + .long(#prop_name) + .required(#required) + .value_parser(clap::value_parser!( + #prop_type_ident + )) + #help + } + }) + }) + .collect::>() + } + _ => Vec::new(), + }; + + quote! { + #( + .arg(#body_arg) + )* + } + }); + + // TODO parameter for body as input json (--body-input?) + // TODO parameter to output a body template (--body-template?) + // TODO deal with all parameters? + + let about = method.summary.as_ref().map(|summary| { + let mut about_str = summary.clone(); + if let Some(description) = &method.description { + about_str.push_str("\n\n"); + about_str.push_str(description); + } + + quote! { + .about(#about_str) + } + }); + + let cli_fn = quote! { + pub fn #fn_name() -> clap::Command + { + clap::Command::new("") + #( + .arg(#args) + )* + #body_arg + #about + } + }; + + let cli_trait = quote! { + fn #fn_name(cmd: clap::Command) -> clap::Command { + cmd + } + }; + + let op_name = format_ident!("{}", &method.operation_id); + + let fn_name = format_ident!("execute_{}", &method.operation_id); + + 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(); + + // TODO this really should be simpler. + let arg_details = arg_type.details(); + let arg_type_name = match &arg_details{ + typify::TypeDetails::Option(opt_id) => { + let inner_type = self.type_space.get_type(opt_id).unwrap(); + inner_type.ident() + } + _ => { + 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()); + } + } + }); + + let body_arg = maybe_body_param.map(|param| { + let OperationParameterType::Type(type_id) = ¶m.typ else { + unreachable!(); + }; + + let body_type = self.type_space.get_type(type_id).unwrap(); + let body_type_ident = body_type.ident(); + + let maybe_body_args = match body_type.details() { + typify::TypeDetails::Struct(s) => { + let args = s + .properties_info() + .filter_map(|prop_info| { + let TypeStructPropInfo { + name: prop_name, + description: _, + required: _, + type_id: body_type_id, + } = prop_info; + let prop_type = self + .type_space + .get_type(&body_type_id) + .unwrap(); + let prop_fn = format_ident!( + "{}", + sanitize(prop_name, Case::Snake) + ); + let prop_name = prop_name.to_kebab_case(); + let prop_type_ident = prop_type.ident(); + let good = + prop_type.has_impl(TypeSpaceImpl::FromStr); + // assert!(good || !required); + + good.then(|| { + quote! { + if let Some(value) = + matches.get_one::<#prop_type_ident>( + #prop_name, + ) + { + // clone here in case the arg type + // doesn't impl From<&T> + body = body.#prop_fn( + value.clone(), + ); + } + } + }) + }) + .collect::>(); + Some(args) + } + _ => None, + }; + + maybe_body_args.map(|body_args| { + quote! { + let request = request.body({ + let mut body = #body_type_ident::builder(); + #( #body_args )* + body + }); + } + }) + }); + + let (_, success_type) = self.extract_responses( + method, + OperationResponseStatus::is_success_or_default, + ); + let (_, error_type) = self.extract_responses( + method, + OperationResponseStatus::is_error_or_default, + ); + + let success_output = match success_type { + crate::method::OperationResponseType::Type(_) => { + quote! { println!("success\n{:#?}", r) } + } + crate::method::OperationResponseType::None => { + quote! { println!("success\n{:#?}", r) } + } + crate::method::OperationResponseType::Raw => quote! { todo!() }, + crate::method::OperationResponseType::Upgrade => quote! { todo!() }, + }; + + let error_output = match error_type { + crate::method::OperationResponseType::Type(_) => { + quote! { println!("error\n{:#?}", r) } + } + crate::method::OperationResponseType::None => { + quote! { println!("success\n{:#?}", r) } + } + crate::method::OperationResponseType::Raw => quote! { todo!() }, + crate::method::OperationResponseType::Upgrade => quote! { todo!() }, + }; + + let execute_fn = quote! { + pub async fn #fn_name(&self, matches: &clap::ArgMatches) + // -> + // Result, Error<#error_type>> + { + let mut request = self.client.#op_name(); + #( #args )* + #body_arg + + let result = request.send().await; + + match result { + Ok(r) => { + #success_output + } + Err(r) => { + #error_output + } + } + } + }; + + let execute_trait = quote! { + fn #fn_name( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut() + ) -> Result<(), String> { + Ok(()) + } + }; + + CliOperation { + cli_fn, + execute_fn, + cli_trait, + execute_trait, + } + } +} diff --git a/progenitor-impl/src/lib.rs b/progenitor-impl/src/lib.rs index a0cb0f06..90cd3544 100644 --- a/progenitor-impl/src/lib.rs +++ b/progenitor-impl/src/lib.rs @@ -14,6 +14,7 @@ use crate::to_schema::ToSchema; pub use typify::TypeSpaceImpl as TypeImpl; pub use typify::TypeSpacePatch as TypePatch; +mod cli; mod method; mod template; mod to_schema; @@ -212,15 +213,11 @@ impl Generator { validate_openapi(spec)?; // Convert our components dictionary to schemars - let schemas = spec - .components - .iter() - .flat_map(|components| { - components.schemas.iter().map(|(name, ref_or_schema)| { - (name.clone(), ref_or_schema.to_schema()) - }) + let schemas = spec.components.iter().flat_map(|components| { + components.schemas.iter().map(|(name, ref_or_schema)| { + (name.clone(), ref_or_schema.to_schema()) }) - .collect::>(); + }); self.type_space.add_ref_types(schemas)?; @@ -521,14 +518,7 @@ impl Generator { // Format the file with rustfmt. let content = rustfmt_wrapper::rustfmt_config(config, output).unwrap(); - // Add newlines after end-braces at <= two levels of indentation. - Ok(if cfg!(not(windows)) { - let regex = regex::Regex::new(r#"(})(\n\s{0,8}[^} ])"#).unwrap(); - regex.replace_all(&content, "$1\n$2").to_string() - } else { - let regex = regex::Regex::new(r#"(})(\r\n\s{0,8}[^} ])"#).unwrap(); - regex.replace_all(&content, "$1\r\n$2").to_string() - }) + space_out_items(content) } // TODO deprecate? @@ -545,7 +535,18 @@ impl Generator { } } -fn validate_openapi(spec: &OpenAPI) -> Result<()> { +pub(crate) fn space_out_items(content: String) -> Result { + // Add newlines after end-braces at <= two levels of indentation. + Ok(if cfg!(not(windows)) { + let regex = regex::Regex::new(r#"(})(\n\s{0,8}[^} ])"#).unwrap(); + regex.replace_all(&content, "$1\n$2").to_string() + } else { + let regex = regex::Regex::new(r#"(})(\r\n\s{0,8}[^} ])"#).unwrap(); + regex.replace_all(&content, "$1\r\n$2").to_string() + }) +} + +pub fn validate_openapi(spec: &OpenAPI) -> Result<()> { match spec.openapi.as_str() { "3.0.0" | "3.0.1" | "3.0.2" | "3.0.3" => (), v => { diff --git a/progenitor-impl/src/method.rs b/progenitor-impl/src/method.rs index 03d82da5..9ab4dc91 100644 --- a/progenitor-impl/src/method.rs +++ b/progenitor-impl/src/method.rs @@ -9,7 +9,7 @@ use std::{ use openapiv3::{Components, Parameter, ReferenceOr, Response, StatusCode}; use proc_macro2::TokenStream; use quote::{format_ident, quote, ToTokens}; -use typify::TypeId; +use typify::{TypeId, TypeSpace}; use crate::{ template::PathTemplate, @@ -20,15 +20,15 @@ use crate::{to_schema::ToSchema, util::ReferenceOrExt}; /// The intermediate representation of an operation that will become a method. pub(crate) struct OperationMethod { - operation_id: String, + pub operation_id: String, pub tags: Vec, method: HttpMethod, path: PathTemplate, - summary: Option, - description: Option, - params: Vec, + pub summary: Option, + pub description: Option, + pub params: Vec, responses: Vec, - dropshot_paginated: Option, + pub dropshot_paginated: Option, dropshot_websocket: bool, } @@ -87,28 +87,28 @@ struct BuilderImpl { body: TokenStream, } -struct DropshotPagination { +pub struct DropshotPagination { item: TypeId, } -struct OperationParameter { +pub struct OperationParameter { /// Sanitized parameter name. - name: String, + pub name: String, /// Original parameter name provided by the API. api_name: String, - description: Option, - typ: OperationParameterType, - kind: OperationParameterKind, + pub description: Option, + pub typ: OperationParameterType, + pub kind: OperationParameterKind, } #[derive(Eq, PartialEq)] -enum OperationParameterType { +pub enum OperationParameterType { Type(TypeId), RawBody, } #[derive(Debug, PartialEq, Eq)] -enum OperationParameterKind { +pub enum OperationParameterKind { Path, Query(bool), Header(bool), @@ -116,7 +116,7 @@ enum OperationParameterKind { } #[derive(Debug, PartialEq, Eq)] -enum BodyContentType { +pub enum BodyContentType { OctetStream, Json, FormUrlencoded, @@ -139,7 +139,7 @@ impl FromStr for BodyContentType { } #[derive(Debug)] -struct OperationResponse { +pub(crate) struct OperationResponse { status_code: OperationResponseStatus, typ: OperationResponseType, // TODO this isn't currently used because dropshot doesn't give us a @@ -166,7 +166,7 @@ impl PartialOrd for OperationResponse { } #[derive(Debug, Clone, Eq, PartialEq)] -enum OperationResponseStatus { +pub(crate) enum OperationResponseStatus { Code(u16), Range(u16), Default, @@ -187,7 +187,7 @@ impl OperationResponseStatus { } } - fn is_success_or_default(&self) -> bool { + pub fn is_success_or_default(&self) -> bool { matches!( self, OperationResponseStatus::Default @@ -197,7 +197,7 @@ impl OperationResponseStatus { ) } - fn is_error_or_default(&self) -> bool { + pub fn is_error_or_default(&self) -> bool { matches!( self, OperationResponseStatus::Default @@ -206,7 +206,7 @@ impl OperationResponseStatus { ) } - fn is_default(&self) -> bool { + pub fn is_default(&self) -> bool { matches!(self, OperationResponseStatus::Default) } } @@ -224,13 +224,33 @@ impl PartialOrd for OperationResponseStatus { } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)] -enum OperationResponseType { +pub(crate) enum OperationResponseType { Type(TypeId), None, Raw, Upgrade, } +impl OperationResponseType { + pub fn into_tokens(self, type_space: &TypeSpace) -> TokenStream { + match self { + OperationResponseType::Type(ref type_id) => { + let type_name = type_space.get_type(type_id).unwrap().ident(); + quote! { #type_name } + } + OperationResponseType::None => { + quote! { () } + } + OperationResponseType::Raw => { + quote! { ByteStream } + } + OperationResponseType::Upgrade => { + quote! { reqwest::Upgraded } + } + } + } +} + impl Generator { pub(crate) fn process_operation( &mut self, @@ -730,6 +750,9 @@ impl Generator { Ok(all) } + /// Common code generation between positional and builder interface-styles. + /// Returns a struct with the success and error types and the core body + /// implementation that marshals arguments and executes the request. fn method_sig_body( &self, method: &OperationMethod, @@ -1070,17 +1093,21 @@ impl Generator { }; Ok(MethodSigBody { - success: response_type, - error: error_type, + success: response_type.into_tokens(&self.type_space), + error: error_type.into_tokens(&self.type_space), body: body_impl, }) } - fn extract_responses<'a>( + /// Extract responses that match criteria specified by the `filter`. The + /// result is a `Vec` that enumerates the cases matching + /// the filter, and a `TokenStream` that respresents the generated type for + /// those cases. + pub(crate) fn extract_responses<'a>( &self, method: &'a OperationMethod, filter: fn(&OperationResponseStatus) -> bool, - ) -> (Vec<&'a OperationResponse>, TokenStream) { + ) -> (Vec<&'a OperationResponse>, OperationResponseType) { let mut response_items = method .responses .iter() @@ -1091,22 +1118,20 @@ impl Generator { // If we have a success range and a default, we can pop off the default // since it will never be hit. Note that this is a no-op for error // responses. - { - let len = response_items.len(); - if len >= 2 { - if let ( - OperationResponse { - status_code: OperationResponseStatus::Range(2), - .. - }, - OperationResponse { - status_code: OperationResponseStatus::Default, - .. - }, - ) = (&response_items[len - 2], &response_items[len - 1]) - { - response_items.pop(); - } + let len = response_items.len(); + if len >= 2 { + if let ( + OperationResponse { + status_code: OperationResponseStatus::Range(2), + .. + }, + OperationResponse { + status_code: OperationResponseStatus::Default, + .. + }, + ) = (&response_items[len - 2], &response_items[len - 1]) + { + response_items.pop(); } } @@ -1119,26 +1144,10 @@ impl Generator { // enum type with variants for each of the response types. assert!(response_types.len() <= 1); let response_type = response_types - .iter() + .into_iter() .next() - .map(|typ| match typ { - OperationResponseType::Type(type_id) => { - let type_name = - self.type_space.get_type(type_id).unwrap().ident(); - quote! { #type_name } - } - OperationResponseType::None => { - quote! { () } - } - OperationResponseType::Raw => { - quote! { ByteStream } - } - OperationResponseType::Upgrade => { - quote! { reqwest::Upgraded } - } - }) - // TODO should this be a bytestream? - .unwrap_or_else(|| quote! { () }); + // TODO should this be OperationResponseType::Raw? + .unwrap_or(OperationResponseType::None); (response_items, response_type) } @@ -1271,9 +1280,9 @@ impl Generator { /// } /// ``` /// - /// All parameters are present and all their types are Result or - /// Result, String> for optional parameters. Each parameter also - /// has a corresponding method: + /// All parameters are present and all their types are `Result` + /// or `Result, String>` for optional parameters. Each parameter + /// also has a corresponding method: /// ```ignore /// impl<'a> OperationId<'a> { /// pub fn param_1(self, value: V) @@ -1295,7 +1304,8 @@ impl Generator { /// ``` /// /// The Client's operation_id method simply invokes the builder's new - /// method: + /// method, which assigns an error value to mandatory field and a + /// `Ok(None)` value to optional ones: /// ```ignore /// impl<'a> OperationId<'a> { /// pub fn new(client: &'a super::Client) -> Self { @@ -1309,7 +1319,7 @@ impl Generator { /// ``` /// /// Finally, builders have methods to execute the operation. This simply - /// resolves each parameter with the ? (Try operator). + /// resolves each parameter with the ? (`Try` operator). /// ```ignore /// impl<'a> OperationId<'a> { /// pub fn send(self) -> Result< diff --git a/progenitor-impl/tests/output/buildomat-cli.out b/progenitor-impl/tests/output/buildomat-cli.out new file mode 100644 index 00000000..801c8243 --- /dev/null +++ b/progenitor-impl/tests/output/buildomat-cli.out @@ -0,0 +1,900 @@ +pub struct Cli { + client: sdk::Client, +} + +impl Cli { + pub fn new(client: sdk::Client) -> Self { + Self { client } + } + + pub fn cli_control_hold() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_control_hold(&self, matches: &clap::ArgMatches) { + let mut request = self.client.control_hold(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_control_resume() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_control_resume(&self, matches: &clap::ArgMatches) { + let mut request = self.client.control_resume(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_task_get() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("task") + .long("task") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + pub async fn execute_task_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.task_get(); + if let Some(value) = matches.get_one::("task") { + request = request.task(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_tasks_get() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_tasks_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.tasks_get(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_task_submit() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("script") + .long("script") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + pub async fn execute_task_submit(&self, matches: &clap::ArgMatches) { + let mut request = self.client.task_submit(); + let request = request.body({ + let mut body = types::TaskSubmit::builder(); + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("script") { + body = body.script(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_task_events_get() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("task") + .long("task") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("minseq") + .long("minseq") + .required(false) + .value_parser(clap::value_parser!(u32)), + ) + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_task_outputs_get() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("task") + .long("task") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + pub async fn execute_task_outputs_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.task_outputs_get(); + if let Some(value) = matches.get_one::("task") { + request = request.task(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_task_output_download() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("task") + .long("task") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("output") + .long("output") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_user_create() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + pub async fn execute_user_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.user_create(); + let request = request.body({ + let mut body = types::UserCreate::builder(); + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_whoami() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_whoami(&self, matches: &clap::ArgMatches) { + let mut request = self.client.whoami(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_worker_bootstrap() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("bootstrap") + .long("bootstrap") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("token") + .long("token") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + pub async fn execute_worker_bootstrap(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_bootstrap(); + let request = request.body({ + let mut body = types::WorkerBootstrap::builder(); + if let Some(value) = matches.get_one::("bootstrap") { + body = body.bootstrap(value.clone()); + } + if let Some(value) = matches.get_one::("token") { + body = body.token(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_worker_ping() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_worker_ping(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_ping(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_worker_task_append() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("task") + .long("task") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("payload") + .long("payload") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("stream") + .long("stream") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("time") + .long("time") + .required(true) + .value_parser(clap::value_parser!(chrono::DateTime)), + ) + } + + 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::("task") { + request = request.task(value.clone()); + } + + let request = request.body({ + let mut body = types::WorkerAppendTask::builder(); + if let Some(value) = matches.get_one::("payload") { + body = body.payload(value.clone()); + } + if let Some(value) = matches.get_one::("stream") { + body = body.stream(value.clone()); + } + if let Some(value) = matches.get_one::>("time") { + body = body.time(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_worker_task_upload_chunk() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("task") + .long("task") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + pub async fn execute_worker_task_upload_chunk(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_task_upload_chunk(); + if let Some(value) = matches.get_one::("task") { + request = request.task(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_worker_task_complete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("task") + .long("task") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("failed") + .long("failed") + .required(true) + .value_parser(clap::value_parser!(bool)), + ) + } + + 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::("task") { + request = request.task(value.clone()); + } + + let request = request.body({ + let mut body = types::WorkerCompleteTask::builder(); + if let Some(value) = matches.get_one::("failed") { + body = body.failed(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_worker_task_add_output() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("task") + .long("task") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("path") + .long("path") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("size") + .long("size") + .required(true) + .value_parser(clap::value_parser!(i64)), + ) + } + + 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::("task") { + request = request.task(value.clone()); + } + + let request = request.body({ + let mut body = types::WorkerAddOutput::builder(); + if let Some(value) = matches.get_one::("path") { + body = body.path(value.clone()); + } + if let Some(value) = matches.get_one::("size") { + body = body.size(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_workers_list() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_workers_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.workers_list(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_workers_recycle() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_workers_recycle(&self, matches: &clap::ArgMatches) { + let mut request = self.client.workers_recycle(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn get_command(cmd: CliCommand) -> clap::Command { + match cmd { + CliCommand::ControlHold => Self::cli_control_hold(), + CliCommand::ControlResume => Self::cli_control_resume(), + CliCommand::TaskGet => Self::cli_task_get(), + CliCommand::TasksGet => Self::cli_tasks_get(), + CliCommand::TaskSubmit => Self::cli_task_submit(), + CliCommand::TaskEventsGet => Self::cli_task_events_get(), + CliCommand::TaskOutputsGet => Self::cli_task_outputs_get(), + CliCommand::TaskOutputDownload => Self::cli_task_output_download(), + CliCommand::UserCreate => Self::cli_user_create(), + CliCommand::Whoami => Self::cli_whoami(), + CliCommand::WorkerBootstrap => Self::cli_worker_bootstrap(), + CliCommand::WorkerPing => Self::cli_worker_ping(), + CliCommand::WorkerTaskAppend => Self::cli_worker_task_append(), + CliCommand::WorkerTaskUploadChunk => Self::cli_worker_task_upload_chunk(), + CliCommand::WorkerTaskComplete => Self::cli_worker_task_complete(), + CliCommand::WorkerTaskAddOutput => Self::cli_worker_task_add_output(), + CliCommand::WorkersList => Self::cli_workers_list(), + CliCommand::WorkersRecycle => Self::cli_workers_recycle(), + } + } + + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { + let _ = match cmd { + CliCommand::ControlHold => { + self.execute_control_hold(matches).await; + } + CliCommand::ControlResume => { + self.execute_control_resume(matches).await; + } + CliCommand::TaskGet => { + self.execute_task_get(matches).await; + } + CliCommand::TasksGet => { + self.execute_tasks_get(matches).await; + } + CliCommand::TaskSubmit => { + self.execute_task_submit(matches).await; + } + CliCommand::TaskEventsGet => { + self.execute_task_events_get(matches).await; + } + CliCommand::TaskOutputsGet => { + self.execute_task_outputs_get(matches).await; + } + CliCommand::TaskOutputDownload => { + self.execute_task_output_download(matches).await; + } + CliCommand::UserCreate => { + self.execute_user_create(matches).await; + } + CliCommand::Whoami => { + self.execute_whoami(matches).await; + } + CliCommand::WorkerBootstrap => { + self.execute_worker_bootstrap(matches).await; + } + CliCommand::WorkerPing => { + self.execute_worker_ping(matches).await; + } + CliCommand::WorkerTaskAppend => { + self.execute_worker_task_append(matches).await; + } + CliCommand::WorkerTaskUploadChunk => { + self.execute_worker_task_upload_chunk(matches).await; + } + CliCommand::WorkerTaskComplete => { + self.execute_worker_task_complete(matches).await; + } + CliCommand::WorkerTaskAddOutput => { + self.execute_worker_task_add_output(matches).await; + } + CliCommand::WorkersList => { + self.execute_workers_list(matches).await; + } + CliCommand::WorkersRecycle => { + self.execute_workers_recycle(matches).await; + } + }; + } +} + +pub trait CliOverride { + fn cli_control_hold(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_control_hold( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_control_resume(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_control_resume( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_task_get(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_task_get( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_tasks_get(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_tasks_get( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_task_submit(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_task_submit( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_task_events_get(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_task_events_get( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_task_outputs_get(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_task_outputs_get( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_task_output_download(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_task_output_download( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_user_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_user_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_whoami(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_whoami( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_worker_bootstrap(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_worker_bootstrap( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_worker_ping(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_worker_ping( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_worker_task_append(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_worker_task_append( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_worker_task_upload_chunk(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_worker_task_upload_chunk( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_worker_task_complete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_worker_task_complete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_worker_task_add_output(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_worker_task_add_output( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_workers_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_workers_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_workers_recycle(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_workers_recycle( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } +} + +#[derive(Copy, Clone, Debug)] +pub enum CliCommand { + ControlHold, + ControlResume, + TaskGet, + TasksGet, + TaskSubmit, + TaskEventsGet, + TaskOutputsGet, + TaskOutputDownload, + UserCreate, + Whoami, + WorkerBootstrap, + WorkerPing, + WorkerTaskAppend, + WorkerTaskUploadChunk, + WorkerTaskComplete, + WorkerTaskAddOutput, + WorkersList, + WorkersRecycle, +} + +impl CliCommand { + pub fn iter() -> impl Iterator { + vec![ + CliCommand::ControlHold, + CliCommand::ControlResume, + CliCommand::TaskGet, + CliCommand::TasksGet, + CliCommand::TaskSubmit, + CliCommand::TaskEventsGet, + CliCommand::TaskOutputsGet, + CliCommand::TaskOutputDownload, + CliCommand::UserCreate, + CliCommand::Whoami, + CliCommand::WorkerBootstrap, + CliCommand::WorkerPing, + CliCommand::WorkerTaskAppend, + CliCommand::WorkerTaskUploadChunk, + CliCommand::WorkerTaskComplete, + CliCommand::WorkerTaskAddOutput, + CliCommand::WorkersList, + CliCommand::WorkersRecycle, + ] + .into_iter() + } +} diff --git a/progenitor-impl/tests/output/keeper-cli.out b/progenitor-impl/tests/output/keeper-cli.out new file mode 100644 index 00000000..f5caac09 --- /dev/null +++ b/progenitor-impl/tests/output/keeper-cli.out @@ -0,0 +1,395 @@ +pub struct Cli { + client: sdk::Client, +} + +impl Cli { + pub fn new(client: sdk::Client) -> Self { + Self { client } + } + + pub fn cli_enrol() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("authorization") + .long("authorization") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("Authorization header (bearer token)"), + ) + .arg( + clap::Arg::new("host") + .long("host") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("key") + .long("key") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + pub async fn execute_enrol(&self, matches: &clap::ArgMatches) { + let mut request = self.client.enrol(); + if let Some(value) = matches.get_one::("authorization") { + request = request.authorization(value.clone()); + } + + let request = request.body({ + let mut body = types::EnrolBody::builder(); + if let Some(value) = matches.get_one::("host") { + body = body.host(value.clone()); + } + if let Some(value) = matches.get_one::("key") { + body = body.key(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_global_jobs() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("authorization") + .long("authorization") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("Authorization header (bearer token)"), + ) + } + + pub async fn execute_global_jobs(&self, matches: &clap::ArgMatches) { + let mut request = self.client.global_jobs(); + if let Some(value) = matches.get_one::("authorization") { + request = request.authorization(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_ping() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("authorization") + .long("authorization") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("Authorization header (bearer token)"), + ) + } + + pub async fn execute_ping(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ping(); + if let Some(value) = matches.get_one::("authorization") { + request = request.authorization(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_report_finish() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("authorization") + .long("authorization") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("Authorization header (bearer token)"), + ) + .arg( + clap::Arg::new("duration-millis") + .long("duration-millis") + .required(true) + .value_parser(clap::value_parser!(i32)), + ) + .arg( + clap::Arg::new("end-time") + .long("end-time") + .required(true) + .value_parser(clap::value_parser!(chrono::DateTime)), + ) + .arg( + clap::Arg::new("exit-status") + .long("exit-status") + .required(true) + .value_parser(clap::value_parser!(i32)), + ) + } + + pub async fn execute_report_finish(&self, matches: &clap::ArgMatches) { + let mut request = self.client.report_finish(); + if let Some(value) = matches.get_one::("authorization") { + request = request.authorization(value.clone()); + } + + let request = request.body({ + let mut body = types::ReportFinishBody::builder(); + if let Some(value) = matches.get_one::("duration-millis") { + body = body.duration_millis(value.clone()); + } + if let Some(value) = + matches.get_one::>("end-time") + { + body = body.end_time(value.clone()); + } + if let Some(value) = matches.get_one::("exit-status") { + body = body.exit_status(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_report_output() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("authorization") + .long("authorization") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("Authorization header (bearer token)"), + ) + } + + 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()); + } + + let request = request.body({ + let mut body = types::ReportOutputBody::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn cli_report_start() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("authorization") + .long("authorization") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("Authorization header (bearer token)"), + ) + .arg( + clap::Arg::new("script") + .long("script") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("start-time") + .long("start-time") + .required(true) + .value_parser(clap::value_parser!(chrono::DateTime)), + ) + } + + pub async fn execute_report_start(&self, matches: &clap::ArgMatches) { + let mut request = self.client.report_start(); + if let Some(value) = matches.get_one::("authorization") { + request = request.authorization(value.clone()); + } + + let request = request.body({ + let mut body = types::ReportStartBody::builder(); + if let Some(value) = matches.get_one::("script") { + body = body.script(value.clone()); + } + if let Some(value) = + matches.get_one::>("start-time") + { + body = body.start_time(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn get_command(cmd: CliCommand) -> clap::Command { + match cmd { + CliCommand::Enrol => Self::cli_enrol(), + CliCommand::GlobalJobs => Self::cli_global_jobs(), + CliCommand::Ping => Self::cli_ping(), + CliCommand::ReportFinish => Self::cli_report_finish(), + CliCommand::ReportOutput => Self::cli_report_output(), + CliCommand::ReportStart => Self::cli_report_start(), + } + } + + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { + let _ = match cmd { + CliCommand::Enrol => { + self.execute_enrol(matches).await; + } + CliCommand::GlobalJobs => { + self.execute_global_jobs(matches).await; + } + CliCommand::Ping => { + self.execute_ping(matches).await; + } + CliCommand::ReportFinish => { + self.execute_report_finish(matches).await; + } + CliCommand::ReportOutput => { + self.execute_report_output(matches).await; + } + CliCommand::ReportStart => { + self.execute_report_start(matches).await; + } + }; + } +} + +pub trait CliOverride { + fn cli_enrol(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_enrol( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_global_jobs(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_global_jobs( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ping(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ping( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_report_finish(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_report_finish( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_report_output(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_report_output( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_report_start(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_report_start( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } +} + +#[derive(Copy, Clone, Debug)] +pub enum CliCommand { + Enrol, + GlobalJobs, + Ping, + ReportFinish, + ReportOutput, + ReportStart, +} + +impl CliCommand { + pub fn iter() -> impl Iterator { + vec![ + CliCommand::Enrol, + CliCommand::GlobalJobs, + CliCommand::Ping, + CliCommand::ReportFinish, + CliCommand::ReportOutput, + CliCommand::ReportStart, + ] + .into_iter() + } +} diff --git a/progenitor-impl/tests/output/nexus-cli.out b/progenitor-impl/tests/output/nexus-cli.out new file mode 100644 index 00000000..a018b779 --- /dev/null +++ b/progenitor-impl/tests/output/nexus-cli.out @@ -0,0 +1,12432 @@ +pub struct Cli { + client: sdk::Client, +} + +impl Cli { + pub fn new(client: sdk::Client) -> Self { + Self { client } + } + + pub fn cli_disk_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a disk by id\n\nUse `GET /v1/disks/{disk}` instead") + } + + pub async fn execute_disk_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.disk_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_image_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch an image by id") + } + + pub async fn execute_image_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.image_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch an instance by id") + } + + pub async fn execute_instance_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_network_interface_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a network interface by id") + } + + pub async fn execute_instance_network_interface_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_network_interface_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about( + "Fetch an organization by id\n\nUse `GET /v1/organizations/{organization}` instead", + ) + } + + pub async fn execute_organization_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a project by id\n\nUse `GET /v1/projects/{project}` instead") + } + + pub async fn execute_project_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.project_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_snapshot_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a snapshot by id") + } + + pub async fn execute_snapshot_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.snapshot_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_route_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a route by id") + } + + pub async fn execute_vpc_router_route_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_router_route_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Get a router by id") + } + + pub async fn execute_vpc_router_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_router_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_subnet_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a subnet by id") + } + + pub async fn execute_vpc_subnet_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_subnet_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a VPC") + } + + pub async fn execute_vpc_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_device_auth_request() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("client-id") + .long("client-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about( + "Start an OAuth 2.0 Device Authorization Grant\n\nThis endpoint is designed to be \ + accessed from an *unauthenticated* API client. It generates and records a \ + `device_code` and `user_code` which must be verified and confirmed prior to a \ + token being granted.", + ) + } + + pub async fn execute_device_auth_request(&self, matches: &clap::ArgMatches) { + let mut request = self.client.device_auth_request(); + let request = request.body({ + let mut body = types::DeviceAuthRequest::builder(); + if let Some(value) = matches.get_one::("client-id") { + body = body.client_id(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub fn cli_device_auth_confirm() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("user-code") + .long("user-code") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .about( + "Confirm an OAuth 2.0 Device Authorization Grant\n\nThis endpoint is designed to \ + be accessed by the user agent (browser), not the client requesting the token. So \ + we do not actually return the token here; it will be returned in response to the \ + poll on `/device/token`.", + ) + } + + pub async fn execute_device_auth_confirm(&self, matches: &clap::ArgMatches) { + let mut request = self.client.device_auth_confirm(); + let request = request.body({ + let mut body = types::DeviceAuthVerify::builder(); + if let Some(value) = matches.get_one::("user-code") { + body = body.user_code(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_device_access_token() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("client-id") + .long("client-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .arg( + clap::Arg::new("device-code") + .long("device-code") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("grant-type") + .long("grant-type") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .about( + "Request a device access token\n\nThis endpoint should be polled by the client \ + until the user code is verified and the grant is confirmed.", + ) + } + + pub async fn execute_device_access_token(&self, matches: &clap::ArgMatches) { + let mut request = self.client.device_access_token(); + let request = request.body({ + let mut body = types::DeviceAccessTokenRequest::builder(); + if let Some(value) = matches.get_one::("client-id") { + body = body.client_id(value.clone()); + } + if let Some(value) = matches.get_one::("device-code") { + body = body.device_code(value.clone()); + } + if let Some(value) = matches.get_one::("grant-type") { + body = body.grant_type(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub fn cli_group_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List groups") + } + + pub async fn execute_group_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.group_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_login_spoof() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("username") + .long("username") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + } + + pub async fn execute_login_spoof(&self, matches: &clap::ArgMatches) { + let mut request = self.client.login_spoof(); + let request = request.body({ + let mut body = types::SpoofLoginBody::builder(); + if let Some(value) = matches.get_one::("username") { + body = body.username(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_login_local() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("password") + .long("password") + .required(true) + .value_parser(clap::value_parser!(types::Password)), + ) + .arg( + clap::Arg::new("username") + .long("username") + .required(true) + .value_parser(clap::value_parser!(types::UserId)), + ) + .about("Authenticate a user (i.e., log in) via username and password") + } + + pub async fn execute_login_local(&self, matches: &clap::ArgMatches) { + let mut request = self.client.login_local(); + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + + let request = request.body({ + let mut body = types::UsernamePasswordCredentials::builder(); + if let Some(value) = matches.get_one::("password") { + body = body.password(value.clone()); + } + if let Some(value) = matches.get_one::("username") { + body = body.username(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_login_saml_begin() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("provider-name") + .long("provider-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Prompt user login\n\nEither display a page asking a user for their credentials, \ + or redirect them to their identity provider.", + ) + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_login_saml() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("provider-name") + .long("provider-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Authenticate a user (i.e., log in) via SAML") + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_logout() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_logout(&self, matches: &clap::ArgMatches) { + let mut request = self.client.logout(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about("List organizations\n\nUse `GET /v1/organizations` instead") + } + + pub async fn execute_organization_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create an organization\n\nUse `POST /v1/organizations` instead") + } + + pub async fn execute_organization_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_create(); + let request = request.body({ + let mut body = types::OrganizationCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .about("Fetch an organization\n\nUse `GET /v1/organizations/{organization}` instead") + } + + pub async fn execute_organization_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_view(); + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .about("Update an organization\n\nUse `PUT /v1/organizations/{organization}` instead") + } + + pub async fn execute_organization_update(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_update(); + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + let request = request.body({ + let mut body = types::OrganizationUpdate::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .about( + "Delete an organization\n\nUse `DELETE /v1/organizations/{organization}` instead", + ) + } + + pub async fn execute_organization_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_delete(); + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_policy_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .about( + "Fetch an organization's IAM policy\n\nUse `GET \ + /v1/organizations/{organization}/policy` instead", + ) + } + + pub async fn execute_organization_policy_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_policy_view(); + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_policy_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .about( + "Update an organization's IAM policy\n\nUse `PUT \ + /v1/organizations/{organization}/policy` instead", + ) + } + + 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()); + } + + let request = request.body({ + let mut body = types::OrganizationRolePolicy::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about("List projects\n\nUse `GET /v1/projects` instead") + } + + 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::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create a project\n\nUse `POST /v1/projects` instead") + } + + pub async fn execute_project_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.project_create(); + if let Some(value) = matches.get_one::("organization-name") { + request = request.organization_name(value.clone()); + } + + let request = request.body({ + let mut body = types::ProjectCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .about("Fetch a project\n\nUse `GET /v1/projects/{project}` instead") + } + + pub async fn execute_project_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.project_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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .about("Update a project\n\nUse `PUT /v1/projects/{project}` instead") + } + + pub async fn execute_project_update(&self, matches: &clap::ArgMatches) { + let mut request = self.client.project_update(); + 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()); + } + + let request = request.body({ + let mut body = types::ProjectUpdate::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .about("Delete a project\n\nUse `DELETE /v1/projects/{project}` instead") + } + + pub async fn execute_project_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.project_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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List disks\n\nUse `GET /v1/disks` instead") + } + + pub async fn execute_disk_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.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::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("size") + .long("size") + .required(true) + .value_parser(clap::value_parser!(types::ByteCount)) + .help("total size of the Disk in bytes"), + ) + .about("Use `POST /v1/disks` instead") + } + + pub async fn execute_disk_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.disk_create(); + 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()); + } + + let request = request.body({ + let mut body = types::DiskCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("size") { + body = body.size(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("disk-name") + .long("disk-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch a disk\n\nUse `GET /v1/disks/{disk}` instead") + } + + pub async fn execute_disk_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.disk_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::("disk-name") { + request = request.disk_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("disk-name") + .long("disk-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Use `DELETE /v1/disks/{disk}` instead") + } + + pub async fn execute_disk_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.disk_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::("disk-name") { + request = request.disk_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_metrics_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("disk-name") + .long("disk-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("metric-name") + .long("metric-name") + .required(true) + .value_parser(clap::value_parser!(types::DiskMetricName)), + ) + .arg( + clap::Arg::new("end-time") + .long("end-time") + .required(false) + .value_parser(clap::value_parser!(chrono::DateTime)) + .help("An exclusive end time of metrics."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("start-time") + .long("start-time") + .required(false) + .value_parser(clap::value_parser!(chrono::DateTime)) + .help("An inclusive start time of metrics."), + ) + .about("Fetch disk metrics") + } + + 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()); + } + + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::>("start-time") + { + request = request.start_time(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_image_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about( + "List images\n\nList images in a project. The images are returned sorted by \ + creation date, with the most recent images appearing first.", + ) + } + + pub async fn execute_image_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.image_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::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_image_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create an image\n\nCreate a new image in a project.") + } + + pub async fn execute_image_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.image_create(); + 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()); + } + + let request = request.body({ + let mut body = types::ImageCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_image_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("image-name") + .long("image-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch an image\n\nFetch the details for a specific image in a project.") + } + + pub async fn execute_image_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.image_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::("image-name") { + request = request.image_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_image_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("image-name") + .long("image-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Delete an image\n\nPermanently delete an image from a project. This operation \ + cannot be undone. Any instances in the project using the image will continue to \ + run, however new instances can not be created with this image.", + ) + } + + pub async fn execute_image_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.image_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::("image-name") { + request = request.image_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List instances") + } + + pub async fn execute_instance_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_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::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("hostname") + .long("hostname") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("memory") + .long("memory") + .required(true) + .value_parser(clap::value_parser!(types::ByteCount)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("ncpus") + .long("ncpus") + .required(true) + .value_parser(clap::value_parser!(types::InstanceCpuCount)), + ) + .arg( + clap::Arg::new("start") + .long("start") + .required(false) + .value_parser(clap::value_parser!(bool)) + .help("Should this instance be started upon creation; true by default."), + ) + .arg( + clap::Arg::new("user-data") + .long("user-data") + .required(false) + .value_parser(clap::value_parser!(String)) + .help( + "User data for instance initialization systems (such as cloud-init). Must \ + be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and / \ + characters with padding). Maximum 32 KiB unencoded data.", + ), + ) + .about("Create an instance\n\nUse `POST /v1/instances` instead") + } + + pub async fn execute_instance_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_create(); + 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()); + } + + let request = request.body({ + let mut body = types::InstanceCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("hostname") { + body = body.hostname(value.clone()); + } + if let Some(value) = matches.get_one::("memory") { + body = body.memory(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("ncpus") { + body = body.ncpus(value.clone()); + } + if let Some(value) = matches.get_one::("start") { + body = body.start(value.clone()); + } + if let Some(value) = matches.get_one::("user-data") { + body = body.user_data(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch an instance\n\nUse `GET /v1/instances/{instance}` instead") + } + + pub async fn execute_instance_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Delete an instance") + } + + pub async fn execute_instance_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_disk_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List an instance's disks\n\nUse `GET /v1/instances/{instance}/disks` instead") + } + + 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()); + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_disk_attach() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Attach a disk to an instance\n\nUse `POST /v1/instances/{instance}/disks/attach` \ + instead", + ) + } + + 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::("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()); + } + + let request = request.body({ + let mut body = types::DiskIdentifier::builder(); + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_disk_detach() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Detach a disk from an instance\n\nUse `POST /v1/disks/{disk}/detach` instead") + } + + 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::("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()); + } + + let request = request.body({ + let mut body = types::DiskIdentifier::builder(); + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_external_ip_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("List external IP addresses") + } + + 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::("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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_migrate() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("dst-sled-id") + .long("dst-sled-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Migrate an instance\n\nUse `POST /v1/instances/{instance}/migrate` instead") + } + + pub async fn execute_instance_migrate(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_migrate(); + 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()); + } + + let request = request.body({ + let mut body = types::InstanceMigrate::builder(); + if let Some(value) = matches.get_one::("dst-sled-id") { + body = body.dst_sled_id(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_network_interface_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List network interfaces") + } + + 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()); + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_network_interface_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("subnet-name") + .long("subnet-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The VPC Subnet in which to create the interface."), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The VPC in which to create the interface."), + ) + .about("Create a network interface") + } + + 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::("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()); + } + + let request = request.body({ + let mut body = types::NetworkInterfaceCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("subnet-name") { + body = body.subnet_name(value.clone()); + } + if let Some(value) = matches.get_one::("vpc-name") { + body = body.vpc_name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_network_interface_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("interface-name") + .long("interface-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch a network interface") + } + + 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()); + } + + if let Some(value) = matches.get_one::("interface-name") { + request = request.interface_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_network_interface_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("interface-name") + .long("interface-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("primary") + .long("primary") + .required(false) + .value_parser(clap::value_parser!(bool)) + .help( + "Make a secondary interface the instance's primary interface.\n\nIf \ + applied to a secondary interface, that interface will become the primary \ + on the next reboot of the instance. Note that this may have implications \ + for routing between instances, as the new primary interface will be on a \ + distinct subnet from the previous primary interface.\n\nNote that this \ + can only be used to select a new primary interface for an instance. \ + Requests to change the primary interface into a secondary will return an \ + error.", + ), + ) + .about("Update a network interface") + } + + 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::("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()); + } + + if let Some(value) = matches.get_one::("interface-name") { + request = request.interface_name(value.clone()); + } + + let request = request.body({ + let mut body = types::NetworkInterfaceUpdate::builder(); + if let Some(value) = matches.get_one::("primary") { + body = body.primary(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_network_interface_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("interface-name") + .long("interface-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Delete a network interface\n\nNote that the primary interface for an instance \ + cannot be deleted if there are any secondary interfaces. A new primary interface \ + must be designated first. The primary interface can be deleted if there are no \ + secondary interfaces.", + ) + } + + 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()); + } + + if let Some(value) = matches.get_one::("interface-name") { + request = request.interface_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_reboot() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Reboot an instance\n\nUse `POST /v1/instances/{instance}/reboot` instead") + } + + pub async fn execute_instance_reboot(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_reboot(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_serial_console() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("from-start") + .long("from-start") + .required(false) + .value_parser(clap::value_parser!(u64)) + .help( + "Character index in the serial buffer from which to read, counting the \ + bytes output since instance start. If this is not provided, \ + `most_recent` must be provided, and if this *is* provided, `most_recent` \ + must *not* be provided.", + ), + ) + .arg( + clap::Arg::new("max-bytes") + .long("max-bytes") + .required(false) + .value_parser(clap::value_parser!(u64)) + .help( + "Maximum number of bytes of buffered serial console contents to return. \ + If the requested range runs to the end of the available buffer, the data \ + returned will be shorter than `max_bytes`.", + ), + ) + .arg( + clap::Arg::new("most-recent") + .long("most-recent") + .required(false) + .value_parser(clap::value_parser!(u64)) + .help( + "Character index in the serial buffer from which to read, counting \ + *backward* from the most recently buffered data retrieved from the \ + instance. (See note on `from_start` about mutual exclusivity)", + ), + ) + .about( + "Fetch an instance's serial console\n\nUse `GET \ + /v1/instances/{instance}/serial-console` instead", + ) + } + + 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::("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()); + } + + if let Some(value) = matches.get_one::("most-recent") { + request = request.most_recent(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_serial_console_stream() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Connect to an instance's serial console\n\nUse `GET \ + /v1/instances/{instance}/serial-console/stream` instead", + ) + } + + 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::("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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub fn cli_instance_start() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Boot an instance\n\nUse `POST /v1/instances/{instance}/start` instead") + } + + pub async fn execute_instance_start(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_start(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_stop() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("instance-name") + .long("instance-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Halt an instance\n\nUse `POST /v1/instances/{instance}/stop` instead") + } + + pub async fn execute_instance_stop(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_stop(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_policy_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .about( + "Fetch a project's IAM policy\n\nUse `GET /v1/projects/{project}/policy` instead", + ) + } + + pub async fn execute_project_policy_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.project_policy_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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_policy_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .about("Update a project's IAM policy") + } + + 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::("organization-name") { + request = request.organization_name(value.clone()); + } + + if let Some(value) = matches.get_one::("project-name") { + request = request.project_name(value.clone()); + } + + let request = request.body({ + let mut body = types::ProjectRolePolicy::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_snapshot_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List snapshots") + } + + pub async fn execute_snapshot_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.snapshot_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::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_snapshot_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("disk") + .long("disk") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The name of the disk to be snapshotted"), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create a snapshot\n\nCreates a point-in-time snapshot from a disk.") + } + + pub async fn execute_snapshot_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.snapshot_create(); + 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()); + } + + let request = request.body({ + let mut body = types::SnapshotCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("disk") { + body = body.disk(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_snapshot_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("snapshot-name") + .long("snapshot-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch a snapshot") + } + + pub async fn execute_snapshot_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.snapshot_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::("snapshot-name") { + request = request.snapshot_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_snapshot_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("snapshot-name") + .long("snapshot-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Delete a snapshot") + } + + pub async fn execute_snapshot_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.snapshot_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::("snapshot-name") { + request = request.snapshot_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List VPCs") + } + + pub async fn execute_vpc_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_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::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The organization's unique name."), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The project's unique name within the organization."), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("dns-name") + .long("dns-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create a VPC") + } + + pub async fn execute_vpc_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_create(); + 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()); + } + + let request = request.body({ + let mut body = types::VpcCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("dns-name") { + body = body.dns_name(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch a VPC") + } + + pub async fn execute_vpc_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_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::("vpc-name") { + request = request.vpc_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Update a VPC") + } + + pub async fn execute_vpc_update(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_update(); + 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()); + } + + let request = request.body({ + let mut body = types::VpcUpdate::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Delete a VPC") + } + + pub async fn execute_vpc_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_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::("vpc-name") { + request = request.vpc_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_firewall_rules_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("List firewall rules") + } + + pub async fn execute_vpc_firewall_rules_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_firewall_rules_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::("vpc-name") { + request = request.vpc_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_firewall_rules_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Replace firewall rules") + } + + 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::("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()); + } + + let request = request.body({ + let mut body = types::VpcFirewallRuleUpdateParams::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List routers") + } + + 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::("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::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create a router") + } + + 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::("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()); + } + + let request = request.body({ + let mut body = types::VpcRouterCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("router-name") + .long("router-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Get a router") + } + + pub async fn execute_vpc_router_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_router_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::("vpc-name") { + request = request.vpc_name(value.clone()); + } + + if let Some(value) = matches.get_one::("router-name") { + request = request.router_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("router-name") + .long("router-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Update a router") + } + + 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::("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::("router-name") { + request = request.router_name(value.clone()); + } + + let request = request.body({ + let mut body = types::VpcRouterUpdate::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("router-name") + .long("router-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Delete a router") + } + + pub async fn execute_vpc_router_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_router_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::("vpc-name") { + request = request.vpc_name(value.clone()); + } + + if let Some(value) = matches.get_one::("router-name") { + request = request.router_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_route_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("router-name") + .long("router-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List routes\n\nList the routes associated with a router in a particular VPC.") + } + + 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::("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::("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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_route_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("router-name") + .long("router-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create a router") + } + + 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::("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::("router-name") { + request = request.router_name(value.clone()); + } + + let request = request.body({ + let mut body = types::RouterRouteCreateParams::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_route_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("router-name") + .long("router-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("route-name") + .long("route-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch a route") + } + + pub async fn execute_vpc_router_route_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_router_route_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::("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::("route-name") { + request = request.route_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_route_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("router-name") + .long("router-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("route-name") + .long("route-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Update a route") + } + + 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::("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::("router-name") { + request = request.router_name(value.clone()); + } + + if let Some(value) = matches.get_one::("route-name") { + request = request.route_name(value.clone()); + } + + let request = request.body({ + let mut body = types::RouterRouteUpdateParams::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_router_route_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("router-name") + .long("router-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("route-name") + .long("route-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Delete a route") + } + + pub async fn execute_vpc_router_route_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_router_route_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::("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::("route-name") { + request = request.route_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_subnet_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List subnets") + } + + 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::("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::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_subnet_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("ipv4-block") + .long("ipv4-block") + .required(true) + .value_parser(clap::value_parser!(types::Ipv4Net)) + .help( + "The IPv4 address range for this subnet.\n\nIt must be allocated from an \ + RFC 1918 private address range, and must not overlap with any other \ + existing subnet in the VPC.", + ), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create a subnet") + } + + 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::("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()); + } + + let request = request.body({ + let mut body = types::VpcSubnetCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("ipv4-block") { + body = body.ipv4_block(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_subnet_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("subnet-name") + .long("subnet-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch a subnet") + } + + pub async fn execute_vpc_subnet_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_subnet_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::("vpc-name") { + request = request.vpc_name(value.clone()); + } + + if let Some(value) = matches.get_one::("subnet-name") { + request = request.subnet_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_subnet_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("subnet-name") + .long("subnet-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Update a subnet") + } + + 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::("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::("subnet-name") { + request = request.subnet_name(value.clone()); + } + + let request = request.body({ + let mut body = types::VpcSubnetUpdate::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_subnet_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("subnet-name") + .long("subnet-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Delete a subnet") + } + + pub async fn execute_vpc_subnet_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.vpc_subnet_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::("vpc-name") { + request = request.vpc_name(value.clone()); + } + + if let Some(value) = matches.get_one::("subnet-name") { + request = request.subnet_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_vpc_subnet_list_network_interfaces() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization-name") + .long("organization-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("project-name") + .long("project-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("vpc-name") + .long("vpc-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("subnet-name") + .long("subnet-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List network interfaces") + } + + 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::("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::("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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_policy_view() -> clap::Command { + clap::Command::new("").about("Fetch the current silo's IAM policy") + } + + pub async fn execute_policy_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.policy_view(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_policy_update() -> clap::Command { + clap::Command::new("").about("Update the current silo's IAM policy") + } + + pub async fn execute_policy_update(&self, matches: &clap::ArgMatches) { + let mut request = self.client.policy_update(); + let request = request.body({ + let mut body = types::SiloRolePolicy::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_role_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .about("List built-in roles") + } + + pub async fn execute_role_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.role_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_role_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("role-name") + .long("role-name") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("The built-in role's unique name."), + ) + .about("Fetch a built-in role") + } + + pub async fn execute_role_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.role_view(); + if let Some(value) = matches.get_one::("role-name") { + request = request.role_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_session_me() -> clap::Command { + clap::Command::new("").about("Fetch the user associated with the current session") + } + + pub async fn execute_session_me(&self, matches: &clap::ArgMatches) { + let mut request = self.client.session_me(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_session_me_groups() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("Fetch the silo\u{a0}groups the current user belongs to") + } + + pub async fn execute_session_me_groups(&self, matches: &clap::ArgMatches) { + let mut request = self.client.session_me_groups(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_session_sshkey_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about( + "List SSH public keys\n\nLists SSH public keys for the currently authenticated \ + user.", + ) + } + + pub async fn execute_session_sshkey_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.session_sshkey_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_session_sshkey_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("public-key") + .long("public-key") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("SSH public key, e.g., `\"ssh-ed25519 AAAAC3NzaC...\"`"), + ) + .about( + "Create an SSH public key\n\nCreate an SSH public key for the currently \ + authenticated user.", + ) + } + + pub async fn execute_session_sshkey_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.session_sshkey_create(); + let request = request.body({ + let mut body = types::SshKeyCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("public-key") { + body = body.public_key(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_session_sshkey_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("ssh-key-name") + .long("ssh-key-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Fetch an SSH public key\n\nFetch an SSH public key associated with the currently \ + authenticated user.", + ) + } + + pub async fn execute_session_sshkey_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.session_sshkey_view(); + if let Some(value) = matches.get_one::("ssh-key-name") { + request = request.ssh_key_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_session_sshkey_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("ssh-key-name") + .long("ssh-key-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Delete an SSH public key\n\nDelete an SSH public key associated with the \ + currently authenticated user.", + ) + } + + pub async fn execute_session_sshkey_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.session_sshkey_delete(); + if let Some(value) = matches.get_one::("ssh-key-name") { + request = request.ssh_key_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_image_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a system-wide image by id") + } + + pub async fn execute_system_image_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_image_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch an IP pool by id") + } + + pub async fn execute_ip_pool_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_view_by_id() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a silo by id") + } + + pub async fn execute_silo_view_by_id(&self, matches: &clap::ArgMatches) { + let mut request = self.client.silo_view_by_id(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_certificate_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about( + "List system-wide certificates\n\nReturns a list of all the system-wide \ + certificates. System-wide certificates are returned sorted by creation date, \ + with the most recent certificates appearing first.", + ) + } + + pub async fn execute_certificate_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.certificate_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_certificate_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("service") + .long("service") + .required(true) + .value_parser(clap::value_parser!(types::ServiceUsingCertificate)) + .help("The service using this certificate"), + ) + .about( + "Create a new system-wide x.509 certificate.\n\nThis certificate is automatically \ + used by the Oxide Control plane to serve external connections.", + ) + } + + pub async fn execute_certificate_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.certificate_create(); + let request = request.body({ + let mut body = types::CertificateCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("service") { + body = body.service(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_certificate_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("certificate") + .long("certificate") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Fetch a certificate\n\nReturns the details of a specific certificate") + } + + pub async fn execute_certificate_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.certificate_view(); + if let Some(value) = matches.get_one::("certificate") { + request = request.certificate(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_certificate_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("certificate") + .long("certificate") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about( + "Delete a certificate\n\nPermanently delete a certificate. This operation cannot \ + be undone.", + ) + } + + pub async fn execute_certificate_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.certificate_delete(); + if let Some(value) = matches.get_one::("certificate") { + request = request.certificate(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_physical_disk_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List physical disks") + } + + pub async fn execute_physical_disk_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.physical_disk_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_rack_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List racks") + } + + pub async fn execute_rack_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.rack_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_rack_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("rack-id") + .long("rack-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)) + .help("The rack's unique ID."), + ) + .about("Fetch a rack") + } + + pub async fn execute_rack_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.rack_view(); + if let Some(value) = matches.get_one::("rack-id") { + request = request.rack_id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_sled_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List sleds") + } + + pub async fn execute_sled_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.sled_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_sled_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("sled-id") + .long("sled-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)) + .help("The sled's unique ID."), + ) + .about("Fetch a sled") + } + + pub async fn execute_sled_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.sled_view(); + if let Some(value) = matches.get_one::("sled-id") { + request = request.sled_id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_sled_physical_disk_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("sled-id") + .long("sled-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)) + .help("The sled's unique ID."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List physical disks attached to sleds") + } + + 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::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_image_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about( + "List system-wide images\n\nReturns a list of all the system-wide images. \ + System-wide images are returned sorted by creation date, with the most recent \ + images appearing first.", + ) + } + + pub async fn execute_system_image_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_image_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_image_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Create a system-wide image\n\nCreate a new system-wide image. This image can \ + then be used by any user in any silo as a base for instances.", + ) + } + + pub async fn execute_system_image_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_image_create(); + let request = request.body({ + let mut body = types::GlobalImageCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_image_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("image-name") + .long("image-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Fetch a system-wide image\n\nReturns the details of a specific system-wide image.", + ) + } + + pub async fn execute_system_image_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_image_view(); + if let Some(value) = matches.get_one::("image-name") { + request = request.image_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_image_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("image-name") + .long("image-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about( + "Delete a system-wide image\n\nPermanently delete a system-wide image. This \ + operation cannot be undone. Any instances using the system-wide image will \ + continue to run, however new instances can not be created with this image.", + ) + } + + pub async fn execute_system_image_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_image_delete(); + if let Some(value) = matches.get_one::("image-name") { + request = request.image_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about("List IP pools") + } + + pub async fn execute_ip_pool_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create an IP pool") + } + + pub async fn execute_ip_pool_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_create(); + let request = request.body({ + let mut body = types::IpPoolCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("pool-name") + .long("pool-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Fetch an IP pool") + } + + pub async fn execute_ip_pool_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_view(); + if let Some(value) = matches.get_one::("pool-name") { + request = request.pool_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("pool-name") + .long("pool-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Update an IP Pool") + } + + 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::("pool-name") { + request = request.pool_name(value.clone()); + } + + let request = request.body({ + let mut body = types::IpPoolUpdate::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("pool-name") + .long("pool-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Delete an IP Pool") + } + + pub async fn execute_ip_pool_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_delete(); + if let Some(value) = matches.get_one::("pool-name") { + request = request.pool_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_range_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("pool-name") + .long("pool-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .about("List ranges for an IP pool\n\nRanges are ordered by their first address.") + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_range_add() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("pool-name") + .long("pool-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Add a range to an IP pool") + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_range_remove() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("pool-name") + .long("pool-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Remove a range from an IP pool") + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_service_view() -> clap::Command { + clap::Command::new("").about("Fetch the IP pool used for Oxide services.") + } + + pub async fn execute_ip_pool_service_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_service_view(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_service_range_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .about( + "List ranges for the IP pool used for Oxide services.\n\nRanges are ordered by \ + their first address.", + ) + } + + pub async fn execute_ip_pool_service_range_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_service_range_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_service_range_add() -> clap::Command { + clap::Command::new("").about("Add a range to an IP pool used for Oxide services.") + } + + pub async fn execute_ip_pool_service_range_add(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_service_range_add(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_ip_pool_service_range_remove() -> clap::Command { + clap::Command::new("").about("Remove a range from an IP pool used for Oxide services.") + } + + pub async fn execute_ip_pool_service_range_remove(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_service_range_remove(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_metric() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("metric-name") + .long("metric-name") + .required(true) + .value_parser(clap::value_parser!(types::SystemMetricName)), + ) + .arg( + clap::Arg::new("end-time") + .long("end-time") + .required(false) + .value_parser(clap::value_parser!(chrono::DateTime)) + .help("An exclusive end time of metrics."), + ) + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)) + .help("The UUID of the container being queried"), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("page-token") + .long("page-token") + .required(false) + .value_parser(clap::value_parser!(String)) + .help("Token returned by previous call to retrieve the subsequent page"), + ) + .arg( + clap::Arg::new("start-time") + .long("start-time") + .required(false) + .value_parser(clap::value_parser!(chrono::DateTime)) + .help("An inclusive start time of metrics."), + ) + .about("Access metrics data") + } + + 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()); + } + + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("page-token") { + request = request.page_token(value.clone()); + } + + if let Some(value) = matches.get_one::>("start-time") + { + request = request.start_time(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_policy_view() -> clap::Command { + clap::Command::new("").about("Fetch the top-level IAM policy") + } + + pub async fn execute_system_policy_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_policy_view(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_policy_update() -> clap::Command { + clap::Command::new("").about("Update the top-level IAM policy") + } + + pub async fn execute_system_policy_update(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_policy_update(); + let request = request.body({ + let mut body = types::FleetRolePolicy::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_saga_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List sagas") + } + + pub async fn execute_saga_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.saga_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_saga_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("saga-id") + .long("saga-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a saga") + } + + pub async fn execute_saga_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.saga_view(); + if let Some(value) = matches.get_one::("saga-id") { + request = request.saga_id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about( + "List silos\n\nLists silos that are discoverable based on the current permissions.", + ) + } + + pub async fn execute_silo_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.silo_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("discoverable") + .long("discoverable") + .required(true) + .value_parser(clap::value_parser!(bool)), + ) + .arg( + clap::Arg::new("identity-mode") + .long("identity-mode") + .required(true) + .value_parser(clap::value_parser!(types::SiloIdentityMode)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create a silo") + } + + pub async fn execute_silo_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.silo_create(); + let request = request.body({ + let mut body = types::SiloCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("discoverable") { + body = body.discoverable(value.clone()); + } + if let Some(value) = matches.get_one::("identity-mode") { + body = body.identity_mode(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .about("Fetch a silo\n\nFetch a silo by name.") + } + + pub async fn execute_silo_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.silo_view(); + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .about("Delete a silo\n\nDelete a silo by name.") + } + + pub async fn execute_silo_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.silo_delete(); + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_identity_provider_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List a silo's IDPs") + } + + 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::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_local_idp_user_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .arg( + clap::Arg::new("external-id") + .long("external-id") + .required(true) + .value_parser(clap::value_parser!(types::UserId)) + .help("username used to log in"), + ) + .about( + "Create a user\n\nUsers can only be created in Silos with `provision_type` == \ + `Fixed`. Otherwise, Silo users are just-in-time (JIT) provisioned when a user \ + first logs in using an external Identity Provider.", + ) + } + + 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::("silo-name") { + request = request.silo_name(value.clone()); + } + + let request = request.body({ + let mut body = types::UserCreate::builder(); + if let Some(value) = matches.get_one::("external-id") { + body = body.external_id(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_local_idp_user_delete() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .arg( + clap::Arg::new("user-id") + .long("user-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)) + .help("The user's internal id"), + ) + .about("Delete a user") + } + + pub async fn execute_local_idp_user_delete(&self, matches: &clap::ArgMatches) { + let mut request = self.client.local_idp_user_delete(); + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + + if let Some(value) = matches.get_one::("user-id") { + request = request.user_id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_local_idp_user_set_password() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .arg( + clap::Arg::new("user-id") + .long("user-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)) + .help("The user's internal id"), + ) + .about( + "Set or invalidate a user's password\n\nPasswords can only be updated for users \ + in Silos with identity mode `LocalOnly`.", + ) + } + + 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::("silo-name") { + request = request.silo_name(value.clone()); + } + + if let Some(value) = matches.get_one::("user-id") { + request = request.user_id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_saml_identity_provider_create() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .arg( + clap::Arg::new("acs-url") + .long("acs-url") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("service provider endpoint where the response will be sent"), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("idp-entity-id") + .long("idp-entity-id") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("idp's entity id"), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("slo-url") + .long("slo-url") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("service provider endpoint where the idp should send log out requests"), + ) + .arg( + clap::Arg::new("sp-client-id") + .long("sp-client-id") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("sp's client id"), + ) + .arg( + clap::Arg::new("technical-contact-email") + .long("technical-contact-email") + .required(true) + .value_parser(clap::value_parser!(String)) + .help("customer's technical contact for saml configuration"), + ) + .about("Create a SAML IDP") + } + + 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::("silo-name") { + request = request.silo_name(value.clone()); + } + + let request = request.body({ + let mut body = types::SamlIdentityProviderCreate::builder(); + if let Some(value) = matches.get_one::("acs-url") { + body = body.acs_url(value.clone()); + } + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("idp-entity-id") { + body = body.idp_entity_id(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("slo-url") { + body = body.slo_url(value.clone()); + } + if let Some(value) = matches.get_one::("sp-client-id") { + body = body.sp_client_id(value.clone()); + } + if let Some(value) = matches.get_one::("technical-contact-email") { + body = body.technical_contact_email(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_saml_identity_provider_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .arg( + clap::Arg::new("provider-name") + .long("provider-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The SAML identity provider's name"), + ) + .about("Fetch a SAML IDP") + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_policy_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .about("Fetch a silo's IAM policy") + } + + pub async fn execute_silo_policy_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.silo_policy_view(); + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_policy_update() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .about("Update a silo's IAM policy") + } + + 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()); + } + + let request = request.body({ + let mut body = types::SiloRolePolicy::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_users_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List users in a silo") + } + + 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::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_silo_user_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("silo-name") + .long("silo-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The silo's unique name."), + ) + .arg( + clap::Arg::new("user-id") + .long("user-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)) + .help("The user's internal id"), + ) + .about("Fetch a user") + } + + pub async fn execute_silo_user_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.silo_user_view(); + if let Some(value) = matches.get_one::("silo-name") { + request = request.silo_name(value.clone()); + } + + if let Some(value) = matches.get_one::("user-id") { + request = request.user_id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_user_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameSortMode)), + ) + .about("List built-in users") + } + + pub async fn execute_system_user_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_user_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_user_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("user-name") + .long("user-name") + .required(true) + .value_parser(clap::value_parser!(types::Name)) + .help("The built-in user's unique name."), + ) + .about("Fetch a built-in user") + } + + pub async fn execute_system_user_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_user_view(); + if let Some(value) = matches.get_one::("user-name") { + request = request.user_name(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_timeseries_schema_get() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .about("List timeseries schema") + } + + pub async fn execute_timeseries_schema_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.timeseries_schema_get(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_user_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List users") + } + + pub async fn execute_user_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.user_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_list_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about("List disks") + } + + pub async fn execute_disk_list_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.disk_list_v1(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(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::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_create_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("size") + .long("size") + .required(true) + .value_parser(clap::value_parser!(types::ByteCount)) + .help("total size of the Disk in bytes"), + ) + .about("Create a disk") + } + + 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::("organization") { + request = request.organization(value.clone()); + } + + if let Some(value) = matches.get_one::("project") { + request = request.project(value.clone()); + } + + let request = request.body({ + let mut body = types::DiskCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("size") { + body = body.size(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_view_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("disk") + .long("disk") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Fetch a disk") + } + + pub async fn execute_disk_view_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.disk_view_v1(); + if let Some(value) = matches.get_one::("disk") { + request = request.disk(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_disk_delete_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("disk") + .long("disk") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Delete a disk") + } + + pub async fn execute_disk_delete_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.disk_delete_v1(); + if let Some(value) = matches.get_one::("disk") { + request = request.disk(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_list_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about("List instances") + } + + pub async fn execute_instance_list_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_list_v1(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(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::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_create_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("hostname") + .long("hostname") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("memory") + .long("memory") + .required(true) + .value_parser(clap::value_parser!(types::ByteCount)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .arg( + clap::Arg::new("ncpus") + .long("ncpus") + .required(true) + .value_parser(clap::value_parser!(types::InstanceCpuCount)), + ) + .arg( + clap::Arg::new("start") + .long("start") + .required(false) + .value_parser(clap::value_parser!(bool)) + .help("Should this instance be started upon creation; true by default."), + ) + .arg( + clap::Arg::new("user-data") + .long("user-data") + .required(false) + .value_parser(clap::value_parser!(String)) + .help( + "User data for instance initialization systems (such as cloud-init). Must \ + be a Base64-encoded string, as specified in RFC 4648 § 4 (+ and / \ + characters with padding). Maximum 32 KiB unencoded data.", + ), + ) + .about("Create an instance") + } + + 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::("organization") { + request = request.organization(value.clone()); + } + + if let Some(value) = matches.get_one::("project") { + request = request.project(value.clone()); + } + + let request = request.body({ + let mut body = types::InstanceCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("hostname") { + body = body.hostname(value.clone()); + } + if let Some(value) = matches.get_one::("memory") { + body = body.memory(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + if let Some(value) = matches.get_one::("ncpus") { + body = body.ncpus(value.clone()); + } + if let Some(value) = matches.get_one::("start") { + body = body.start(value.clone()); + } + if let Some(value) = matches.get_one::("user-data") { + body = body.user_data(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_view_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Fetch an instance") + } + + pub async fn execute_instance_view_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_view_v1(); + if let Some(value) = matches.get_one::("instance") { + request = request.instance(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_delete_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Delete an instance") + } + + pub async fn execute_instance_delete_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_delete_v1(); + if let Some(value) = matches.get_one::("instance") { + request = request.instance(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_disk_list_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about("List an instance's disks") + } + + pub async fn execute_instance_disk_list_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_disk_list_v1(); + if let Some(value) = matches.get_one::("instance") { + request = request.instance(value.clone()); + } + + if let Some(value) = matches.get_one::("limit") { + request = request.limit(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::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_disk_attach_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("disk") + .long("disk") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Attach a disk to an instance") + } + + 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::("instance") { + request = request.instance(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()); + } + + let request = request.body({ + let mut body = types::DiskPath::builder(); + if let Some(value) = matches.get_one::("disk") { + body = body.disk(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_disk_detach_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("disk") + .long("disk") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Detach a disk from an instance") + } + + 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::("instance") { + request = request.instance(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()); + } + + let request = request.body({ + let mut body = types::DiskPath::builder(); + if let Some(value) = matches.get_one::("disk") { + body = body.disk(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_migrate_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("dst-sled-id") + .long("dst-sled-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Migrate an instance") + } + + 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::("instance") { + request = request.instance(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()); + } + + let request = request.body({ + let mut body = types::InstanceMigrate::builder(); + if let Some(value) = matches.get_one::("dst-sled-id") { + body = body.dst_sled_id(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_reboot_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Reboot an instance") + } + + pub async fn execute_instance_reboot_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_reboot_v1(); + if let Some(value) = matches.get_one::("instance") { + request = request.instance(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_serial_console_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("from-start") + .long("from-start") + .required(false) + .value_parser(clap::value_parser!(u64)) + .help( + "Character index in the serial buffer from which to read, counting the \ + bytes output since instance start. If this is not provided, \ + `most_recent` must be provided, and if this *is* provided, `most_recent` \ + must *not* be provided.", + ), + ) + .arg( + clap::Arg::new("max-bytes") + .long("max-bytes") + .required(false) + .value_parser(clap::value_parser!(u64)) + .help( + "Maximum number of bytes of buffered serial console contents to return. \ + If the requested range runs to the end of the available buffer, the data \ + returned will be shorter than `max_bytes`.", + ), + ) + .arg( + clap::Arg::new("most-recent") + .long("most-recent") + .required(false) + .value_parser(clap::value_parser!(u64)) + .help( + "Character index in the serial buffer from which to read, counting \ + *backward* from the most recently buffered data retrieved from the \ + instance. (See note on `from_start` about mutual exclusivity)", + ), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Fetch an instance's serial console") + } + + 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::("max-bytes") { + request = request.max_bytes(value.clone()); + } + + if let Some(value) = matches.get_one::("most-recent") { + request = request.most_recent(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_serial_console_stream_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Stream an instance's serial console") + } + + pub async fn execute_instance_serial_console_stream_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_serial_console_stream_v1(); + if let Some(value) = matches.get_one::("instance") { + request = request.instance(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub fn cli_instance_start_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Boot an instance") + } + + pub async fn execute_instance_start_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_start_v1(); + if let Some(value) = matches.get_one::("instance") { + request = request.instance(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_stop_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("instance") + .long("instance") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("project") + .long("project") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Stop an instance") + } + + pub async fn execute_instance_stop_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_stop_v1(); + if let Some(value) = matches.get_one::("instance") { + request = request.instance(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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_list_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about("List organizations") + } + + pub async fn execute_organization_list_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_list_v1(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_create_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create an organization") + } + + pub async fn execute_organization_create_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_create_v1(); + let request = request.body({ + let mut body = types::OrganizationCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_view_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization") + .long("organization") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Fetch an organization") + } + + pub async fn execute_organization_view_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_view_v1(); + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_update_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization") + .long("organization") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Update an organization") + } + + 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::("organization") { + request = request.organization(value.clone()); + } + + let request = request.body({ + let mut body = types::OrganizationUpdate::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_delete_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization") + .long("organization") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Delete an organization") + } + + pub async fn execute_organization_delete_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_delete_v1(); + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_policy_view_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization") + .long("organization") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Fetch an organization's IAM policy") + } + + pub async fn execute_organization_policy_view_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_policy_view_v1(); + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_organization_policy_update_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization") + .long("organization") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Update an organization's IAM policy") + } + + 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()); + } + + let request = request.body({ + let mut body = types::OrganizationRolePolicy::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_list_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::NameOrIdSortMode)), + ) + .about("List projects") + } + + pub async fn execute_project_list_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.project_list_v1(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + if let Some(value) = matches.get_one::("sort-by") { + request = request.sort_by(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_create_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("organization") + .long("organization") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("description") + .long("description") + .required(true) + .value_parser(clap::value_parser!(String)), + ) + .arg( + clap::Arg::new("name") + .long("name") + .required(true) + .value_parser(clap::value_parser!(types::Name)), + ) + .about("Create a project") + } + + 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::("organization") { + request = request.organization(value.clone()); + } + + let request = request.body({ + let mut body = types::ProjectCreate::builder(); + if let Some(value) = matches.get_one::("description") { + body = body.description(value.clone()); + } + if let Some(value) = matches.get_one::("name") { + body = body.name(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_view_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("project") + .long("project") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Fetch a project") + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_update_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("project") + .long("project") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Update a project") + } + + 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::("project") { + request = request.project(value.clone()); + } + + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + let request = request.body({ + let mut body = types::ProjectUpdate::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_delete_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("project") + .long("project") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Delete a project") + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_policy_view_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("project") + .long("project") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Fetch a project's IAM policy") + } + + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_project_policy_update_v1() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("project") + .long("project") + .required(true) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .arg( + clap::Arg::new("organization") + .long("organization") + .required(false) + .value_parser(clap::value_parser!(types::NameOrId)), + ) + .about("Update a project's IAM policy") + } + + 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::("project") { + request = request.project(value.clone()); + } + + if let Some(value) = matches.get_one::("organization") { + request = request.organization(value.clone()); + } + + let request = request.body({ + let mut body = types::ProjectRolePolicy::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_component_version_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("View version and update status of component tree") + } + + pub async fn execute_system_component_version_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_component_version_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_update_deployments_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List all update deployments") + } + + pub async fn execute_update_deployments_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.update_deployments_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_update_deployment_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Fetch a system update deployment") + } + + pub async fn execute_update_deployment_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.update_deployment_view(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_update_refresh() -> clap::Command { + clap::Command::new("").about("Refresh update data") + } + + pub async fn execute_system_update_refresh(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_refresh(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_update_start() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("version") + .long("version") + .required(true) + .value_parser(clap::value_parser!(types::SemverVersion)), + ) + .about("Start system update") + } + + pub async fn execute_system_update_start(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_start(); + let request = request.body({ + let mut body = types::SystemUpdateStart::builder(); + if let Some(value) = matches.get_one::("version") { + body = body.version(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_update_stop() -> clap::Command { + clap::Command::new("") + .about("Stop system update\n\nIf there is no update in progress, do nothing.") + } + + pub async fn execute_system_update_stop(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_stop(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_update_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .required(false) + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .help("Maximum number of items returned by a single call"), + ) + .arg( + clap::Arg::new("sort-by") + .long("sort-by") + .required(false) + .value_parser(clap::value_parser!(types::IdSortMode)), + ) + .about("List all updates") + } + + pub async fn execute_system_update_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_list(); + 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()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_update_view() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("version") + .long("version") + .required(true) + .value_parser(clap::value_parser!(types::SemverVersion)), + ) + .about("View system update") + } + + pub async fn execute_system_update_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_view(); + if let Some(value) = matches.get_one::("version") { + request = request.version(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_update_components_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("version") + .long("version") + .required(true) + .value_parser(clap::value_parser!(types::SemverVersion)), + ) + .about("View system update component tree") + } + + pub async fn execute_system_update_components_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_components_list(); + if let Some(value) = matches.get_one::("version") { + request = request.version(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_system_version() -> clap::Command { + clap::Command::new("").about("View system version and update status") + } + + pub async fn execute_system_version(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_version(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn get_command(cmd: CliCommand) -> clap::Command { + match cmd { + CliCommand::DiskViewById => Self::cli_disk_view_by_id(), + CliCommand::ImageViewById => Self::cli_image_view_by_id(), + CliCommand::InstanceViewById => Self::cli_instance_view_by_id(), + CliCommand::InstanceNetworkInterfaceViewById => { + Self::cli_instance_network_interface_view_by_id() + } + CliCommand::OrganizationViewById => Self::cli_organization_view_by_id(), + CliCommand::ProjectViewById => Self::cli_project_view_by_id(), + CliCommand::SnapshotViewById => Self::cli_snapshot_view_by_id(), + CliCommand::VpcRouterRouteViewById => Self::cli_vpc_router_route_view_by_id(), + CliCommand::VpcRouterViewById => Self::cli_vpc_router_view_by_id(), + CliCommand::VpcSubnetViewById => Self::cli_vpc_subnet_view_by_id(), + CliCommand::VpcViewById => Self::cli_vpc_view_by_id(), + CliCommand::DeviceAuthRequest => Self::cli_device_auth_request(), + CliCommand::DeviceAuthConfirm => Self::cli_device_auth_confirm(), + CliCommand::DeviceAccessToken => Self::cli_device_access_token(), + CliCommand::GroupList => Self::cli_group_list(), + CliCommand::LoginSpoof => Self::cli_login_spoof(), + CliCommand::LoginLocal => Self::cli_login_local(), + CliCommand::LoginSamlBegin => Self::cli_login_saml_begin(), + CliCommand::LoginSaml => Self::cli_login_saml(), + CliCommand::Logout => Self::cli_logout(), + CliCommand::OrganizationList => Self::cli_organization_list(), + CliCommand::OrganizationCreate => Self::cli_organization_create(), + CliCommand::OrganizationView => Self::cli_organization_view(), + CliCommand::OrganizationUpdate => Self::cli_organization_update(), + CliCommand::OrganizationDelete => Self::cli_organization_delete(), + CliCommand::OrganizationPolicyView => Self::cli_organization_policy_view(), + CliCommand::OrganizationPolicyUpdate => Self::cli_organization_policy_update(), + CliCommand::ProjectList => Self::cli_project_list(), + CliCommand::ProjectCreate => Self::cli_project_create(), + CliCommand::ProjectView => Self::cli_project_view(), + CliCommand::ProjectUpdate => Self::cli_project_update(), + CliCommand::ProjectDelete => Self::cli_project_delete(), + CliCommand::DiskList => Self::cli_disk_list(), + CliCommand::DiskCreate => Self::cli_disk_create(), + CliCommand::DiskView => Self::cli_disk_view(), + CliCommand::DiskDelete => Self::cli_disk_delete(), + CliCommand::DiskMetricsList => Self::cli_disk_metrics_list(), + CliCommand::ImageList => Self::cli_image_list(), + CliCommand::ImageCreate => Self::cli_image_create(), + CliCommand::ImageView => Self::cli_image_view(), + CliCommand::ImageDelete => Self::cli_image_delete(), + CliCommand::InstanceList => Self::cli_instance_list(), + CliCommand::InstanceCreate => Self::cli_instance_create(), + CliCommand::InstanceView => Self::cli_instance_view(), + CliCommand::InstanceDelete => Self::cli_instance_delete(), + CliCommand::InstanceDiskList => Self::cli_instance_disk_list(), + CliCommand::InstanceDiskAttach => Self::cli_instance_disk_attach(), + CliCommand::InstanceDiskDetach => Self::cli_instance_disk_detach(), + CliCommand::InstanceExternalIpList => Self::cli_instance_external_ip_list(), + CliCommand::InstanceMigrate => Self::cli_instance_migrate(), + CliCommand::InstanceNetworkInterfaceList => Self::cli_instance_network_interface_list(), + CliCommand::InstanceNetworkInterfaceCreate => { + Self::cli_instance_network_interface_create() + } + CliCommand::InstanceNetworkInterfaceView => Self::cli_instance_network_interface_view(), + CliCommand::InstanceNetworkInterfaceUpdate => { + Self::cli_instance_network_interface_update() + } + CliCommand::InstanceNetworkInterfaceDelete => { + Self::cli_instance_network_interface_delete() + } + CliCommand::InstanceReboot => Self::cli_instance_reboot(), + CliCommand::InstanceSerialConsole => Self::cli_instance_serial_console(), + CliCommand::InstanceSerialConsoleStream => Self::cli_instance_serial_console_stream(), + CliCommand::InstanceStart => Self::cli_instance_start(), + CliCommand::InstanceStop => Self::cli_instance_stop(), + CliCommand::ProjectPolicyView => Self::cli_project_policy_view(), + CliCommand::ProjectPolicyUpdate => Self::cli_project_policy_update(), + CliCommand::SnapshotList => Self::cli_snapshot_list(), + CliCommand::SnapshotCreate => Self::cli_snapshot_create(), + CliCommand::SnapshotView => Self::cli_snapshot_view(), + CliCommand::SnapshotDelete => Self::cli_snapshot_delete(), + CliCommand::VpcList => Self::cli_vpc_list(), + CliCommand::VpcCreate => Self::cli_vpc_create(), + CliCommand::VpcView => Self::cli_vpc_view(), + CliCommand::VpcUpdate => Self::cli_vpc_update(), + CliCommand::VpcDelete => Self::cli_vpc_delete(), + CliCommand::VpcFirewallRulesView => Self::cli_vpc_firewall_rules_view(), + CliCommand::VpcFirewallRulesUpdate => Self::cli_vpc_firewall_rules_update(), + CliCommand::VpcRouterList => Self::cli_vpc_router_list(), + CliCommand::VpcRouterCreate => Self::cli_vpc_router_create(), + CliCommand::VpcRouterView => Self::cli_vpc_router_view(), + CliCommand::VpcRouterUpdate => Self::cli_vpc_router_update(), + CliCommand::VpcRouterDelete => Self::cli_vpc_router_delete(), + CliCommand::VpcRouterRouteList => Self::cli_vpc_router_route_list(), + CliCommand::VpcRouterRouteCreate => Self::cli_vpc_router_route_create(), + CliCommand::VpcRouterRouteView => Self::cli_vpc_router_route_view(), + CliCommand::VpcRouterRouteUpdate => Self::cli_vpc_router_route_update(), + CliCommand::VpcRouterRouteDelete => Self::cli_vpc_router_route_delete(), + CliCommand::VpcSubnetList => Self::cli_vpc_subnet_list(), + CliCommand::VpcSubnetCreate => Self::cli_vpc_subnet_create(), + CliCommand::VpcSubnetView => Self::cli_vpc_subnet_view(), + CliCommand::VpcSubnetUpdate => Self::cli_vpc_subnet_update(), + CliCommand::VpcSubnetDelete => Self::cli_vpc_subnet_delete(), + CliCommand::VpcSubnetListNetworkInterfaces => { + Self::cli_vpc_subnet_list_network_interfaces() + } + CliCommand::PolicyView => Self::cli_policy_view(), + CliCommand::PolicyUpdate => Self::cli_policy_update(), + CliCommand::RoleList => Self::cli_role_list(), + CliCommand::RoleView => Self::cli_role_view(), + CliCommand::SessionMe => Self::cli_session_me(), + CliCommand::SessionMeGroups => Self::cli_session_me_groups(), + CliCommand::SessionSshkeyList => Self::cli_session_sshkey_list(), + CliCommand::SessionSshkeyCreate => Self::cli_session_sshkey_create(), + CliCommand::SessionSshkeyView => Self::cli_session_sshkey_view(), + CliCommand::SessionSshkeyDelete => Self::cli_session_sshkey_delete(), + CliCommand::SystemImageViewById => Self::cli_system_image_view_by_id(), + CliCommand::IpPoolViewById => Self::cli_ip_pool_view_by_id(), + CliCommand::SiloViewById => Self::cli_silo_view_by_id(), + CliCommand::CertificateList => Self::cli_certificate_list(), + CliCommand::CertificateCreate => Self::cli_certificate_create(), + CliCommand::CertificateView => Self::cli_certificate_view(), + CliCommand::CertificateDelete => Self::cli_certificate_delete(), + CliCommand::PhysicalDiskList => Self::cli_physical_disk_list(), + CliCommand::RackList => Self::cli_rack_list(), + CliCommand::RackView => Self::cli_rack_view(), + CliCommand::SledList => Self::cli_sled_list(), + CliCommand::SledView => Self::cli_sled_view(), + CliCommand::SledPhysicalDiskList => Self::cli_sled_physical_disk_list(), + CliCommand::SystemImageList => Self::cli_system_image_list(), + CliCommand::SystemImageCreate => Self::cli_system_image_create(), + CliCommand::SystemImageView => Self::cli_system_image_view(), + CliCommand::SystemImageDelete => Self::cli_system_image_delete(), + CliCommand::IpPoolList => Self::cli_ip_pool_list(), + CliCommand::IpPoolCreate => Self::cli_ip_pool_create(), + CliCommand::IpPoolView => Self::cli_ip_pool_view(), + CliCommand::IpPoolUpdate => Self::cli_ip_pool_update(), + CliCommand::IpPoolDelete => Self::cli_ip_pool_delete(), + CliCommand::IpPoolRangeList => Self::cli_ip_pool_range_list(), + CliCommand::IpPoolRangeAdd => Self::cli_ip_pool_range_add(), + CliCommand::IpPoolRangeRemove => Self::cli_ip_pool_range_remove(), + CliCommand::IpPoolServiceView => Self::cli_ip_pool_service_view(), + CliCommand::IpPoolServiceRangeList => Self::cli_ip_pool_service_range_list(), + CliCommand::IpPoolServiceRangeAdd => Self::cli_ip_pool_service_range_add(), + CliCommand::IpPoolServiceRangeRemove => Self::cli_ip_pool_service_range_remove(), + CliCommand::SystemMetric => Self::cli_system_metric(), + CliCommand::SystemPolicyView => Self::cli_system_policy_view(), + CliCommand::SystemPolicyUpdate => Self::cli_system_policy_update(), + CliCommand::SagaList => Self::cli_saga_list(), + CliCommand::SagaView => Self::cli_saga_view(), + CliCommand::SiloList => Self::cli_silo_list(), + CliCommand::SiloCreate => Self::cli_silo_create(), + CliCommand::SiloView => Self::cli_silo_view(), + CliCommand::SiloDelete => Self::cli_silo_delete(), + CliCommand::SiloIdentityProviderList => Self::cli_silo_identity_provider_list(), + CliCommand::LocalIdpUserCreate => Self::cli_local_idp_user_create(), + CliCommand::LocalIdpUserDelete => Self::cli_local_idp_user_delete(), + CliCommand::LocalIdpUserSetPassword => Self::cli_local_idp_user_set_password(), + CliCommand::SamlIdentityProviderCreate => Self::cli_saml_identity_provider_create(), + CliCommand::SamlIdentityProviderView => Self::cli_saml_identity_provider_view(), + CliCommand::SiloPolicyView => Self::cli_silo_policy_view(), + CliCommand::SiloPolicyUpdate => Self::cli_silo_policy_update(), + CliCommand::SiloUsersList => Self::cli_silo_users_list(), + CliCommand::SiloUserView => Self::cli_silo_user_view(), + CliCommand::SystemUserList => Self::cli_system_user_list(), + CliCommand::SystemUserView => Self::cli_system_user_view(), + CliCommand::TimeseriesSchemaGet => Self::cli_timeseries_schema_get(), + CliCommand::UserList => Self::cli_user_list(), + CliCommand::DiskListV1 => Self::cli_disk_list_v1(), + CliCommand::DiskCreateV1 => Self::cli_disk_create_v1(), + CliCommand::DiskViewV1 => Self::cli_disk_view_v1(), + CliCommand::DiskDeleteV1 => Self::cli_disk_delete_v1(), + CliCommand::InstanceListV1 => Self::cli_instance_list_v1(), + CliCommand::InstanceCreateV1 => Self::cli_instance_create_v1(), + CliCommand::InstanceViewV1 => Self::cli_instance_view_v1(), + CliCommand::InstanceDeleteV1 => Self::cli_instance_delete_v1(), + CliCommand::InstanceDiskListV1 => Self::cli_instance_disk_list_v1(), + CliCommand::InstanceDiskAttachV1 => Self::cli_instance_disk_attach_v1(), + CliCommand::InstanceDiskDetachV1 => Self::cli_instance_disk_detach_v1(), + CliCommand::InstanceMigrateV1 => Self::cli_instance_migrate_v1(), + CliCommand::InstanceRebootV1 => Self::cli_instance_reboot_v1(), + CliCommand::InstanceSerialConsoleV1 => Self::cli_instance_serial_console_v1(), + CliCommand::InstanceSerialConsoleStreamV1 => { + Self::cli_instance_serial_console_stream_v1() + } + CliCommand::InstanceStartV1 => Self::cli_instance_start_v1(), + CliCommand::InstanceStopV1 => Self::cli_instance_stop_v1(), + CliCommand::OrganizationListV1 => Self::cli_organization_list_v1(), + CliCommand::OrganizationCreateV1 => Self::cli_organization_create_v1(), + CliCommand::OrganizationViewV1 => Self::cli_organization_view_v1(), + CliCommand::OrganizationUpdateV1 => Self::cli_organization_update_v1(), + CliCommand::OrganizationDeleteV1 => Self::cli_organization_delete_v1(), + CliCommand::OrganizationPolicyViewV1 => Self::cli_organization_policy_view_v1(), + CliCommand::OrganizationPolicyUpdateV1 => Self::cli_organization_policy_update_v1(), + CliCommand::ProjectListV1 => Self::cli_project_list_v1(), + CliCommand::ProjectCreateV1 => Self::cli_project_create_v1(), + CliCommand::ProjectViewV1 => Self::cli_project_view_v1(), + CliCommand::ProjectUpdateV1 => Self::cli_project_update_v1(), + CliCommand::ProjectDeleteV1 => Self::cli_project_delete_v1(), + CliCommand::ProjectPolicyViewV1 => Self::cli_project_policy_view_v1(), + CliCommand::ProjectPolicyUpdateV1 => Self::cli_project_policy_update_v1(), + CliCommand::SystemComponentVersionList => Self::cli_system_component_version_list(), + CliCommand::UpdateDeploymentsList => Self::cli_update_deployments_list(), + CliCommand::UpdateDeploymentView => Self::cli_update_deployment_view(), + CliCommand::SystemUpdateRefresh => Self::cli_system_update_refresh(), + CliCommand::SystemUpdateStart => Self::cli_system_update_start(), + CliCommand::SystemUpdateStop => Self::cli_system_update_stop(), + CliCommand::SystemUpdateList => Self::cli_system_update_list(), + CliCommand::SystemUpdateView => Self::cli_system_update_view(), + CliCommand::SystemUpdateComponentsList => Self::cli_system_update_components_list(), + CliCommand::SystemVersion => Self::cli_system_version(), + } + } + + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { + let _ = match cmd { + CliCommand::DiskViewById => { + self.execute_disk_view_by_id(matches).await; + } + CliCommand::ImageViewById => { + self.execute_image_view_by_id(matches).await; + } + CliCommand::InstanceViewById => { + self.execute_instance_view_by_id(matches).await; + } + CliCommand::InstanceNetworkInterfaceViewById => { + self.execute_instance_network_interface_view_by_id(matches) + .await; + } + CliCommand::OrganizationViewById => { + self.execute_organization_view_by_id(matches).await; + } + CliCommand::ProjectViewById => { + self.execute_project_view_by_id(matches).await; + } + CliCommand::SnapshotViewById => { + self.execute_snapshot_view_by_id(matches).await; + } + CliCommand::VpcRouterRouteViewById => { + self.execute_vpc_router_route_view_by_id(matches).await; + } + CliCommand::VpcRouterViewById => { + self.execute_vpc_router_view_by_id(matches).await; + } + CliCommand::VpcSubnetViewById => { + self.execute_vpc_subnet_view_by_id(matches).await; + } + CliCommand::VpcViewById => { + self.execute_vpc_view_by_id(matches).await; + } + CliCommand::DeviceAuthRequest => { + self.execute_device_auth_request(matches).await; + } + CliCommand::DeviceAuthConfirm => { + self.execute_device_auth_confirm(matches).await; + } + CliCommand::DeviceAccessToken => { + self.execute_device_access_token(matches).await; + } + CliCommand::GroupList => { + self.execute_group_list(matches).await; + } + CliCommand::LoginSpoof => { + self.execute_login_spoof(matches).await; + } + CliCommand::LoginLocal => { + self.execute_login_local(matches).await; + } + CliCommand::LoginSamlBegin => { + self.execute_login_saml_begin(matches).await; + } + CliCommand::LoginSaml => { + self.execute_login_saml(matches).await; + } + CliCommand::Logout => { + self.execute_logout(matches).await; + } + CliCommand::OrganizationList => { + self.execute_organization_list(matches).await; + } + CliCommand::OrganizationCreate => { + self.execute_organization_create(matches).await; + } + CliCommand::OrganizationView => { + self.execute_organization_view(matches).await; + } + CliCommand::OrganizationUpdate => { + self.execute_organization_update(matches).await; + } + CliCommand::OrganizationDelete => { + self.execute_organization_delete(matches).await; + } + CliCommand::OrganizationPolicyView => { + self.execute_organization_policy_view(matches).await; + } + CliCommand::OrganizationPolicyUpdate => { + self.execute_organization_policy_update(matches).await; + } + CliCommand::ProjectList => { + self.execute_project_list(matches).await; + } + CliCommand::ProjectCreate => { + self.execute_project_create(matches).await; + } + CliCommand::ProjectView => { + self.execute_project_view(matches).await; + } + CliCommand::ProjectUpdate => { + self.execute_project_update(matches).await; + } + CliCommand::ProjectDelete => { + self.execute_project_delete(matches).await; + } + CliCommand::DiskList => { + self.execute_disk_list(matches).await; + } + CliCommand::DiskCreate => { + self.execute_disk_create(matches).await; + } + CliCommand::DiskView => { + self.execute_disk_view(matches).await; + } + CliCommand::DiskDelete => { + self.execute_disk_delete(matches).await; + } + CliCommand::DiskMetricsList => { + self.execute_disk_metrics_list(matches).await; + } + CliCommand::ImageList => { + self.execute_image_list(matches).await; + } + CliCommand::ImageCreate => { + self.execute_image_create(matches).await; + } + CliCommand::ImageView => { + self.execute_image_view(matches).await; + } + CliCommand::ImageDelete => { + self.execute_image_delete(matches).await; + } + CliCommand::InstanceList => { + self.execute_instance_list(matches).await; + } + CliCommand::InstanceCreate => { + self.execute_instance_create(matches).await; + } + CliCommand::InstanceView => { + self.execute_instance_view(matches).await; + } + CliCommand::InstanceDelete => { + self.execute_instance_delete(matches).await; + } + CliCommand::InstanceDiskList => { + self.execute_instance_disk_list(matches).await; + } + CliCommand::InstanceDiskAttach => { + self.execute_instance_disk_attach(matches).await; + } + CliCommand::InstanceDiskDetach => { + self.execute_instance_disk_detach(matches).await; + } + CliCommand::InstanceExternalIpList => { + self.execute_instance_external_ip_list(matches).await; + } + CliCommand::InstanceMigrate => { + self.execute_instance_migrate(matches).await; + } + CliCommand::InstanceNetworkInterfaceList => { + self.execute_instance_network_interface_list(matches).await; + } + CliCommand::InstanceNetworkInterfaceCreate => { + self.execute_instance_network_interface_create(matches) + .await; + } + CliCommand::InstanceNetworkInterfaceView => { + self.execute_instance_network_interface_view(matches).await; + } + CliCommand::InstanceNetworkInterfaceUpdate => { + self.execute_instance_network_interface_update(matches) + .await; + } + CliCommand::InstanceNetworkInterfaceDelete => { + self.execute_instance_network_interface_delete(matches) + .await; + } + CliCommand::InstanceReboot => { + self.execute_instance_reboot(matches).await; + } + CliCommand::InstanceSerialConsole => { + self.execute_instance_serial_console(matches).await; + } + CliCommand::InstanceSerialConsoleStream => { + self.execute_instance_serial_console_stream(matches).await; + } + CliCommand::InstanceStart => { + self.execute_instance_start(matches).await; + } + CliCommand::InstanceStop => { + self.execute_instance_stop(matches).await; + } + CliCommand::ProjectPolicyView => { + self.execute_project_policy_view(matches).await; + } + CliCommand::ProjectPolicyUpdate => { + self.execute_project_policy_update(matches).await; + } + CliCommand::SnapshotList => { + self.execute_snapshot_list(matches).await; + } + CliCommand::SnapshotCreate => { + self.execute_snapshot_create(matches).await; + } + CliCommand::SnapshotView => { + self.execute_snapshot_view(matches).await; + } + CliCommand::SnapshotDelete => { + self.execute_snapshot_delete(matches).await; + } + CliCommand::VpcList => { + self.execute_vpc_list(matches).await; + } + CliCommand::VpcCreate => { + self.execute_vpc_create(matches).await; + } + CliCommand::VpcView => { + self.execute_vpc_view(matches).await; + } + CliCommand::VpcUpdate => { + self.execute_vpc_update(matches).await; + } + CliCommand::VpcDelete => { + self.execute_vpc_delete(matches).await; + } + CliCommand::VpcFirewallRulesView => { + self.execute_vpc_firewall_rules_view(matches).await; + } + CliCommand::VpcFirewallRulesUpdate => { + self.execute_vpc_firewall_rules_update(matches).await; + } + CliCommand::VpcRouterList => { + self.execute_vpc_router_list(matches).await; + } + CliCommand::VpcRouterCreate => { + self.execute_vpc_router_create(matches).await; + } + CliCommand::VpcRouterView => { + self.execute_vpc_router_view(matches).await; + } + CliCommand::VpcRouterUpdate => { + self.execute_vpc_router_update(matches).await; + } + CliCommand::VpcRouterDelete => { + self.execute_vpc_router_delete(matches).await; + } + CliCommand::VpcRouterRouteList => { + self.execute_vpc_router_route_list(matches).await; + } + CliCommand::VpcRouterRouteCreate => { + self.execute_vpc_router_route_create(matches).await; + } + CliCommand::VpcRouterRouteView => { + self.execute_vpc_router_route_view(matches).await; + } + CliCommand::VpcRouterRouteUpdate => { + self.execute_vpc_router_route_update(matches).await; + } + CliCommand::VpcRouterRouteDelete => { + self.execute_vpc_router_route_delete(matches).await; + } + CliCommand::VpcSubnetList => { + self.execute_vpc_subnet_list(matches).await; + } + CliCommand::VpcSubnetCreate => { + self.execute_vpc_subnet_create(matches).await; + } + CliCommand::VpcSubnetView => { + self.execute_vpc_subnet_view(matches).await; + } + CliCommand::VpcSubnetUpdate => { + self.execute_vpc_subnet_update(matches).await; + } + CliCommand::VpcSubnetDelete => { + self.execute_vpc_subnet_delete(matches).await; + } + CliCommand::VpcSubnetListNetworkInterfaces => { + self.execute_vpc_subnet_list_network_interfaces(matches) + .await; + } + CliCommand::PolicyView => { + self.execute_policy_view(matches).await; + } + CliCommand::PolicyUpdate => { + self.execute_policy_update(matches).await; + } + CliCommand::RoleList => { + self.execute_role_list(matches).await; + } + CliCommand::RoleView => { + self.execute_role_view(matches).await; + } + CliCommand::SessionMe => { + self.execute_session_me(matches).await; + } + CliCommand::SessionMeGroups => { + self.execute_session_me_groups(matches).await; + } + CliCommand::SessionSshkeyList => { + self.execute_session_sshkey_list(matches).await; + } + CliCommand::SessionSshkeyCreate => { + self.execute_session_sshkey_create(matches).await; + } + CliCommand::SessionSshkeyView => { + self.execute_session_sshkey_view(matches).await; + } + CliCommand::SessionSshkeyDelete => { + self.execute_session_sshkey_delete(matches).await; + } + CliCommand::SystemImageViewById => { + self.execute_system_image_view_by_id(matches).await; + } + CliCommand::IpPoolViewById => { + self.execute_ip_pool_view_by_id(matches).await; + } + CliCommand::SiloViewById => { + self.execute_silo_view_by_id(matches).await; + } + CliCommand::CertificateList => { + self.execute_certificate_list(matches).await; + } + CliCommand::CertificateCreate => { + self.execute_certificate_create(matches).await; + } + CliCommand::CertificateView => { + self.execute_certificate_view(matches).await; + } + CliCommand::CertificateDelete => { + self.execute_certificate_delete(matches).await; + } + CliCommand::PhysicalDiskList => { + self.execute_physical_disk_list(matches).await; + } + CliCommand::RackList => { + self.execute_rack_list(matches).await; + } + CliCommand::RackView => { + self.execute_rack_view(matches).await; + } + CliCommand::SledList => { + self.execute_sled_list(matches).await; + } + CliCommand::SledView => { + self.execute_sled_view(matches).await; + } + CliCommand::SledPhysicalDiskList => { + self.execute_sled_physical_disk_list(matches).await; + } + CliCommand::SystemImageList => { + self.execute_system_image_list(matches).await; + } + CliCommand::SystemImageCreate => { + self.execute_system_image_create(matches).await; + } + CliCommand::SystemImageView => { + self.execute_system_image_view(matches).await; + } + CliCommand::SystemImageDelete => { + self.execute_system_image_delete(matches).await; + } + CliCommand::IpPoolList => { + self.execute_ip_pool_list(matches).await; + } + CliCommand::IpPoolCreate => { + self.execute_ip_pool_create(matches).await; + } + CliCommand::IpPoolView => { + self.execute_ip_pool_view(matches).await; + } + CliCommand::IpPoolUpdate => { + self.execute_ip_pool_update(matches).await; + } + CliCommand::IpPoolDelete => { + self.execute_ip_pool_delete(matches).await; + } + CliCommand::IpPoolRangeList => { + self.execute_ip_pool_range_list(matches).await; + } + CliCommand::IpPoolRangeAdd => { + self.execute_ip_pool_range_add(matches).await; + } + CliCommand::IpPoolRangeRemove => { + self.execute_ip_pool_range_remove(matches).await; + } + CliCommand::IpPoolServiceView => { + self.execute_ip_pool_service_view(matches).await; + } + CliCommand::IpPoolServiceRangeList => { + self.execute_ip_pool_service_range_list(matches).await; + } + CliCommand::IpPoolServiceRangeAdd => { + self.execute_ip_pool_service_range_add(matches).await; + } + CliCommand::IpPoolServiceRangeRemove => { + self.execute_ip_pool_service_range_remove(matches).await; + } + CliCommand::SystemMetric => { + self.execute_system_metric(matches).await; + } + CliCommand::SystemPolicyView => { + self.execute_system_policy_view(matches).await; + } + CliCommand::SystemPolicyUpdate => { + self.execute_system_policy_update(matches).await; + } + CliCommand::SagaList => { + self.execute_saga_list(matches).await; + } + CliCommand::SagaView => { + self.execute_saga_view(matches).await; + } + CliCommand::SiloList => { + self.execute_silo_list(matches).await; + } + CliCommand::SiloCreate => { + self.execute_silo_create(matches).await; + } + CliCommand::SiloView => { + self.execute_silo_view(matches).await; + } + CliCommand::SiloDelete => { + self.execute_silo_delete(matches).await; + } + CliCommand::SiloIdentityProviderList => { + self.execute_silo_identity_provider_list(matches).await; + } + CliCommand::LocalIdpUserCreate => { + self.execute_local_idp_user_create(matches).await; + } + CliCommand::LocalIdpUserDelete => { + self.execute_local_idp_user_delete(matches).await; + } + CliCommand::LocalIdpUserSetPassword => { + self.execute_local_idp_user_set_password(matches).await; + } + CliCommand::SamlIdentityProviderCreate => { + self.execute_saml_identity_provider_create(matches).await; + } + CliCommand::SamlIdentityProviderView => { + self.execute_saml_identity_provider_view(matches).await; + } + CliCommand::SiloPolicyView => { + self.execute_silo_policy_view(matches).await; + } + CliCommand::SiloPolicyUpdate => { + self.execute_silo_policy_update(matches).await; + } + CliCommand::SiloUsersList => { + self.execute_silo_users_list(matches).await; + } + CliCommand::SiloUserView => { + self.execute_silo_user_view(matches).await; + } + CliCommand::SystemUserList => { + self.execute_system_user_list(matches).await; + } + CliCommand::SystemUserView => { + self.execute_system_user_view(matches).await; + } + CliCommand::TimeseriesSchemaGet => { + self.execute_timeseries_schema_get(matches).await; + } + CliCommand::UserList => { + self.execute_user_list(matches).await; + } + CliCommand::DiskListV1 => { + self.execute_disk_list_v1(matches).await; + } + CliCommand::DiskCreateV1 => { + self.execute_disk_create_v1(matches).await; + } + CliCommand::DiskViewV1 => { + self.execute_disk_view_v1(matches).await; + } + CliCommand::DiskDeleteV1 => { + self.execute_disk_delete_v1(matches).await; + } + CliCommand::InstanceListV1 => { + self.execute_instance_list_v1(matches).await; + } + CliCommand::InstanceCreateV1 => { + self.execute_instance_create_v1(matches).await; + } + CliCommand::InstanceViewV1 => { + self.execute_instance_view_v1(matches).await; + } + CliCommand::InstanceDeleteV1 => { + self.execute_instance_delete_v1(matches).await; + } + CliCommand::InstanceDiskListV1 => { + self.execute_instance_disk_list_v1(matches).await; + } + CliCommand::InstanceDiskAttachV1 => { + self.execute_instance_disk_attach_v1(matches).await; + } + CliCommand::InstanceDiskDetachV1 => { + self.execute_instance_disk_detach_v1(matches).await; + } + CliCommand::InstanceMigrateV1 => { + self.execute_instance_migrate_v1(matches).await; + } + CliCommand::InstanceRebootV1 => { + self.execute_instance_reboot_v1(matches).await; + } + CliCommand::InstanceSerialConsoleV1 => { + self.execute_instance_serial_console_v1(matches).await; + } + CliCommand::InstanceSerialConsoleStreamV1 => { + self.execute_instance_serial_console_stream_v1(matches) + .await; + } + CliCommand::InstanceStartV1 => { + self.execute_instance_start_v1(matches).await; + } + CliCommand::InstanceStopV1 => { + self.execute_instance_stop_v1(matches).await; + } + CliCommand::OrganizationListV1 => { + self.execute_organization_list_v1(matches).await; + } + CliCommand::OrganizationCreateV1 => { + self.execute_organization_create_v1(matches).await; + } + CliCommand::OrganizationViewV1 => { + self.execute_organization_view_v1(matches).await; + } + CliCommand::OrganizationUpdateV1 => { + self.execute_organization_update_v1(matches).await; + } + CliCommand::OrganizationDeleteV1 => { + self.execute_organization_delete_v1(matches).await; + } + CliCommand::OrganizationPolicyViewV1 => { + self.execute_organization_policy_view_v1(matches).await; + } + CliCommand::OrganizationPolicyUpdateV1 => { + self.execute_organization_policy_update_v1(matches).await; + } + CliCommand::ProjectListV1 => { + self.execute_project_list_v1(matches).await; + } + CliCommand::ProjectCreateV1 => { + self.execute_project_create_v1(matches).await; + } + CliCommand::ProjectViewV1 => { + self.execute_project_view_v1(matches).await; + } + CliCommand::ProjectUpdateV1 => { + self.execute_project_update_v1(matches).await; + } + CliCommand::ProjectDeleteV1 => { + self.execute_project_delete_v1(matches).await; + } + CliCommand::ProjectPolicyViewV1 => { + self.execute_project_policy_view_v1(matches).await; + } + CliCommand::ProjectPolicyUpdateV1 => { + self.execute_project_policy_update_v1(matches).await; + } + CliCommand::SystemComponentVersionList => { + self.execute_system_component_version_list(matches).await; + } + CliCommand::UpdateDeploymentsList => { + self.execute_update_deployments_list(matches).await; + } + CliCommand::UpdateDeploymentView => { + self.execute_update_deployment_view(matches).await; + } + CliCommand::SystemUpdateRefresh => { + self.execute_system_update_refresh(matches).await; + } + CliCommand::SystemUpdateStart => { + self.execute_system_update_start(matches).await; + } + CliCommand::SystemUpdateStop => { + self.execute_system_update_stop(matches).await; + } + CliCommand::SystemUpdateList => { + self.execute_system_update_list(matches).await; + } + CliCommand::SystemUpdateView => { + self.execute_system_update_view(matches).await; + } + CliCommand::SystemUpdateComponentsList => { + self.execute_system_update_components_list(matches).await; + } + CliCommand::SystemVersion => { + self.execute_system_version(matches).await; + } + }; + } +} + +pub trait CliOverride { + fn cli_disk_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_image_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_image_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_network_interface_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_network_interface_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_snapshot_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_snapshot_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_route_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_route_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_subnet_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_subnet_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_device_auth_request(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_device_auth_request( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_device_auth_confirm(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_device_auth_confirm( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_device_access_token(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_device_access_token( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_group_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_group_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_login_spoof(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_login_spoof( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_login_local(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_login_local( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_login_saml_begin(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_login_saml_begin( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_login_saml(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_login_saml( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_logout(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_logout( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_policy_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_policy_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_policy_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_policy_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_metrics_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_metrics_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_image_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_image_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_image_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_image_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_image_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_image_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_image_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_image_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_disk_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_disk_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_disk_attach(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_disk_attach( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_disk_detach(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_disk_detach( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_external_ip_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_external_ip_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_migrate(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_migrate( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_network_interface_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_network_interface_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_network_interface_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_network_interface_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_network_interface_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_network_interface_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_network_interface_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_network_interface_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_network_interface_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_network_interface_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_reboot(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_reboot( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_serial_console(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_serial_console( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_serial_console_stream(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_serial_console_stream( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_start(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_start( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_stop(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_stop( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_policy_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_policy_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_policy_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_policy_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_snapshot_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_snapshot_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_snapshot_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_snapshot_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_snapshot_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_snapshot_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_snapshot_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_snapshot_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_firewall_rules_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_firewall_rules_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_firewall_rules_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_firewall_rules_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_route_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_route_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_route_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_route_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_route_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_route_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_route_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_route_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_router_route_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_router_route_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_subnet_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_subnet_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_subnet_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_subnet_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_subnet_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_subnet_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_subnet_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_subnet_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_subnet_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_subnet_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_vpc_subnet_list_network_interfaces(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_vpc_subnet_list_network_interfaces( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_policy_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_policy_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_policy_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_policy_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_role_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_role_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_role_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_role_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_session_me(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_session_me( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_session_me_groups(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_session_me_groups( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_session_sshkey_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_session_sshkey_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_session_sshkey_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_session_sshkey_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_session_sshkey_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_session_sshkey_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_session_sshkey_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_session_sshkey_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_image_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_image_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_view_by_id(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_view_by_id( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_certificate_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_certificate_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_certificate_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_certificate_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_certificate_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_certificate_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_certificate_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_certificate_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_physical_disk_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_physical_disk_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_rack_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_rack_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_rack_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_rack_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_sled_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_sled_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_sled_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_sled_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_sled_physical_disk_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_sled_physical_disk_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_image_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_image_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_image_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_image_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_image_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_image_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_image_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_image_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_range_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_range_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_range_add(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_range_add( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_range_remove(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_range_remove( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_service_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_service_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_service_range_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_service_range_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_service_range_add(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_service_range_add( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_ip_pool_service_range_remove(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_ip_pool_service_range_remove( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_metric(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_metric( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_policy_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_policy_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_policy_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_policy_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_saga_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_saga_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_saga_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_saga_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_identity_provider_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_identity_provider_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_local_idp_user_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_local_idp_user_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_local_idp_user_delete(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_local_idp_user_delete( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_local_idp_user_set_password(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_local_idp_user_set_password( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_saml_identity_provider_create(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_saml_identity_provider_create( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_saml_identity_provider_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_saml_identity_provider_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_policy_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_policy_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_policy_update(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_policy_update( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_users_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_users_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_silo_user_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_silo_user_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_user_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_user_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_user_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_user_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_timeseries_schema_get(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_timeseries_schema_get( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_user_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_user_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_list_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_list_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_create_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_create_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_view_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_view_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_disk_delete_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_disk_delete_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_list_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_list_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_create_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_create_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_view_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_view_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_delete_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_delete_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_disk_list_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_disk_list_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_disk_attach_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_disk_attach_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_disk_detach_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_disk_detach_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_migrate_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_migrate_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_reboot_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_reboot_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_serial_console_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_serial_console_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_serial_console_stream_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_serial_console_stream_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_start_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_start_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_stop_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_stop_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_list_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_list_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_create_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_create_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_view_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_view_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_update_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_update_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_delete_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_delete_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_policy_view_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_policy_view_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_organization_policy_update_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_organization_policy_update_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_list_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_list_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_create_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_create_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_view_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_view_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_update_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_update_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_delete_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_delete_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_policy_view_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_policy_view_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_project_policy_update_v1(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_project_policy_update_v1( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_component_version_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_component_version_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_update_deployments_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_update_deployments_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_update_deployment_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_update_deployment_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_update_refresh(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_update_refresh( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_update_start(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_update_start( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_update_stop(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_update_stop( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_update_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_update_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_update_view(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_update_view( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_update_components_list(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_update_components_list( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_system_version(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_system_version( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } +} + +#[derive(Copy, Clone, Debug)] +pub enum CliCommand { + DiskViewById, + ImageViewById, + InstanceViewById, + InstanceNetworkInterfaceViewById, + OrganizationViewById, + ProjectViewById, + SnapshotViewById, + VpcRouterRouteViewById, + VpcRouterViewById, + VpcSubnetViewById, + VpcViewById, + DeviceAuthRequest, + DeviceAuthConfirm, + DeviceAccessToken, + GroupList, + LoginSpoof, + LoginLocal, + LoginSamlBegin, + LoginSaml, + Logout, + OrganizationList, + OrganizationCreate, + OrganizationView, + OrganizationUpdate, + OrganizationDelete, + OrganizationPolicyView, + OrganizationPolicyUpdate, + ProjectList, + ProjectCreate, + ProjectView, + ProjectUpdate, + ProjectDelete, + DiskList, + DiskCreate, + DiskView, + DiskDelete, + DiskMetricsList, + ImageList, + ImageCreate, + ImageView, + ImageDelete, + InstanceList, + InstanceCreate, + InstanceView, + InstanceDelete, + InstanceDiskList, + InstanceDiskAttach, + InstanceDiskDetach, + InstanceExternalIpList, + InstanceMigrate, + InstanceNetworkInterfaceList, + InstanceNetworkInterfaceCreate, + InstanceNetworkInterfaceView, + InstanceNetworkInterfaceUpdate, + InstanceNetworkInterfaceDelete, + InstanceReboot, + InstanceSerialConsole, + InstanceSerialConsoleStream, + InstanceStart, + InstanceStop, + ProjectPolicyView, + ProjectPolicyUpdate, + SnapshotList, + SnapshotCreate, + SnapshotView, + SnapshotDelete, + VpcList, + VpcCreate, + VpcView, + VpcUpdate, + VpcDelete, + VpcFirewallRulesView, + VpcFirewallRulesUpdate, + VpcRouterList, + VpcRouterCreate, + VpcRouterView, + VpcRouterUpdate, + VpcRouterDelete, + VpcRouterRouteList, + VpcRouterRouteCreate, + VpcRouterRouteView, + VpcRouterRouteUpdate, + VpcRouterRouteDelete, + VpcSubnetList, + VpcSubnetCreate, + VpcSubnetView, + VpcSubnetUpdate, + VpcSubnetDelete, + VpcSubnetListNetworkInterfaces, + PolicyView, + PolicyUpdate, + RoleList, + RoleView, + SessionMe, + SessionMeGroups, + SessionSshkeyList, + SessionSshkeyCreate, + SessionSshkeyView, + SessionSshkeyDelete, + SystemImageViewById, + IpPoolViewById, + SiloViewById, + CertificateList, + CertificateCreate, + CertificateView, + CertificateDelete, + PhysicalDiskList, + RackList, + RackView, + SledList, + SledView, + SledPhysicalDiskList, + SystemImageList, + SystemImageCreate, + SystemImageView, + SystemImageDelete, + IpPoolList, + IpPoolCreate, + IpPoolView, + IpPoolUpdate, + IpPoolDelete, + IpPoolRangeList, + IpPoolRangeAdd, + IpPoolRangeRemove, + IpPoolServiceView, + IpPoolServiceRangeList, + IpPoolServiceRangeAdd, + IpPoolServiceRangeRemove, + SystemMetric, + SystemPolicyView, + SystemPolicyUpdate, + SagaList, + SagaView, + SiloList, + SiloCreate, + SiloView, + SiloDelete, + SiloIdentityProviderList, + LocalIdpUserCreate, + LocalIdpUserDelete, + LocalIdpUserSetPassword, + SamlIdentityProviderCreate, + SamlIdentityProviderView, + SiloPolicyView, + SiloPolicyUpdate, + SiloUsersList, + SiloUserView, + SystemUserList, + SystemUserView, + TimeseriesSchemaGet, + UserList, + DiskListV1, + DiskCreateV1, + DiskViewV1, + DiskDeleteV1, + InstanceListV1, + InstanceCreateV1, + InstanceViewV1, + InstanceDeleteV1, + InstanceDiskListV1, + InstanceDiskAttachV1, + InstanceDiskDetachV1, + InstanceMigrateV1, + InstanceRebootV1, + InstanceSerialConsoleV1, + InstanceSerialConsoleStreamV1, + InstanceStartV1, + InstanceStopV1, + OrganizationListV1, + OrganizationCreateV1, + OrganizationViewV1, + OrganizationUpdateV1, + OrganizationDeleteV1, + OrganizationPolicyViewV1, + OrganizationPolicyUpdateV1, + ProjectListV1, + ProjectCreateV1, + ProjectViewV1, + ProjectUpdateV1, + ProjectDeleteV1, + ProjectPolicyViewV1, + ProjectPolicyUpdateV1, + SystemComponentVersionList, + UpdateDeploymentsList, + UpdateDeploymentView, + SystemUpdateRefresh, + SystemUpdateStart, + SystemUpdateStop, + SystemUpdateList, + SystemUpdateView, + SystemUpdateComponentsList, + SystemVersion, +} + +impl CliCommand { + pub fn iter() -> impl Iterator { + vec![ + CliCommand::DiskViewById, + CliCommand::ImageViewById, + CliCommand::InstanceViewById, + CliCommand::InstanceNetworkInterfaceViewById, + CliCommand::OrganizationViewById, + CliCommand::ProjectViewById, + CliCommand::SnapshotViewById, + CliCommand::VpcRouterRouteViewById, + CliCommand::VpcRouterViewById, + CliCommand::VpcSubnetViewById, + CliCommand::VpcViewById, + CliCommand::DeviceAuthRequest, + CliCommand::DeviceAuthConfirm, + CliCommand::DeviceAccessToken, + CliCommand::GroupList, + CliCommand::LoginSpoof, + CliCommand::LoginLocal, + CliCommand::LoginSamlBegin, + CliCommand::LoginSaml, + CliCommand::Logout, + CliCommand::OrganizationList, + CliCommand::OrganizationCreate, + CliCommand::OrganizationView, + CliCommand::OrganizationUpdate, + CliCommand::OrganizationDelete, + CliCommand::OrganizationPolicyView, + CliCommand::OrganizationPolicyUpdate, + CliCommand::ProjectList, + CliCommand::ProjectCreate, + CliCommand::ProjectView, + CliCommand::ProjectUpdate, + CliCommand::ProjectDelete, + CliCommand::DiskList, + CliCommand::DiskCreate, + CliCommand::DiskView, + CliCommand::DiskDelete, + CliCommand::DiskMetricsList, + CliCommand::ImageList, + CliCommand::ImageCreate, + CliCommand::ImageView, + CliCommand::ImageDelete, + CliCommand::InstanceList, + CliCommand::InstanceCreate, + CliCommand::InstanceView, + CliCommand::InstanceDelete, + CliCommand::InstanceDiskList, + CliCommand::InstanceDiskAttach, + CliCommand::InstanceDiskDetach, + CliCommand::InstanceExternalIpList, + CliCommand::InstanceMigrate, + CliCommand::InstanceNetworkInterfaceList, + CliCommand::InstanceNetworkInterfaceCreate, + CliCommand::InstanceNetworkInterfaceView, + CliCommand::InstanceNetworkInterfaceUpdate, + CliCommand::InstanceNetworkInterfaceDelete, + CliCommand::InstanceReboot, + CliCommand::InstanceSerialConsole, + CliCommand::InstanceSerialConsoleStream, + CliCommand::InstanceStart, + CliCommand::InstanceStop, + CliCommand::ProjectPolicyView, + CliCommand::ProjectPolicyUpdate, + CliCommand::SnapshotList, + CliCommand::SnapshotCreate, + CliCommand::SnapshotView, + CliCommand::SnapshotDelete, + CliCommand::VpcList, + CliCommand::VpcCreate, + CliCommand::VpcView, + CliCommand::VpcUpdate, + CliCommand::VpcDelete, + CliCommand::VpcFirewallRulesView, + CliCommand::VpcFirewallRulesUpdate, + CliCommand::VpcRouterList, + CliCommand::VpcRouterCreate, + CliCommand::VpcRouterView, + CliCommand::VpcRouterUpdate, + CliCommand::VpcRouterDelete, + CliCommand::VpcRouterRouteList, + CliCommand::VpcRouterRouteCreate, + CliCommand::VpcRouterRouteView, + CliCommand::VpcRouterRouteUpdate, + CliCommand::VpcRouterRouteDelete, + CliCommand::VpcSubnetList, + CliCommand::VpcSubnetCreate, + CliCommand::VpcSubnetView, + CliCommand::VpcSubnetUpdate, + CliCommand::VpcSubnetDelete, + CliCommand::VpcSubnetListNetworkInterfaces, + CliCommand::PolicyView, + CliCommand::PolicyUpdate, + CliCommand::RoleList, + CliCommand::RoleView, + CliCommand::SessionMe, + CliCommand::SessionMeGroups, + CliCommand::SessionSshkeyList, + CliCommand::SessionSshkeyCreate, + CliCommand::SessionSshkeyView, + CliCommand::SessionSshkeyDelete, + CliCommand::SystemImageViewById, + CliCommand::IpPoolViewById, + CliCommand::SiloViewById, + CliCommand::CertificateList, + CliCommand::CertificateCreate, + CliCommand::CertificateView, + CliCommand::CertificateDelete, + CliCommand::PhysicalDiskList, + CliCommand::RackList, + CliCommand::RackView, + CliCommand::SledList, + CliCommand::SledView, + CliCommand::SledPhysicalDiskList, + CliCommand::SystemImageList, + CliCommand::SystemImageCreate, + CliCommand::SystemImageView, + CliCommand::SystemImageDelete, + CliCommand::IpPoolList, + CliCommand::IpPoolCreate, + CliCommand::IpPoolView, + CliCommand::IpPoolUpdate, + CliCommand::IpPoolDelete, + CliCommand::IpPoolRangeList, + CliCommand::IpPoolRangeAdd, + CliCommand::IpPoolRangeRemove, + CliCommand::IpPoolServiceView, + CliCommand::IpPoolServiceRangeList, + CliCommand::IpPoolServiceRangeAdd, + CliCommand::IpPoolServiceRangeRemove, + CliCommand::SystemMetric, + CliCommand::SystemPolicyView, + CliCommand::SystemPolicyUpdate, + CliCommand::SagaList, + CliCommand::SagaView, + CliCommand::SiloList, + CliCommand::SiloCreate, + CliCommand::SiloView, + CliCommand::SiloDelete, + CliCommand::SiloIdentityProviderList, + CliCommand::LocalIdpUserCreate, + CliCommand::LocalIdpUserDelete, + CliCommand::LocalIdpUserSetPassword, + CliCommand::SamlIdentityProviderCreate, + CliCommand::SamlIdentityProviderView, + CliCommand::SiloPolicyView, + CliCommand::SiloPolicyUpdate, + CliCommand::SiloUsersList, + CliCommand::SiloUserView, + CliCommand::SystemUserList, + CliCommand::SystemUserView, + CliCommand::TimeseriesSchemaGet, + CliCommand::UserList, + CliCommand::DiskListV1, + CliCommand::DiskCreateV1, + CliCommand::DiskViewV1, + CliCommand::DiskDeleteV1, + CliCommand::InstanceListV1, + CliCommand::InstanceCreateV1, + CliCommand::InstanceViewV1, + CliCommand::InstanceDeleteV1, + CliCommand::InstanceDiskListV1, + CliCommand::InstanceDiskAttachV1, + CliCommand::InstanceDiskDetachV1, + CliCommand::InstanceMigrateV1, + CliCommand::InstanceRebootV1, + CliCommand::InstanceSerialConsoleV1, + CliCommand::InstanceSerialConsoleStreamV1, + CliCommand::InstanceStartV1, + CliCommand::InstanceStopV1, + CliCommand::OrganizationListV1, + CliCommand::OrganizationCreateV1, + CliCommand::OrganizationViewV1, + CliCommand::OrganizationUpdateV1, + CliCommand::OrganizationDeleteV1, + CliCommand::OrganizationPolicyViewV1, + CliCommand::OrganizationPolicyUpdateV1, + CliCommand::ProjectListV1, + CliCommand::ProjectCreateV1, + CliCommand::ProjectViewV1, + CliCommand::ProjectUpdateV1, + CliCommand::ProjectDeleteV1, + CliCommand::ProjectPolicyViewV1, + CliCommand::ProjectPolicyUpdateV1, + CliCommand::SystemComponentVersionList, + CliCommand::UpdateDeploymentsList, + CliCommand::UpdateDeploymentView, + CliCommand::SystemUpdateRefresh, + CliCommand::SystemUpdateStart, + CliCommand::SystemUpdateStop, + CliCommand::SystemUpdateList, + CliCommand::SystemUpdateView, + CliCommand::SystemUpdateComponentsList, + CliCommand::SystemVersion, + ] + .into_iter() + } +} diff --git a/progenitor-impl/tests/output/param-overrides-cli.out b/progenitor-impl/tests/output/param-overrides-cli.out new file mode 100644 index 00000000..0c535cc2 --- /dev/null +++ b/progenitor-impl/tests/output/param-overrides-cli.out @@ -0,0 +1,88 @@ +pub struct Cli { + client: sdk::Client, +} + +impl Cli { + pub fn new(client: sdk::Client) -> Self { + Self { client } + } + + pub fn cli_key_get() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("key") + .long("key") + .required(false) + .value_parser(clap::value_parser!(bool)) + .help("The same key parameter that overlaps with the path level parameter"), + ) + .arg( + clap::Arg::new("unique-key") + .long("unique-key") + .required(false) + .value_parser(clap::value_parser!(String)) + .help("A key parameter that will not be overridden by the path spec"), + ) + } + + pub async fn execute_key_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.key_get(); + if let Some(value) = matches.get_one::("key") { + request = request.key(value.clone()); + } + + if let Some(value) = matches.get_one::("unique-key") { + request = request.unique_key(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub fn get_command(cmd: CliCommand) -> clap::Command { + match cmd { + CliCommand::KeyGet => Self::cli_key_get(), + } + } + + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { + let _ = match cmd { + CliCommand::KeyGet => { + self.execute_key_get(matches).await; + } + }; + } +} + +pub trait CliOverride { + fn cli_key_get(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_key_get( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } +} + +#[derive(Copy, Clone, Debug)] +pub enum CliCommand { + KeyGet, +} + +impl CliCommand { + pub fn iter() -> impl Iterator { + vec![CliCommand::KeyGet].into_iter() + } +} diff --git a/progenitor-impl/tests/output/propolis-server-cli.out b/progenitor-impl/tests/output/propolis-server-cli.out new file mode 100644 index 00000000..93957f1f --- /dev/null +++ b/progenitor-impl/tests/output/propolis-server-cli.out @@ -0,0 +1,340 @@ +pub struct Cli { + client: sdk::Client, +} + +impl Cli { + pub fn new(client: sdk::Client) -> Self { + Self { client } + } + + pub fn cli_instance_get() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_instance_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_get(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_ensure() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_instance_ensure(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_ensure(); + let request = request.body({ + let mut body = types::InstanceEnsureRequest::builder(); + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_issue_crucible_snapshot_request() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("id") + .long("id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .arg( + clap::Arg::new("snapshot-id") + .long("snapshot-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + .about("Issue a snapshot request to a crucible backend") + } + + pub async fn execute_instance_issue_crucible_snapshot_request( + &self, + matches: &clap::ArgMatches, + ) { + let mut request = self.client.instance_issue_crucible_snapshot_request(); + if let Some(value) = matches.get_one::("id") { + request = request.id(value.clone()); + } + + if let Some(value) = matches.get_one::("snapshot-id") { + request = request.snapshot_id(value.clone()); + } + + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_migrate_status() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("migration-id") + .long("migration-id") + .required(true) + .value_parser(clap::value_parser!(uuid::Uuid)), + ) + } + + pub async fn execute_instance_migrate_status(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_migrate_status(); + let request = request.body({ + let mut body = types::InstanceMigrateStatusRequest::builder(); + if let Some(value) = matches.get_one::("migration-id") { + body = body.migration_id(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_serial() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_instance_serial(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_serial(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub fn cli_instance_state_put() -> clap::Command { + clap::Command::new("") + } + + pub async fn execute_instance_state_put(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_state_put(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn cli_instance_state_monitor() -> clap::Command { + clap::Command::new("").arg( + clap::Arg::new("gen") + .long("gen") + .required(true) + .value_parser(clap::value_parser!(u64)), + ) + } + + pub async fn execute_instance_state_monitor(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_state_monitor(); + let request = request.body({ + let mut body = types::InstanceStateMonitorRequest::builder(); + if let Some(value) = matches.get_one::("gen") { + body = body.gen(value.clone()); + } + body + }); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub fn get_command(cmd: CliCommand) -> clap::Command { + match cmd { + CliCommand::InstanceGet => Self::cli_instance_get(), + CliCommand::InstanceEnsure => Self::cli_instance_ensure(), + CliCommand::InstanceIssueCrucibleSnapshotRequest => { + Self::cli_instance_issue_crucible_snapshot_request() + } + CliCommand::InstanceMigrateStatus => Self::cli_instance_migrate_status(), + CliCommand::InstanceSerial => Self::cli_instance_serial(), + CliCommand::InstanceStatePut => Self::cli_instance_state_put(), + CliCommand::InstanceStateMonitor => Self::cli_instance_state_monitor(), + } + } + + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { + let _ = match cmd { + CliCommand::InstanceGet => { + self.execute_instance_get(matches).await; + } + CliCommand::InstanceEnsure => { + self.execute_instance_ensure(matches).await; + } + CliCommand::InstanceIssueCrucibleSnapshotRequest => { + self.execute_instance_issue_crucible_snapshot_request(matches) + .await; + } + CliCommand::InstanceMigrateStatus => { + self.execute_instance_migrate_status(matches).await; + } + CliCommand::InstanceSerial => { + self.execute_instance_serial(matches).await; + } + CliCommand::InstanceStatePut => { + self.execute_instance_state_put(matches).await; + } + CliCommand::InstanceStateMonitor => { + self.execute_instance_state_monitor(matches).await; + } + }; + } +} + +pub trait CliOverride { + fn cli_instance_get(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_get( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_ensure(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_ensure( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_issue_crucible_snapshot_request(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_issue_crucible_snapshot_request( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_migrate_status(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_migrate_status( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_serial(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_serial( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_state_put(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_state_put( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } + + fn cli_instance_state_monitor(cmd: clap::Command) -> clap::Command { + cmd + } + + fn execute_instance_state_monitor( + &self, + matches: &clap::ArgMatches, + request: &mut (), + body: &mut (), + ) -> Result<(), String> { + Ok(()) + } +} + +#[derive(Copy, Clone, Debug)] +pub enum CliCommand { + InstanceGet, + InstanceEnsure, + InstanceIssueCrucibleSnapshotRequest, + InstanceMigrateStatus, + InstanceSerial, + InstanceStatePut, + InstanceStateMonitor, +} + +impl CliCommand { + pub fn iter() -> impl Iterator { + vec![ + CliCommand::InstanceGet, + CliCommand::InstanceEnsure, + CliCommand::InstanceIssueCrucibleSnapshotRequest, + CliCommand::InstanceMigrateStatus, + CliCommand::InstanceSerial, + CliCommand::InstanceStatePut, + CliCommand::InstanceStateMonitor, + ] + .into_iter() + } +} diff --git a/progenitor-impl/tests/test_output.rs b/progenitor-impl/tests/test_output.rs index 9b686df0..82391693 100644 --- a/progenitor-impl/tests/test_output.rs +++ b/progenitor-impl/tests/test_output.rs @@ -34,6 +34,7 @@ fn verify_apis(openapi_file: &str) { let spec = load_api(in_path); + // Positional generation. let mut generator = Generator::default(); let output = generator.generate_text_normalize_comments(&spec).unwrap(); expectorate::assert_contents( @@ -41,6 +42,7 @@ fn verify_apis(openapi_file: &str) { &output, ); + // Builder generation with derives and patches. let mut generator = Generator::new( GenerationSettings::default() .with_interface(InterfaceStyle::Builder) @@ -65,17 +67,24 @@ fn verify_apis(openapi_file: &str) { &output, ); + // Builder generation with tags. let mut generator = Generator::new( GenerationSettings::default() .with_interface(InterfaceStyle::Builder) .with_tag(TagStyle::Separate), ); let output = generator.generate_text_normalize_comments(&spec).unwrap(); - println!("{output}"); expectorate::assert_contents( format!("tests/output/{}-builder-tagged.out", openapi_stem), &output, ); + + // CLI generation. + let output = generator.cli_text(&spec, "sdk").unwrap(); + expectorate::assert_contents( + format!("tests/output/{}-cli.out", openapi_stem), + &output, + ); } #[test] diff --git a/progenitor/tests/build_nexus.rs b/progenitor/tests/build_nexus.rs index f2315341..a9fd73af 100644 --- a/progenitor/tests/build_nexus.rs +++ b/progenitor/tests/build_nexus.rs @@ -27,20 +27,17 @@ mod builder_untagged { use futures::StreamExt; mod nexus_client { - use std::convert::Infallible; - - #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] - pub struct MyIpv4Net(pub String); - impl std::fmt::Display for MyIpv4Net { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(&self.0) + #[derive(Clone, serde::Serialize, serde::Deserialize, Debug)] + pub struct MyIpv4Net(String); + impl std::str::FromStr for MyIpv4Net { + type Err = std::convert::Infallible; + fn from_str(value: &str) -> Result { + Ok(Self(value.to_string())) } } - impl std::str::FromStr for MyIpv4Net { - type Err = Infallible; - - fn from_str(s: &str) -> Result { - Ok(Self(s.to_string())) + impl ToString for MyIpv4Net { + fn to_string(&self) -> String { + self.0.clone() } } progenitor::generate_api!( @@ -62,9 +59,7 @@ mod builder_untagged { pub fn _ignore() { // Verify the replacement above. - let _ignore = nexus_client::types::IpNet::V4(nexus_client::MyIpv4Net( - String::new(), - )); + let _ignore = nexus_client::types::IpNet::V4("".parse().unwrap()); let client = Client::new(""); let stream = client