diff --git a/Cargo.lock b/Cargo.lock index 811c7afa..59587ef5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -940,7 +940,7 @@ dependencies = [ "slog-bunyan", "slog-json", "slog-term", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-rustls 0.25.0", "toml", @@ -1510,7 +1510,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.7", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -2222,7 +2222,7 @@ version = "5.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d385da3c602d29036d2f70beed71c36604df7570be17fed4c5b839616785bf" dependencies = [ - "base64 0.22.1", + "base64 0.21.7", "chrono", "getrandom", "http 1.1.0", @@ -2232,7 +2232,7 @@ dependencies = [ "serde_json", "serde_path_to_error", "sha2", - "thiserror", + "thiserror 1.0.69", "url", ] @@ -2343,7 +2343,7 @@ dependencies = [ "schemars", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "toml", "toml_edit", @@ -2664,7 +2664,7 @@ dependencies = [ [[package]] name = "progenitor" version = "0.8.0" -source = "git+https://github.com/oxidecomputer/progenitor#789c4b66f7649bd67a9d4bf53928cf82557c223c" +source = "git+https://github.com/oxidecomputer/progenitor#dfc6e0f2ab9f407e927be791c4fa57cf4e0c1549" dependencies = [ "progenitor-client 0.8.0 (git+https://github.com/oxidecomputer/progenitor)", "progenitor-impl", @@ -2689,7 +2689,7 @@ dependencies = [ [[package]] name = "progenitor-client" version = "0.8.0" -source = "git+https://github.com/oxidecomputer/progenitor#789c4b66f7649bd67a9d4bf53928cf82557c223c" +source = "git+https://github.com/oxidecomputer/progenitor#dfc6e0f2ab9f407e927be791c4fa57cf4e0c1549" dependencies = [ "bytes", "futures-core", @@ -2703,7 +2703,7 @@ dependencies = [ [[package]] name = "progenitor-impl" version = "0.8.0" -source = "git+https://github.com/oxidecomputer/progenitor#789c4b66f7649bd67a9d4bf53928cf82557c223c" +source = "git+https://github.com/oxidecomputer/progenitor#dfc6e0f2ab9f407e927be791c4fa57cf4e0c1549" dependencies = [ "heck", "http 1.1.0", @@ -2716,7 +2716,7 @@ dependencies = [ "serde", "serde_json", "syn", - "thiserror", + "thiserror 1.0.69", "typify", "unicode-ident", ] @@ -2724,7 +2724,7 @@ dependencies = [ [[package]] name = "progenitor-macro" version = "0.8.0" -source = "git+https://github.com/oxidecomputer/progenitor#789c4b66f7649bd67a9d4bf53928cf82557c223c" +source = "git+https://github.com/oxidecomputer/progenitor#dfc6e0f2ab9f407e927be791c4fa57cf4e0c1549" dependencies = [ "openapiv3", "proc-macro2", @@ -2751,7 +2751,7 @@ dependencies = [ "rustc-hash", "rustls 0.23.12", "socket2 0.5.7", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", ] @@ -2768,7 +2768,7 @@ dependencies = [ "rustc-hash", "rustls 0.23.12", "slab", - "thiserror", + "thiserror 1.0.69", "tinyvec", "tracing", ] @@ -2874,7 +2874,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -3016,7 +3016,7 @@ checksum = "f1adc9dfed5cc999077978cc7163b9282c5751c8d39827c4ea8c8c220ca5a440" dependencies = [ "serde", "tempfile", - "thiserror", + "thiserror 1.0.69", "toml", "toolchain_find", ] @@ -3707,7 +3707,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -3721,6 +3730,17 @@ dependencies = [ "syn", ] +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "thouart" version = "0.1.0" @@ -3731,7 +3751,7 @@ dependencies = [ "regex", "term", "termini", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-tungstenite", "winapi", @@ -4015,7 +4035,7 @@ dependencies = [ "log", "rand", "sha1", - "thiserror", + "thiserror 1.0.69", "url", "utf-8", ] @@ -4029,7 +4049,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "typify" version = "0.2.0" -source = "git+https://github.com/oxidecomputer/typify#e22bf1bfc0f1a03b091a342b057eb10dfad3047e" +source = "git+https://github.com/oxidecomputer/typify#a1986aaa2275bc71ee4f660c9ddf82d6aa29caca" dependencies = [ "typify-impl", "typify-macro", @@ -4038,7 +4058,7 @@ dependencies = [ [[package]] name = "typify-impl" version = "0.2.0" -source = "git+https://github.com/oxidecomputer/typify#e22bf1bfc0f1a03b091a342b057eb10dfad3047e" +source = "git+https://github.com/oxidecomputer/typify#a1986aaa2275bc71ee4f660c9ddf82d6aa29caca" dependencies = [ "heck", "log", @@ -4050,14 +4070,14 @@ dependencies = [ "serde", "serde_json", "syn", - "thiserror", + "thiserror 2.0.3", "unicode-ident", ] [[package]] name = "typify-macro" version = "0.2.0" -source = "git+https://github.com/oxidecomputer/typify#e22bf1bfc0f1a03b091a342b057eb10dfad3047e" +source = "git+https://github.com/oxidecomputer/typify#a1986aaa2275bc71ee4f660c9ddf82d6aa29caca" dependencies = [ "proc-macro2", "quote", @@ -4357,7 +4377,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] diff --git a/cli/src/cli_builder.rs b/cli/src/cli_builder.rs index d029ed8d..9d4beb18 100644 --- a/cli/src/cli_builder.rs +++ b/cli/src/cli_builder.rs @@ -577,8 +577,8 @@ fn xxx<'a>(command: CliCommand) -> Option<&'a str> { CliCommand::ProbeView => Some("experimental probe view"), // Metrics-related subcommands - CliCommand::TimeseriesQuery => Some("experimental timeseries query"), - CliCommand::TimeseriesSchemaList => Some("experimental timeseries schema list"), + CliCommand::SystemTimeseriesQuery => Some("experimental timeseries query"), + CliCommand::SystemTimeseriesSchemaList => Some("experimental timeseries schema list"), // Commands not yet implemented CliCommand::DeviceAccessToken diff --git a/cli/src/cmd_net.rs b/cli/src/cmd_net.rs index d89b56ca..05ad9721 100644 --- a/cli/src/cmd_net.rs +++ b/cli/src/cmd_net.rs @@ -95,7 +95,7 @@ pub struct CmdLinkAdd { /// The forward error correction mode of the link. #[arg(long, value_enum)] - pub fec: CliLinkFec, + pub fec: Option, /// Maximum transmission unit for the link. #[arg(long, default_value_t = 1500u16)] @@ -126,7 +126,7 @@ impl AuthenticatedCmd for CmdLinkAdd { }); let link = LinkConfigCreate { autoneg: self.autoneg, - fec: self.fec.into(), + fec: self.fec.map(|fec| fec.into()), mtu: self.mtu, speed: self.speed.into(), lldp: LldpLinkConfigCreate { @@ -1248,7 +1248,13 @@ impl AuthenticatedCmd for CmdPortConfig { )?; for l in &config.links { - writeln!(&mut tw, "{:?}\t{:?}\t{:?}", l.autoneg, l.fec, l.speed,)?; + writeln!( + &mut tw, + "{}\t{}\t{}", + l.autoneg, + l.fec.map_or("".to_string(), |fec| fec.to_string()), + l.speed, + )?; } tw.flush()?; println_nopipe!(); diff --git a/cli/src/cmd_timeseries/dashboard.rs b/cli/src/cmd_timeseries/dashboard.rs index beef1181..b335dba8 100644 --- a/cli/src/cmd_timeseries/dashboard.rs +++ b/cli/src/cmd_timeseries/dashboard.rs @@ -12,7 +12,7 @@ use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind, KeyM use futures::{FutureExt, StreamExt}; use oxide::{ types::{MetricType, Table as OxqlTable, Timeseries, TimeseriesQuery, ValueArray}, - Client, ClientMetricsExt, + Client, ClientSystemMetricsExt, }; use ratatui::{ prelude::{Alignment, Constraint, Direction, Layout}, @@ -218,7 +218,7 @@ async fn client_query_loop( _ = &mut done => break, _ = interval.tick() => { let request = client - .timeseries_query() + .system_timeseries_query() .body(TimeseriesQuery { query: query.clone() }); match request.send().await { Ok(response) => { diff --git a/cli/src/generated_cli.rs b/cli/src/generated_cli.rs index 596fcab0..605f97ee 100644 --- a/cli/src/generated_cli.rs +++ b/cli/src/generated_cli.rs @@ -230,14 +230,14 @@ impl Cli { CliCommand::SiloPolicyUpdate => Self::cli_silo_policy_update(), CliCommand::SiloQuotasView => Self::cli_silo_quotas_view(), CliCommand::SiloQuotasUpdate => Self::cli_silo_quotas_update(), + CliCommand::SystemTimeseriesQuery => Self::cli_system_timeseries_query(), + CliCommand::SystemTimeseriesSchemaList => Self::cli_system_timeseries_schema_list(), CliCommand::SiloUserList => Self::cli_silo_user_list(), CliCommand::SiloUserView => Self::cli_silo_user_view(), CliCommand::UserBuiltinList => Self::cli_user_builtin_list(), CliCommand::UserBuiltinView => Self::cli_user_builtin_view(), CliCommand::SiloUtilizationList => Self::cli_silo_utilization_list(), CliCommand::SiloUtilizationView => Self::cli_silo_utilization_view(), - CliCommand::TimeseriesQuery => Self::cli_timeseries_query(), - CliCommand::TimeseriesSchemaList => Self::cli_timeseries_schema_list(), CliCommand::UserList => Self::cli_user_list(), CliCommand::UtilizationView => Self::cli_utilization_view(), CliCommand::VpcFirewallRulesView => Self::cli_vpc_firewall_rules_view(), @@ -5399,6 +5399,45 @@ impl Cli { .long_about("If a quota value is not specified, it will remain unchanged.") } + pub fn cli_system_timeseries_query() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("query") + .long("query") + .value_parser(clap::value_parser!(String)) + .required_unless_present("json-body") + .help("A timeseries query string, written in the Oximeter query language."), + ) + .arg( + clap::Arg::new("json-body") + .long("json-body") + .value_name("JSON-FILE") + .required(false) + .value_parser(clap::value_parser!(std::path::PathBuf)) + .help("Path to a file that contains the full json body."), + ) + .arg( + clap::Arg::new("json-body-template") + .long("json-body-template") + .action(clap::ArgAction::SetTrue) + .help("XXX"), + ) + .about("Run timeseries query") + .long_about("Queries are written in OxQL.") + } + + pub fn cli_system_timeseries_schema_list() -> clap::Command { + clap::Command::new("") + .arg( + clap::Arg::new("limit") + .long("limit") + .value_parser(clap::value_parser!(std::num::NonZeroU32)) + .required(false) + .help("Maximum number of items returned by a single call"), + ) + .about("List timeseries schemas") + } + pub fn cli_silo_user_list() -> clap::Command { clap::Command::new("") .arg( @@ -5519,45 +5558,6 @@ impl Cli { .about("Fetch current utilization for given silo") } - pub fn cli_timeseries_query() -> clap::Command { - clap::Command::new("") - .arg( - clap::Arg::new("query") - .long("query") - .value_parser(clap::value_parser!(String)) - .required_unless_present("json-body") - .help("A timeseries query string, written in the Oximeter query language."), - ) - .arg( - clap::Arg::new("json-body") - .long("json-body") - .value_name("JSON-FILE") - .required(false) - .value_parser(clap::value_parser!(std::path::PathBuf)) - .help("Path to a file that contains the full json body."), - ) - .arg( - clap::Arg::new("json-body-template") - .long("json-body-template") - .action(clap::ArgAction::SetTrue) - .help("XXX"), - ) - .about("Run timeseries query") - .long_about("Queries are written in OxQL.") - } - - pub fn cli_timeseries_schema_list() -> clap::Command { - clap::Command::new("") - .arg( - clap::Arg::new("limit") - .long("limit") - .value_parser(clap::value_parser!(std::num::NonZeroU32)) - .required(false) - .help("Maximum number of items returned by a single call"), - ) - .about("List timeseries schemas") - } - pub fn cli_user_list() -> clap::Command { clap::Command::new("") .arg( @@ -6886,14 +6886,18 @@ impl Cli { 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::SystemTimeseriesQuery => { + self.execute_system_timeseries_query(matches).await + } + CliCommand::SystemTimeseriesSchemaList => { + self.execute_system_timeseries_schema_list(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::TimeseriesQuery => self.execute_timeseries_query(matches).await, - CliCommand::TimeseriesSchemaList => self.execute_timeseries_schema_list(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, @@ -12746,6 +12750,73 @@ impl Cli { } } + pub async fn execute_system_timeseries_query( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.system_timeseries_query(); + if let Some(value) = matches.get_one::("query") { + request = request.body_map(|body| body.query(value.clone())) + } + + if let Some(value) = matches.get_one::("json-body") { + let body_txt = std::fs::read_to_string(value).unwrap(); + let body_value = serde_json::from_str::(&body_txt).unwrap(); + request = request.body(body_value); + } + + self.config + .execute_system_timeseries_query(matches, &mut request)?; + let result = request.send().await; + match result { + Ok(r) => { + self.config.success_item(&r); + Ok(()) + } + Err(r) => { + self.config.error(&r); + Err(anyhow::Error::new(r)) + } + } + } + + pub async fn execute_system_timeseries_schema_list( + &self, + matches: &clap::ArgMatches, + ) -> anyhow::Result<()> { + let mut request = self.client.system_timeseries_schema_list(); + if let Some(value) = matches.get_one::("limit") { + request = request.limit(value.clone()); + } + + self.config + .execute_system_timeseries_schema_list(matches, &mut request)?; + self.config + .list_start::(); + let mut stream = futures::StreamExt::take( + request.stream(), + matches + .get_one::("limit") + .map_or(usize::MAX, |x| x.get() as usize), + ); + loop { + match futures::TryStreamExt::try_next(&mut stream).await { + Err(r) => { + self.config.list_end_error(&r); + return Err(anyhow::Error::new(r)); + } + Ok(None) => { + self.config + .list_end_success::(); + return Ok(()); + } + Ok(Some(value)) => { + self.config.list_item(&value); + } + } + } + } + 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") { @@ -12938,70 +13009,6 @@ impl Cli { } } - pub async fn execute_timeseries_query(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> { - let mut request = self.client.timeseries_query(); - if let Some(value) = matches.get_one::("query") { - request = request.body_map(|body| body.query(value.clone())) - } - - if let Some(value) = matches.get_one::("json-body") { - let body_txt = std::fs::read_to_string(value).unwrap(); - let body_value = serde_json::from_str::(&body_txt).unwrap(); - request = request.body(body_value); - } - - self.config - .execute_timeseries_query(matches, &mut request)?; - let result = request.send().await; - match result { - Ok(r) => { - self.config.success_item(&r); - Ok(()) - } - Err(r) => { - self.config.error(&r); - Err(anyhow::Error::new(r)) - } - } - } - - pub async fn execute_timeseries_schema_list( - &self, - matches: &clap::ArgMatches, - ) -> anyhow::Result<()> { - let mut request = self.client.timeseries_schema_list(); - if let Some(value) = matches.get_one::("limit") { - request = request.limit(value.clone()); - } - - self.config - .execute_timeseries_schema_list(matches, &mut request)?; - self.config - .list_start::(); - let mut stream = futures::StreamExt::take( - request.stream(), - matches - .get_one::("limit") - .map_or(usize::MAX, |x| x.get() as usize), - ); - loop { - match futures::TryStreamExt::try_next(&mut stream).await { - Err(r) => { - self.config.list_end_error(&r); - return Err(anyhow::Error::new(r)); - } - Ok(None) => { - self.config - .list_end_success::(); - return Ok(()); - } - Ok(Some(value)) => { - self.config.list_item(&value); - } - } - } - } - 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") { @@ -15386,66 +15393,66 @@ pub trait CliConfig { Ok(()) } - fn execute_silo_user_list( + fn execute_system_timeseries_query( &self, matches: &clap::ArgMatches, - request: &mut builder::SiloUserList, + request: &mut builder::SystemTimeseriesQuery, ) -> anyhow::Result<()> { Ok(()) } - fn execute_silo_user_view( + fn execute_system_timeseries_schema_list( &self, matches: &clap::ArgMatches, - request: &mut builder::SiloUserView, + request: &mut builder::SystemTimeseriesSchemaList, ) -> anyhow::Result<()> { Ok(()) } - fn execute_user_builtin_list( + fn execute_silo_user_list( &self, matches: &clap::ArgMatches, - request: &mut builder::UserBuiltinList, + request: &mut builder::SiloUserList, ) -> anyhow::Result<()> { Ok(()) } - fn execute_user_builtin_view( + fn execute_silo_user_view( &self, matches: &clap::ArgMatches, - request: &mut builder::UserBuiltinView, + request: &mut builder::SiloUserView, ) -> anyhow::Result<()> { Ok(()) } - fn execute_silo_utilization_list( + fn execute_user_builtin_list( &self, matches: &clap::ArgMatches, - request: &mut builder::SiloUtilizationList, + request: &mut builder::UserBuiltinList, ) -> anyhow::Result<()> { Ok(()) } - fn execute_silo_utilization_view( + fn execute_user_builtin_view( &self, matches: &clap::ArgMatches, - request: &mut builder::SiloUtilizationView, + request: &mut builder::UserBuiltinView, ) -> anyhow::Result<()> { Ok(()) } - fn execute_timeseries_query( + fn execute_silo_utilization_list( &self, matches: &clap::ArgMatches, - request: &mut builder::TimeseriesQuery, + request: &mut builder::SiloUtilizationList, ) -> anyhow::Result<()> { Ok(()) } - fn execute_timeseries_schema_list( + fn execute_silo_utilization_view( &self, matches: &clap::ArgMatches, - request: &mut builder::TimeseriesSchemaList, + request: &mut builder::SiloUtilizationView, ) -> anyhow::Result<()> { Ok(()) } @@ -15828,14 +15835,14 @@ pub enum CliCommand { SiloPolicyUpdate, SiloQuotasView, SiloQuotasUpdate, + SystemTimeseriesQuery, + SystemTimeseriesSchemaList, SiloUserList, SiloUserView, UserBuiltinList, UserBuiltinView, SiloUtilizationList, SiloUtilizationView, - TimeseriesQuery, - TimeseriesSchemaList, UserList, UtilizationView, VpcFirewallRulesView, @@ -16041,14 +16048,14 @@ impl CliCommand { CliCommand::SiloPolicyUpdate, CliCommand::SiloQuotasView, CliCommand::SiloQuotasUpdate, + CliCommand::SystemTimeseriesQuery, + CliCommand::SystemTimeseriesSchemaList, CliCommand::SiloUserList, CliCommand::SiloUserView, CliCommand::UserBuiltinList, CliCommand::UserBuiltinView, CliCommand::SiloUtilizationList, CliCommand::SiloUtilizationView, - CliCommand::TimeseriesQuery, - CliCommand::TimeseriesSchemaList, CliCommand::UserList, CliCommand::UtilizationView, CliCommand::VpcFirewallRulesView, diff --git a/cli/tests/data/test_switch_port_settings_show.stdout b/cli/tests/data/test_switch_port_settings_show.stdout index 990251e4..d0d42b4d 100644 --- a/cli/tests/data/test_switch_port_settings_show.stdout +++ b/cli/tests/data/test_switch_port_settings_show.stdout @@ -1,7 +1,7 @@ switch0/qsfp0 ============= -Autoneg Fec Speed -false None Speed100G +Autoneg Fec Speed +false speed100_g Address Lot VLAN 169.254.10.2/30 initial-infra None @@ -17,7 +17,7 @@ Destination Nexthop Vlan Preference switch1/qsfp0 ============= Autoneg Fec Speed -false None Speed100G +false none speed100_g Address Lot VLAN 169.254.20.2/30 initial-infra None diff --git a/cli/tests/test_net.rs b/cli/tests/test_net.rs index ea6372be..3fce3990 100644 --- a/cli/tests/test_net.rs +++ b/cli/tests/test_net.rs @@ -165,7 +165,7 @@ fn test_port_config() { link_lldp: Vec::new(), links: vec![SwitchPortLinkConfig { autoneg: false, - fec: LinkFec::None, + fec: None, link_name: String::from("phy0"), lldp_link_config_id: None, mtu: 1500, @@ -259,7 +259,7 @@ fn test_port_config() { link_lldp: Vec::new(), links: vec![SwitchPortLinkConfig { autoneg: false, - fec: LinkFec::None, + fec: Some(LinkFec::None), link_name: String::from("phy0"), lldp_link_config_id: None, mtu: 1500, diff --git a/oxide.json b/oxide.json index f12ff473..a272b916 100644 --- a/oxide.json +++ b/oxide.json @@ -7,7 +7,7 @@ "url": "https://oxide.computer", "email": "api@oxide.computer" }, - "version": "20241204.0" + "version": "20241204.0.0" }, "paths": { "/device/auth": { @@ -8490,6 +8490,96 @@ } } }, + "/v1/system/timeseries/query": { + "post": { + "tags": [ + "system/metrics" + ], + "summary": "Run timeseries query", + "description": "Queries are written in OxQL.", + "operationId": "system_timeseries_query", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TimeseriesQuery" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OxqlQueryResult" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + } + } + }, + "/v1/system/timeseries/schemas": { + "get": { + "tags": [ + "system/metrics" + ], + "summary": "List timeseries schemas", + "operationId": "system_timeseries_schema_list", + "parameters": [ + { + "in": "query", + "name": "limit", + "description": "Maximum number of items returned by a single call", + "schema": { + "nullable": true, + "type": "integer", + "format": "uint32", + "minimum": 1 + } + }, + { + "in": "query", + "name": "page_token", + "description": "Token returned by previous call to retrieve the subsequent page", + "schema": { + "nullable": true, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TimeseriesSchemaResultsPage" + } + } + } + }, + "4XX": { + "$ref": "#/components/responses/Error" + }, + "5XX": { + "$ref": "#/components/responses/Error" + } + }, + "x-dropshot-pagination": { + "required": [] + } + } + }, "/v1/system/users": { "get": { "tags": [ @@ -8800,96 +8890,6 @@ } } }, - "/v1/timeseries/query": { - "post": { - "tags": [ - "metrics" - ], - "summary": "Run timeseries query", - "description": "Queries are written in OxQL.", - "operationId": "timeseries_query", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TimeseriesQuery" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/OxqlQueryResult" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - } - } - }, - "/v1/timeseries/schema": { - "get": { - "tags": [ - "metrics" - ], - "summary": "List timeseries schemas", - "operationId": "timeseries_schema_list", - "parameters": [ - { - "in": "query", - "name": "limit", - "description": "Maximum number of items returned by a single call", - "schema": { - "nullable": true, - "type": "integer", - "format": "uint32", - "minimum": 1 - } - }, - { - "in": "query", - "name": "page_token", - "description": "Token returned by previous call to retrieve the subsequent page", - "schema": { - "nullable": true, - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "successful operation", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TimeseriesSchemaResultsPage" - } - } - } - }, - "4XX": { - "$ref": "#/components/responses/Error" - }, - "5XX": { - "$ref": "#/components/responses/Error" - } - }, - "x-dropshot-pagination": { - "required": [] - } - } - }, "/v1/users": { "get": { "tags": [ @@ -17166,6 +17166,7 @@ "type": "boolean" }, "fec": { + "nullable": true, "description": "The forward error correction mode of the link.", "allOf": [ { @@ -17207,7 +17208,6 @@ }, "required": [ "autoneg", - "fec", "lldp", "mtu", "speed" @@ -20410,6 +20410,7 @@ "type": "boolean" }, "fec": { + "nullable": true, "description": "The forward error correction mode of the link.", "allOf": [ { @@ -20455,7 +20456,6 @@ }, "required": [ "autoneg", - "fec", "link_name", "mtu", "port_settings_id", diff --git a/sdk-httpmock/src/generated_httpmock.rs b/sdk-httpmock/src/generated_httpmock.rs index 3ebf4a56..639a57d2 100644 --- a/sdk-httpmock/src/generated_httpmock.rs +++ b/sdk-httpmock/src/generated_httpmock.rs @@ -13879,6 +13879,152 @@ pub mod operations { } } + pub struct SystemTimeseriesQueryWhen(httpmock::When); + impl SystemTimeseriesQueryWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::POST) + .path_matches(regex::Regex::new("^/v1/system/timeseries/query$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn body(self, value: &types::TimeseriesQuery) -> Self { + Self(self.0.json_body_obj(value)) + } + } + + pub struct SystemTimeseriesQueryThen(httpmock::Then); + impl SystemTimeseriesQueryThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::OxqlQueryResult) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + + pub struct SystemTimeseriesSchemaListWhen(httpmock::When); + impl SystemTimeseriesSchemaListWhen { + pub fn new(inner: httpmock::When) -> Self { + Self( + inner + .method(httpmock::Method::GET) + .path_matches(regex::Regex::new("^/v1/system/timeseries/schemas$").unwrap()), + ) + } + + pub fn into_inner(self) -> httpmock::When { + self.0 + } + + pub fn limit(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("limit", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "limit")) + .is_none() + })) + } + } + + pub fn page_token<'a, T>(self, value: T) -> Self + where + T: Into>, + { + if let Some(value) = value.into() { + Self(self.0.query_param("page_token", value.to_string())) + } else { + Self(self.0.matches(|req| { + req.query_params + .as_ref() + .and_then(|qs| qs.iter().find(|(key, _)| key == "page_token")) + .is_none() + })) + } + } + } + + pub struct SystemTimeseriesSchemaListThen(httpmock::Then); + impl SystemTimeseriesSchemaListThen { + pub fn new(inner: httpmock::Then) -> Self { + Self(inner) + } + + pub fn into_inner(self) -> httpmock::Then { + self.0 + } + + pub fn ok(self, value: &types::TimeseriesSchemaResultsPage) -> Self { + Self( + self.0 + .status(200u16) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn client_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 4u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + + pub fn server_error(self, status: u16, value: &types::Error) -> Self { + assert_eq!(status / 100u16, 5u16); + Self( + self.0 + .status(status) + .header("content-type", "application/json") + .json_body_obj(value), + ) + } + } + pub struct SiloUserListWhen(httpmock::When); impl SiloUserListWhen { pub fn new(inner: httpmock::When) -> Self { @@ -14395,152 +14541,6 @@ pub mod operations { } } - pub struct TimeseriesQueryWhen(httpmock::When); - impl TimeseriesQueryWhen { - pub fn new(inner: httpmock::When) -> Self { - Self( - inner - .method(httpmock::Method::POST) - .path_matches(regex::Regex::new("^/v1/timeseries/query$").unwrap()), - ) - } - - pub fn into_inner(self) -> httpmock::When { - self.0 - } - - pub fn body(self, value: &types::TimeseriesQuery) -> Self { - Self(self.0.json_body_obj(value)) - } - } - - pub struct TimeseriesQueryThen(httpmock::Then); - impl TimeseriesQueryThen { - pub fn new(inner: httpmock::Then) -> Self { - Self(inner) - } - - pub fn into_inner(self) -> httpmock::Then { - self.0 - } - - pub fn ok(self, value: &types::OxqlQueryResult) -> Self { - Self( - self.0 - .status(200u16) - .header("content-type", "application/json") - .json_body_obj(value), - ) - } - - pub fn client_error(self, status: u16, value: &types::Error) -> Self { - assert_eq!(status / 100u16, 4u16); - Self( - self.0 - .status(status) - .header("content-type", "application/json") - .json_body_obj(value), - ) - } - - pub fn server_error(self, status: u16, value: &types::Error) -> Self { - assert_eq!(status / 100u16, 5u16); - Self( - self.0 - .status(status) - .header("content-type", "application/json") - .json_body_obj(value), - ) - } - } - - pub struct TimeseriesSchemaListWhen(httpmock::When); - impl TimeseriesSchemaListWhen { - pub fn new(inner: httpmock::When) -> Self { - Self( - inner - .method(httpmock::Method::GET) - .path_matches(regex::Regex::new("^/v1/timeseries/schema$").unwrap()), - ) - } - - pub fn into_inner(self) -> httpmock::When { - self.0 - } - - pub fn limit(self, value: T) -> Self - where - T: Into>, - { - if let Some(value) = value.into() { - Self(self.0.query_param("limit", value.to_string())) - } else { - Self(self.0.matches(|req| { - req.query_params - .as_ref() - .and_then(|qs| qs.iter().find(|(key, _)| key == "limit")) - .is_none() - })) - } - } - - pub fn page_token<'a, T>(self, value: T) -> Self - where - T: Into>, - { - if let Some(value) = value.into() { - Self(self.0.query_param("page_token", value.to_string())) - } else { - Self(self.0.matches(|req| { - req.query_params - .as_ref() - .and_then(|qs| qs.iter().find(|(key, _)| key == "page_token")) - .is_none() - })) - } - } - } - - pub struct TimeseriesSchemaListThen(httpmock::Then); - impl TimeseriesSchemaListThen { - pub fn new(inner: httpmock::Then) -> Self { - Self(inner) - } - - pub fn into_inner(self) -> httpmock::Then { - self.0 - } - - pub fn ok(self, value: &types::TimeseriesSchemaResultsPage) -> Self { - Self( - self.0 - .status(200u16) - .header("content-type", "application/json") - .json_body_obj(value), - ) - } - - pub fn client_error(self, status: u16, value: &types::Error) -> Self { - assert_eq!(status / 100u16, 4u16); - Self( - self.0 - .status(status) - .header("content-type", "application/json") - .json_body_obj(value), - ) - } - - pub fn server_error(self, status: u16, value: &types::Error) -> Self { - assert_eq!(status / 100u16, 5u16); - Self( - self.0 - .status(status) - .header("content-type", "application/json") - .json_body_obj(value), - ) - } - } - pub struct UserListWhen(httpmock::When); impl UserListWhen { pub fn new(inner: httpmock::When) -> Self { @@ -17626,6 +17626,15 @@ pub trait MockServerExt { fn silo_quotas_update(&self, config_fn: F) -> httpmock::Mock where F: FnOnce(operations::SiloQuotasUpdateWhen, operations::SiloQuotasUpdateThen); + fn system_timeseries_query(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemTimeseriesQueryWhen, operations::SystemTimeseriesQueryThen); + fn system_timeseries_schema_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SystemTimeseriesSchemaListWhen, + operations::SystemTimeseriesSchemaListThen, + ); fn silo_user_list(&self, config_fn: F) -> httpmock::Mock where F: FnOnce(operations::SiloUserListWhen, operations::SiloUserListThen); @@ -17644,12 +17653,6 @@ pub trait MockServerExt { fn silo_utilization_view(&self, config_fn: F) -> httpmock::Mock where F: FnOnce(operations::SiloUtilizationViewWhen, operations::SiloUtilizationViewThen); - fn timeseries_query(&self, config_fn: F) -> httpmock::Mock - where - F: FnOnce(operations::TimeseriesQueryWhen, operations::TimeseriesQueryThen); - fn timeseries_schema_list(&self, config_fn: F) -> httpmock::Mock - where - F: FnOnce(operations::TimeseriesSchemaListWhen, operations::TimeseriesSchemaListThen); fn user_list(&self, config_fn: F) -> httpmock::Mock where F: FnOnce(operations::UserListWhen, operations::UserListThen); @@ -19963,6 +19966,33 @@ impl MockServerExt for httpmock::MockServer { }) } + fn system_timeseries_query(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce(operations::SystemTimeseriesQueryWhen, operations::SystemTimeseriesQueryThen), + { + self.mock(|when, then| { + config_fn( + operations::SystemTimeseriesQueryWhen::new(when), + operations::SystemTimeseriesQueryThen::new(then), + ) + }) + } + + fn system_timeseries_schema_list(&self, config_fn: F) -> httpmock::Mock + where + F: FnOnce( + operations::SystemTimeseriesSchemaListWhen, + operations::SystemTimeseriesSchemaListThen, + ), + { + self.mock(|when, then| { + config_fn( + operations::SystemTimeseriesSchemaListWhen::new(when), + operations::SystemTimeseriesSchemaListThen::new(then), + ) + }) + } + fn silo_user_list(&self, config_fn: F) -> httpmock::Mock where F: FnOnce(operations::SiloUserListWhen, operations::SiloUserListThen), @@ -20035,30 +20065,6 @@ impl MockServerExt for httpmock::MockServer { }) } - fn timeseries_query(&self, config_fn: F) -> httpmock::Mock - where - F: FnOnce(operations::TimeseriesQueryWhen, operations::TimeseriesQueryThen), - { - self.mock(|when, then| { - config_fn( - operations::TimeseriesQueryWhen::new(when), - operations::TimeseriesQueryThen::new(then), - ) - }) - } - - fn timeseries_schema_list(&self, config_fn: F) -> httpmock::Mock - where - F: FnOnce(operations::TimeseriesSchemaListWhen, operations::TimeseriesSchemaListThen), - { - self.mock(|when, then| { - config_fn( - operations::TimeseriesSchemaListWhen::new(when), - operations::TimeseriesSchemaListThen::new(then), - ) - }) - } - fn user_list(&self, config_fn: F) -> httpmock::Mock where F: FnOnce(operations::UserListWhen, operations::UserListThen), diff --git a/sdk/src/generated_sdk.rs b/sdk/src/generated_sdk.rs index 3c1c0625..3ace96d8 100644 --- a/sdk/src/generated_sdk.rs +++ b/sdk/src/generated_sdk.rs @@ -15010,7 +15010,6 @@ pub mod types { /// "type": "object", /// "required": [ /// "autoneg", - /// "fec", /// "lldp", /// "mtu", /// "speed" @@ -15022,9 +15021,16 @@ pub mod types { /// }, /// "fec": { /// "description": "The forward error correction mode of the link.", - /// "allOf": [ + /// "oneOf": [ + /// { + /// "type": "null" + /// }, /// { - /// "$ref": "#/components/schemas/LinkFec" + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/LinkFec" + /// } + /// ] /// } /// ] /// }, @@ -15077,7 +15083,8 @@ pub mod types { /// Whether or not to set autonegotiation pub autoneg: bool, /// The forward error correction mode of the link. - pub fec: LinkFec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fec: Option, /// The link-layer discovery protocol (LLDP) configuration for the link. pub lldp: LldpLinkConfigCreate, /// Maximum transmission unit for the link. @@ -23654,7 +23661,6 @@ pub mod types { /// "type": "object", /// "required": [ /// "autoneg", - /// "fec", /// "link_name", /// "mtu", /// "port_settings_id", @@ -23668,9 +23674,16 @@ pub mod types { /// }, /// "fec": { /// "description": "The forward error correction mode of the link.", - /// "allOf": [ + /// "oneOf": [ + /// { + /// "type": "null" + /// }, /// { - /// "$ref": "#/components/schemas/LinkFec" + /// "allOf": [ + /// { + /// "$ref": "#/components/schemas/LinkFec" + /// } + /// ] /// } /// ] /// }, @@ -23726,7 +23739,8 @@ pub mod types { /// Whether or not the link has autonegotiation enabled. pub autoneg: bool, /// The forward error correction mode of the link. - pub fec: LinkFec, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub fec: Option, /// The name of this link. pub link_name: String, /// The link-layer discovery protocol service configuration id for this @@ -38948,7 +38962,7 @@ pub mod types { #[derive(Clone, Debug)] pub struct LinkConfigCreate { autoneg: Result, - fec: Result, + fec: Result, String>, lldp: Result, mtu: Result, speed: Result, @@ -38959,7 +38973,7 @@ pub mod types { fn default() -> Self { Self { autoneg: Err("no value supplied for autoneg".to_string()), - fec: Err("no value supplied for fec".to_string()), + fec: Ok(Default::default()), lldp: Err("no value supplied for lldp".to_string()), mtu: Err("no value supplied for mtu".to_string()), speed: Err("no value supplied for speed".to_string()), @@ -38981,7 +38995,7 @@ pub mod types { } pub fn fec(mut self, value: T) -> Self where - T: std::convert::TryInto, + T: std::convert::TryInto>, T::Error: std::fmt::Display, { self.fec = value @@ -45321,7 +45335,7 @@ pub mod types { #[derive(Clone, Debug)] pub struct SwitchPortLinkConfig { autoneg: Result, - fec: Result, + fec: Result, String>, link_name: Result, lldp_link_config_id: Result, String>, mtu: Result, @@ -45334,7 +45348,7 @@ pub mod types { fn default() -> Self { Self { autoneg: Err("no value supplied for autoneg".to_string()), - fec: Err("no value supplied for fec".to_string()), + fec: Ok(Default::default()), link_name: Err("no value supplied for link_name".to_string()), lldp_link_config_id: Ok(Default::default()), mtu: Err("no value supplied for mtu".to_string()), @@ -45358,7 +45372,7 @@ pub mod types { } pub fn fec(mut self, value: T) -> Self where - T: std::convert::TryInto, + T: std::convert::TryInto>, T::Error: std::fmt::Display, { self.fec = value @@ -49208,7 +49222,7 @@ pub mod types { /// /// API for interacting with the Oxide control plane /// -/// Version: 20241204.0 +/// Version: 20241204.0.0 pub struct Client { pub(crate) baseurl: String, pub(crate) client: reqwest::Client, @@ -49261,7 +49275,7 @@ impl Client { /// This string is pulled directly from the source OpenAPI /// document and may be in any format the API selects. pub fn api_version(&self) -> &'static str { - "20241204.0" + "20241204.0.0" } } @@ -50495,49 +50509,12 @@ pub trait ClientMetricsExt { /// .await; /// ``` fn silo_metric(&self) -> builder::SiloMetric; - /// Run timeseries query - /// - /// Queries are written in OxQL. - /// - /// Sends a `POST` request to `/v1/timeseries/query` - /// - /// ```ignore - /// let response = client.timeseries_query() - /// .body(body) - /// .send() - /// .await; - /// ``` - fn timeseries_query(&self) -> builder::TimeseriesQuery; - /// List timeseries schemas - /// - /// Sends a `GET` request to `/v1/timeseries/schema` - /// - /// Arguments: - /// - `limit`: Maximum number of items returned by a single call - /// - `page_token`: Token returned by previous call to retrieve the - /// subsequent page - /// ```ignore - /// let response = client.timeseries_schema_list() - /// .limit(limit) - /// .page_token(page_token) - /// .send() - /// .await; - /// ``` - fn timeseries_schema_list(&self) -> builder::TimeseriesSchemaList; } impl ClientMetricsExt for Client { fn silo_metric(&self) -> builder::SiloMetric { builder::SiloMetric::new(self) } - - fn timeseries_query(&self) -> builder::TimeseriesQuery { - builder::TimeseriesQuery::new(self) - } - - fn timeseries_schema_list(&self) -> builder::TimeseriesSchemaList { - builder::TimeseriesSchemaList::new(self) - } } /// System-wide IAM policy @@ -51926,12 +51903,49 @@ pub trait ClientSystemMetricsExt { /// .await; /// ``` fn system_metric(&self) -> builder::SystemMetric; + /// Run timeseries query + /// + /// Queries are written in OxQL. + /// + /// Sends a `POST` request to `/v1/system/timeseries/query` + /// + /// ```ignore + /// let response = client.system_timeseries_query() + /// .body(body) + /// .send() + /// .await; + /// ``` + fn system_timeseries_query(&self) -> builder::SystemTimeseriesQuery; + /// List timeseries schemas + /// + /// Sends a `GET` request to `/v1/system/timeseries/schemas` + /// + /// Arguments: + /// - `limit`: Maximum number of items returned by a single call + /// - `page_token`: Token returned by previous call to retrieve the + /// subsequent page + /// ```ignore + /// let response = client.system_timeseries_schema_list() + /// .limit(limit) + /// .page_token(page_token) + /// .send() + /// .await; + /// ``` + fn system_timeseries_schema_list(&self) -> builder::SystemTimeseriesSchemaList; } impl ClientSystemMetricsExt for Client { fn system_metric(&self) -> builder::SystemMetric { builder::SystemMetric::new(self) } + + fn system_timeseries_query(&self) -> builder::SystemTimeseriesQuery { + builder::SystemTimeseriesQuery::new(self) + } + + fn system_timeseries_schema_list(&self) -> builder::SystemTimeseriesSchemaList { + builder::SystemTimeseriesSchemaList::new(self) + } } /// This provides rack-level network configuration. @@ -71466,6 +71480,207 @@ pub mod builder { } } + /// Builder for [`ClientSystemMetricsExt::system_timeseries_query`] + /// + /// [`ClientSystemMetricsExt::system_timeseries_query`]: super::ClientSystemMetricsExt::system_timeseries_query + #[derive(Debug, Clone)] + pub struct SystemTimeseriesQuery<'a> { + client: &'a super::Client, + body: Result, + } + + impl<'a> SystemTimeseriesQuery<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + body: Ok(types::builder::TimeseriesQuery::default()), + } + } + + pub fn body(mut self, value: V) -> Self + where + V: std::convert::TryInto, + >::Error: std::fmt::Display, + { + self.body = value + .try_into() + .map(From::from) + .map_err(|s| format!("conversion to `TimeseriesQuery` for body failed: {}", s)); + self + } + + pub fn body_map(mut self, f: F) -> Self + where + F: std::ops::FnOnce(types::builder::TimeseriesQuery) -> types::builder::TimeseriesQuery, + { + self.body = self.body.map(f); + self + } + + /// Sends a `POST` request to `/v1/system/timeseries/query` + pub async fn send( + self, + ) -> Result, Error> { + let Self { client, body } = self; + let body = body + .and_then(|v| types::TimeseriesQuery::try_from(v).map_err(|e| e.to_string())) + .map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/timeseries/query", client.baseurl,); + #[allow(unused_mut)] + let mut request = client + .client + .post(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .json(&body) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + } + + /// Builder for [`ClientSystemMetricsExt::system_timeseries_schema_list`] + /// + /// [`ClientSystemMetricsExt::system_timeseries_schema_list`]: super::ClientSystemMetricsExt::system_timeseries_schema_list + #[derive(Debug, Clone)] + pub struct SystemTimeseriesSchemaList<'a> { + client: &'a super::Client, + limit: Result, String>, + page_token: Result, String>, + } + + impl<'a> SystemTimeseriesSchemaList<'a> { + pub fn new(client: &'a super::Client) -> Self { + Self { + client: client, + limit: Ok(None), + page_token: Ok(None), + } + } + + pub fn limit(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.limit = value.try_into().map(Some).map_err(|_| { + "conversion to `std :: num :: NonZeroU32` for limit failed".to_string() + }); + self + } + + pub fn page_token(mut self, value: V) -> Self + where + V: std::convert::TryInto, + { + self.page_token = value + .try_into() + .map(Some) + .map_err(|_| "conversion to `String` for page_token failed".to_string()); + self + } + + /// Sends a `GET` request to `/v1/system/timeseries/schemas` + pub async fn send( + self, + ) -> Result, Error> + { + let Self { + client, + limit, + page_token, + } = self; + let limit = limit.map_err(Error::InvalidRequest)?; + let page_token = page_token.map_err(Error::InvalidRequest)?; + let url = format!("{}/v1/system/timeseries/schemas", client.baseurl,); + let mut query = Vec::with_capacity(2usize); + if let Some(v) = &limit { + query.push(("limit", v.to_string())); + } + if let Some(v) = &page_token { + query.push(("page_token", v.to_string())); + } + #[allow(unused_mut)] + let mut request = client + .client + .get(url) + .header( + reqwest::header::ACCEPT, + reqwest::header::HeaderValue::from_static("application/json"), + ) + .query(&query) + .build()?; + let result = client.client.execute(request).await; + let response = result?; + match response.status().as_u16() { + 200u16 => ResponseValue::from_response(response).await, + 400u16..=499u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + 500u16..=599u16 => Err(Error::ErrorResponse( + ResponseValue::from_response(response).await?, + )), + _ => Err(Error::UnexpectedResponse(response)), + } + } + + /// Streams `GET` requests to `/v1/system/timeseries/schemas` + pub fn stream( + self, + ) -> impl futures::Stream>> + Unpin + 'a + { + use futures::StreamExt; + use futures::TryFutureExt; + use futures::TryStreamExt; + let next = Self { + page_token: Ok(None), + ..self.clone() + }; + self.send() + .map_ok(move |page| { + let page = page.into_inner(); + let first = futures::stream::iter(page.items).map(Ok); + let rest = futures::stream::try_unfold( + (page.next_page, next), + |(next_page, next)| async { + if next_page.is_none() { + Ok(None) + } else { + Self { + page_token: Ok(next_page), + ..next.clone() + } + .send() + .map_ok(|page| { + let page = page.into_inner(); + Some(( + futures::stream::iter(page.items).map(Ok), + (page.next_page, next), + )) + }) + .await + } + }, + ) + .try_flatten(); + first.chain(rest) + }) + .try_flatten_stream() + .boxed() + } + } + /// Builder for [`ClientSystemSilosExt::silo_user_list`] /// /// [`ClientSystemSilosExt::silo_user_list`]: super::ClientSystemSilosExt::silo_user_list @@ -72131,207 +72346,6 @@ pub mod builder { } } - /// Builder for [`ClientMetricsExt::timeseries_query`] - /// - /// [`ClientMetricsExt::timeseries_query`]: super::ClientMetricsExt::timeseries_query - #[derive(Debug, Clone)] - pub struct TimeseriesQuery<'a> { - client: &'a super::Client, - body: Result, - } - - impl<'a> TimeseriesQuery<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client: client, - body: Ok(types::builder::TimeseriesQuery::default()), - } - } - - pub fn body(mut self, value: V) -> Self - where - V: std::convert::TryInto, - >::Error: std::fmt::Display, - { - self.body = value - .try_into() - .map(From::from) - .map_err(|s| format!("conversion to `TimeseriesQuery` for body failed: {}", s)); - self - } - - pub fn body_map(mut self, f: F) -> Self - where - F: std::ops::FnOnce(types::builder::TimeseriesQuery) -> types::builder::TimeseriesQuery, - { - self.body = self.body.map(f); - self - } - - /// Sends a `POST` request to `/v1/timeseries/query` - pub async fn send( - self, - ) -> Result, Error> { - let Self { client, body } = self; - let body = body - .and_then(|v| types::TimeseriesQuery::try_from(v).map_err(|e| e.to_string())) - .map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/timeseries/query", client.baseurl,); - #[allow(unused_mut)] - let mut request = client - .client - .post(url) - .header( - reqwest::header::ACCEPT, - reqwest::header::HeaderValue::from_static("application/json"), - ) - .json(&body) - .build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - } - - /// Builder for [`ClientMetricsExt::timeseries_schema_list`] - /// - /// [`ClientMetricsExt::timeseries_schema_list`]: super::ClientMetricsExt::timeseries_schema_list - #[derive(Debug, Clone)] - pub struct TimeseriesSchemaList<'a> { - client: &'a super::Client, - limit: Result, String>, - page_token: Result, String>, - } - - impl<'a> TimeseriesSchemaList<'a> { - pub fn new(client: &'a super::Client) -> Self { - Self { - client: client, - limit: Ok(None), - page_token: Ok(None), - } - } - - pub fn limit(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.limit = value.try_into().map(Some).map_err(|_| { - "conversion to `std :: num :: NonZeroU32` for limit failed".to_string() - }); - self - } - - pub fn page_token(mut self, value: V) -> Self - where - V: std::convert::TryInto, - { - self.page_token = value - .try_into() - .map(Some) - .map_err(|_| "conversion to `String` for page_token failed".to_string()); - self - } - - /// Sends a `GET` request to `/v1/timeseries/schema` - pub async fn send( - self, - ) -> Result, Error> - { - let Self { - client, - limit, - page_token, - } = self; - let limit = limit.map_err(Error::InvalidRequest)?; - let page_token = page_token.map_err(Error::InvalidRequest)?; - let url = format!("{}/v1/timeseries/schema", client.baseurl,); - let mut query = Vec::with_capacity(2usize); - if let Some(v) = &limit { - query.push(("limit", v.to_string())); - } - if let Some(v) = &page_token { - query.push(("page_token", v.to_string())); - } - #[allow(unused_mut)] - let mut request = client - .client - .get(url) - .header( - reqwest::header::ACCEPT, - reqwest::header::HeaderValue::from_static("application/json"), - ) - .query(&query) - .build()?; - let result = client.client.execute(request).await; - let response = result?; - match response.status().as_u16() { - 200u16 => ResponseValue::from_response(response).await, - 400u16..=499u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - 500u16..=599u16 => Err(Error::ErrorResponse( - ResponseValue::from_response(response).await?, - )), - _ => Err(Error::UnexpectedResponse(response)), - } - } - - /// Streams `GET` requests to `/v1/timeseries/schema` - pub fn stream( - self, - ) -> impl futures::Stream>> + Unpin + 'a - { - use futures::StreamExt; - use futures::TryFutureExt; - use futures::TryStreamExt; - let next = Self { - page_token: Ok(None), - ..self.clone() - }; - self.send() - .map_ok(move |page| { - let page = page.into_inner(); - let first = futures::stream::iter(page.items).map(Ok); - let rest = futures::stream::try_unfold( - (page.next_page, next), - |(next_page, next)| async { - if next_page.is_none() { - Ok(None) - } else { - Self { - page_token: Ok(next_page), - ..next.clone() - } - .send() - .map_ok(|page| { - let page = page.into_inner(); - Some(( - futures::stream::iter(page.items).map(Ok), - (page.next_page, next), - )) - }) - .await - } - }, - ) - .try_flatten(); - first.chain(rest) - }) - .try_flatten_stream() - .boxed() - } - } - /// Builder for [`ClientSilosExt::user_list`] /// /// [`ClientSilosExt::user_list`]: super::ClientSilosExt::user_list