From e4359fb57c999ae54fb8c918736c0b6c4ae70280 Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Mon, 5 Feb 2024 16:21:02 -0800 Subject: [PATCH] pick up new progenitor CLI interface (#545) --- Cargo.lock | 41 +- cli/Cargo.toml | 1 + cli/src/cli_builder.rs | 7 +- cli/src/generated_cli.rs | 3627 +++++++++-------- cli/src/main.rs | 89 +- cli/tests/data/test_instance_create.stdout | 31 +- .../data/test_projects_list_paginated.stdout | 153 +- .../test_projects_list_paginated_fail.stdout | 63 + .../data/test_projects_simple_list.stdout | 18 +- .../data/test_silo_idp_saml_create.stdout | 30 +- cli/tests/test_projects.rs | 16 +- cli/tests/test_silo_idp_saml.rs | 117 +- 12 files changed, 2214 insertions(+), 1979 deletions(-) create mode 100644 cli/tests/data/test_projects_list_paginated_fail.stdout diff --git a/Cargo.lock b/Cargo.lock index 634e70d6..b0e7217d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,6 +38,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -1275,6 +1281,10 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heck" @@ -1413,7 +1423,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.5", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -2012,7 +2022,7 @@ dependencies = [ "futures", "progenitor-client 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand", - "regress", + "regress 0.7.1", "reqwest", "schemars", "serde", @@ -2052,6 +2062,7 @@ dependencies = [ "rand", "rcgen", "reqwest", + "schemars", "serde", "serde_json", "tabwriter", @@ -2311,7 +2322,7 @@ dependencies = [ [[package]] name = "progenitor" version = "0.5.0" -source = "git+https://github.com/oxidecomputer/progenitor#3ff2ec1d5ff67a095e49e48b0064f9e40e1f7f1a" +source = "git+https://github.com/oxidecomputer/progenitor#dc5e1f1840a51354adb2b1aa31218f923aef3d64" dependencies = [ "progenitor-client 0.5.0 (git+https://github.com/oxidecomputer/progenitor)", "progenitor-impl", @@ -2337,7 +2348,7 @@ dependencies = [ [[package]] name = "progenitor-client" version = "0.5.0" -source = "git+https://github.com/oxidecomputer/progenitor#3ff2ec1d5ff67a095e49e48b0064f9e40e1f7f1a" +source = "git+https://github.com/oxidecomputer/progenitor#dc5e1f1840a51354adb2b1aa31218f923aef3d64" dependencies = [ "bytes", "futures-core", @@ -2351,7 +2362,7 @@ dependencies = [ [[package]] name = "progenitor-impl" version = "0.5.0" -source = "git+https://github.com/oxidecomputer/progenitor#3ff2ec1d5ff67a095e49e48b0064f9e40e1f7f1a" +source = "git+https://github.com/oxidecomputer/progenitor#dc5e1f1840a51354adb2b1aa31218f923aef3d64" dependencies = [ "getopts", "heck", @@ -2373,7 +2384,7 @@ dependencies = [ [[package]] name = "progenitor-macro" version = "0.5.0" -source = "git+https://github.com/oxidecomputer/progenitor#3ff2ec1d5ff67a095e49e48b0064f9e40e1f7f1a" +source = "git+https://github.com/oxidecomputer/progenitor#dc5e1f1840a51354adb2b1aa31218f923aef3d64" dependencies = [ "openapiv3", "proc-macro2", @@ -2503,6 +2514,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "regress" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f5f39ba4513916c1b2657b72af6ec671f091cd637992f58d0ede5cae4e5dea0" +dependencies = [ + "hashbrown 0.14.3", + "memchr", +] + [[package]] name = "reqwest" version = "0.11.24" @@ -3552,7 +3573,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "typify" version = "0.0.15" -source = "git+https://github.com/oxidecomputer/typify#87d82b2b6ba0cccf91d2605203c5f13cc4ca1c8c" +source = "git+https://github.com/oxidecomputer/typify#b2deb3a6a5141e07b43eb0fa89b29b403f2912b6" dependencies = [ "typify-impl", "typify-macro", @@ -3561,13 +3582,13 @@ dependencies = [ [[package]] name = "typify-impl" version = "0.0.15" -source = "git+https://github.com/oxidecomputer/typify#87d82b2b6ba0cccf91d2605203c5f13cc4ca1c8c" +source = "git+https://github.com/oxidecomputer/typify#b2deb3a6a5141e07b43eb0fa89b29b403f2912b6" dependencies = [ "heck", "log", "proc-macro2", "quote", - "regress", + "regress 0.8.0", "schemars", "serde_json", "syn 2.0.48", @@ -3578,7 +3599,7 @@ dependencies = [ [[package]] name = "typify-macro" version = "0.0.15" -source = "git+https://github.com/oxidecomputer/typify#87d82b2b6ba0cccf91d2605203c5f13cc4ca1c8c" +source = "git+https://github.com/oxidecomputer/typify#b2deb3a6a5141e07b43eb0fa89b29b403f2912b6" dependencies = [ "proc-macro2", "quote", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index de7191e9..44922afc 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -34,6 +34,7 @@ open = { workspace = true } oxide = { workspace = true } predicates = { workspace = true } reqwest = { workspace = true, features = ["native-tls-vendored"] } +schemars = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } tabwriter = { workspace = true } diff --git a/cli/src/cli_builder.rs b/cli/src/cli_builder.rs index d4ca9dc9..105e19ce 100644 --- a/cli/src/cli_builder.rs +++ b/cli/src/cli_builder.rs @@ -74,7 +74,7 @@ impl<'a> Default for NewCli<'a> { let Some(path) = xxx(op) else { continue }; runner.add_cmd(path, GeneratedCmd(op)); - let cmd = Cli::get_command(op); + let cmd = Cli::::get_command(op); let cmd = match op { CliCommand::IpPoolRangeAdd | CliCommand::IpPoolRangeRemove @@ -245,9 +245,8 @@ struct GeneratedCmd(CliCommand); #[async_trait] impl RunIt for GeneratedCmd { async fn run_cmd(&self, matches: &ArgMatches, ctx: &Context) -> Result<()> { - let cli = Cli::new_with_override(ctx.client()?.clone(), OxideOverride); - cli.execute(self.0, matches).await; - Ok(()) + let cli = Cli::new(ctx.client()?.clone(), OxideOverride::default()); + cli.execute(self.0, matches).await } fn is_subtree(&self) -> bool { diff --git a/cli/src/generated_cli.rs b/cli/src/generated_cli.rs index 31e32cd1..2d3d18ab 100644 --- a/cli/src/generated_cli.rs +++ b/cli/src/generated_cli.rs @@ -1,14 +1,14 @@ // The contents of this file are generated; do not modify them. use oxide::*; -pub struct Cli { +pub struct Cli { client: Client, - over: T, + config: T, } -impl Cli { - pub fn new(client: Client) -> Self { - Self { client, over: () } +impl Cli { + pub fn new(client: Client, config: T) -> Self { + Self { client, config } } pub fn get_command(cmd: CliCommand) -> clap::Command { @@ -5189,554 +5189,303 @@ impl Cli { ) .about("Delete a VPC") } -} - -impl Cli { - pub fn new_with_override(client: Client, over: T) -> Self { - Self { client, over } - } - pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) { + pub async fn execute(&self, cmd: CliCommand, matches: &clap::ArgMatches) -> anyhow::Result<()> { match cmd { - CliCommand::DeviceAuthRequest => { - self.execute_device_auth_request(matches).await; - } - CliCommand::DeviceAuthConfirm => { - self.execute_device_auth_confirm(matches).await; - } - CliCommand::DeviceAccessToken => { - self.execute_device_access_token(matches).await; - } - CliCommand::LoginSaml => { - self.execute_login_saml(matches).await; - } - CliCommand::CertificateList => { - self.execute_certificate_list(matches).await; - } - CliCommand::CertificateCreate => { - self.execute_certificate_create(matches).await; - } - CliCommand::CertificateView => { - self.execute_certificate_view(matches).await; - } - CliCommand::CertificateDelete => { - self.execute_certificate_delete(matches).await; - } - CliCommand::DiskList => { - self.execute_disk_list(matches).await; - } - CliCommand::DiskCreate => { - self.execute_disk_create(matches).await; - } - CliCommand::DiskView => { - self.execute_disk_view(matches).await; - } - CliCommand::DiskDelete => { - self.execute_disk_delete(matches).await; - } - CliCommand::DiskBulkWriteImport => { - self.execute_disk_bulk_write_import(matches).await; - } + CliCommand::DeviceAuthRequest => self.execute_device_auth_request(matches).await, + CliCommand::DeviceAuthConfirm => self.execute_device_auth_confirm(matches).await, + CliCommand::DeviceAccessToken => self.execute_device_access_token(matches).await, + CliCommand::LoginSaml => self.execute_login_saml(matches).await, + CliCommand::CertificateList => self.execute_certificate_list(matches).await, + CliCommand::CertificateCreate => self.execute_certificate_create(matches).await, + CliCommand::CertificateView => self.execute_certificate_view(matches).await, + CliCommand::CertificateDelete => self.execute_certificate_delete(matches).await, + CliCommand::DiskList => self.execute_disk_list(matches).await, + CliCommand::DiskCreate => self.execute_disk_create(matches).await, + CliCommand::DiskView => self.execute_disk_view(matches).await, + CliCommand::DiskDelete => self.execute_disk_delete(matches).await, + CliCommand::DiskBulkWriteImport => self.execute_disk_bulk_write_import(matches).await, CliCommand::DiskBulkWriteImportStart => { - self.execute_disk_bulk_write_import_start(matches).await; + self.execute_disk_bulk_write_import_start(matches).await } CliCommand::DiskBulkWriteImportStop => { - self.execute_disk_bulk_write_import_stop(matches).await; - } - CliCommand::DiskFinalizeImport => { - self.execute_disk_finalize_import(matches).await; - } - CliCommand::DiskMetricsList => { - self.execute_disk_metrics_list(matches).await; - } - CliCommand::FloatingIpList => { - self.execute_floating_ip_list(matches).await; - } - CliCommand::FloatingIpCreate => { - self.execute_floating_ip_create(matches).await; - } - CliCommand::FloatingIpView => { - self.execute_floating_ip_view(matches).await; - } - CliCommand::FloatingIpDelete => { - self.execute_floating_ip_delete(matches).await; - } - CliCommand::FloatingIpAttach => { - self.execute_floating_ip_attach(matches).await; - } - CliCommand::FloatingIpDetach => { - self.execute_floating_ip_detach(matches).await; - } - CliCommand::GroupList => { - self.execute_group_list(matches).await; - } - CliCommand::GroupView => { - self.execute_group_view(matches).await; - } - CliCommand::ImageList => { - self.execute_image_list(matches).await; - } - CliCommand::ImageCreate => { - self.execute_image_create(matches).await; - } - CliCommand::ImageView => { - self.execute_image_view(matches).await; - } - CliCommand::ImageDelete => { - self.execute_image_delete(matches).await; - } - CliCommand::ImageDemote => { - self.execute_image_demote(matches).await; - } - CliCommand::ImagePromote => { - self.execute_image_promote(matches).await; - } - CliCommand::InstanceList => { - self.execute_instance_list(matches).await; - } - CliCommand::InstanceCreate => { - self.execute_instance_create(matches).await; - } - CliCommand::InstanceView => { - self.execute_instance_view(matches).await; - } - CliCommand::InstanceDelete => { - self.execute_instance_delete(matches).await; - } - CliCommand::InstanceDiskList => { - self.execute_instance_disk_list(matches).await; - } - CliCommand::InstanceDiskAttach => { - self.execute_instance_disk_attach(matches).await; - } - CliCommand::InstanceDiskDetach => { - self.execute_instance_disk_detach(matches).await; - } + self.execute_disk_bulk_write_import_stop(matches).await + } + CliCommand::DiskFinalizeImport => self.execute_disk_finalize_import(matches).await, + CliCommand::DiskMetricsList => self.execute_disk_metrics_list(matches).await, + CliCommand::FloatingIpList => self.execute_floating_ip_list(matches).await, + CliCommand::FloatingIpCreate => self.execute_floating_ip_create(matches).await, + CliCommand::FloatingIpView => self.execute_floating_ip_view(matches).await, + CliCommand::FloatingIpDelete => self.execute_floating_ip_delete(matches).await, + CliCommand::FloatingIpAttach => self.execute_floating_ip_attach(matches).await, + CliCommand::FloatingIpDetach => self.execute_floating_ip_detach(matches).await, + CliCommand::GroupList => self.execute_group_list(matches).await, + CliCommand::GroupView => self.execute_group_view(matches).await, + CliCommand::ImageList => self.execute_image_list(matches).await, + CliCommand::ImageCreate => self.execute_image_create(matches).await, + CliCommand::ImageView => self.execute_image_view(matches).await, + CliCommand::ImageDelete => self.execute_image_delete(matches).await, + CliCommand::ImageDemote => self.execute_image_demote(matches).await, + CliCommand::ImagePromote => self.execute_image_promote(matches).await, + CliCommand::InstanceList => self.execute_instance_list(matches).await, + CliCommand::InstanceCreate => self.execute_instance_create(matches).await, + CliCommand::InstanceView => self.execute_instance_view(matches).await, + CliCommand::InstanceDelete => self.execute_instance_delete(matches).await, + CliCommand::InstanceDiskList => self.execute_instance_disk_list(matches).await, + CliCommand::InstanceDiskAttach => self.execute_instance_disk_attach(matches).await, + CliCommand::InstanceDiskDetach => self.execute_instance_disk_detach(matches).await, CliCommand::InstanceExternalIpList => { - self.execute_instance_external_ip_list(matches).await; + self.execute_instance_external_ip_list(matches).await } CliCommand::InstanceEphemeralIpAttach => { - self.execute_instance_ephemeral_ip_attach(matches).await; + self.execute_instance_ephemeral_ip_attach(matches).await } CliCommand::InstanceEphemeralIpDetach => { - self.execute_instance_ephemeral_ip_detach(matches).await; - } - CliCommand::InstanceMigrate => { - self.execute_instance_migrate(matches).await; - } - CliCommand::InstanceReboot => { - self.execute_instance_reboot(matches).await; + self.execute_instance_ephemeral_ip_detach(matches).await } + CliCommand::InstanceMigrate => self.execute_instance_migrate(matches).await, + CliCommand::InstanceReboot => self.execute_instance_reboot(matches).await, CliCommand::InstanceSerialConsole => { - self.execute_instance_serial_console(matches).await; + self.execute_instance_serial_console(matches).await } CliCommand::InstanceSerialConsoleStream => { - self.execute_instance_serial_console_stream(matches).await; + self.execute_instance_serial_console_stream(matches).await } CliCommand::InstanceSshPublicKeyList => { - self.execute_instance_ssh_public_key_list(matches).await; - } - CliCommand::InstanceStart => { - self.execute_instance_start(matches).await; - } - CliCommand::InstanceStop => { - self.execute_instance_stop(matches).await; - } - CliCommand::ProjectIpPoolList => { - self.execute_project_ip_pool_list(matches).await; - } - CliCommand::ProjectIpPoolView => { - self.execute_project_ip_pool_view(matches).await; - } - CliCommand::LoginLocal => { - self.execute_login_local(matches).await; - } - CliCommand::Logout => { - self.execute_logout(matches).await; - } - CliCommand::CurrentUserView => { - self.execute_current_user_view(matches).await; - } - CliCommand::CurrentUserGroups => { - self.execute_current_user_groups(matches).await; - } + self.execute_instance_ssh_public_key_list(matches).await + } + CliCommand::InstanceStart => self.execute_instance_start(matches).await, + CliCommand::InstanceStop => self.execute_instance_stop(matches).await, + CliCommand::ProjectIpPoolList => self.execute_project_ip_pool_list(matches).await, + CliCommand::ProjectIpPoolView => self.execute_project_ip_pool_view(matches).await, + CliCommand::LoginLocal => self.execute_login_local(matches).await, + CliCommand::Logout => self.execute_logout(matches).await, + CliCommand::CurrentUserView => self.execute_current_user_view(matches).await, + CliCommand::CurrentUserGroups => self.execute_current_user_groups(matches).await, CliCommand::CurrentUserSshKeyList => { - self.execute_current_user_ssh_key_list(matches).await; + self.execute_current_user_ssh_key_list(matches).await } CliCommand::CurrentUserSshKeyCreate => { - self.execute_current_user_ssh_key_create(matches).await; + self.execute_current_user_ssh_key_create(matches).await } CliCommand::CurrentUserSshKeyView => { - self.execute_current_user_ssh_key_view(matches).await; + self.execute_current_user_ssh_key_view(matches).await } CliCommand::CurrentUserSshKeyDelete => { - self.execute_current_user_ssh_key_delete(matches).await; - } - CliCommand::SiloMetric => { - self.execute_silo_metric(matches).await; + self.execute_current_user_ssh_key_delete(matches).await } + CliCommand::SiloMetric => self.execute_silo_metric(matches).await, CliCommand::InstanceNetworkInterfaceList => { - self.execute_instance_network_interface_list(matches).await; + self.execute_instance_network_interface_list(matches).await } CliCommand::InstanceNetworkInterfaceCreate => { self.execute_instance_network_interface_create(matches) - .await; + .await } CliCommand::InstanceNetworkInterfaceView => { - self.execute_instance_network_interface_view(matches).await; + self.execute_instance_network_interface_view(matches).await } CliCommand::InstanceNetworkInterfaceUpdate => { self.execute_instance_network_interface_update(matches) - .await; + .await } CliCommand::InstanceNetworkInterfaceDelete => { self.execute_instance_network_interface_delete(matches) - .await; - } - CliCommand::Ping => { - self.execute_ping(matches).await; - } - CliCommand::PolicyView => { - self.execute_policy_view(matches).await; - } - CliCommand::PolicyUpdate => { - self.execute_policy_update(matches).await; - } - CliCommand::ProjectList => { - self.execute_project_list(matches).await; - } - CliCommand::ProjectCreate => { - self.execute_project_create(matches).await; - } - CliCommand::ProjectView => { - self.execute_project_view(matches).await; - } - CliCommand::ProjectUpdate => { - self.execute_project_update(matches).await; - } - CliCommand::ProjectDelete => { - self.execute_project_delete(matches).await; - } - CliCommand::ProjectPolicyView => { - self.execute_project_policy_view(matches).await; - } - CliCommand::ProjectPolicyUpdate => { - self.execute_project_policy_update(matches).await; - } - CliCommand::SnapshotList => { - self.execute_snapshot_list(matches).await; - } - CliCommand::SnapshotCreate => { - self.execute_snapshot_create(matches).await; - } - CliCommand::SnapshotView => { - self.execute_snapshot_view(matches).await; - } - CliCommand::SnapshotDelete => { - self.execute_snapshot_delete(matches).await; - } - CliCommand::PhysicalDiskList => { - self.execute_physical_disk_list(matches).await; - } - CliCommand::RackList => { - self.execute_rack_list(matches).await; - } - CliCommand::RackView => { - self.execute_rack_view(matches).await; - } - CliCommand::SledList => { - self.execute_sled_list(matches).await; - } - CliCommand::SledAdd => { - self.execute_sled_add(matches).await; - } - CliCommand::SledView => { - self.execute_sled_view(matches).await; - } - CliCommand::SledPhysicalDiskList => { - self.execute_sled_physical_disk_list(matches).await; - } - CliCommand::SledInstanceList => { - self.execute_sled_instance_list(matches).await; - } + .await + } + CliCommand::Ping => self.execute_ping(matches).await, + CliCommand::PolicyView => self.execute_policy_view(matches).await, + CliCommand::PolicyUpdate => self.execute_policy_update(matches).await, + CliCommand::ProjectList => self.execute_project_list(matches).await, + CliCommand::ProjectCreate => self.execute_project_create(matches).await, + CliCommand::ProjectView => self.execute_project_view(matches).await, + CliCommand::ProjectUpdate => self.execute_project_update(matches).await, + CliCommand::ProjectDelete => self.execute_project_delete(matches).await, + CliCommand::ProjectPolicyView => self.execute_project_policy_view(matches).await, + CliCommand::ProjectPolicyUpdate => self.execute_project_policy_update(matches).await, + CliCommand::SnapshotList => self.execute_snapshot_list(matches).await, + CliCommand::SnapshotCreate => self.execute_snapshot_create(matches).await, + CliCommand::SnapshotView => self.execute_snapshot_view(matches).await, + CliCommand::SnapshotDelete => self.execute_snapshot_delete(matches).await, + CliCommand::PhysicalDiskList => self.execute_physical_disk_list(matches).await, + CliCommand::RackList => self.execute_rack_list(matches).await, + CliCommand::RackView => self.execute_rack_view(matches).await, + CliCommand::SledList => self.execute_sled_list(matches).await, + CliCommand::SledAdd => self.execute_sled_add(matches).await, + CliCommand::SledView => self.execute_sled_view(matches).await, + CliCommand::SledPhysicalDiskList => self.execute_sled_physical_disk_list(matches).await, + CliCommand::SledInstanceList => self.execute_sled_instance_list(matches).await, CliCommand::SledSetProvisionState => { - self.execute_sled_set_provision_state(matches).await; + self.execute_sled_set_provision_state(matches).await } CliCommand::SledListUninitialized => { - self.execute_sled_list_uninitialized(matches).await; + self.execute_sled_list_uninitialized(matches).await } CliCommand::NetworkingSwitchPortList => { - self.execute_networking_switch_port_list(matches).await; + self.execute_networking_switch_port_list(matches).await } CliCommand::NetworkingSwitchPortApplySettings => { self.execute_networking_switch_port_apply_settings(matches) - .await; + .await } CliCommand::NetworkingSwitchPortClearSettings => { self.execute_networking_switch_port_clear_settings(matches) - .await; - } - CliCommand::SwitchList => { - self.execute_switch_list(matches).await; - } - CliCommand::SwitchView => { - self.execute_switch_view(matches).await; + .await } + CliCommand::SwitchList => self.execute_switch_list(matches).await, + CliCommand::SwitchView => self.execute_switch_view(matches).await, CliCommand::SiloIdentityProviderList => { - self.execute_silo_identity_provider_list(matches).await; - } - CliCommand::LocalIdpUserCreate => { - self.execute_local_idp_user_create(matches).await; - } - CliCommand::LocalIdpUserDelete => { - self.execute_local_idp_user_delete(matches).await; + self.execute_silo_identity_provider_list(matches).await } + CliCommand::LocalIdpUserCreate => self.execute_local_idp_user_create(matches).await, + CliCommand::LocalIdpUserDelete => self.execute_local_idp_user_delete(matches).await, CliCommand::LocalIdpUserSetPassword => { - self.execute_local_idp_user_set_password(matches).await; + self.execute_local_idp_user_set_password(matches).await } CliCommand::SamlIdentityProviderCreate => { - self.execute_saml_identity_provider_create(matches).await; + self.execute_saml_identity_provider_create(matches).await } CliCommand::SamlIdentityProviderView => { - self.execute_saml_identity_provider_view(matches).await; - } - CliCommand::IpPoolList => { - self.execute_ip_pool_list(matches).await; - } - CliCommand::IpPoolCreate => { - self.execute_ip_pool_create(matches).await; - } - CliCommand::IpPoolView => { - self.execute_ip_pool_view(matches).await; - } - CliCommand::IpPoolUpdate => { - self.execute_ip_pool_update(matches).await; - } - CliCommand::IpPoolDelete => { - self.execute_ip_pool_delete(matches).await; - } - CliCommand::IpPoolRangeList => { - self.execute_ip_pool_range_list(matches).await; - } - CliCommand::IpPoolRangeAdd => { - self.execute_ip_pool_range_add(matches).await; - } - CliCommand::IpPoolRangeRemove => { - self.execute_ip_pool_range_remove(matches).await; - } - CliCommand::IpPoolSiloList => { - self.execute_ip_pool_silo_list(matches).await; - } - CliCommand::IpPoolSiloLink => { - self.execute_ip_pool_silo_link(matches).await; - } - CliCommand::IpPoolSiloUpdate => { - self.execute_ip_pool_silo_update(matches).await; - } - CliCommand::IpPoolSiloUnlink => { - self.execute_ip_pool_silo_unlink(matches).await; - } - CliCommand::IpPoolServiceView => { - self.execute_ip_pool_service_view(matches).await; - } + self.execute_saml_identity_provider_view(matches).await + } + CliCommand::IpPoolList => self.execute_ip_pool_list(matches).await, + CliCommand::IpPoolCreate => self.execute_ip_pool_create(matches).await, + CliCommand::IpPoolView => self.execute_ip_pool_view(matches).await, + CliCommand::IpPoolUpdate => self.execute_ip_pool_update(matches).await, + CliCommand::IpPoolDelete => self.execute_ip_pool_delete(matches).await, + CliCommand::IpPoolRangeList => self.execute_ip_pool_range_list(matches).await, + CliCommand::IpPoolRangeAdd => self.execute_ip_pool_range_add(matches).await, + CliCommand::IpPoolRangeRemove => self.execute_ip_pool_range_remove(matches).await, + CliCommand::IpPoolSiloList => self.execute_ip_pool_silo_list(matches).await, + CliCommand::IpPoolSiloLink => self.execute_ip_pool_silo_link(matches).await, + CliCommand::IpPoolSiloUpdate => self.execute_ip_pool_silo_update(matches).await, + CliCommand::IpPoolSiloUnlink => self.execute_ip_pool_silo_unlink(matches).await, + CliCommand::IpPoolServiceView => self.execute_ip_pool_service_view(matches).await, CliCommand::IpPoolServiceRangeList => { - self.execute_ip_pool_service_range_list(matches).await; + self.execute_ip_pool_service_range_list(matches).await } CliCommand::IpPoolServiceRangeAdd => { - self.execute_ip_pool_service_range_add(matches).await; + self.execute_ip_pool_service_range_add(matches).await } CliCommand::IpPoolServiceRangeRemove => { - self.execute_ip_pool_service_range_remove(matches).await; - } - CliCommand::SystemMetric => { - self.execute_system_metric(matches).await; + self.execute_ip_pool_service_range_remove(matches).await } + CliCommand::SystemMetric => self.execute_system_metric(matches).await, CliCommand::NetworkingAddressLotList => { - self.execute_networking_address_lot_list(matches).await; + self.execute_networking_address_lot_list(matches).await } CliCommand::NetworkingAddressLotCreate => { - self.execute_networking_address_lot_create(matches).await; + self.execute_networking_address_lot_create(matches).await } CliCommand::NetworkingAddressLotDelete => { - self.execute_networking_address_lot_delete(matches).await; + self.execute_networking_address_lot_delete(matches).await } CliCommand::NetworkingAddressLotBlockList => { self.execute_networking_address_lot_block_list(matches) - .await; - } - CliCommand::NetworkingBfdDisable => { - self.execute_networking_bfd_disable(matches).await; - } - CliCommand::NetworkingBfdEnable => { - self.execute_networking_bfd_enable(matches).await; - } - CliCommand::NetworkingBfdStatus => { - self.execute_networking_bfd_status(matches).await; + .await } + CliCommand::NetworkingBfdDisable => self.execute_networking_bfd_disable(matches).await, + CliCommand::NetworkingBfdEnable => self.execute_networking_bfd_enable(matches).await, + CliCommand::NetworkingBfdStatus => self.execute_networking_bfd_status(matches).await, CliCommand::NetworkingBgpConfigList => { - self.execute_networking_bgp_config_list(matches).await; + self.execute_networking_bgp_config_list(matches).await } CliCommand::NetworkingBgpConfigCreate => { - self.execute_networking_bgp_config_create(matches).await; + self.execute_networking_bgp_config_create(matches).await } CliCommand::NetworkingBgpConfigDelete => { - self.execute_networking_bgp_config_delete(matches).await; + self.execute_networking_bgp_config_delete(matches).await } CliCommand::NetworkingBgpAnnounceSetList => { - self.execute_networking_bgp_announce_set_list(matches).await; + self.execute_networking_bgp_announce_set_list(matches).await } CliCommand::NetworkingBgpAnnounceSetCreate => { self.execute_networking_bgp_announce_set_create(matches) - .await; + .await } CliCommand::NetworkingBgpAnnounceSetDelete => { self.execute_networking_bgp_announce_set_delete(matches) - .await; + .await } CliCommand::NetworkingBgpImportedRoutesIpv4 => { self.execute_networking_bgp_imported_routes_ipv4(matches) - .await; - } - CliCommand::NetworkingBgpStatus => { - self.execute_networking_bgp_status(matches).await; + .await } + CliCommand::NetworkingBgpStatus => self.execute_networking_bgp_status(matches).await, CliCommand::NetworkingLoopbackAddressList => { - self.execute_networking_loopback_address_list(matches).await; + self.execute_networking_loopback_address_list(matches).await } CliCommand::NetworkingLoopbackAddressCreate => { self.execute_networking_loopback_address_create(matches) - .await; + .await } CliCommand::NetworkingLoopbackAddressDelete => { self.execute_networking_loopback_address_delete(matches) - .await; + .await } CliCommand::NetworkingSwitchPortSettingsList => { self.execute_networking_switch_port_settings_list(matches) - .await; + .await } CliCommand::NetworkingSwitchPortSettingsCreate => { self.execute_networking_switch_port_settings_create(matches) - .await; + .await } CliCommand::NetworkingSwitchPortSettingsDelete => { self.execute_networking_switch_port_settings_delete(matches) - .await; + .await } CliCommand::NetworkingSwitchPortSettingsView => { self.execute_networking_switch_port_settings_view(matches) - .await; - } - CliCommand::SystemPolicyView => { - self.execute_system_policy_view(matches).await; - } - CliCommand::SystemPolicyUpdate => { - self.execute_system_policy_update(matches).await; - } - CliCommand::RoleList => { - self.execute_role_list(matches).await; - } - CliCommand::RoleView => { - self.execute_role_view(matches).await; - } - CliCommand::SystemQuotasList => { - self.execute_system_quotas_list(matches).await; - } - CliCommand::SiloList => { - self.execute_silo_list(matches).await; - } - CliCommand::SiloCreate => { - self.execute_silo_create(matches).await; - } - CliCommand::SiloView => { - self.execute_silo_view(matches).await; - } - CliCommand::SiloDelete => { - self.execute_silo_delete(matches).await; - } - CliCommand::SiloIpPoolList => { - self.execute_silo_ip_pool_list(matches).await; - } - CliCommand::SiloPolicyView => { - self.execute_silo_policy_view(matches).await; - } - CliCommand::SiloPolicyUpdate => { - self.execute_silo_policy_update(matches).await; - } - CliCommand::SiloQuotasView => { - self.execute_silo_quotas_view(matches).await; - } - CliCommand::SiloQuotasUpdate => { - self.execute_silo_quotas_update(matches).await; - } - CliCommand::SiloUserList => { - self.execute_silo_user_list(matches).await; - } - CliCommand::SiloUserView => { - self.execute_silo_user_view(matches).await; - } - CliCommand::UserBuiltinList => { - self.execute_user_builtin_list(matches).await; - } - CliCommand::UserBuiltinView => { - self.execute_user_builtin_view(matches).await; - } - CliCommand::SiloUtilizationList => { - self.execute_silo_utilization_list(matches).await; - } - CliCommand::SiloUtilizationView => { - self.execute_silo_utilization_view(matches).await; - } - CliCommand::UserList => { - self.execute_user_list(matches).await; - } - CliCommand::UtilizationView => { - self.execute_utilization_view(matches).await; - } - CliCommand::VpcFirewallRulesView => { - self.execute_vpc_firewall_rules_view(matches).await; - } + .await + } + CliCommand::SystemPolicyView => self.execute_system_policy_view(matches).await, + CliCommand::SystemPolicyUpdate => self.execute_system_policy_update(matches).await, + CliCommand::RoleList => self.execute_role_list(matches).await, + CliCommand::RoleView => self.execute_role_view(matches).await, + CliCommand::SystemQuotasList => self.execute_system_quotas_list(matches).await, + CliCommand::SiloList => self.execute_silo_list(matches).await, + CliCommand::SiloCreate => self.execute_silo_create(matches).await, + CliCommand::SiloView => self.execute_silo_view(matches).await, + CliCommand::SiloDelete => self.execute_silo_delete(matches).await, + CliCommand::SiloIpPoolList => self.execute_silo_ip_pool_list(matches).await, + CliCommand::SiloPolicyView => self.execute_silo_policy_view(matches).await, + CliCommand::SiloPolicyUpdate => self.execute_silo_policy_update(matches).await, + CliCommand::SiloQuotasView => self.execute_silo_quotas_view(matches).await, + CliCommand::SiloQuotasUpdate => self.execute_silo_quotas_update(matches).await, + CliCommand::SiloUserList => self.execute_silo_user_list(matches).await, + CliCommand::SiloUserView => self.execute_silo_user_view(matches).await, + CliCommand::UserBuiltinList => self.execute_user_builtin_list(matches).await, + CliCommand::UserBuiltinView => self.execute_user_builtin_view(matches).await, + CliCommand::SiloUtilizationList => self.execute_silo_utilization_list(matches).await, + CliCommand::SiloUtilizationView => self.execute_silo_utilization_view(matches).await, + CliCommand::UserList => self.execute_user_list(matches).await, + CliCommand::UtilizationView => self.execute_utilization_view(matches).await, + CliCommand::VpcFirewallRulesView => self.execute_vpc_firewall_rules_view(matches).await, CliCommand::VpcFirewallRulesUpdate => { - self.execute_vpc_firewall_rules_update(matches).await; - } - CliCommand::VpcSubnetList => { - self.execute_vpc_subnet_list(matches).await; - } - CliCommand::VpcSubnetCreate => { - self.execute_vpc_subnet_create(matches).await; - } - CliCommand::VpcSubnetView => { - self.execute_vpc_subnet_view(matches).await; - } - CliCommand::VpcSubnetUpdate => { - self.execute_vpc_subnet_update(matches).await; - } - CliCommand::VpcSubnetDelete => { - self.execute_vpc_subnet_delete(matches).await; + self.execute_vpc_firewall_rules_update(matches).await } + CliCommand::VpcSubnetList => self.execute_vpc_subnet_list(matches).await, + CliCommand::VpcSubnetCreate => self.execute_vpc_subnet_create(matches).await, + CliCommand::VpcSubnetView => self.execute_vpc_subnet_view(matches).await, + CliCommand::VpcSubnetUpdate => self.execute_vpc_subnet_update(matches).await, + CliCommand::VpcSubnetDelete => self.execute_vpc_subnet_delete(matches).await, CliCommand::VpcSubnetListNetworkInterfaces => { self.execute_vpc_subnet_list_network_interfaces(matches) - .await; - } - CliCommand::VpcList => { - self.execute_vpc_list(matches).await; - } - CliCommand::VpcCreate => { - self.execute_vpc_create(matches).await; - } - CliCommand::VpcView => { - self.execute_vpc_view(matches).await; - } - CliCommand::VpcUpdate => { - self.execute_vpc_update(matches).await; - } - CliCommand::VpcDelete => { - self.execute_vpc_delete(matches).await; + .await } + CliCommand::VpcList => self.execute_vpc_list(matches).await, + CliCommand::VpcCreate => self.execute_vpc_create(matches).await, + CliCommand::VpcView => self.execute_vpc_view(matches).await, + CliCommand::VpcUpdate => self.execute_vpc_update(matches).await, + CliCommand::VpcDelete => self.execute_vpc_delete(matches).await, } } - pub async fn execute_device_auth_request(&self, matches: &clap::ArgMatches) { + pub async fn execute_device_auth_request( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { 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())) @@ -5748,9 +5497,8 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_device_auth_request(matches, &mut request) - .unwrap(); + self.config + .execute_device_auth_request(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { @@ -5762,7 +5510,10 @@ impl Cli { } } - pub async fn execute_device_auth_confirm(&self, matches: &clap::ArgMatches) { + pub async fn execute_device_auth_confirm( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { 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())) @@ -5774,21 +5525,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_device_auth_confirm(matches, &mut request) - .unwrap(); + self.config + .execute_device_auth_confirm(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_device_access_token(&self, matches: &clap::ArgMatches) { + pub async fn execute_device_access_token( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { 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())) @@ -5809,9 +5564,8 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_device_access_token(matches, &mut request) - .unwrap(); + self.config + .execute_device_access_token(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { @@ -5823,7 +5577,7 @@ impl Cli { } } - pub async fn execute_login_saml(&self, matches: &clap::ArgMatches) { + pub async fn execute_login_saml(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.login_saml(); if let Some(value) = matches.get_one::("provider-name") { request = request.provider_name(value.clone()); @@ -5833,19 +5587,20 @@ impl Cli { request = request.silo_name(value.clone()); } - self.over.execute_login_saml(matches, &mut request).unwrap(); + self.config.execute_login_saml(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { todo!() } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_certificate_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_certificate_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.certificate_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -5855,27 +5610,32 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_certificate_list(matches, &mut request) - .unwrap(); + self.config + .execute_certificate_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_certificate_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_certificate_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.certificate_create(); if let Some(value) = matches.get_one::("cert") { request = request.body_map(|body| body.cert(value.clone())) @@ -5903,61 +5663,67 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_certificate_create(matches, &mut request) - .unwrap(); + self.config + .execute_certificate_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_certificate_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_certificate_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { 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(); + self.config + .execute_certificate_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_certificate_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_certificate_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { 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(); + self.config + .execute_certificate_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_disk_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.disk_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -5971,25 +5737,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over.execute_disk_list(matches, &mut request).unwrap(); + self.config.execute_disk_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_disk_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_create(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.disk_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -6013,21 +5781,21 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_disk_create(matches, &mut request) - .unwrap(); + self.config.execute_disk_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_disk_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.disk_view(); if let Some(value) = matches.get_one::("disk") { request = request.disk(value.clone()); @@ -6037,19 +5805,21 @@ impl Cli { request = request.project(value.clone()); } - self.over.execute_disk_view(matches, &mut request).unwrap(); + self.config.execute_disk_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_disk_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_delete(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.disk_delete(); if let Some(value) = matches.get_one::("disk") { request = request.disk(value.clone()); @@ -6059,21 +5829,24 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_disk_delete(matches, &mut request) - .unwrap(); + self.config.execute_disk_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_disk_bulk_write_import(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_bulk_write_import( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.disk_bulk_write_import(); if let Some(value) = matches.get_one::("base64-encoded-data") { request = request.body_map(|body| body.base64_encoded_data(value.clone())) @@ -6098,21 +5871,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_disk_bulk_write_import(matches, &mut request) - .unwrap(); + self.config + .execute_disk_bulk_write_import(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_disk_bulk_write_import_start(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_bulk_write_import_start( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.disk_bulk_write_import_start(); if let Some(value) = matches.get_one::("disk") { request = request.disk(value.clone()); @@ -6122,21 +5899,25 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_disk_bulk_write_import_start(matches, &mut request) - .unwrap(); + self.config + .execute_disk_bulk_write_import_start(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_disk_bulk_write_import_stop(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_bulk_write_import_stop( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.disk_bulk_write_import_stop(); if let Some(value) = matches.get_one::("disk") { request = request.disk(value.clone()); @@ -6146,21 +5927,25 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_disk_bulk_write_import_stop(matches, &mut request) - .unwrap(); + self.config + .execute_disk_bulk_write_import_stop(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_disk_finalize_import(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_finalize_import( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.disk_finalize_import(); if let Some(value) = matches.get_one::("disk") { request = request.disk(value.clone()); @@ -6180,21 +5965,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_disk_finalize_import(matches, &mut request) - .unwrap(); + self.config + .execute_disk_finalize_import(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_disk_metrics_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_disk_metrics_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.disk_metrics_list(); if let Some(value) = matches.get_one::("disk") { request = request.disk(value.clone()); @@ -6225,27 +6014,29 @@ impl Cli { request = request.start_time(value.clone()); } - self.over - .execute_disk_metrics_list(matches, &mut request) - .unwrap(); + self.config + .execute_disk_metrics_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_floating_ip_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_floating_ip_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.floating_ip_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -6259,27 +6050,32 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_floating_ip_list(matches, &mut request) - .unwrap(); + self.config + .execute_floating_ip_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_floating_ip_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_floating_ip_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.floating_ip_create(); if let Some(value) = matches.get_one::("address") { request = request.body_map(|body| body.address(value.clone())) @@ -6307,21 +6103,22 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_floating_ip_create(matches, &mut request) - .unwrap(); + self.config + .execute_floating_ip_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_floating_ip_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_floating_ip_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.floating_ip_view(); if let Some(value) = matches.get_one::("floating-ip") { request = request.floating_ip(value.clone()); @@ -6331,21 +6128,25 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_floating_ip_view(matches, &mut request) - .unwrap(); + self.config + .execute_floating_ip_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_floating_ip_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_floating_ip_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.floating_ip_delete(); if let Some(value) = matches.get_one::("floating-ip") { request = request.floating_ip(value.clone()); @@ -6355,21 +6156,25 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_floating_ip_delete(matches, &mut request) - .unwrap(); + self.config + .execute_floating_ip_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_floating_ip_attach(&self, matches: &clap::ArgMatches) { + pub async fn execute_floating_ip_attach( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.floating_ip_attach(); if let Some(value) = matches.get_one::("floating-ip") { request = request.floating_ip(value.clone()); @@ -6393,21 +6198,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_floating_ip_attach(matches, &mut request) - .unwrap(); + self.config + .execute_floating_ip_attach(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_floating_ip_detach(&self, matches: &clap::ArgMatches) { + pub async fn execute_floating_ip_detach( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.floating_ip_detach(); if let Some(value) = matches.get_one::("floating-ip") { request = request.floating_ip(value.clone()); @@ -6417,21 +6226,22 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_floating_ip_detach(matches, &mut request) - .unwrap(); + self.config + .execute_floating_ip_detach(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_group_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_group_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.group_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -6441,43 +6251,47 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over.execute_group_list(matches, &mut request).unwrap(); + self.config.execute_group_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_group_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_group_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.group_view(); if let Some(value) = matches.get_one::("group-id") { request = request.group_id(value.clone()); } - self.over.execute_group_view(matches, &mut request).unwrap(); + self.config.execute_group_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_image_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_image_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.image_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -6491,25 +6305,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over.execute_image_list(matches, &mut request).unwrap(); + self.config.execute_image_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_image_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_image_create(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.image_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -6537,21 +6353,21 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_image_create(matches, &mut request) - .unwrap(); + self.config.execute_image_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_image_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_image_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.image_view(); if let Some(value) = matches.get_one::("image") { request = request.image(value.clone()); @@ -6561,19 +6377,21 @@ impl Cli { request = request.project(value.clone()); } - self.over.execute_image_view(matches, &mut request).unwrap(); + self.config.execute_image_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_image_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_image_delete(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.image_delete(); if let Some(value) = matches.get_one::("image") { request = request.image(value.clone()); @@ -6583,21 +6401,21 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_image_delete(matches, &mut request) - .unwrap(); + self.config.execute_image_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_image_demote(&self, matches: &clap::ArgMatches) { + pub async fn execute_image_demote(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.image_demote(); if let Some(value) = matches.get_one::("image") { request = request.image(value.clone()); @@ -6607,21 +6425,21 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_image_demote(matches, &mut request) - .unwrap(); + self.config.execute_image_demote(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_image_promote(&self, matches: &clap::ArgMatches) { + pub async fn execute_image_promote(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.image_promote(); if let Some(value) = matches.get_one::("image") { request = request.image(value.clone()); @@ -6631,21 +6449,21 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_image_promote(matches, &mut request) - .unwrap(); + self.config.execute_image_promote(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.instance_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -6659,27 +6477,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_instance_list(matches, &mut request) - .unwrap(); + self.config.execute_instance_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_instance_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_create(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.instance_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -6719,21 +6537,21 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_instance_create(matches, &mut request) - .unwrap(); + self.config.execute_instance_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.instance_view(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -6743,21 +6561,21 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_view(matches, &mut request) - .unwrap(); + self.config.execute_instance_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_delete(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.instance_delete(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -6767,21 +6585,24 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_delete(matches, &mut request) - .unwrap(); + self.config.execute_instance_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_disk_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_disk_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_disk_list(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -6799,27 +6620,31 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_instance_disk_list(matches, &mut request) - .unwrap(); + self.config + .execute_instance_disk_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_instance_disk_attach(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_disk_attach( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_disk_attach(); if let Some(value) = matches.get_one::("disk") { request = request.body_map(|body| body.disk(value.clone())) @@ -6839,21 +6664,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_instance_disk_attach(matches, &mut request) - .unwrap(); + self.config + .execute_instance_disk_attach(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_disk_detach(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_disk_detach( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_disk_detach(); if let Some(value) = matches.get_one::("disk") { request = request.body_map(|body| body.disk(value.clone())) @@ -6873,21 +6702,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_instance_disk_detach(matches, &mut request) - .unwrap(); + self.config + .execute_instance_disk_detach(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_external_ip_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_external_ip_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_external_ip_list(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -6897,21 +6730,25 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_external_ip_list(matches, &mut request) - .unwrap(); + self.config + .execute_instance_external_ip_list(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_ephemeral_ip_attach(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_ephemeral_ip_attach( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_ephemeral_ip_attach(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -6931,21 +6768,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_instance_ephemeral_ip_attach(matches, &mut request) - .unwrap(); + self.config + .execute_instance_ephemeral_ip_attach(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_ephemeral_ip_detach(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_ephemeral_ip_detach( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_ephemeral_ip_detach(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -6955,21 +6796,22 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_ephemeral_ip_detach(matches, &mut request) - .unwrap(); + self.config + .execute_instance_ephemeral_ip_detach(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_migrate(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_migrate(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.instance_migrate(); if let Some(value) = matches.get_one::("dst-sled-id") { request = request.body_map(|body| body.dst_sled_id(value.clone())) @@ -6989,21 +6831,22 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_instance_migrate(matches, &mut request) - .unwrap(); + self.config + .execute_instance_migrate(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_reboot(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_reboot(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.instance_reboot(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -7013,21 +6856,24 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_reboot(matches, &mut request) - .unwrap(); + self.config.execute_instance_reboot(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_serial_console(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_serial_console( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_serial_console(); if let Some(value) = matches.get_one::("from-start") { request = request.from_start(value.clone()); @@ -7049,21 +6895,25 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_serial_console(matches, &mut request) - .unwrap(); + self.config + .execute_instance_serial_console(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_serial_console_stream(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_serial_console_stream( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_serial_console_stream(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -7077,9 +6927,8 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_serial_console_stream(matches, &mut request) - .unwrap(); + self.config + .execute_instance_serial_console_stream(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { @@ -7091,7 +6940,10 @@ impl Cli { } } - pub async fn execute_instance_ssh_public_key_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_ssh_public_key_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_ssh_public_key_list(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -7109,27 +6961,28 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_instance_ssh_public_key_list(matches, &mut request) - .unwrap(); + self.config + .execute_instance_ssh_public_key_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_instance_start(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_start(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.instance_start(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -7139,21 +6992,21 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_start(matches, &mut request) - .unwrap(); + self.config.execute_instance_start(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_stop(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_stop(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.instance_stop(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -7163,21 +7016,24 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_stop(matches, &mut request) - .unwrap(); + self.config.execute_instance_stop(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_project_ip_pool_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_ip_pool_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.project_ip_pool_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -7187,47 +7043,53 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_project_ip_pool_list(matches, &mut request) - .unwrap(); + self.config + .execute_project_ip_pool_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_project_ip_pool_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_ip_pool_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.project_ip_pool_view(); if let Some(value) = matches.get_one::("pool") { request = request.pool(value.clone()); } - self.over - .execute_project_ip_pool_view(matches, &mut request) - .unwrap(); + self.config + .execute_project_ip_pool_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_login_local(&self, matches: &clap::ArgMatches) { + pub async fn execute_login_local(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.login_local(); if let Some(value) = matches.get_one::("password") { request = request.body_map(|body| body.password(value.clone())) @@ -7248,51 +7110,60 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_login_local(matches, &mut request) - .unwrap(); + self.config.execute_login_local(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_logout(&self, matches: &clap::ArgMatches) { + pub async fn execute_logout(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.logout(); - self.over.execute_logout(matches, &mut request).unwrap(); + self.config.execute_logout(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_current_user_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_current_user_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.current_user_view(); - self.over - .execute_current_user_view(matches, &mut request) - .unwrap(); + self.config + .execute_current_user_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_current_user_groups(&self, matches: &clap::ArgMatches) { + pub async fn execute_current_user_groups( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.current_user_groups(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -7302,27 +7173,31 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_current_user_groups(matches, &mut request) - .unwrap(); + self.config + .execute_current_user_groups(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_current_user_ssh_key_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_current_user_ssh_key_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.current_user_ssh_key_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -7332,27 +7207,31 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_current_user_ssh_key_list(matches, &mut request) - .unwrap(); + self.config + .execute_current_user_ssh_key_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_current_user_ssh_key_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_current_user_ssh_key_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.current_user_ssh_key_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -7372,61 +7251,70 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_current_user_ssh_key_create(matches, &mut request) - .unwrap(); + self.config + .execute_current_user_ssh_key_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_current_user_ssh_key_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_current_user_ssh_key_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.current_user_ssh_key_view(); if let Some(value) = matches.get_one::("ssh-key") { request = request.ssh_key(value.clone()); } - self.over - .execute_current_user_ssh_key_view(matches, &mut request) - .unwrap(); + self.config + .execute_current_user_ssh_key_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_current_user_ssh_key_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_current_user_ssh_key_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.current_user_ssh_key_delete(); if let Some(value) = matches.get_one::("ssh-key") { request = request.ssh_key(value.clone()); } - self.over - .execute_current_user_ssh_key_delete(matches, &mut request) - .unwrap(); + self.config + .execute_current_user_ssh_key_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_metric(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_metric(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_metric(); if let Some(value) = matches.get_one::>("end-time") { request = request.end_time(value.clone()); @@ -7453,27 +7341,31 @@ impl Cli { request = request.start_time(value.clone()); } - self.over - .execute_silo_metric(matches, &mut request) - .unwrap(); + self.config.execute_silo_metric(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_instance_network_interface_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_network_interface_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_network_interface_list(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -7491,27 +7383,33 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_instance_network_interface_list(matches, &mut request) - .unwrap(); + self.config + .execute_instance_network_interface_list(matches, &mut request)?; + self.config + .list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_instance_network_interface_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_network_interface_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_network_interface_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -7548,21 +7446,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_instance_network_interface_create(matches, &mut request) - .unwrap(); + self.config + .execute_instance_network_interface_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_network_interface_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_network_interface_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_network_interface_view(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -7576,21 +7478,25 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_network_interface_view(matches, &mut request) - .unwrap(); + self.config + .execute_instance_network_interface_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_network_interface_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_network_interface_update( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_network_interface_update(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -7623,21 +7529,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_instance_network_interface_update(matches, &mut request) - .unwrap(); + self.config + .execute_instance_network_interface_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_instance_network_interface_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_instance_network_interface_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.instance_network_interface_delete(); if let Some(value) = matches.get_one::("instance") { request = request.instance(value.clone()); @@ -7651,51 +7561,54 @@ impl Cli { request = request.project(value.clone()); } - self.over - .execute_instance_network_interface_delete(matches, &mut request) - .unwrap(); + self.config + .execute_instance_network_interface_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ping(&self, matches: &clap::ArgMatches) { + pub async fn execute_ping(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.ping(); - self.over.execute_ping(matches, &mut request).unwrap(); + self.config.execute_ping(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_policy_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_policy_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.policy_view(); - self.over - .execute_policy_view(matches, &mut request) - .unwrap(); + self.config.execute_policy_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_policy_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_policy_update(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.policy_update(); if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); @@ -7703,21 +7616,21 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_policy_update(matches, &mut request) - .unwrap(); + self.config.execute_policy_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_project_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.project_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -7727,27 +7640,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_project_list(matches, &mut request) - .unwrap(); + self.config.execute_project_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_project_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_create(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.project_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -7763,41 +7676,41 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_project_create(matches, &mut request) - .unwrap(); + self.config.execute_project_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_project_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.project_view(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); } - self.over - .execute_project_view(matches, &mut request) - .unwrap(); + self.config.execute_project_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_project_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_update(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.project_update(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -7817,61 +7730,68 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_project_update(matches, &mut request) - .unwrap(); + self.config.execute_project_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_project_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_delete(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.project_delete(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); } - self.over - .execute_project_delete(matches, &mut request) - .unwrap(); + self.config.execute_project_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_project_policy_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_policy_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.project_policy_view(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); } - self.over - .execute_project_policy_view(matches, &mut request) - .unwrap(); + self.config + .execute_project_policy_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_project_policy_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_project_policy_update( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.project_policy_update(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -7883,21 +7803,22 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_project_policy_update(matches, &mut request) - .unwrap(); + self.config + .execute_project_policy_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_snapshot_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_snapshot_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.snapshot_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -7911,27 +7832,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_snapshot_list(matches, &mut request) - .unwrap(); + self.config.execute_snapshot_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_snapshot_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_snapshot_create(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.snapshot_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -7955,21 +7876,21 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_snapshot_create(matches, &mut request) - .unwrap(); + self.config.execute_snapshot_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_snapshot_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_snapshot_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.snapshot_view(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -7979,21 +7900,21 @@ impl Cli { request = request.snapshot(value.clone()); } - self.over - .execute_snapshot_view(matches, &mut request) - .unwrap(); + self.config.execute_snapshot_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_snapshot_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_snapshot_delete(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.snapshot_delete(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -8003,21 +7924,24 @@ impl Cli { request = request.snapshot(value.clone()); } - self.over - .execute_snapshot_delete(matches, &mut request) - .unwrap(); + self.config.execute_snapshot_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_physical_disk_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_physical_disk_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.physical_disk_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8027,27 +7951,29 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_physical_disk_list(matches, &mut request) - .unwrap(); + self.config + .execute_physical_disk_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_rack_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_rack_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.rack_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8057,43 +7983,47 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over.execute_rack_list(matches, &mut request).unwrap(); + self.config.execute_rack_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_rack_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_rack_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { 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(); + self.config.execute_rack_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_sled_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_sled_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.sled_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8103,25 +8033,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over.execute_sled_list(matches, &mut request).unwrap(); + self.config.execute_sled_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_sled_add(&self, matches: &clap::ArgMatches) { + pub async fn execute_sled_add(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.sled_add(); if let Some(value) = matches.get_one::("part") { request = request.body_map(|body| body.part(value.clone())) @@ -8137,37 +8069,44 @@ impl Cli { request = request.body(body_value); } - self.over.execute_sled_add(matches, &mut request).unwrap(); + self.config.execute_sled_add(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_sled_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_sled_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { 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(); + self.config.execute_sled_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_sled_physical_disk_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_sled_physical_disk_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.sled_physical_disk_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8181,27 +8120,32 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_sled_physical_disk_list(matches, &mut request) - .unwrap(); + self.config + .execute_sled_physical_disk_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_sled_instance_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_sled_instance_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.sled_instance_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8215,27 +8159,32 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_sled_instance_list(matches, &mut request) - .unwrap(); + self.config + .execute_sled_instance_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_sled_set_provision_state(&self, matches: &clap::ArgMatches) { + pub async fn execute_sled_set_provision_state( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.sled_set_provision_state(); if let Some(value) = matches.get_one::("sled-id") { request = request.sled_id(value.clone()); @@ -8252,47 +8201,57 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_sled_set_provision_state(matches, &mut request) - .unwrap(); + self.config + .execute_sled_set_provision_state(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_sled_list_uninitialized(&self, matches: &clap::ArgMatches) { + pub async fn execute_sled_list_uninitialized( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.sled_list_uninitialized(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); } - self.over - .execute_sled_list_uninitialized(matches, &mut request) - .unwrap(); + self.config + .execute_sled_list_uninitialized(matches, &mut request)?; + self.config + .list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_networking_switch_port_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_switch_port_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_switch_port_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8306,27 +8265,32 @@ impl Cli { request = request.switch_port_id(value.clone()); } - self.over - .execute_networking_switch_port_list(matches, &mut request) - .unwrap(); + self.config + .execute_networking_switch_port_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_networking_switch_port_apply_settings(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_switch_port_apply_settings( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_switch_port_apply_settings(); if let Some(value) = matches.get_one::("port") { request = request.port(value.clone()); @@ -8351,21 +8315,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_networking_switch_port_apply_settings(matches, &mut request) - .unwrap(); + self.config + .execute_networking_switch_port_apply_settings(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_switch_port_clear_settings(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_switch_port_clear_settings( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_switch_port_clear_settings(); if let Some(value) = matches.get_one::("port") { request = request.port(value.clone()); @@ -8379,21 +8347,22 @@ impl Cli { request = request.switch_location(value.clone()); } - self.over - .execute_networking_switch_port_clear_settings(matches, &mut request) - .unwrap(); + self.config + .execute_networking_switch_port_clear_settings(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_switch_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_switch_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.switch_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8403,47 +8372,50 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_switch_list(matches, &mut request) - .unwrap(); + self.config.execute_switch_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_switch_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_switch_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.switch_view(); if let Some(value) = matches.get_one::("switch-id") { request = request.switch_id(value.clone()); } - self.over - .execute_switch_view(matches, &mut request) - .unwrap(); + self.config.execute_switch_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_identity_provider_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_identity_provider_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.silo_identity_provider_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8457,27 +8429,33 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_silo_identity_provider_list(matches, &mut request) - .unwrap(); + self.config + .execute_silo_identity_provider_list(matches, &mut request)?; + self.config + .list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_local_idp_user_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_local_idp_user_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.local_idp_user_create(); if let Some(value) = matches.get_one::("external-id") { request = request.body_map(|body| body.external_id(value.clone())) @@ -8493,21 +8471,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_local_idp_user_create(matches, &mut request) - .unwrap(); + self.config + .execute_local_idp_user_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_local_idp_user_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_local_idp_user_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.local_idp_user_delete(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); @@ -8517,21 +8499,25 @@ impl Cli { request = request.user_id(value.clone()); } - self.over - .execute_local_idp_user_delete(matches, &mut request) - .unwrap(); + self.config + .execute_local_idp_user_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_local_idp_user_set_password(&self, matches: &clap::ArgMatches) { + pub async fn execute_local_idp_user_set_password( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.local_idp_user_set_password(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); @@ -8547,21 +8533,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_local_idp_user_set_password(matches, &mut request) - .unwrap(); + self.config + .execute_local_idp_user_set_password(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_saml_identity_provider_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_saml_identity_provider_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.saml_identity_provider_create(); if let Some(value) = matches.get_one::("acs-url") { request = request.body_map(|body| body.acs_url(value.clone())) @@ -8606,21 +8596,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_saml_identity_provider_create(matches, &mut request) - .unwrap(); + self.config + .execute_saml_identity_provider_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_saml_identity_provider_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_saml_identity_provider_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.saml_identity_provider_view(); if let Some(value) = matches.get_one::("provider") { request = request.provider(value.clone()); @@ -8630,21 +8624,22 @@ impl Cli { request = request.silo(value.clone()); } - self.over - .execute_saml_identity_provider_view(matches, &mut request) - .unwrap(); + self.config + .execute_saml_identity_provider_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.ip_pool_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8654,27 +8649,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_ip_pool_list(matches, &mut request) - .unwrap(); + self.config.execute_ip_pool_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_ip_pool_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_create(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { 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())) @@ -8690,41 +8685,41 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_ip_pool_create(matches, &mut request) - .unwrap(); + self.config.execute_ip_pool_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.ip_pool_view(); if let Some(value) = matches.get_one::("pool") { request = request.pool(value.clone()); } - self.over - .execute_ip_pool_view(matches, &mut request) - .unwrap(); + self.config.execute_ip_pool_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_update(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.ip_pool_update(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -8744,41 +8739,44 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_ip_pool_update(matches, &mut request) - .unwrap(); + self.config.execute_ip_pool_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_delete(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.ip_pool_delete(); if let Some(value) = matches.get_one::("pool") { request = request.pool(value.clone()); } - self.over - .execute_ip_pool_delete(matches, &mut request) - .unwrap(); + self.config.execute_ip_pool_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_range_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_range_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_range_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8788,27 +8786,32 @@ impl Cli { request = request.pool(value.clone()); } - self.over - .execute_ip_pool_range_list(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_range_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_ip_pool_range_add(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_range_add( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_range_add(); if let Some(value) = matches.get_one::("pool") { request = request.pool(value.clone()); @@ -8820,21 +8823,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_ip_pool_range_add(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_range_add(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_range_remove(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_range_remove( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_range_remove(); if let Some(value) = matches.get_one::("pool") { request = request.pool(value.clone()); @@ -8846,21 +8853,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_ip_pool_range_remove(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_range_remove(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_silo_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_silo_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_silo_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -8874,27 +8885,32 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_ip_pool_silo_list(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_silo_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_ip_pool_silo_link(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_silo_link( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_silo_link(); if let Some(value) = matches.get_one::("is-default") { request = request.body_map(|body| body.is_default(value.clone())) @@ -8914,21 +8930,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_ip_pool_silo_link(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_silo_link(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_silo_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_silo_update( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_silo_update(); if let Some(value) = matches.get_one::("is-default") { request = request.body_map(|body| body.is_default(value.clone())) @@ -8948,21 +8968,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_ip_pool_silo_update(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_silo_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_silo_unlink(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_silo_unlink( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_silo_unlink(); if let Some(value) = matches.get_one::("pool") { request = request.pool(value.clone()); @@ -8972,63 +8996,76 @@ impl Cli { request = request.silo(value.clone()); } - self.over - .execute_ip_pool_silo_unlink(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_silo_unlink(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_service_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_service_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_service_view(); - self.over - .execute_ip_pool_service_view(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_service_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_service_range_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_service_range_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { 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(); + self.config + .execute_ip_pool_service_range_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_ip_pool_service_range_add(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_service_range_add( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_service_range_add(); if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); @@ -9036,21 +9073,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_ip_pool_service_range_add(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_service_range_add(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_ip_pool_service_range_remove(&self, matches: &clap::ArgMatches) { + pub async fn execute_ip_pool_service_range_remove( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.ip_pool_service_range_remove(); if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); @@ -9058,21 +9099,22 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_ip_pool_service_range_remove(matches, &mut request) - .unwrap(); + self.config + .execute_ip_pool_service_range_remove(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_system_metric(&self, matches: &clap::ArgMatches) { + pub async fn execute_system_metric(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.system_metric(); if let Some(value) = matches.get_one::>("end-time") { request = request.end_time(value.clone()); @@ -9099,27 +9141,31 @@ impl Cli { request = request.start_time(value.clone()); } - self.over - .execute_system_metric(matches, &mut request) - .unwrap(); + self.config.execute_system_metric(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_networking_address_lot_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_address_lot_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_address_lot_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -9129,27 +9175,32 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_networking_address_lot_list(matches, &mut request) - .unwrap(); + self.config + .execute_networking_address_lot_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_networking_address_lot_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_address_lot_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_address_lot_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -9169,41 +9220,49 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_networking_address_lot_create(matches, &mut request) - .unwrap(); + self.config + .execute_networking_address_lot_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_address_lot_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_address_lot_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_address_lot_delete(); if let Some(value) = matches.get_one::("address-lot") { request = request.address_lot(value.clone()); } - self.over - .execute_networking_address_lot_delete(matches, &mut request) - .unwrap(); + self.config + .execute_networking_address_lot_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_address_lot_block_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_address_lot_block_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_address_lot_block_list(); if let Some(value) = matches.get_one::("address-lot") { request = request.address_lot(value.clone()); @@ -9217,27 +9276,33 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_networking_address_lot_block_list(matches, &mut request) - .unwrap(); + self.config + .execute_networking_address_lot_block_list(matches, &mut request)?; + self.config + .list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_networking_bfd_disable(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bfd_disable( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bfd_disable(); if let Some(value) = matches.get_one::("remote") { request = request.body_map(|body| body.remote(value.clone())) @@ -9253,21 +9318,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_networking_bfd_disable(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bfd_disable(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bfd_enable(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bfd_enable( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bfd_enable(); if let Some(value) = matches.get_one::("detection-threshold") { request = request.body_map(|body| body.detection_threshold(value.clone())) @@ -9299,37 +9368,45 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_networking_bfd_enable(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bfd_enable(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bfd_status(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bfd_status( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bfd_status(); - self.over - .execute_networking_bfd_status(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bfd_status(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bgp_config_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bgp_config_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bgp_config_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -9343,27 +9420,32 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_networking_bgp_config_list(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bgp_config_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_networking_bgp_config_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bgp_config_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bgp_config_create(); if let Some(value) = matches.get_one::("asn") { request = request.body_map(|body| body.asn(value.clone())) @@ -9391,61 +9473,73 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_networking_bgp_config_create(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bgp_config_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bgp_config_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bgp_config_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bgp_config_delete(); if let Some(value) = matches.get_one::("name-or-id") { request = request.name_or_id(value.clone()); } - self.over - .execute_networking_bgp_config_delete(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bgp_config_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bgp_announce_set_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bgp_announce_set_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bgp_announce_set_list(); if let Some(value) = matches.get_one::("name-or-id") { request = request.name_or_id(value.clone()); } - self.over - .execute_networking_bgp_announce_set_list(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bgp_announce_set_list(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bgp_announce_set_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bgp_announce_set_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bgp_announce_set_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -9462,77 +9556,93 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_networking_bgp_announce_set_create(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bgp_announce_set_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bgp_announce_set_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bgp_announce_set_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bgp_announce_set_delete(); if let Some(value) = matches.get_one::("name-or-id") { request = request.name_or_id(value.clone()); } - self.over - .execute_networking_bgp_announce_set_delete(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bgp_announce_set_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bgp_imported_routes_ipv4(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bgp_imported_routes_ipv4( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bgp_imported_routes_ipv4(); if let Some(value) = matches.get_one::("asn") { request = request.asn(value.clone()); } - self.over - .execute_networking_bgp_imported_routes_ipv4(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bgp_imported_routes_ipv4(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_bgp_status(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_bgp_status( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_bgp_status(); - self.over - .execute_networking_bgp_status(matches, &mut request) - .unwrap(); + self.config + .execute_networking_bgp_status(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_loopback_address_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_loopback_address_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_loopback_address_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -9542,27 +9652,33 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_networking_loopback_address_list(matches, &mut request) - .unwrap(); + self.config + .execute_networking_loopback_address_list(matches, &mut request)?; + self.config + .list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_networking_loopback_address_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_loopback_address_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_loopback_address_create(); if let Some(value) = matches.get_one::("address") { request = request.body_map(|body| body.address(value.clone())) @@ -9595,21 +9711,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_networking_loopback_address_create(matches, &mut request) - .unwrap(); + self.config + .execute_networking_loopback_address_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_loopback_address_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_loopback_address_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_loopback_address_delete(); if let Some(value) = matches.get_one::("address") { request = request.address(value.clone()); @@ -9627,21 +9747,25 @@ impl Cli { request = request.switch_location(value.clone()); } - self.over - .execute_networking_loopback_address_delete(matches, &mut request) - .unwrap(); + self.config + .execute_networking_loopback_address_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_switch_port_settings_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_switch_port_settings_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_switch_port_settings_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -9655,27 +9779,33 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_networking_switch_port_settings_list(matches, &mut request) - .unwrap(); + self.config + .execute_networking_switch_port_settings_list(matches, &mut request)?; + self.config + .list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_networking_switch_port_settings_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_switch_port_settings_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_switch_port_settings_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -9692,77 +9822,93 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_networking_switch_port_settings_create(matches, &mut request) - .unwrap(); + self.config + .execute_networking_switch_port_settings_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_switch_port_settings_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_switch_port_settings_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_switch_port_settings_delete(); if let Some(value) = matches.get_one::("port-settings") { request = request.port_settings(value.clone()); } - self.over - .execute_networking_switch_port_settings_delete(matches, &mut request) - .unwrap(); + self.config + .execute_networking_switch_port_settings_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_networking_switch_port_settings_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_networking_switch_port_settings_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.networking_switch_port_settings_view(); if let Some(value) = matches.get_one::("port") { request = request.port(value.clone()); } - self.over - .execute_networking_switch_port_settings_view(matches, &mut request) - .unwrap(); + self.config + .execute_networking_switch_port_settings_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_system_policy_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_system_policy_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.system_policy_view(); - self.over - .execute_system_policy_view(matches, &mut request) - .unwrap(); + self.config + .execute_system_policy_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_system_policy_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_system_policy_update( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.system_policy_update(); if let Some(value) = matches.get_one::("json-body") { let body_txt = std::fs::read_to_string(value).unwrap(); @@ -9770,63 +9916,71 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_system_policy_update(matches, &mut request) - .unwrap(); + self.config + .execute_system_policy_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_role_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_role_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { 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(); + self.config.execute_role_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_role_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_role_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { 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(); + self.config.execute_role_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_system_quotas_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_system_quotas_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.system_quotas_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -9836,27 +9990,29 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_system_quotas_list(matches, &mut request) - .unwrap(); + self.config + .execute_system_quotas_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_silo_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -9866,25 +10022,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over.execute_silo_list(matches, &mut request).unwrap(); + self.config.execute_silo_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_silo_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_create(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_create(); if let Some(value) = matches.get_one::("admin-group-name") { request = request.body_map(|body| body.admin_group_name(value.clone())) @@ -9912,59 +10070,64 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_silo_create(matches, &mut request) - .unwrap(); + self.config.execute_silo_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_view(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); } - self.over.execute_silo_view(matches, &mut request).unwrap(); + self.config.execute_silo_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_delete(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_delete(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); } - self.over - .execute_silo_delete(matches, &mut request) - .unwrap(); + self.config.execute_silo_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_ip_pool_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_ip_pool_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.silo_ip_pool_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -9978,47 +10141,53 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_silo_ip_pool_list(matches, &mut request) - .unwrap(); + self.config + .execute_silo_ip_pool_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_silo_policy_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_policy_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_policy_view(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); } - self.over - .execute_silo_policy_view(matches, &mut request) - .unwrap(); + self.config + .execute_silo_policy_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_policy_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_policy_update( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.silo_policy_update(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); @@ -10030,41 +10199,46 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_silo_policy_update(matches, &mut request) - .unwrap(); + self.config + .execute_silo_policy_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_quotas_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_quotas_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_quotas_view(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); } - self.over - .execute_silo_quotas_view(matches, &mut request) - .unwrap(); + self.config + .execute_silo_quotas_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_quotas_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_quotas_update( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.silo_quotas_update(); if let Some(value) = matches.get_one::("cpus") { request = request.body_map(|body| body.cpus(value.clone())) @@ -10088,21 +10262,22 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_silo_quotas_update(matches, &mut request) - .unwrap(); + self.config + .execute_silo_quotas_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_user_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_user_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_user_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -10116,27 +10291,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_silo_user_list(matches, &mut request) - .unwrap(); + self.config.execute_silo_user_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_silo_user_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_user_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.silo_user_view(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); @@ -10146,21 +10321,24 @@ impl Cli { request = request.user_id(value.clone()); } - self.over - .execute_silo_user_view(matches, &mut request) - .unwrap(); + self.config.execute_silo_user_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_user_builtin_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_user_builtin_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.user_builtin_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -10170,47 +10348,56 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_user_builtin_list(matches, &mut request) - .unwrap(); + self.config + .execute_user_builtin_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_user_builtin_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_user_builtin_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.user_builtin_view(); if let Some(value) = matches.get_one::("user") { request = request.user(value.clone()); } - self.over - .execute_user_builtin_view(matches, &mut request) - .unwrap(); + self.config + .execute_user_builtin_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_silo_utilization_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_utilization_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.silo_utilization_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -10220,47 +10407,54 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over - .execute_silo_utilization_list(matches, &mut request) - .unwrap(); + self.config + .execute_silo_utilization_list(matches, &mut request)?; + self.config + .list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_silo_utilization_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_silo_utilization_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.silo_utilization_view(); if let Some(value) = matches.get_one::("silo") { request = request.silo(value.clone()); } - self.over - .execute_silo_utilization_view(matches, &mut request) - .unwrap(); + self.config + .execute_silo_utilization_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_user_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_user_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.user_list(); if let Some(value) = matches.get_one::("group") { request = request.group(value.clone()); @@ -10274,41 +10468,47 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over.execute_user_list(matches, &mut request).unwrap(); + self.config.execute_user_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_utilization_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_utilization_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.utilization_view(); - self.over - .execute_utilization_view(matches, &mut request) - .unwrap(); + self.config + .execute_utilization_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_firewall_rules_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_firewall_rules_view( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.vpc_firewall_rules_view(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -10318,21 +10518,25 @@ impl Cli { request = request.vpc(value.clone()); } - self.over - .execute_vpc_firewall_rules_view(matches, &mut request) - .unwrap(); + self.config + .execute_vpc_firewall_rules_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_firewall_rules_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_firewall_rules_update( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.vpc_firewall_rules_update(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -10349,21 +10553,22 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_vpc_firewall_rules_update(matches, &mut request) - .unwrap(); + self.config + .execute_vpc_firewall_rules_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_subnet_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_subnet_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.vpc_subnet_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -10381,27 +10586,31 @@ impl Cli { request = request.vpc(value.clone()); } - self.over - .execute_vpc_subnet_list(matches, &mut request) - .unwrap(); + self.config.execute_vpc_subnet_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_vpc_subnet_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_subnet_create( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.vpc_subnet_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -10433,21 +10642,22 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_vpc_subnet_create(matches, &mut request) - .unwrap(); + self.config + .execute_vpc_subnet_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_subnet_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_subnet_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.vpc_subnet_view(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -10461,21 +10671,24 @@ impl Cli { request = request.vpc(value.clone()); } - self.over - .execute_vpc_subnet_view(matches, &mut request) - .unwrap(); + self.config.execute_vpc_subnet_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_subnet_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_subnet_update( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.vpc_subnet_update(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -10503,21 +10716,25 @@ impl Cli { request = request.body(body_value); } - self.over - .execute_vpc_subnet_update(matches, &mut request) - .unwrap(); + self.config + .execute_vpc_subnet_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_subnet_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_subnet_delete( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.vpc_subnet_delete(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -10531,21 +10748,25 @@ impl Cli { request = request.vpc(value.clone()); } - self.over - .execute_vpc_subnet_delete(matches, &mut request) - .unwrap(); + self.config + .execute_vpc_subnet_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_subnet_list_network_interfaces(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_subnet_list_network_interfaces( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { let mut request = self.client.vpc_subnet_list_network_interfaces(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -10567,27 +10788,30 @@ impl Cli { request = request.vpc(value.clone()); } - self.over - .execute_vpc_subnet_list_network_interfaces(matches, &mut request) - .unwrap(); + self.config + .execute_vpc_subnet_list_network_interfaces(matches, &mut request)?; + self.config + .list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config + .list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_vpc_list(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.vpc_list(); if let Some(value) = matches.get_one::("limit") { request = request.limit(value.clone()); @@ -10601,25 +10825,27 @@ impl Cli { request = request.sort_by(value.clone()); } - self.over.execute_vpc_list(matches, &mut request).unwrap(); + self.config.execute_vpc_list(matches, &mut request)?; + self.config.list_start::(); let mut stream = request.stream(); loop { match futures::TryStreamExt::try_next(&mut stream).await { Err(r) => { - println!("error\n{:#?}", r); - break; + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); } Ok(None) => { - break; + self.config.list_end_success::(); + return Ok(()); } Ok(Some(value)) => { - println!("{:#?}", value); + self.config.list_item(&value); } } } } - pub async fn execute_vpc_create(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_create(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.vpc_create(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -10647,19 +10873,21 @@ impl Cli { request = request.body(body_value); } - self.over.execute_vpc_create(matches, &mut request).unwrap(); + self.config.execute_vpc_create(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_view(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_view(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.vpc_view(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -10669,19 +10897,21 @@ impl Cli { request = request.vpc(value.clone()); } - self.over.execute_vpc_view(matches, &mut request).unwrap(); + self.config.execute_vpc_view(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_update(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_update(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.vpc_update(); if let Some(value) = matches.get_one::("description") { request = request.body_map(|body| body.description(value.clone())) @@ -10709,19 +10939,21 @@ impl Cli { request = request.body(body_value); } - self.over.execute_vpc_update(matches, &mut request).unwrap(); + self.config.execute_vpc_update(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } - pub async fn execute_vpc_delete(&self, matches: &clap::ArgMatches) { + pub async fn execute_vpc_delete(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { let mut request = self.client.vpc_delete(); if let Some(value) = matches.get_one::("project") { request = request.project(value.clone()); @@ -10731,25 +10963,45 @@ impl Cli { request = request.vpc(value.clone()); } - self.over.execute_vpc_delete(matches, &mut request).unwrap(); + self.config.execute_vpc_delete(matches, &mut request)?; let result = request.send().await; match result { Ok(r) => { - println!("success\n{:#?}", r) + self.config.item_success(&r); + Ok(()) } Err(r) => { - println!("error\n{:#?}", r) + self.config.item_error(&r); + Err(anyhow::Error::new(r)) } } } } -pub trait CliOverride { +pub trait CliConfig { + fn item_success(&self, value: &ResponseValue) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug; + fn item_error(&self, value: &Error) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug; + fn list_start(&self) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug; + fn list_item(&self, value: &T) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug; + fn list_end_success(&self) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug; + fn list_end_error(&self, value: &Error) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug; fn execute_device_auth_request( &self, matches: &clap::ArgMatches, request: &mut builder::DeviceAuthRequest, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10757,7 +11009,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DeviceAuthConfirm, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10765,7 +11017,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DeviceAccessToken, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10773,7 +11025,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::LoginSaml, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10781,7 +11033,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CertificateList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10789,7 +11041,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CertificateCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10797,7 +11049,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CertificateView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10805,7 +11057,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CertificateDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10813,7 +11065,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10821,7 +11073,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10829,7 +11081,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10837,7 +11089,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10845,7 +11097,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskBulkWriteImport, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10853,7 +11105,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskBulkWriteImportStart, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10861,7 +11113,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskBulkWriteImportStop, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10869,7 +11121,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskFinalizeImport, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10877,7 +11129,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::DiskMetricsList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10885,7 +11137,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::FloatingIpList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10893,7 +11145,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::FloatingIpCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10901,7 +11153,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::FloatingIpView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10909,7 +11161,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::FloatingIpDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10917,7 +11169,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::FloatingIpAttach, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10925,7 +11177,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::FloatingIpDetach, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10933,7 +11185,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::GroupList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10941,7 +11193,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::GroupView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10949,7 +11201,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ImageList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10957,7 +11209,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ImageCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10965,7 +11217,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ImageView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10973,7 +11225,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ImageDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10981,7 +11233,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ImageDemote, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10989,7 +11241,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ImagePromote, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -10997,7 +11249,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11005,7 +11257,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11013,7 +11265,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11021,7 +11273,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11029,7 +11281,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceDiskList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11037,7 +11289,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceDiskAttach, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11045,7 +11297,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceDiskDetach, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11053,7 +11305,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceExternalIpList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11061,7 +11313,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceEphemeralIpAttach, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11069,7 +11321,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceEphemeralIpDetach, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11077,7 +11329,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceMigrate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11085,7 +11337,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceReboot, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11093,7 +11345,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceSerialConsole, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11101,7 +11353,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceSerialConsoleStream, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11109,7 +11361,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceSshPublicKeyList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11117,7 +11369,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceStart, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11125,7 +11377,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceStop, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11133,7 +11385,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectIpPoolList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11141,7 +11393,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectIpPoolView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11149,7 +11401,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::LoginLocal, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11157,7 +11409,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::Logout, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11165,7 +11417,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CurrentUserView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11173,7 +11425,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CurrentUserGroups, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11181,7 +11433,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CurrentUserSshKeyList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11189,7 +11441,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CurrentUserSshKeyCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11197,7 +11449,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CurrentUserSshKeyView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11205,7 +11457,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::CurrentUserSshKeyDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11213,7 +11465,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloMetric, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11221,7 +11473,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceNetworkInterfaceList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11229,7 +11481,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceNetworkInterfaceCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11237,7 +11489,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceNetworkInterfaceView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11245,7 +11497,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceNetworkInterfaceUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11253,7 +11505,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::InstanceNetworkInterfaceDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11261,7 +11513,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::Ping, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11269,7 +11521,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::PolicyView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11277,7 +11529,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::PolicyUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11285,7 +11537,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11293,7 +11545,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11301,7 +11553,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11309,7 +11561,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11317,7 +11569,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11325,7 +11577,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectPolicyView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11333,7 +11585,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::ProjectPolicyUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11341,7 +11593,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SnapshotList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11349,7 +11601,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SnapshotCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11357,7 +11609,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SnapshotView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11365,7 +11617,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SnapshotDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11373,7 +11625,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::PhysicalDiskList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11381,7 +11633,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::RackList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11389,7 +11641,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::RackView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11397,7 +11649,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SledList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11405,7 +11657,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SledAdd, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11413,7 +11665,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SledView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11421,7 +11673,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SledPhysicalDiskList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11429,7 +11681,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SledInstanceList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11437,7 +11689,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SledSetProvisionState, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11445,7 +11697,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SledListUninitialized, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11453,7 +11705,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingSwitchPortList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11461,7 +11713,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingSwitchPortApplySettings, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11469,7 +11721,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingSwitchPortClearSettings, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11477,7 +11729,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SwitchList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11485,7 +11737,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SwitchView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11493,7 +11745,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloIdentityProviderList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11501,7 +11753,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::LocalIdpUserCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11509,7 +11761,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::LocalIdpUserDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11517,7 +11769,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::LocalIdpUserSetPassword, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11525,7 +11777,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SamlIdentityProviderCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11533,7 +11785,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SamlIdentityProviderView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11541,7 +11793,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11549,7 +11801,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11557,7 +11809,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11565,7 +11817,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11573,7 +11825,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11581,7 +11833,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolRangeList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11589,7 +11841,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolRangeAdd, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11597,7 +11849,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolRangeRemove, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11605,7 +11857,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolSiloList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11613,7 +11865,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolSiloLink, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11621,7 +11873,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolSiloUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11629,7 +11881,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolSiloUnlink, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11637,7 +11889,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolServiceView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11645,7 +11897,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolServiceRangeList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11653,7 +11905,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolServiceRangeAdd, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11661,7 +11913,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::IpPoolServiceRangeRemove, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11669,7 +11921,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SystemMetric, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11677,7 +11929,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingAddressLotList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11685,7 +11937,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingAddressLotCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11693,7 +11945,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingAddressLotDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11701,7 +11953,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingAddressLotBlockList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11709,7 +11961,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBfdDisable, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11717,7 +11969,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBfdEnable, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11725,7 +11977,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBfdStatus, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11733,7 +11985,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBgpConfigList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11741,7 +11993,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBgpConfigCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11749,7 +12001,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBgpConfigDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11757,7 +12009,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBgpAnnounceSetList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11765,7 +12017,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBgpAnnounceSetCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11773,7 +12025,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBgpAnnounceSetDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11781,7 +12033,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBgpImportedRoutesIpv4, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11789,7 +12041,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingBgpStatus, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11797,7 +12049,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingLoopbackAddressList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11805,7 +12057,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingLoopbackAddressCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11813,7 +12065,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingLoopbackAddressDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11821,7 +12073,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingSwitchPortSettingsList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11829,7 +12081,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingSwitchPortSettingsCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11837,7 +12089,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingSwitchPortSettingsDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11845,7 +12097,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::NetworkingSwitchPortSettingsView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11853,7 +12105,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SystemPolicyView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11861,7 +12113,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SystemPolicyUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11869,7 +12121,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::RoleList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11877,7 +12129,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::RoleView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11885,7 +12137,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SystemQuotasList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11893,7 +12145,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11901,7 +12153,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11909,7 +12161,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11917,7 +12169,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11925,7 +12177,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloIpPoolList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11933,7 +12185,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloPolicyView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11941,7 +12193,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloPolicyUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11949,7 +12201,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloQuotasView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11957,7 +12209,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloQuotasUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11965,7 +12217,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloUserList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11973,7 +12225,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloUserView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11981,7 +12233,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::UserBuiltinList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11989,7 +12241,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::UserBuiltinView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -11997,7 +12249,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloUtilizationList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12005,7 +12257,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::SiloUtilizationView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12013,7 +12265,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::UserList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12021,7 +12273,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::UtilizationView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12029,7 +12281,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcFirewallRulesView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12037,7 +12289,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcFirewallRulesUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12045,7 +12297,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcSubnetList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12053,7 +12305,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcSubnetCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12061,7 +12313,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcSubnetView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12069,7 +12321,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcSubnetUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12077,7 +12329,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcSubnetDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12085,7 +12337,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcSubnetListNetworkInterfaces, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12093,7 +12345,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcList, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12101,7 +12353,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12109,7 +12361,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcView, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12117,7 +12369,7 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcUpdate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } @@ -12125,12 +12377,11 @@ pub trait CliOverride { &self, matches: &clap::ArgMatches, request: &mut builder::VpcDelete, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { Ok(()) } } -impl CliOverride for () {} #[derive(Copy, Clone, Debug)] pub enum CliCommand { DeviceAuthRequest, diff --git a/cli/src/main.rs b/cli/src/main.rs index 2bab21f5..9cef30be 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -7,11 +7,12 @@ #![forbid(unsafe_code)] use std::net::IpAddr; +use std::sync::atomic::AtomicBool; use anyhow::Result; use async_trait::async_trait; use cli_builder::NewCli; -use generated_cli::CliOverride; +use generated_cli::CliConfig; use oxide::context::Context; use oxide::types::{IdpMetadataSource, IpRange, Ipv4Range, Ipv6Range}; @@ -65,36 +66,96 @@ async fn main() { } } -struct OxideOverride; +#[derive(Default)] +struct OxideOverride { + needs_comma: AtomicBool, +} impl OxideOverride { - fn ip_range(matches: &clap::ArgMatches) -> Result { + fn ip_range(matches: &clap::ArgMatches) -> anyhow::Result { let first = matches.get_one::("first").unwrap(); let last = matches.get_one::("last").unwrap(); match (first, last) { (IpAddr::V4(first), IpAddr::V4(last)) => { - let range = Ipv4Range::try_from(Ipv4Range::builder().first(*first).last(*last)) - .map_err(|e| e.to_string())?; + let range = Ipv4Range::try_from(Ipv4Range::builder().first(*first).last(*last))?; Ok(range.into()) } (IpAddr::V6(first), IpAddr::V6(last)) => { - let range = Ipv6Range::try_from(Ipv6Range::builder().first(*first).last(*last)) - .map_err(|e| e.to_string())?; + let range = Ipv6Range::try_from(Ipv6Range::builder().first(*first).last(*last))?; Ok(range.into()) } - _ => Err("first and last must either both be ipv4 or ipv6 addresses".to_string()), + _ => anyhow::bail!( + "first and last must either both be ipv4 or ipv6 addresses".to_string() + ), } } } -impl CliOverride for OxideOverride { +impl CliConfig for OxideOverride { + fn item_success(&self, value: &oxide::ResponseValue) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug, + { + let s = serde_json::to_string_pretty(std::ops::Deref::deref(value)) + .expect("failed to serialize return to json"); + println!("{}", s); + } + + fn item_error(&self, _value: &oxide::Error) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug, + { + eprintln!("error"); + } + + fn list_start(&self) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug, + { + self.needs_comma + .store(false, std::sync::atomic::Ordering::Relaxed); + print!("["); + } + + fn list_item(&self, value: &T) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug, + { + let s = serde_json::to_string_pretty(&[value]).expect("failed to serialize result to json"); + if self.needs_comma.load(std::sync::atomic::Ordering::Relaxed) { + print!(", {}", &s[4..s.len() - 2]); + } else { + print!("\n{}", &s[2..s.len() - 2]); + }; + self.needs_comma + .store(true, std::sync::atomic::Ordering::Relaxed); + } + + fn list_end_success(&self) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug, + { + if self.needs_comma.load(std::sync::atomic::Ordering::Relaxed) { + println!("\n]"); + } else { + println!("]"); + } + } + + fn list_end_error(&self, _value: &oxide::Error) + where + T: schemars::JsonSchema + serde::Serialize + std::fmt::Debug, + { + self.list_end_success::() + } + // Deal with all the operations that require an `IpPool` as input fn execute_ip_pool_range_add( &self, matches: &clap::ArgMatches, request: &mut oxide::builder::IpPoolRangeAdd, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { *request = request.to_owned().body(Self::ip_range(matches)?); Ok(()) } @@ -102,7 +163,7 @@ impl CliOverride for OxideOverride { &self, matches: &clap::ArgMatches, request: &mut oxide::builder::IpPoolRangeRemove, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { *request = request.to_owned().body(Self::ip_range(matches)?); Ok(()) } @@ -110,7 +171,7 @@ impl CliOverride for OxideOverride { &self, matches: &clap::ArgMatches, request: &mut oxide::builder::IpPoolServiceRangeAdd, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { *request = request.to_owned().body(Self::ip_range(matches)?); Ok(()) } @@ -118,7 +179,7 @@ impl CliOverride for OxideOverride { &self, matches: &clap::ArgMatches, request: &mut oxide::builder::IpPoolServiceRangeRemove, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { *request = request.to_owned().body(Self::ip_range(matches)?); Ok(()) } @@ -127,7 +188,7 @@ impl CliOverride for OxideOverride { &self, matches: &clap::ArgMatches, request: &mut oxide::builder::SamlIdentityProviderCreate, - ) -> Result<(), String> { + ) -> anyhow::Result<()> { match matches .get_one::("idp_metadata_source") .map(clap::Id::as_str) diff --git a/cli/tests/data/test_instance_create.stdout b/cli/tests/data/test_instance_create.stdout index 6d7db959..e0305a27 100644 --- a/cli/tests/data/test_instance_create.stdout +++ b/cli/tests/data/test_instance_create.stdout @@ -1,20 +1,13 @@ -success -Instance { - description: "description is required for some reason", - hostname: "hostname", - id: 6270889a-e74d-fa7c-849b-22449cd6138e, - memory: ByteCount( - 4294967296, - ), - name: Name( - "name", - ), - ncpus: InstanceCpuCount( - 4, - ), - project_id: 78d4484c-6234-dab6-ae7f-7f1572d3814f, - run_state: Creating, - time_created: 2018-07-10T22:24:56Z, - time_modified: 2015-03-05T05:47:06Z, - time_run_state_updated: 2000-11-09T10:15:15Z, +{ + "description": "description is required for some reason", + "hostname": "hostname", + "id": "6270889a-e74d-fa7c-849b-22449cd6138e", + "memory": 4294967296, + "name": "name", + "ncpus": 4, + "project_id": "78d4484c-6234-dab6-ae7f-7f1572d3814f", + "run_state": "creating", + "time_created": "2018-07-10T22:24:56Z", + "time_modified": "2015-03-05T05:47:06Z", + "time_run_state_updated": "2000-11-09T10:15:15Z" } diff --git a/cli/tests/data/test_projects_list_paginated.stdout b/cli/tests/data/test_projects_list_paginated.stdout index 16bce45d..733df4e5 100644 --- a/cli/tests/data/test_projects_list_paginated.stdout +++ b/cli/tests/data/test_projects_list_paginated.stdout @@ -1,90 +1,63 @@ -Project { - description: "qaid", - id: e5627088-9ae7-4dfa-7c84-9b22449cd613, - name: Name( - "faqir", - ), - time_created: 1977-01-13T04:02:13Z, - time_modified: 1966-08-21T15:21:35Z, -} -Project { - description: "tranqs", - id: 484c6234-dab6-ae7f-7f15-72d3814fac05, - name: Name( - "sheqalim", - ), - time_created: 2018-07-10T22:24:56Z, - time_modified: 2015-03-05T05:47:06Z, -} -Project { - description: "qwerty", - id: 60476b03-d381-efed-f6bf-2f6f8574ebcf, - name: Name( - "sheqel", - ), - time_created: 2000-07-30T04:25:31Z, - time_modified: 2013-03-21T09:08:43Z, -} -Project { - description: "qintars", - id: b7b19bf9-9d60-85fe-55ca-ed04d1f82edd, - name: Name( - "umiaq", - ), - time_created: 2021-09-12T16:08:22Z, - time_modified: 2000-10-22T10:00:45Z, -} -Project { - description: "qindarka", - id: d224273a-7e3a-9d37-c965-26bcefee17d1, - name: Name( - "umiaq", - ), - time_created: 1976-01-23T14:07:51Z, - time_modified: 1977-09-18T03:33:50Z, -} -Project { - description: "suqs", - id: 111d64af-f804-d6d4-ca07-83fdd3360be4, - name: Name( - "umiaqs", - ), - time_created: 1994-05-14T16:05:28Z, - time_modified: 1987-01-04T09:57:22Z, -} -Project { - description: "qaid", - id: bad1e6d1-513f-a027-85a8-54fe287434c0, - name: Name( - "qoph", - ), - time_created: 1985-02-23T23:20:30Z, - time_modified: 2019-04-24T23:07:34Z, -} -Project { - description: "qintar", - id: e279e87b-399a-8249-3b41-5a0f3fe846e4, - name: Name( - "qwertys", - ), - time_created: 1966-12-07T12:58:59Z, - time_modified: 2005-07-15T10:50:18Z, -} -Project { - description: "qoph", - id: 1eb83a7c-2564-9ba3-3e81-8afae2b25c33, - name: Name( - "qanats", - ), - time_created: 1948-01-13T03:52:20Z, - time_modified: 1994-06-17T06:31:27Z, -} -Project { - description: "qiviuts", - id: d7a3ffb8-d0fc-c25e-8afd-ea493e1f07fb, - name: Name( - "qanat", - ), - time_created: 1984-11-30T13:04:28Z, - time_modified: 1987-02-11T00:52:13Z, -} +[ + { + "description": "qaid", + "id": "e5627088-9ae7-4dfa-7c84-9b22449cd613", + "name": "faqir", + "time_created": "1977-01-13T04:02:13Z", + "time_modified": "1966-08-21T15:21:35Z" + }, { + "description": "tranqs", + "id": "484c6234-dab6-ae7f-7f15-72d3814fac05", + "name": "sheqalim", + "time_created": "2018-07-10T22:24:56Z", + "time_modified": "2015-03-05T05:47:06Z" + }, { + "description": "qwerty", + "id": "60476b03-d381-efed-f6bf-2f6f8574ebcf", + "name": "sheqel", + "time_created": "2000-07-30T04:25:31Z", + "time_modified": "2013-03-21T09:08:43Z" + }, { + "description": "qintars", + "id": "b7b19bf9-9d60-85fe-55ca-ed04d1f82edd", + "name": "umiaq", + "time_created": "2021-09-12T16:08:22Z", + "time_modified": "2000-10-22T10:00:45Z" + }, { + "description": "qindarka", + "id": "d224273a-7e3a-9d37-c965-26bcefee17d1", + "name": "umiaq", + "time_created": "1976-01-23T14:07:51Z", + "time_modified": "1977-09-18T03:33:50Z" + }, { + "description": "suqs", + "id": "111d64af-f804-d6d4-ca07-83fdd3360be4", + "name": "umiaqs", + "time_created": "1994-05-14T16:05:28Z", + "time_modified": "1987-01-04T09:57:22Z" + }, { + "description": "qaid", + "id": "bad1e6d1-513f-a027-85a8-54fe287434c0", + "name": "qoph", + "time_created": "1985-02-23T23:20:30Z", + "time_modified": "2019-04-24T23:07:34Z" + }, { + "description": "qintar", + "id": "e279e87b-399a-8249-3b41-5a0f3fe846e4", + "name": "qwertys", + "time_created": "1966-12-07T12:58:59Z", + "time_modified": "2005-07-15T10:50:18Z" + }, { + "description": "qoph", + "id": "1eb83a7c-2564-9ba3-3e81-8afae2b25c33", + "name": "qanats", + "time_created": "1948-01-13T03:52:20Z", + "time_modified": "1994-06-17T06:31:27Z" + }, { + "description": "qiviuts", + "id": "d7a3ffb8-d0fc-c25e-8afd-ea493e1f07fb", + "name": "qanat", + "time_created": "1984-11-30T13:04:28Z", + "time_modified": "1987-02-11T00:52:13Z" + } +] diff --git a/cli/tests/data/test_projects_list_paginated_fail.stdout b/cli/tests/data/test_projects_list_paginated_fail.stdout new file mode 100644 index 00000000..733df4e5 --- /dev/null +++ b/cli/tests/data/test_projects_list_paginated_fail.stdout @@ -0,0 +1,63 @@ +[ + { + "description": "qaid", + "id": "e5627088-9ae7-4dfa-7c84-9b22449cd613", + "name": "faqir", + "time_created": "1977-01-13T04:02:13Z", + "time_modified": "1966-08-21T15:21:35Z" + }, { + "description": "tranqs", + "id": "484c6234-dab6-ae7f-7f15-72d3814fac05", + "name": "sheqalim", + "time_created": "2018-07-10T22:24:56Z", + "time_modified": "2015-03-05T05:47:06Z" + }, { + "description": "qwerty", + "id": "60476b03-d381-efed-f6bf-2f6f8574ebcf", + "name": "sheqel", + "time_created": "2000-07-30T04:25:31Z", + "time_modified": "2013-03-21T09:08:43Z" + }, { + "description": "qintars", + "id": "b7b19bf9-9d60-85fe-55ca-ed04d1f82edd", + "name": "umiaq", + "time_created": "2021-09-12T16:08:22Z", + "time_modified": "2000-10-22T10:00:45Z" + }, { + "description": "qindarka", + "id": "d224273a-7e3a-9d37-c965-26bcefee17d1", + "name": "umiaq", + "time_created": "1976-01-23T14:07:51Z", + "time_modified": "1977-09-18T03:33:50Z" + }, { + "description": "suqs", + "id": "111d64af-f804-d6d4-ca07-83fdd3360be4", + "name": "umiaqs", + "time_created": "1994-05-14T16:05:28Z", + "time_modified": "1987-01-04T09:57:22Z" + }, { + "description": "qaid", + "id": "bad1e6d1-513f-a027-85a8-54fe287434c0", + "name": "qoph", + "time_created": "1985-02-23T23:20:30Z", + "time_modified": "2019-04-24T23:07:34Z" + }, { + "description": "qintar", + "id": "e279e87b-399a-8249-3b41-5a0f3fe846e4", + "name": "qwertys", + "time_created": "1966-12-07T12:58:59Z", + "time_modified": "2005-07-15T10:50:18Z" + }, { + "description": "qoph", + "id": "1eb83a7c-2564-9ba3-3e81-8afae2b25c33", + "name": "qanats", + "time_created": "1948-01-13T03:52:20Z", + "time_modified": "1994-06-17T06:31:27Z" + }, { + "description": "qiviuts", + "id": "d7a3ffb8-d0fc-c25e-8afd-ea493e1f07fb", + "name": "qanat", + "time_created": "1984-11-30T13:04:28Z", + "time_modified": "1987-02-11T00:52:13Z" + } +] diff --git a/cli/tests/data/test_projects_simple_list.stdout b/cli/tests/data/test_projects_simple_list.stdout index 25d3d501..07299d67 100644 --- a/cli/tests/data/test_projects_simple_list.stdout +++ b/cli/tests/data/test_projects_simple_list.stdout @@ -1,9 +1,9 @@ -Project { - description: "qat", - id: 70889ae7-4dfa-7c84-9b22-449cd6138e2d, - name: Name( - "qaids", - ), - time_created: 1966-08-21T15:21:35Z, - time_modified: 2019-05-25T09:39:02Z, -} +[ + { + "description": "qat", + "id": "70889ae7-4dfa-7c84-9b22-449cd6138e2d", + "name": "qaids", + "time_created": "1966-08-21T15:21:35Z", + "time_modified": "2019-05-25T09:39:02Z" + } +] diff --git a/cli/tests/data/test_silo_idp_saml_create.stdout b/cli/tests/data/test_silo_idp_saml_create.stdout index 8d5f32ba..50ac88ee 100644 --- a/cli/tests/data/test_silo_idp_saml_create.stdout +++ b/cli/tests/data/test_silo_idp_saml_create.stdout @@ -1,19 +1,13 @@ -success -SamlIdentityProvider { - acs_url: "http://nope.nope", - description: "for all the security I guess", - group_attribute_name: None, - id: 6270889a-e74d-fa7c-849b-22449cd6138e, - idp_entity_id: "17", - name: Name( - "samlrific", - ), - public_cert: Some( - "qaid", - ), - slo_url: "http://nope.nope", - sp_client_id: "17", - technical_contact_email: "anyone@but.adam", - time_created: 1977-12-10T14:17:08Z, - time_modified: 2022-11-13T08:30:19Z, +{ + "acs_url": "http://nope.nope", + "description": "for all the security I guess", + "id": "6270889a-e74d-fa7c-849b-22449cd6138e", + "idp_entity_id": "17", + "name": "samlrific", + "public_cert": "qaid", + "slo_url": "http://nope.nope", + "sp_client_id": "17", + "technical_contact_email": "anyone@but.adam", + "time_created": "1977-12-10T14:17:08Z", + "time_modified": "2022-11-13T08:30:19Z" } diff --git a/cli/tests/test_projects.rs b/cli/tests/test_projects.rs index 4cabcb25..bf2bab9f 100644 --- a/cli/tests/test_projects.rs +++ b/cli/tests/test_projects.rs @@ -129,15 +129,6 @@ fn test_projects_list_paginated_fail() { }); }); - let output = format!( - "{}error\nError Response: status: 400 Bad Request", - results - .iter() - .map(|item| format!("{:#?}\n", item)) - .collect::>() - .join(""), - ); - Command::cargo_bin("oxide") .unwrap() .env("RUST_BACKTRACE", "1") @@ -146,8 +137,11 @@ fn test_projects_list_paginated_fail() { .arg("project") .arg("list") .assert() - .success() - .stdout(predicates::str::starts_with(output)); + .failure() + // .stdout(predicates::str::starts_with(output)); + .stdout(expectorate::eq_file_or_panic( + "tests/data/test_projects_list_paginated_fail.stdout", + )); mock_p1.assert(); mock_p2.assert(); diff --git a/cli/tests/test_silo_idp_saml.rs b/cli/tests/test_silo_idp_saml.rs index 85d1c22c..145a1f35 100644 --- a/cli/tests/test_silo_idp_saml.rs +++ b/cli/tests/test_silo_idp_saml.rs @@ -6,10 +6,7 @@ use assert_cmd::Command; use httpmock::MockServer; -use oxide::types::{ - IdpMetadataSource, Project, ProjectResultsPage, SamlIdentityProvider, - SamlIdentityProviderCreate, -}; +use oxide::types::{IdpMetadataSource, SamlIdentityProvider, SamlIdentityProviderCreate}; use oxide_httpmock::MockServerExt; use rand::SeedableRng; use test_common::JsonMock; @@ -81,115 +78,3 @@ fn test_silo_idp_saml_create() { mock.assert(); } - -#[test] -fn test_projects_list_paginated() { - let mut src = rand::rngs::SmallRng::seed_from_u64(42); - let server = MockServer::start(); - - let results = (0..10) - .map(|_| Project::mock_value(&mut src).unwrap()) - .collect::>(); - - let mock_p3 = server.project_list(|when, then| { - when.page_token("page-3"); - then.ok(&ProjectResultsPage { - items: Vec::new(), - next_page: None, - }); - }); - let mock_p2 = server.project_list(|when, then| { - when.page_token("page-2"); - then.ok(&ProjectResultsPage { - items: results[5..].into(), - next_page: Some("page-3".to_string()), - }); - }); - let mock_p1 = server.project_list(|when, then| { - when.into_inner().any_request(); - then.ok(&ProjectResultsPage { - items: results[0..5].into(), - next_page: Some("page-2".to_string()), - }); - }); - - Command::cargo_bin("oxide") - .unwrap() - .env("RUST_BACKTRACE", "1") - .env("OXIDE_HOST", server.url("")) - .env("OXIDE_TOKEN", "fake-token") - .arg("project") - .arg("list") - .arg("--limit") - .arg("10") - .assert() - .success() - .stdout(expectorate::eq_file_or_panic( - "tests/data/test_projects_list_paginated.stdout", - )); - - mock_p1.assert(); - mock_p2.assert(); - // Because we hit the limit, we should not fetch the final page. - mock_p3.assert_hits(0); -} - -#[test] -fn test_projects_list_paginated_fail() { - let mut src = rand::rngs::SmallRng::seed_from_u64(42); - let server = MockServer::start(); - - let results = (0..10) - .map(|_| Project::mock_value(&mut src).unwrap()) - .collect::>(); - - let mock_p3 = server.project_list(|when, then| { - when.page_token("page-3"); - then.client_error( - 400, - &oxide::types::Error { - error_code: None, - message: "".to_string(), - request_id: "".to_string(), - }, - ); - }); - let mock_p2 = server.project_list(|when, then| { - when.page_token("page-2"); - then.ok(&ProjectResultsPage { - items: results[5..].into(), - next_page: Some("page-3".to_string()), - }); - }); - let mock_p1 = server.project_list(|when, then| { - when.into_inner().any_request(); - then.ok(&ProjectResultsPage { - items: results[0..5].into(), - next_page: Some("page-2".to_string()), - }); - }); - - let output = format!( - "{}error\nError Response: status: 400 Bad Request", - results - .iter() - .map(|item| format!("{:#?}\n", item)) - .collect::>() - .join(""), - ); - - Command::cargo_bin("oxide") - .unwrap() - .env("RUST_BACKTRACE", "1") - .env("OXIDE_HOST", server.url("")) - .env("OXIDE_TOKEN", "fake-token") - .arg("project") - .arg("list") - .assert() - .success() - .stdout(predicates::str::starts_with(output)); - - mock_p1.assert(); - mock_p2.assert(); - mock_p3.assert(); -}