From 4ae36894a223353b66a03c9dccef7b3d899aefdd Mon Sep 17 00:00:00 2001 From: Ulysse Mavrocordatos Date: Fri, 2 Oct 2026 11:24:29 +0200 Subject: [PATCH] gate hand-written downtime list for generated takeover --- src/commands/downtime.rs | 6 +++++- src/commands/mod.rs | 6 ++++++ src/main.rs | 21 +++++++++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/commands/downtime.rs b/src/commands/downtime.rs index 3a683d96..1e6141ab 100644 --- a/src/commands/downtime.rs +++ b/src/commands/downtime.rs @@ -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 @@ -52,6 +55,7 @@ mod tests { use crate::test_support::*; + #[cfg(not(generated_op = "downtime.list"))] #[tokio::test] async fn test_downtime_list() { let _lock = lock_env().await; diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 4cfb96a3..9b85ec08 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -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; diff --git a/src/main.rs b/src/main.rs index 4ec21018..124fbb79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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"))] @@ -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", @@ -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, @@ -12758,7 +12774,7 @@ mod test_agent_schema { "flags": [{"name": "file", "type": "string", "required": true}] }, get, - {"name": "list", "read_only": true} + list ] }) ); @@ -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?,