From 3eb26e729a0e3f43839242cf9412dfa405ab826c Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 15 Oct 2026 12:58:36 +0000 Subject: [PATCH] Regenerate client from commit 29cf6bc of spec repo --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/generated/downtime.rs | 85 ++++++++++++++++++++++++++++++++++++++- src/generated/surface.txt | 1 + 4 files changed, 87 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 526078bd..3d216ada 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1069,7 +1069,7 @@ checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" [[package]] name = "datadog-api-client" version = "0.38.0" -source = "git+https://github.com/DataDog/datadog-api-client-rust?rev=008f178b20563bd3b708756cf50cc9e18084709e#008f178b20563bd3b708756cf50cc9e18084709e" +source = "git+https://github.com/DataDog/datadog-api-client-rust?rev=0c6dbfbf73069fc670ca25083918606ecd6f58a2#0c6dbfbf73069fc670ca25083918606ecd6f58a2" dependencies = [ "async-stream", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 56c63a84..7f10fcc4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -136,7 +136,7 @@ zip = { version = "8", default-features = false, features = ["deflate"], optiona # Datadog API client — pinned to a git rev # Use default-features = false; feature sets are activated per-target via features above -datadog-api-client = { git = "https://github.com/DataDog/datadog-api-client-rust", rev = "008f178b20563bd3b708756cf50cc9e18084709e", optional = true, default-features = false } +datadog-api-client = { git = "https://github.com/DataDog/datadog-api-client-rust", rev = "0c6dbfbf73069fc670ca25083918606ecd6f58a2", optional = true, default-features = false } # HTTP middleware (version-matched to DD client; compiles on all targets) reqwest-middleware = "0.5" diff --git a/src/generated/downtime.rs b/src/generated/downtime.rs index caed9a06..81b808e6 100644 --- a/src/generated/downtime.rs +++ b/src/generated/downtime.rs @@ -1,7 +1,9 @@ // Code generated by openapi-transformer. DO NOT EDIT. use anyhow::Result; -use datadog_api_client::datadogV2::api_downtimes::{DowntimesAPI, GetDowntimeOptionalParams}; +use datadog_api_client::datadogV2::api_downtimes::{ + DowntimesAPI, GetDowntimeOptionalParams, ListDowntimesOptionalParams, +}; use datadog_api_client::datadogV2::model::DowntimeCreateRequest; use crate::config::Config; @@ -45,6 +47,24 @@ pub enum Command { #[arg(long = "with-run-as")] with_run_as: Option, }, + /// Get all downtimes + /// + /// Get all scheduled downtimes. + List { + /// Only return downtimes that are active when the request is made. + #[arg(long = "current-only")] + current_only: Option, + /// 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")] + include: Option, + /// Specific offset to use as the beginning of the returned page. + #[arg(long = "page-offset")] + page_offset: Option, + /// Maximum number of downtimes in the response. + #[arg(long = "page-limit")] + page_limit: Option, + }, } pub async fn run(cfg: &Config, command: Command) -> Result<()> { @@ -56,6 +76,12 @@ pub async fn run(cfg: &Config, command: Command) -> Result<()> { include, with_run_as, } => get(cfg, downtime_id, include, with_run_as).await, + Command::List { + current_only, + include, + page_offset, + page_limit, + } => list(cfg, current_only, include, page_offset, page_limit).await, } } @@ -110,6 +136,52 @@ pub async fn get( formatter::output(cfg, &resp) } +/// Get all downtimes +/// +/// Get all scheduled downtimes. +pub async fn list( + cfg: &Config, + current_only: Option, + include: Option, + page_offset: Option, + page_limit: Option, +) -> Result<()> { + let api = crate::make_api!(DowntimesAPI, cfg); + let mut params = ListDowntimesOptionalParams::default(); + if let Some(v) = current_only { + params = params.current_only(v); + } + if let Some(v) = include { + params = params.include(v); + } + if let Some(v) = page_offset { + params = params.page_offset(v); + } + if let Some(v) = page_limit { + params = params.page_limit(v); + } + let resp = api + .list_downtimes(params) + .await + .map_err(|e| anyhow::anyhow!("failed to list_downtimes: {:?}", e))?; + let count = resp.data.as_ref().map_or(0, |d| d.len()); + let truncated = false; + let next_action: Option = None; + let meta = formatter::Metadata { + count: Some(count), + truncated, + command: Some("downtime list".to_string()), + next_action, + }; + formatter::format_and_print( + &resp, + &cfg.output_format, + cfg.agent_mode, + Some(&meta), + cfg.jq.as_deref(), + ) +} + #[cfg(test)] mod tests { use crate::test_support::*; @@ -124,4 +196,15 @@ mod tests { assert!(result.is_ok(), "get failed: {:?}", result.err()); cleanup_env(); } + + #[tokio::test] + async fn test_list_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"}], "meta": {"page": {"total_filtered_count": 1}}}"##).await; + let result = super::list(&cfg, None, None, None, None).await; + assert!(result.is_ok(), "list failed: {:?}", result.err()); + cleanup_env(); + } } diff --git a/src/generated/surface.txt b/src/generated/surface.txt index dc300700..f164d159 100644 --- a/src/generated/surface.txt +++ b/src/generated/surface.txt @@ -4,3 +4,4 @@ downtime downtime.cancel downtime.create downtime.get +downtime.list