Skip to content

Commit

Permalink
Rebuilt with latest dependency updates
Browse files Browse the repository at this point in the history
  • Loading branch information
oxide-reflector-bot[bot] committed Dec 4, 2024
1 parent 320dede commit e0abb16
Show file tree
Hide file tree
Showing 4 changed files with 322 additions and 0 deletions.
81 changes: 81 additions & 0 deletions cli/src/generated_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ impl<T: CliConfig> Cli<T> {
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::UserList => Self::cli_user_list(),
CliCommand::UtilizationView => Self::cli_utilization_view(),
CliCommand::VpcFirewallRulesView => Self::cli_vpc_firewall_rules_view(),
Expand Down Expand Up @@ -5572,6 +5573,44 @@ impl<T: CliConfig> Cli<T> {
.about("Fetch current utilization for given silo")
}

pub fn cli_timeseries_query() -> clap::Command {
clap::Command::new("")
.arg(
clap::Arg::new("project")
.long("project")
.value_parser(clap::value_parser!(types::NameOrId))
.required(true)
.help("Name or ID of the project"),
)
.arg(
clap::Arg::new("query")
.long("query")
.value_parser(clap::value_parser!(::std::string::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 project-scoped timeseries query")
.long_about(
"Queries are written in OxQL. Project must be specified by name or ID in URL \
query parameter. The OxQL query will only return timeseries data from the \
specified project.",
)
}

pub fn cli_user_list() -> clap::Command {
clap::Command::new("")
.arg(
Expand Down Expand Up @@ -6912,6 +6951,7 @@ impl<T: CliConfig> Cli<T> {
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::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,
Expand Down Expand Up @@ -13031,6 +13071,37 @@ impl<T: CliConfig> Cli<T> {
}
}

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::<types::NameOrId>("project") {
request = request.project(value.clone());
}

if let Some(value) = matches.get_one::<::std::string::String>("query") {
request = request.body_map(|body| body.query(value.clone()))
}

if let Some(value) = matches.get_one::<std::path::PathBuf>("json-body") {
let body_txt = std::fs::read_to_string(value).unwrap();
let body_value = serde_json::from_str::<types::TimeseriesQuery>(&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_user_list(&self, matches: &clap::ArgMatches) -> anyhow::Result<()> {
let mut request = self.client.user_list();
if let Some(value) = matches.get_one::<uuid::Uuid>("group") {
Expand Down Expand Up @@ -15479,6 +15550,14 @@ pub trait CliConfig {
Ok(())
}

fn execute_timeseries_query(
&self,
matches: &clap::ArgMatches,
request: &mut builder::TimeseriesQuery,
) -> anyhow::Result<()> {
Ok(())
}

fn execute_user_list(
&self,
matches: &clap::ArgMatches,
Expand Down Expand Up @@ -15865,6 +15944,7 @@ pub enum CliCommand {
UserBuiltinView,
SiloUtilizationList,
SiloUtilizationView,
TimeseriesQuery,
UserList,
UtilizationView,
VpcFirewallRulesView,
Expand Down Expand Up @@ -16078,6 +16158,7 @@ impl CliCommand {
CliCommand::UserBuiltinView,
CliCommand::SiloUtilizationList,
CliCommand::SiloUtilizationView,
CliCommand::TimeseriesQuery,
CliCommand::UserList,
CliCommand::UtilizationView,
CliCommand::VpcFirewallRulesView,
Expand Down
49 changes: 49 additions & 0 deletions oxide.json
Original file line number Diff line number Diff line change
Expand Up @@ -8890,6 +8890,55 @@
}
}
},
"/v1/timeseries/query": {
"post": {
"tags": [
"hidden"
],
"summary": "Run project-scoped timeseries query",
"description": "Queries are written in OxQL. Project must be specified by name or ID in URL query parameter. The OxQL query will only return timeseries data from the specified project.",
"operationId": "timeseries_query",
"parameters": [
{
"in": "query",
"name": "project",
"description": "Name or ID of the project",
"required": true,
"schema": {
"$ref": "#/components/schemas/NameOrId"
}
}
],
"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/users": {
"get": {
"tags": [
Expand Down
78 changes: 78 additions & 0 deletions sdk-httpmock/src/generated_httpmock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14541,6 +14541,69 @@ 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 project(self, value: &types::NameOrId) -> Self {
Self(self.0.query_param("project", value.to_string()))
}

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 UserListWhen(httpmock::When);
impl UserListWhen {
pub fn new(inner: httpmock::When) -> Self {
Expand Down Expand Up @@ -17653,6 +17716,9 @@ pub trait MockServerExt {
fn silo_utilization_view<F>(&self, config_fn: F) -> httpmock::Mock
where
F: FnOnce(operations::SiloUtilizationViewWhen, operations::SiloUtilizationViewThen);
fn timeseries_query<F>(&self, config_fn: F) -> httpmock::Mock
where
F: FnOnce(operations::TimeseriesQueryWhen, operations::TimeseriesQueryThen);
fn user_list<F>(&self, config_fn: F) -> httpmock::Mock
where
F: FnOnce(operations::UserListWhen, operations::UserListThen);
Expand Down Expand Up @@ -20065,6 +20131,18 @@ impl MockServerExt for httpmock::MockServer {
})
}

fn timeseries_query<F>(&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 user_list<F>(&self, config_fn: F) -> httpmock::Mock
where
F: FnOnce(operations::UserListWhen, operations::UserListThen),
Expand Down
Loading

0 comments on commit e0abb16

Please sign in to comment.