Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/commands/downtime.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use anyhow::Result;
use datadog_api_client::datadogV2::api_downtimes::DowntimesAPI;
#[cfg(not(generated_op = "downtime.get"))]
use datadog_api_client::datadogV2::api_downtimes::GetDowntimeOptionalParams;
use datadog_api_client::datadogV2::api_downtimes::{DowntimesAPI, ListDowntimesOptionalParams};
#[cfg(not(generated_op = "downtime.list"))]
use datadog_api_client::datadogV2::api_downtimes::ListDowntimesOptionalParams;

use crate::config::Config;
use crate::formatter;

#[cfg(not(generated_op = "downtime.list"))]
pub async fn list(cfg: &Config) -> Result<()> {
let api = crate::make_api!(DowntimesAPI, cfg);
let resp = api
Expand Down Expand Up @@ -52,6 +55,7 @@ mod tests {

use crate::test_support::*;

#[cfg(not(generated_op = "downtime.list"))]
Comment thread
MintsInc marked this conversation as resolved.
#[tokio::test]
async fn test_downtime_list() {
let _lock = lock_env().await;
Expand Down
6 changes: 6 additions & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ pub mod ddsql;
pub mod debugger;
pub mod deployment_gates;
pub mod docs;
#[cfg(not(all(
generated_op = "downtime.list",
generated_op = "downtime.get",
generated_op = "downtime.create",
generated_op = "downtime.cancel"
)))]
pub mod downtime;
pub mod error_tracking;
pub mod events;
Expand Down
21 changes: 19 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4536,6 +4536,7 @@ enum EventActions {
#[derive(Subcommand)]
enum DowntimeActions {
/// List all downtimes
#[cfg(not(generated_op = "downtime.list"))]
List,
/// Get downtime details
#[cfg(not(generated_op = "downtime.get"))]
Expand Down Expand Up @@ -12723,7 +12724,8 @@ mod test_agent_schema {
let document = build_cli_surface(&Cli::command());
let commands = document["commands"].as_array().unwrap();
let downtime = find_command(commands, &["downtime"]).expect("downtime command not found");
// The generated `downtime get` exposes the spec's optional query parameters as flags.
// The generated `downtime get` and `downtime list` expose the spec's optional query
// parameters as flags.
let get = if cfg!(generated_op = "downtime.get") {
serde_json::json!({
"name": "get",
Expand All @@ -12741,6 +12743,20 @@ mod test_agent_schema {
"args": [{"name": "id", "type": "string", "required": true}]
})
};
let list = if cfg!(generated_op = "downtime.list") {
serde_json::json!({
"name": "list",
"read_only": true,
"flags": [
{"name": "current-only", "type": "string", "required": false},
{"name": "include", "type": "string", "required": false},
{"name": "page-limit", "type": "string", "required": false},
{"name": "page-offset", "type": "string", "required": false}
]
})
} else {
serde_json::json!({"name": "list", "read_only": true})
};

assert_eq!(
downtime,
Expand All @@ -12758,7 +12774,7 @@ mod test_agent_schema {
"flags": [{"name": "file", "type": "string", "required": true}]
},
get,
{"name": "list", "read_only": true}
list
]
})
);
Expand Down Expand Up @@ -14960,6 +14976,7 @@ async fn main_inner() -> anyhow::Result<()> {
Commands::Downtime { action } => {
cfg.validate_auth()?;
match action {
#[cfg(not(generated_op = "downtime.list"))]
DowntimeActions::List => commands::downtime::list(&cfg).await?,
#[cfg(not(generated_op = "downtime.get"))]
DowntimeActions::Get { id } => commands::downtime::get(&cfg, &id).await?,
Expand Down
Loading