Skip to content

Commit ee9f80e

Browse files
Regenerate client from spec repo
1 parent fe0397c commit ee9f80e

16 files changed

Lines changed: 105 additions & 8 deletions

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ zip = { version = "8", default-features = false, features = ["deflate"], optiona
135135

136136
# Datadog API client — pinned to 0.32.0 tag
137137
# Use default-features = false; feature sets are activated per-target via features above
138-
datadog-api-client = { git = "https://github.com/DataDog/datadog-api-client-rust", rev = "b769778d0c58806b615165fb444e6f02dc2e86c0", optional = true, default-features = false }
138+
datadog-api-client = { git = "https://github.com/DataDog/datadog-api-client-rust", rev = "317a95eb0c208160fc48a2a3524b50a3affb4f4b", optional = true, default-features = false }
139139

140140
# HTTP middleware (version-matched to DD client; compiles on all targets)
141141
reqwest-middleware = "0.5"

src/auth/callback.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
13
#[cfg(not(target_arch = "wasm32"))]
24
use anyhow::bail;
35
use anyhow::Result;

src/auth/dcr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
13
#[cfg(not(target_arch = "wasm32"))]
24
use anyhow::{bail, Context, Result};
35
#[cfg(not(target_arch = "wasm32"))]

src/auth/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
13
pub mod callback;
24
pub mod dcr;
35
pub mod pkce;

src/auth/pkce.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
13
#[cfg(not(target_arch = "wasm32"))]
24
use anyhow::Result;
35
#[cfg(not(target_arch = "wasm32"))]

src/auth/storage.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
13
use anyhow::{Context, Result};
24
use std::path::PathBuf;
35

src/auth/types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
13
use chrono::Utc;
24
use serde::{Deserialize, Serialize};
35

src/client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
13
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
24

35
#[cfg(not(target_arch = "wasm32"))]

src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
13
use anyhow::{bail, Result};
24
#[cfg(not(feature = "browser"))]
35
use serde::Deserialize;

src/downtime.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Code generated by openapi-transformer. DO NOT EDIT.
2+
3+
use anyhow::Result;
4+
use datadog_api_client::datadogV2::api_downtimes::{DowntimesAPI, GetDowntimeOptionalParams};
5+
6+
use crate::config::Config;
7+
use crate::formatter;
8+
9+
#[derive(clap::Subcommand)]
10+
pub enum Command {
11+
/// Get a downtime
12+
///
13+
/// Get downtime detail by `downtime_id`.
14+
Get {
15+
/// ID of the downtime to fetch.
16+
downtime_id: String,
17+
/// Comma-separated list of resource paths for related resources to include in the response. Supported resource
18+
/// paths are `created_by` and `monitor`.
19+
#[arg(long)] include: Option<String>,
20+
},
21+
}
22+
23+
pub async fn run(cfg: &Config, command: Command) -> Result<()> {
24+
match command {
25+
Command::Get { downtime_id, include } => get(cfg, downtime_id, include).await,
26+
}
27+
}
28+
29+
/// Get a downtime
30+
///
31+
/// Get downtime detail by `downtime_id`.
32+
pub async fn get(cfg: &Config, downtime_id: String, include: Option<String>) -> Result<()> {
33+
let api = crate::make_api!(DowntimesAPI, cfg);
34+
let mut params = GetDowntimeOptionalParams::default();
35+
if let Some(v) = include {
36+
params = params.include(v);
37+
}
38+
let resp = api
39+
.get_downtime(downtime_id, params)
40+
.await
41+
.map_err(|e| anyhow::anyhow!("failed to get_downtime: {:?}", e))?;
42+
formatter::output(cfg, &resp)
43+
}
44+
45+
#[cfg(test)]
46+
mod tests {
47+
use crate::test_support::*;
48+
49+
#[tokio::test]
50+
async fn test_get_ok() {
51+
let _lock = lock_env().await;
52+
let mut server = mockito::Server::new_async().await;
53+
let cfg = test_config(&server.url());
54+
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;
55+
let result = super::get(&cfg, "test".to_string(), None).await;
56+
assert!(result.is_ok(), "get failed: {:?}", result.err());
57+
cleanup_env();
58+
}
59+
}

0 commit comments

Comments
 (0)