diff --git a/progenitor-impl/src/cli.rs b/progenitor-impl/src/cli.rs index f79e807..194150a 100644 --- a/progenitor-impl/src/cli.rs +++ b/progenitor-impl/src/cli.rs @@ -19,7 +19,6 @@ use crate::{ struct CliOperation { cli_fn: TokenStream, execute_fn: TokenStream, - cli_trait: TokenStream, execute_trait: TokenStream, } @@ -85,33 +84,9 @@ impl Generator { .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_ops = methods.iter().map(|op| &op.cli_fn); + let execute_ops = methods.iter().map(|op| &op.execute_fn); + let trait_ops = methods.iter().map(|op| &op.execute_trait); let cli_fns = raw_methods .iter() @@ -145,16 +120,15 @@ impl Generator { let crate_ident = format_ident!("{}", crate_name); let code = quote! { - pub struct Cli { + pub struct Cli { client: #crate_ident::Client, + over: T, } impl Cli { pub fn new(client: #crate_ident::Client) -> Self { - Self { client } + Self { client, over: () } } - #(#ops)* - pub fn get_command(cmd: CliCommand) -> clap::Command { match cmd { #( @@ -163,26 +137,41 @@ impl Generator { } } + #(#cli_ops)* + } + + impl Cli { + pub fn new_with_override( + client: #crate_ident::Client, + over: T, + ) -> Self { + Self { client, over } + } + pub async fn execute( &self, cmd: CliCommand, matches: &clap::ArgMatches, ) { - let _ = match cmd { + match cmd { #( CliCommand::#cli_variants => { // TODO ... do something with output self.#execute_fns(matches).await; } )* - }; + } } + + #(#execute_ops)* } pub trait CliOverride { #(#trait_ops)* } + impl CliOverride for () {} + #[derive(Copy, Clone, Debug)] pub enum CliCommand { #(#cli_variants,)* @@ -348,12 +337,6 @@ impl Generator { } }; - 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); @@ -404,7 +387,6 @@ impl Generator { }; 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) => { @@ -439,10 +421,10 @@ impl Generator { ) { // clone here in case the arg type - // doesn't impl From<&T> - body = body.#prop_fn( - value.clone(), - ); + // doesn't impl TryFrom<&T> + request = request.body_map(|body| { + body.#prop_fn(value.clone()) + }) } } }) @@ -453,13 +435,10 @@ impl Generator { _ => None, }; + // TODO rework this. maybe_body_args.map(|body_args| { quote! { - let request = request.body({ - let mut body = #body_type_ident::builder(); - #( #body_args )* - body - }); + #( #body_args )* } }) }); @@ -504,6 +483,11 @@ impl Generator { #( #args )* #body_arg + // TODO don't want to unwrap. + self.over + .#fn_name(matches, &mut request) + .unwrap(); + let result = request.send().await; match result { @@ -517,12 +501,15 @@ impl Generator { } }; + // TODO this is copy-pasted--unwisely? + let struct_name = sanitize(&method.operation_id, Case::Pascal); + let struct_ident = format_ident!("{}", struct_name); + let execute_trait = quote! { fn #fn_name( &self, matches: &clap::ArgMatches, - request: &mut (), - body: &mut() + request: &mut builder :: #struct_ident, ) -> Result<(), String> { Ok(()) } @@ -531,7 +518,6 @@ impl Generator { CliOperation { cli_fn, execute_fn, - cli_trait, execute_trait, } } diff --git a/progenitor-impl/tests/output/buildomat-cli.out b/progenitor-impl/tests/output/buildomat-cli.out index 801c824..3e56cdf 100644 --- a/progenitor-impl/tests/output/buildomat-cli.out +++ b/progenitor-impl/tests/output/buildomat-cli.out @@ -1,46 +1,44 @@ -pub struct Cli { +pub struct Cli { client: sdk::Client, + over: T, } impl Cli { pub fn new(client: sdk::Client) -> Self { - Self { client } + Self { client, over: () } + } + + 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 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") @@ -50,40 +48,10 @@ impl Cli { ) } - 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( @@ -100,29 +68,6 @@ impl Cli { ) } - 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( @@ -139,27 +84,6 @@ impl Cli { ) } - pub async fn execute_task_events_get(&self, matches: &clap::ArgMatches) { - let mut request = self.client.task_events_get(); - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } - - if let Some(value) = matches.get_one::("minseq") { - request = request.minseq(value.clone()); - } - - 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") @@ -169,23 +93,6 @@ impl Cli { ) } - 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( @@ -202,27 +109,6 @@ impl Cli { ) } - pub async fn execute_task_output_download(&self, matches: &clap::ArgMatches) { - let mut request = self.client.task_output_download(); - if let Some(value) = matches.get_one::("task") { - request = request.task(value.clone()); - } - - if let Some(value) = matches.get_one::("output") { - request = request.output(value.clone()); - } - - 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") @@ -232,43 +118,10 @@ impl Cli { ) } - 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( @@ -285,46 +138,10 @@ impl Cli { ) } - 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( @@ -353,36 +170,6 @@ impl Cli { ) } - pub async fn execute_worker_task_append(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_task_append(); - if let Some(value) = matches.get_one::("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") @@ -392,23 +179,6 @@ impl Cli { ) } - 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( @@ -425,30 +195,6 @@ impl Cli { ) } - pub async fn execute_worker_task_complete(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_task_complete(); - if let Some(value) = matches.get_one::("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( @@ -471,92 +217,22 @@ impl Cli { ) } - pub async fn execute_worker_task_add_output(&self, matches: &clap::ArgMatches) { - let mut request = self.client.worker_task_add_output(); - if let Some(value) = matches.get_one::("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(), - } +impl Cli { + pub fn new_with_override(client: sdk::Client, over: T) -> Self { + Self { client, over } } pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { - let _ = match cmd { + match cmd { CliCommand::ControlHold => { self.execute_control_hold(matches).await; } @@ -611,246 +287,524 @@ impl Cli { CliCommand::WorkersRecycle => { self.execute_workers_recycle(matches).await; } - }; + } + } + + pub async fn execute_control_hold(&self, matches: &clap::ArgMatches) { + let mut request = self.client.control_hold(); + self.over + .execute_control_hold(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_control_resume(&self, matches: &clap::ArgMatches) { + let mut request = self.client.control_resume(); + self.over + .execute_control_resume(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_task_get(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_tasks_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.tasks_get(); + self.over.execute_tasks_get(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_task_submit(&self, matches: &clap::ArgMatches) { + let mut request = self.client.task_submit(); + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("script") { + request = request.body_map(|body| body.script(value.clone())) + } + + self.over + .execute_task_submit(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_task_events_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_task_outputs_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_task_output_download(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_user_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.user_create(); + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_user_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_whoami(&self, matches: &clap::ArgMatches) { + let mut request = self.client.whoami(); + self.over.execute_whoami(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_worker_bootstrap(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_bootstrap(); + if let Some(value) = matches.get_one::("bootstrap") { + request = request.body_map(|body| body.bootstrap(value.clone())) + } + + if let Some(value) = matches.get_one::("token") { + request = request.body_map(|body| body.token(value.clone())) + } + + self.over + .execute_worker_bootstrap(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_worker_ping(&self, matches: &clap::ArgMatches) { + let mut request = self.client.worker_ping(); + self.over + .execute_worker_ping(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("payload") { + request = request.body_map(|body| body.payload(value.clone())) + } + + if let Some(value) = matches.get_one::("stream") { + request = request.body_map(|body| body.stream(value.clone())) + } + + if let Some(value) = matches.get_one::>("time") { + request = request.body_map(|body| body.time(value.clone())) + } + + self.over + .execute_worker_task_append(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_worker_task_upload_chunk(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("failed") { + request = request.body_map(|body| body.failed(value.clone())) + } + + self.over + .execute_worker_task_complete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("path") { + request = request.body_map(|body| body.path(value.clone())) + } + + if let Some(value) = matches.get_one::("size") { + request = request.body_map(|body| body.size(value.clone())) + } + + self.over + .execute_worker_task_add_output(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_workers_list(&self, matches: &clap::ArgMatches) { + let mut request = self.client.workers_list(); + self.over + .execute_workers_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + pub async fn execute_workers_recycle(&self, matches: &clap::ArgMatches) { + let mut request = self.client.workers_recycle(); + self.over + .execute_workers_recycle(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } } } 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 (), + request: &mut builder::ControlHold, ) -> 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 (), + request: &mut builder::ControlResume, ) -> 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 (), + request: &mut builder::TaskGet, ) -> 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 (), + request: &mut builder::TasksGet, ) -> 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 (), + request: &mut builder::TaskSubmit, ) -> 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 (), + request: &mut builder::TaskEventsGet, ) -> 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 (), + request: &mut builder::TaskOutputsGet, ) -> 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 (), + request: &mut builder::TaskOutputDownload, ) -> 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 (), + request: &mut builder::UserCreate, ) -> Result<(), String> { Ok(()) } - fn cli_whoami(cmd: clap::Command) -> clap::Command { - cmd - } - fn execute_whoami( &self, matches: &clap::ArgMatches, - request: &mut (), - body: &mut (), + request: &mut builder::Whoami, ) -> 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 (), + request: &mut builder::WorkerBootstrap, ) -> 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 (), + request: &mut builder::WorkerPing, ) -> 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 (), + request: &mut builder::WorkerTaskAppend, ) -> 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 (), + request: &mut builder::WorkerTaskUploadChunk, ) -> 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 (), + request: &mut builder::WorkerTaskComplete, ) -> 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 (), + request: &mut builder::WorkerTaskAddOutput, ) -> 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 (), + request: &mut builder::WorkersList, ) -> 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 (), + request: &mut builder::WorkersRecycle, ) -> Result<(), String> { Ok(()) } } +impl CliOverride for () {} + #[derive(Copy, Clone, Debug)] pub enum CliCommand { ControlHold, diff --git a/progenitor-impl/tests/output/keeper-cli.out b/progenitor-impl/tests/output/keeper-cli.out index f5caac0..a46827f 100644 --- a/progenitor-impl/tests/output/keeper-cli.out +++ b/progenitor-impl/tests/output/keeper-cli.out @@ -1,10 +1,22 @@ -pub struct Cli { +pub struct Cli { client: sdk::Client, + over: T, } impl Cli { pub fn new(client: sdk::Client) -> Self { - Self { client } + Self { client, over: () } + } + + 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 fn cli_enrol() -> clap::Command { @@ -30,33 +42,6 @@ impl Cli { ) } - pub async fn execute_enrol(&self, matches: &clap::ArgMatches) { - let mut request = self.client.enrol(); - if let Some(value) = matches.get_one::("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") @@ -67,23 +52,6 @@ impl Cli { ) } - 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") @@ -94,23 +62,6 @@ impl Cli { ) } - 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( @@ -140,38 +91,6 @@ impl Cli { ) } - pub async fn execute_report_finish(&self, matches: &clap::ArgMatches) { - let mut request = self.client.report_finish(); - if let Some(value) = matches.get_one::("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") @@ -182,27 +101,6 @@ impl Cli { ) } - pub async fn execute_report_output(&self, matches: &clap::ArgMatches) { - let mut request = self.client.report_output(); - if let Some(value) = matches.get_one::("authorization") { - request = request.authorization(value.clone()); - } - - 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( @@ -225,49 +123,15 @@ impl Cli { .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(), - } +impl Cli { + pub fn new_with_override(client: sdk::Client, over: T) -> Self { + Self { client, over } } pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { - let _ = match cmd { + match cmd { CliCommand::Enrol => { self.execute_enrol(matches).await; } @@ -286,90 +150,207 @@ impl Cli { CliCommand::ReportStart => { self.execute_report_start(matches).await; } - }; + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("host") { + request = request.body_map(|body| body.host(value.clone())) + } + + if let Some(value) = matches.get_one::("key") { + request = request.body_map(|body| body.key(value.clone())) + } + + self.over.execute_enrol(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_global_jobs(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_ping(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("duration-millis") { + request = request.body_map(|body| body.duration_millis(value.clone())) + } + + if let Some(value) = matches.get_one::>("end-time") { + request = request.body_map(|body| body.end_time(value.clone())) + } + + if let Some(value) = matches.get_one::("exit-status") { + request = request.body_map(|body| body.exit_status(value.clone())) + } + + self.over + .execute_report_finish(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_report_output(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("script") { + request = request.body_map(|body| body.script(value.clone())) + } + + if let Some(value) = matches.get_one::>("start-time") + { + request = request.body_map(|body| body.start_time(value.clone())) + } + + self.over + .execute_report_start(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("success\n{:#?}", r) + } + } } } pub trait CliOverride { - fn cli_enrol(cmd: clap::Command) -> clap::Command { - cmd - } - fn execute_enrol( &self, matches: &clap::ArgMatches, - request: &mut (), - body: &mut (), + request: &mut builder::Enrol, ) -> 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 (), + request: &mut builder::GlobalJobs, ) -> Result<(), String> { Ok(()) } - fn cli_ping(cmd: clap::Command) -> clap::Command { - cmd - } - fn execute_ping( &self, matches: &clap::ArgMatches, - request: &mut (), - body: &mut (), + request: &mut builder::Ping, ) -> 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 (), + request: &mut builder::ReportFinish, ) -> 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 (), + request: &mut builder::ReportOutput, ) -> 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 (), + request: &mut builder::ReportStart, ) -> Result<(), String> { Ok(()) } } +impl CliOverride for () {} + #[derive(Copy, Clone, Debug)] pub enum CliCommand { Enrol, diff --git a/progenitor-impl/tests/output/nexus-cli.out b/progenitor-impl/tests/output/nexus-cli.out index a018b77..dec7a5c 100644 --- a/progenitor-impl/tests/output/nexus-cli.out +++ b/progenitor-impl/tests/output/nexus-cli.out @@ -1,8743 +1,11 @@ -pub struct Cli { +pub struct Cli { client: sdk::Client, + over: T, } 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) - } - } + Self { client, over: () } } pub fn get_command(cmd: CliCommand) -> clap::Command { @@ -8949,8 +217,4170 @@ impl Cli { } } + 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 fn cli_logout() -> clap::Command { + clap::Command::new("") + } + + 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 fn cli_policy_view() -> clap::Command { + clap::Command::new("").about("Fetch the current silo's IAM policy") + } + + pub fn cli_policy_update() -> clap::Command { + clap::Command::new("").about("Update the current silo's IAM policy") + } + + 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 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 fn cli_session_me() -> clap::Command { + clap::Command::new("").about("Fetch the user associated with the current session") + } + + 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 fn cli_ip_pool_service_view() -> clap::Command { + clap::Command::new("").about("Fetch the IP pool used for Oxide services.") + } + + 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 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 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 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 fn cli_system_policy_view() -> clap::Command { + clap::Command::new("").about("Fetch the top-level IAM policy") + } + + pub fn cli_system_policy_update() -> clap::Command { + clap::Command::new("").about("Update the top-level IAM policy") + } + + 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 fn cli_system_update_refresh() -> clap::Command { + clap::Command::new("").about("Refresh update data") + } + + 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 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 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 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 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 fn cli_system_version() -> clap::Command { + clap::Command::new("").about("View system version and update status") + } +} + +impl Cli { + pub fn new_with_override(client: sdk::Client, over: T) -> Self { + Self { client, over } + } + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { - let _ = match cmd { + match cmd { CliCommand::DiskViewById => { self.execute_disk_view_by_id(matches).await; } @@ -9533,2508 +4963,6532 @@ impl Cli { CliCommand::SystemVersion => { self.execute_system_version(matches).await; } - }; + } + } + + 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()); + } + + self.over + .execute_disk_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_image_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_network_interface_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_snapshot_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_route_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_subnet_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_device_auth_request(&self, matches: &clap::ArgMatches) { + let mut request = self.client.device_auth_request(); + if let Some(value) = matches.get_one::("client-id") { + request = request.body_map(|body| body.client_id(value.clone())) + } + + self.over + .execute_device_auth_request(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub async fn execute_device_auth_confirm(&self, matches: &clap::ArgMatches) { + let mut request = self.client.device_auth_confirm(); + if let Some(value) = matches.get_one::("user-code") { + request = request.body_map(|body| body.user_code(value.clone())) + } + + self.over + .execute_device_auth_confirm(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_device_access_token(&self, matches: &clap::ArgMatches) { + let mut request = self.client.device_access_token(); + if let Some(value) = matches.get_one::("client-id") { + request = request.body_map(|body| body.client_id(value.clone())) + } + + if let Some(value) = matches.get_one::("device-code") { + request = request.body_map(|body| body.device_code(value.clone())) + } + + if let Some(value) = matches.get_one::("grant-type") { + request = request.body_map(|body| body.grant_type(value.clone())) + } + + self.over + .execute_device_access_token(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + 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()); + } + + self.over.execute_group_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_login_spoof(&self, matches: &clap::ArgMatches) { + let mut request = self.client.login_spoof(); + if let Some(value) = matches.get_one::("username") { + request = request.body_map(|body| body.username(value.clone())) + } + + self.over + .execute_login_spoof(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("password") { + request = request.body_map(|body| body.password(value.clone())) + } + + if let Some(value) = matches.get_one::("username") { + request = request.body_map(|body| body.username(value.clone())) + } + + self.over + .execute_login_local(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_login_saml_begin(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_login_saml(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_logout(&self, matches: &clap::ArgMatches) { + let mut request = self.client.logout(); + self.over.execute_logout(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_organization_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_create(); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_organization_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_policy_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_policy_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_project_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_disk_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("size") { + request = request.body_map(|body| body.size(value.clone())) + } + + self.over + .execute_disk_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_disk_view(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_disk_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_disk_metrics_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_image_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_image_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_image_view(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_image_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("hostname") { + request = request.body_map(|body| body.hostname(value.clone())) + } + + if let Some(value) = matches.get_one::("memory") { + request = request.body_map(|body| body.memory(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("ncpus") { + request = request.body_map(|body| body.ncpus(value.clone())) + } + + if let Some(value) = matches.get_one::("start") { + request = request.body_map(|body| body.start(value.clone())) + } + + if let Some(value) = matches.get_one::("user-data") { + request = request.body_map(|body| body.user_data(value.clone())) + } + + self.over + .execute_instance_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_disk_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_instance_disk_attach(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_instance_disk_detach(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_external_ip_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("dst-sled-id") { + request = request.body_map(|body| body.dst_sled_id(value.clone())) + } + + self.over + .execute_instance_migrate(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_network_interface_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("subnet-name") { + request = request.body_map(|body| body.subnet_name(value.clone())) + } + + if let Some(value) = matches.get_one::("vpc-name") { + request = request.body_map(|body| body.vpc_name(value.clone())) + } + + self.over + .execute_instance_network_interface_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_network_interface_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("primary") { + request = request.body_map(|body| body.primary(value.clone())) + } + + self.over + .execute_instance_network_interface_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_network_interface_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_reboot(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_serial_console(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_serial_console_stream(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + 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()); + } + + self.over + .execute_instance_start(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_stop(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_policy_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_policy_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_snapshot_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("disk") { + request = request.body_map(|body| body.disk(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_snapshot_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_snapshot_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_snapshot_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_vpc_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("dns-name") { + request = request.body_map(|body| body.dns_name(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over.execute_vpc_create(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_vpc_view(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_vpc_update(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_vpc_delete(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_firewall_rules_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_firewall_rules_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_vpc_router_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_route_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_vpc_router_route_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_route_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_route_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_router_route_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_subnet_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("ipv4-block") { + request = request.body_map(|body| body.ipv4_block(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_vpc_subnet_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_subnet_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_subnet_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_subnet_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_vpc_subnet_list_network_interfaces(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_policy_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.policy_view(); + self.over + .execute_policy_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_policy_update(&self, matches: &clap::ArgMatches) { + let mut request = self.client.policy_update(); + self.over + .execute_policy_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_role_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_role_view(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_session_me(&self, matches: &clap::ArgMatches) { + let mut request = self.client.session_me(); + self.over.execute_session_me(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_session_me_groups(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_session_sshkey_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_session_sshkey_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.session_sshkey_create(); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("public-key") { + request = request.body_map(|body| body.public_key(value.clone())) + } + + self.over + .execute_session_sshkey_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_session_sshkey_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_session_sshkey_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_image_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_silo_view_by_id(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_certificate_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_certificate_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.certificate_create(); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("service") { + request = request.body_map(|body| body.service(value.clone())) + } + + self.over + .execute_certificate_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_certificate_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_certificate_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_physical_disk_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_rack_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_rack_view(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_sled_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_sled_view(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_sled_physical_disk_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_image_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_system_image_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_image_create(); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_system_image_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_image_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_image_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_ip_pool_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_create(); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_ip_pool_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_range_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_range_add(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_range_remove(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_ip_pool_service_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_service_view(); + self.over + .execute_ip_pool_service_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_ip_pool_service_range_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_ip_pool_service_range_add(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_service_range_add(); + self.over + .execute_ip_pool_service_range_add(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_ip_pool_service_range_remove(&self, matches: &clap::ArgMatches) { + let mut request = self.client.ip_pool_service_range_remove(); + self.over + .execute_ip_pool_service_range_remove(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_metric(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_system_policy_view(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_policy_view(); + self.over + .execute_system_policy_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_system_policy_update(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_policy_update(); + self.over + .execute_system_policy_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_saga_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_saga_view(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_silo_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_silo_create(&self, matches: &clap::ArgMatches) { + let mut request = self.client.silo_create(); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("discoverable") { + request = request.body_map(|body| body.discoverable(value.clone())) + } + + if let Some(value) = matches.get_one::("identity-mode") { + request = request.body_map(|body| body.identity_mode(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_silo_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_silo_view(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_silo_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_silo_identity_provider_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("external-id") { + request = request.body_map(|body| body.external_id(value.clone())) + } + + self.over + .execute_local_idp_user_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_local_idp_user_delete(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_local_idp_user_set_password(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("acs-url") { + request = request.body_map(|body| body.acs_url(value.clone())) + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("idp-entity-id") { + request = request.body_map(|body| body.idp_entity_id(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("slo-url") { + request = request.body_map(|body| body.slo_url(value.clone())) + } + + if let Some(value) = matches.get_one::("sp-client-id") { + request = request.body_map(|body| body.sp_client_id(value.clone())) + } + + if let Some(value) = matches.get_one::("technical-contact-email") { + request = request.body_map(|body| body.technical_contact_email(value.clone())) + } + + self.over + .execute_saml_identity_provider_create(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_saml_identity_provider_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_silo_policy_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_silo_policy_update(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_silo_users_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_silo_user_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_user_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_user_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_timeseries_schema_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over.execute_user_list(matches, &mut request).unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_disk_list_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("size") { + request = request.body_map(|body| body.size(value.clone())) + } + + self.over + .execute_disk_create_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_disk_view_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_disk_delete_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_list_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("hostname") { + request = request.body_map(|body| body.hostname(value.clone())) + } + + if let Some(value) = matches.get_one::("memory") { + request = request.body_map(|body| body.memory(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + if let Some(value) = matches.get_one::("ncpus") { + request = request.body_map(|body| body.ncpus(value.clone())) + } + + if let Some(value) = matches.get_one::("start") { + request = request.body_map(|body| body.start(value.clone())) + } + + if let Some(value) = matches.get_one::("user-data") { + request = request.body_map(|body| body.user_data(value.clone())) + } + + self.over + .execute_instance_create_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_view_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_delete_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_disk_list_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("disk") { + request = request.body_map(|body| body.disk(value.clone())) + } + + self.over + .execute_instance_disk_attach_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("disk") { + request = request.body_map(|body| body.disk(value.clone())) + } + + self.over + .execute_instance_disk_detach_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("dst-sled-id") { + request = request.body_map(|body| body.dst_sled_id(value.clone())) + } + + self.over + .execute_instance_migrate_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_reboot_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_serial_console_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_serial_console_stream_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + 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()); + } + + self.over + .execute_instance_start_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_stop_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_list_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_organization_create_v1(&self, matches: &clap::ArgMatches) { + let mut request = self.client.organization_create_v1(); + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_organization_create_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_view_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_update_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_delete_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_policy_view_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_organization_policy_update_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_list_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + if let Some(value) = matches.get_one::("description") { + request = request.body_map(|body| body.description(value.clone())) + } + + if let Some(value) = matches.get_one::("name") { + request = request.body_map(|body| body.name(value.clone())) + } + + self.over + .execute_project_create_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_view_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_update_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_delete_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_policy_view_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_project_policy_update_v1(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_component_version_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_update_deployments_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_update_deployment_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_system_update_refresh(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_refresh(); + self.over + .execute_system_update_refresh(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_system_update_start(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_start(); + if let Some(value) = matches.get_one::("version") { + request = request.body_map(|body| body.version(value.clone())) + } + + self.over + .execute_system_update_start(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_system_update_stop(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_update_stop(); + self.over + .execute_system_update_stop(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_update_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_update_view(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_system_update_components_list(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_system_version(&self, matches: &clap::ArgMatches) { + let mut request = self.client.system_version(); + self.over + .execute_system_version(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } } } 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 (), + request: &mut builder::DiskViewById, ) -> 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 (), + request: &mut builder::ImageViewById, ) -> 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 (), + request: &mut builder::InstanceViewById, ) -> 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 (), + request: &mut builder::InstanceNetworkInterfaceViewById, ) -> 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 (), + request: &mut builder::OrganizationViewById, ) -> 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 (), + request: &mut builder::ProjectViewById, ) -> 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 (), + request: &mut builder::SnapshotViewById, ) -> 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 (), + request: &mut builder::VpcRouterRouteViewById, ) -> 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 (), + request: &mut builder::VpcRouterViewById, ) -> 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 (), + request: &mut builder::VpcSubnetViewById, ) -> 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 (), + request: &mut builder::VpcViewById, ) -> 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 (), + request: &mut builder::DeviceAuthRequest, ) -> 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 (), + request: &mut builder::DeviceAuthConfirm, ) -> 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 (), + request: &mut builder::DeviceAccessToken, ) -> 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 (), + request: &mut builder::GroupList, ) -> 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 (), + request: &mut builder::LoginSpoof, ) -> 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 (), + request: &mut builder::LoginLocal, ) -> 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 (), + request: &mut builder::LoginSamlBegin, ) -> 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 (), + request: &mut builder::LoginSaml, ) -> Result<(), String> { Ok(()) } - fn cli_logout(cmd: clap::Command) -> clap::Command { - cmd - } - fn execute_logout( &self, matches: &clap::ArgMatches, - request: &mut (), - body: &mut (), + request: &mut builder::Logout, ) -> 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 (), + request: &mut builder::OrganizationList, ) -> 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 (), + request: &mut builder::OrganizationCreate, ) -> 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 (), + request: &mut builder::OrganizationView, ) -> 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 (), + request: &mut builder::OrganizationUpdate, ) -> 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 (), + request: &mut builder::OrganizationDelete, ) -> 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 (), + request: &mut builder::OrganizationPolicyView, ) -> 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 (), + request: &mut builder::OrganizationPolicyUpdate, ) -> 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 (), + request: &mut builder::ProjectList, ) -> 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 (), + request: &mut builder::ProjectCreate, ) -> 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 (), + request: &mut builder::ProjectView, ) -> 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 (), + request: &mut builder::ProjectUpdate, ) -> 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 (), + request: &mut builder::ProjectDelete, ) -> 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 (), + request: &mut builder::DiskList, ) -> 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 (), + request: &mut builder::DiskCreate, ) -> 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 (), + request: &mut builder::DiskView, ) -> 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 (), + request: &mut builder::DiskDelete, ) -> 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 (), + request: &mut builder::DiskMetricsList, ) -> 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 (), + request: &mut builder::ImageList, ) -> 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 (), + request: &mut builder::ImageCreate, ) -> 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 (), + request: &mut builder::ImageView, ) -> 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 (), + request: &mut builder::ImageDelete, ) -> 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 (), + request: &mut builder::InstanceList, ) -> 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 (), + request: &mut builder::InstanceCreate, ) -> 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 (), + request: &mut builder::InstanceView, ) -> 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 (), + request: &mut builder::InstanceDelete, ) -> 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 (), + request: &mut builder::InstanceDiskList, ) -> 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 (), + request: &mut builder::InstanceDiskAttach, ) -> 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 (), + request: &mut builder::InstanceDiskDetach, ) -> 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 (), + request: &mut builder::InstanceExternalIpList, ) -> 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 (), + request: &mut builder::InstanceMigrate, ) -> 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 (), + request: &mut builder::InstanceNetworkInterfaceList, ) -> 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 (), + request: &mut builder::InstanceNetworkInterfaceCreate, ) -> 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 (), + request: &mut builder::InstanceNetworkInterfaceView, ) -> 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 (), + request: &mut builder::InstanceNetworkInterfaceUpdate, ) -> 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 (), + request: &mut builder::InstanceNetworkInterfaceDelete, ) -> 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 (), + request: &mut builder::InstanceReboot, ) -> 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 (), + request: &mut builder::InstanceSerialConsole, ) -> 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 (), + request: &mut builder::InstanceSerialConsoleStream, ) -> 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 (), + request: &mut builder::InstanceStart, ) -> 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 (), + request: &mut builder::InstanceStop, ) -> 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 (), + request: &mut builder::ProjectPolicyView, ) -> 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 (), + request: &mut builder::ProjectPolicyUpdate, ) -> 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 (), + request: &mut builder::SnapshotList, ) -> 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 (), + request: &mut builder::SnapshotCreate, ) -> 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 (), + request: &mut builder::SnapshotView, ) -> 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 (), + request: &mut builder::SnapshotDelete, ) -> 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 (), + request: &mut builder::VpcList, ) -> 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 (), + request: &mut builder::VpcCreate, ) -> 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 (), + request: &mut builder::VpcView, ) -> 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 (), + request: &mut builder::VpcUpdate, ) -> 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 (), + request: &mut builder::VpcDelete, ) -> 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 (), + request: &mut builder::VpcFirewallRulesView, ) -> 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 (), + request: &mut builder::VpcFirewallRulesUpdate, ) -> 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 (), + request: &mut builder::VpcRouterList, ) -> 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 (), + request: &mut builder::VpcRouterCreate, ) -> 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 (), + request: &mut builder::VpcRouterView, ) -> 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 (), + request: &mut builder::VpcRouterUpdate, ) -> 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 (), + request: &mut builder::VpcRouterDelete, ) -> 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 (), + request: &mut builder::VpcRouterRouteList, ) -> 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 (), + request: &mut builder::VpcRouterRouteCreate, ) -> 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 (), + request: &mut builder::VpcRouterRouteView, ) -> 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 (), + request: &mut builder::VpcRouterRouteUpdate, ) -> 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 (), + request: &mut builder::VpcRouterRouteDelete, ) -> 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 (), + request: &mut builder::VpcSubnetList, ) -> 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 (), + request: &mut builder::VpcSubnetCreate, ) -> 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 (), + request: &mut builder::VpcSubnetView, ) -> 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 (), + request: &mut builder::VpcSubnetUpdate, ) -> 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 (), + request: &mut builder::VpcSubnetDelete, ) -> 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 (), + request: &mut builder::VpcSubnetListNetworkInterfaces, ) -> 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 (), + request: &mut builder::PolicyView, ) -> 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 (), + request: &mut builder::PolicyUpdate, ) -> 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 (), + request: &mut builder::RoleList, ) -> 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 (), + request: &mut builder::RoleView, ) -> 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 (), + request: &mut builder::SessionMe, ) -> 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 (), + request: &mut builder::SessionMeGroups, ) -> 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 (), + request: &mut builder::SessionSshkeyList, ) -> 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 (), + request: &mut builder::SessionSshkeyCreate, ) -> 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 (), + request: &mut builder::SessionSshkeyView, ) -> 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 (), + request: &mut builder::SessionSshkeyDelete, ) -> 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 (), + request: &mut builder::SystemImageViewById, ) -> 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 (), + request: &mut builder::IpPoolViewById, ) -> 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 (), + request: &mut builder::SiloViewById, ) -> 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 (), + request: &mut builder::CertificateList, ) -> 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 (), + request: &mut builder::CertificateCreate, ) -> 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 (), + request: &mut builder::CertificateView, ) -> 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 (), + request: &mut builder::CertificateDelete, ) -> 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 (), + request: &mut builder::PhysicalDiskList, ) -> 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 (), + request: &mut builder::RackList, ) -> 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 (), + request: &mut builder::RackView, ) -> 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 (), + request: &mut builder::SledList, ) -> 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 (), + request: &mut builder::SledView, ) -> 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 (), + request: &mut builder::SledPhysicalDiskList, ) -> 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 (), + request: &mut builder::SystemImageList, ) -> 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 (), + request: &mut builder::SystemImageCreate, ) -> 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 (), + request: &mut builder::SystemImageView, ) -> 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 (), + request: &mut builder::SystemImageDelete, ) -> 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 (), + request: &mut builder::IpPoolList, ) -> 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 (), + request: &mut builder::IpPoolCreate, ) -> 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 (), + request: &mut builder::IpPoolView, ) -> 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 (), + request: &mut builder::IpPoolUpdate, ) -> 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 (), + request: &mut builder::IpPoolDelete, ) -> 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 (), + request: &mut builder::IpPoolRangeList, ) -> 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 (), + request: &mut builder::IpPoolRangeAdd, ) -> 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 (), + request: &mut builder::IpPoolRangeRemove, ) -> 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 (), + request: &mut builder::IpPoolServiceView, ) -> 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 (), + request: &mut builder::IpPoolServiceRangeList, ) -> 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 (), + request: &mut builder::IpPoolServiceRangeAdd, ) -> 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 (), + request: &mut builder::IpPoolServiceRangeRemove, ) -> 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 (), + request: &mut builder::SystemMetric, ) -> 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 (), + request: &mut builder::SystemPolicyView, ) -> 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 (), + request: &mut builder::SystemPolicyUpdate, ) -> 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 (), + request: &mut builder::SagaList, ) -> 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 (), + request: &mut builder::SagaView, ) -> 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 (), + request: &mut builder::SiloList, ) -> 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 (), + request: &mut builder::SiloCreate, ) -> 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 (), + request: &mut builder::SiloView, ) -> 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 (), + request: &mut builder::SiloDelete, ) -> 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 (), + request: &mut builder::SiloIdentityProviderList, ) -> 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 (), + request: &mut builder::LocalIdpUserCreate, ) -> 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 (), + request: &mut builder::LocalIdpUserDelete, ) -> 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 (), + request: &mut builder::LocalIdpUserSetPassword, ) -> 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 (), + request: &mut builder::SamlIdentityProviderCreate, ) -> 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 (), + request: &mut builder::SamlIdentityProviderView, ) -> 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 (), + request: &mut builder::SiloPolicyView, ) -> 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 (), + request: &mut builder::SiloPolicyUpdate, ) -> 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 (), + request: &mut builder::SiloUsersList, ) -> 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 (), + request: &mut builder::SiloUserView, ) -> 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 (), + request: &mut builder::SystemUserList, ) -> 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 (), + request: &mut builder::SystemUserView, ) -> 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 (), + request: &mut builder::TimeseriesSchemaGet, ) -> 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 (), + request: &mut builder::UserList, ) -> 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 (), + request: &mut builder::DiskListV1, ) -> 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 (), + request: &mut builder::DiskCreateV1, ) -> 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 (), + request: &mut builder::DiskViewV1, ) -> 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 (), + request: &mut builder::DiskDeleteV1, ) -> 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 (), + request: &mut builder::InstanceListV1, ) -> 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 (), + request: &mut builder::InstanceCreateV1, ) -> 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 (), + request: &mut builder::InstanceViewV1, ) -> 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 (), + request: &mut builder::InstanceDeleteV1, ) -> 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 (), + request: &mut builder::InstanceDiskListV1, ) -> 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 (), + request: &mut builder::InstanceDiskAttachV1, ) -> 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 (), + request: &mut builder::InstanceDiskDetachV1, ) -> 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 (), + request: &mut builder::InstanceMigrateV1, ) -> 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 (), + request: &mut builder::InstanceRebootV1, ) -> 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 (), + request: &mut builder::InstanceSerialConsoleV1, ) -> 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 (), + request: &mut builder::InstanceSerialConsoleStreamV1, ) -> 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 (), + request: &mut builder::InstanceStartV1, ) -> 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 (), + request: &mut builder::InstanceStopV1, ) -> 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 (), + request: &mut builder::OrganizationListV1, ) -> 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 (), + request: &mut builder::OrganizationCreateV1, ) -> 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 (), + request: &mut builder::OrganizationViewV1, ) -> 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 (), + request: &mut builder::OrganizationUpdateV1, ) -> 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 (), + request: &mut builder::OrganizationDeleteV1, ) -> 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 (), + request: &mut builder::OrganizationPolicyViewV1, ) -> 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 (), + request: &mut builder::OrganizationPolicyUpdateV1, ) -> 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 (), + request: &mut builder::ProjectListV1, ) -> 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 (), + request: &mut builder::ProjectCreateV1, ) -> 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 (), + request: &mut builder::ProjectViewV1, ) -> 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 (), + request: &mut builder::ProjectUpdateV1, ) -> 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 (), + request: &mut builder::ProjectDeleteV1, ) -> 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 (), + request: &mut builder::ProjectPolicyViewV1, ) -> 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 (), + request: &mut builder::ProjectPolicyUpdateV1, ) -> 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 (), + request: &mut builder::SystemComponentVersionList, ) -> 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 (), + request: &mut builder::UpdateDeploymentsList, ) -> 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 (), + request: &mut builder::UpdateDeploymentView, ) -> 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 (), + request: &mut builder::SystemUpdateRefresh, ) -> 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 (), + request: &mut builder::SystemUpdateStart, ) -> 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 (), + request: &mut builder::SystemUpdateStop, ) -> 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 (), + request: &mut builder::SystemUpdateList, ) -> 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 (), + request: &mut builder::SystemUpdateView, ) -> 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 (), + request: &mut builder::SystemUpdateComponentsList, ) -> 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 (), + request: &mut builder::SystemVersion, ) -> Result<(), String> { Ok(()) } } +impl CliOverride for () {} + #[derive(Copy, Clone, Debug)] pub enum CliCommand { DiskViewById, diff --git a/progenitor-impl/tests/output/param-overrides-cli.out b/progenitor-impl/tests/output/param-overrides-cli.out index 0c535cc..0595ca7 100644 --- a/progenitor-impl/tests/output/param-overrides-cli.out +++ b/progenitor-impl/tests/output/param-overrides-cli.out @@ -1,10 +1,17 @@ -pub struct Cli { +pub struct Cli { client: sdk::Client, + over: T, } impl Cli { pub fn new(client: sdk::Client) -> Self { - Self { client } + Self { client, over: () } + } + + pub fn get_command(cmd: CliCommand) -> clap::Command { + match cmd { + CliCommand::KeyGet => Self::cli_key_get(), + } } pub fn cli_key_get() -> clap::Command { @@ -24,6 +31,20 @@ impl Cli { .help("A key parameter that will not be overridden by the path spec"), ) } +} + +impl Cli { + pub fn new_with_override(client: sdk::Client, over: T) -> Self { + Self { client, over } + } + + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { + match cmd { + CliCommand::KeyGet => { + self.execute_key_get(matches).await; + } + } + } pub async fn execute_key_get(&self, matches: &clap::ArgMatches) { let mut request = self.client.key_get(); @@ -35,6 +56,7 @@ impl Cli { request = request.unique_key(value.clone()); } + self.over.execute_key_get(matches, &mut request).unwrap(); let result = request.send().await; match result { Ok(r) => { @@ -45,37 +67,20 @@ impl Cli { } } } - - 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 (), + request: &mut builder::KeyGet, ) -> Result<(), String> { Ok(()) } } +impl CliOverride for () {} + #[derive(Copy, Clone, Debug)] pub enum CliCommand { KeyGet, diff --git a/progenitor-impl/tests/output/propolis-server-cli.out b/progenitor-impl/tests/output/propolis-server-cli.out index 93957f1..47794ee 100644 --- a/progenitor-impl/tests/output/propolis-server-cli.out +++ b/progenitor-impl/tests/output/propolis-server-cli.out @@ -1,50 +1,35 @@ -pub struct Cli { +pub struct Cli { client: sdk::Client, + over: T, } impl Cli { pub fn new(client: sdk::Client) -> Self { - Self { client } + Self { client, over: () } + } + + 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 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( @@ -62,30 +47,6 @@ impl Cli { .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") @@ -95,60 +56,14 @@ impl Cli { ) } - 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") @@ -157,43 +72,15 @@ impl Cli { .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(), - } +impl Cli { + pub fn new_with_override(client: sdk::Client, over: T) -> Self { + Self { client, over } } pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { - let _ = match cmd { + match cmd { CliCommand::InstanceGet => { self.execute_instance_get(matches).await; } @@ -216,103 +103,201 @@ impl Cli { CliCommand::InstanceStateMonitor => { self.execute_instance_state_monitor(matches).await; } - }; + } + } + + pub async fn execute_instance_get(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_get(); + self.over + .execute_instance_get(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_instance_ensure(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_ensure(); + self.over + .execute_instance_ensure(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + 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()); + } + + self.over + .execute_instance_issue_crucible_snapshot_request(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_instance_migrate_status(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_migrate_status(); + if let Some(value) = matches.get_one::("migration-id") { + request = request.body_map(|body| body.migration_id(value.clone())) + } + + self.over + .execute_instance_migrate_status(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_instance_serial(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_serial(); + self.over + .execute_instance_serial(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + todo!() + } + Err(r) => { + todo!() + } + } + } + + pub async fn execute_instance_state_put(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_state_put(); + self.over + .execute_instance_state_put(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } + } + + pub async fn execute_instance_state_monitor(&self, matches: &clap::ArgMatches) { + let mut request = self.client.instance_state_monitor(); + if let Some(value) = matches.get_one::("gen") { + request = request.body_map(|body| body.gen(value.clone())) + } + + self.over + .execute_instance_state_monitor(matches, &mut request) + .unwrap(); + let result = request.send().await; + match result { + Ok(r) => { + println!("success\n{:#?}", r) + } + Err(r) => { + println!("error\n{:#?}", r) + } + } } } 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 (), + request: &mut builder::InstanceGet, ) -> 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 (), + request: &mut builder::InstanceEnsure, ) -> 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 (), + request: &mut builder::InstanceIssueCrucibleSnapshotRequest, ) -> 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 (), + request: &mut builder::InstanceMigrateStatus, ) -> 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 (), + request: &mut builder::InstanceSerial, ) -> 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 (), + request: &mut builder::InstanceStatePut, ) -> 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 (), + request: &mut builder::InstanceStateMonitor, ) -> Result<(), String> { Ok(()) } } +impl CliOverride for () {} + #[derive(Copy, Clone, Debug)] pub enum CliCommand { InstanceGet,