From 3e70ac94a1f068f1bb8507cac8f2b103c7736fdc Mon Sep 17 00:00:00 2001 From: "dd-octo-sts[bot]" <200755185+dd-octo-sts[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 14:17:42 +0000 Subject: [PATCH 1/2] Regenerate client from spec repo --- src/auth/callback.rs | 2 ++ src/auth/dcr.rs | 2 ++ src/auth/mod.rs | 2 ++ src/auth/pkce.rs | 2 ++ src/auth/storage.rs | 2 ++ src/auth/types.rs | 2 ++ src/client.rs | 2 ++ src/config.rs | 2 ++ src/downtime.rs | 59 ++++++++++++++++++++++++++++++++++++++++++++ src/formatter.rs | 2 ++ src/generated.rs | 27 ++++++++++++++++++++ src/useragent.rs | 2 ++ src/util.rs | 2 ++ src/version.rs | 2 ++ 14 files changed, 110 insertions(+) create mode 100644 src/downtime.rs create mode 100644 src/generated.rs diff --git a/src/auth/callback.rs b/src/auth/callback.rs index d55cef01..59c88e27 100644 --- a/src/auth/callback.rs +++ b/src/auth/callback.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + #[cfg(not(target_arch = "wasm32"))] use anyhow::bail; use anyhow::Result; diff --git a/src/auth/dcr.rs b/src/auth/dcr.rs index 22a6ad8e..56fa02c4 100644 --- a/src/auth/dcr.rs +++ b/src/auth/dcr.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + #[cfg(not(target_arch = "wasm32"))] use anyhow::{bail, Context, Result}; #[cfg(not(target_arch = "wasm32"))] diff --git a/src/auth/mod.rs b/src/auth/mod.rs index f86404f9..90519af2 100644 --- a/src/auth/mod.rs +++ b/src/auth/mod.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + pub mod callback; pub mod dcr; pub mod pkce; diff --git a/src/auth/pkce.rs b/src/auth/pkce.rs index 737f7b3e..5832cee5 100644 --- a/src/auth/pkce.rs +++ b/src/auth/pkce.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + #[cfg(not(target_arch = "wasm32"))] use anyhow::Result; #[cfg(not(target_arch = "wasm32"))] diff --git a/src/auth/storage.rs b/src/auth/storage.rs index ce48dca0..8d69d6a5 100644 --- a/src/auth/storage.rs +++ b/src/auth/storage.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + use anyhow::{Context, Result}; use std::path::PathBuf; diff --git a/src/auth/types.rs b/src/auth/types.rs index 2e5708b6..f5396a01 100644 --- a/src/auth/types.rs +++ b/src/auth/types.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + use chrono::Utc; use serde::{Deserialize, Serialize}; diff --git a/src/client.rs b/src/client.rs index bd7dcbe9..f4ed4e96 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + use reqwest_middleware::{ClientBuilder, ClientWithMiddleware}; #[cfg(not(target_arch = "wasm32"))] diff --git a/src/config.rs b/src/config.rs index eaeb11b4..cbbad8a4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + use anyhow::{bail, Result}; #[cfg(not(feature = "browser"))] use serde::Deserialize; diff --git a/src/downtime.rs b/src/downtime.rs new file mode 100644 index 00000000..4a52c920 --- /dev/null +++ b/src/downtime.rs @@ -0,0 +1,59 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + +use anyhow::Result; +use datadog_api_client::datadogV2::api_downtimes::{DowntimesAPI, GetDowntimeOptionalParams}; + +use crate::config::Config; +use crate::formatter; + +#[derive(clap::Subcommand)] +pub enum Command { + /// Get a downtime + /// + /// Get downtime detail by `downtime_id`. + Get { + /// ID of the downtime to fetch. + downtime_id: String, + /// Comma-separated list of resource paths for related resources to include in the response. Supported resource + /// paths are `created_by` and `monitor`. + #[arg(long)] include: Option, + }, +} + +pub async fn run(cfg: &Config, command: Command) -> Result<()> { + match command { + Command::Get { downtime_id, include } => get(cfg, downtime_id, include).await, + } +} + +/// Get a downtime +/// +/// Get downtime detail by `downtime_id`. +pub async fn get(cfg: &Config, downtime_id: String, include: Option) -> Result<()> { + let api = crate::make_api!(DowntimesAPI, cfg); + let mut params = GetDowntimeOptionalParams::default(); + if let Some(v) = include { + params = params.include(v); + } + let resp = api + .get_downtime(downtime_id, params) + .await + .map_err(|e| anyhow::anyhow!("failed to get_downtime: {:?}", e))?; + formatter::output(cfg, &resp) +} + +#[cfg(test)] +mod tests { + use crate::test_support::*; + + #[tokio::test] + async fn test_get_ok() { + let _lock = lock_env().await; + let mut server = mockito::Server::new_async().await; + let cfg = test_config(&server.url()); + let _mock = mock_any(&mut server, "GET", r##"{"data": {"attributes": {"created": "2024-01-01T00:00:00+00:00", "display_timezone": "America/New_York", "message": "Message about the downtime", "modified": "2024-01-01T00:00:00+00:00", "monitor_identifier": {"monitor_tags": ["*"]}, "mute_first_recovery_notification": false, "notify_end_states": ["alert", "warn"], "notify_end_types": ["canceled", "expired"], "scope": "env:(staging OR prod) AND datacenter:us-east-1", "status": "active"}, "id": "00000000-0000-1234-0000-000000000000", "type": "downtime"}}"##).await; + let result = super::get(&cfg, "test".to_string(), None).await; + assert!(result.is_ok(), "get failed: {:?}", result.err()); + cleanup_env(); + } +} diff --git a/src/formatter.rs b/src/formatter.rs index 19360fe5..198983e2 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + use anyhow::Result; use serde::Serialize; diff --git a/src/generated.rs b/src/generated.rs new file mode 100644 index 00000000..d2ecd1c0 --- /dev/null +++ b/src/generated.rs @@ -0,0 +1,27 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + +#[path = "downtime.rs"] +pub mod downtime; + +use anyhow::Result; + +use crate::config::Config; + +/// All spec-generated pup commands. +/// +/// Re-run the generator to add or remove tags; pup never needs manual changes +/// for new commands. +#[derive(clap::Subcommand)] +pub enum GeneratedCommand { + /// Manage downtime resources + Downtime { + #[command(subcommand)] + action: downtime::Command, + }, +} + +pub async fn run(cfg: &Config, command: GeneratedCommand) -> Result<()> { + match command { + GeneratedCommand::Downtime { action } => downtime::run(cfg, action).await, + } +} diff --git a/src/useragent.rs b/src/useragent.rs index 6016e381..2c6b19cc 100644 --- a/src/useragent.rs +++ b/src/useragent.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + use crate::version; #[allow(dead_code)] diff --git a/src/util.rs b/src/util.rs index 055465af..b4c427d1 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + use anyhow::{bail, Result}; use chrono::Utc; use regex::Regex; diff --git a/src/version.rs b/src/version.rs index 52db4dce..eed3b368 100644 --- a/src/version.rs +++ b/src/version.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + /// Version is set at build time via env var or defaults to Cargo package version. pub const VERSION: &str = env!("CARGO_PKG_VERSION"); From fd132add96fb5c6d9aa98d9a2983d8aa528e42a2 Mon Sep 17 00:00:00 2001 From: Ulysse Mavrocordatos Date: Fri, 17 Jul 2026 17:11:56 +0200 Subject: [PATCH 2/2] wire generated CLI commands into main.rs PR #651 added src/generated.rs and src/downtime.rs (openapi-transformer's first end-to-end run) but nothing referenced them, so they were dead code: not compiled, not linted, not reachable by any command. Add mod generated, flatten GeneratedCommand into the Commands enum so generated subcommands appear as top-level peers (pup downtime get ..., not pup generated downtime get ...), and route the new arm through main_inner() following the existing per-domain pattern. Known blocker, not resolved here: pup already hand-writes a top-level downtime command (list/get/create/cancel). The generated GeneratedCommand::Downtime collides with it - clap's debug assertion panics at runtime ("command name `downtime` is duplicated") on any invocation that builds the full Command tree (e.g. --no-agent --help). cargo build/test pass because neither constructs that tree. This needs a product decision (retire/merge the hand-written downtime command, or pick a different pilot operation upstream in datadog-api-spec) before this can actually ship. --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index bdae9ab0..a45de31d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ mod config; mod extensions; mod filter; mod formatter; +mod generated; #[cfg(not(target_arch = "wasm32"))] mod runbooks; #[cfg(not(target_arch = "wasm32"))] @@ -2859,6 +2860,8 @@ enum Commands { #[command(subcommand)] action: WorkflowActions, }, + #[command(flatten)] + Generated(generated::GeneratedCommand), } // ---- Extensions ---- @@ -15802,6 +15805,11 @@ async fn main_inner() -> anyhow::Result<()> { } }, }, + // --- Generated --- + Commands::Generated(action) => { + cfg.validate_auth()?; + generated::run(&cfg, action).await?; + } // --- LLM Observability --- Commands::LlmObs { action } => { cfg.validate_auth()?;