Skip to content

Commit 2d0edc0

Browse files
Regenerate client from spec repo
1 parent 1fcead9 commit 2d0edc0

15 files changed

Lines changed: 112 additions & 30 deletions

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: 3 additions & 16 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"))]
@@ -724,14 +726,6 @@ static OAUTH_EXCLUDED_ENDPOINTS: &[EndpointRequirement] = &[
724726
path: "/api/ui/profiling/",
725727
method: "GET",
726728
},
727-
// Events intake (1)
728-
// Posting an event uses the V1 intake endpoint, which authenticates with the
729-
// API key and does not accept OAuth2 bearer tokens. Listing/getting events
730-
// (GET) is fine over OAuth, so only POST is excluded.
731-
EndpointRequirement {
732-
path: "/api/v1/events",
733-
method: "POST",
734-
},
735729
];
736730

737731
// ---------------------------------------------------------------------------
@@ -1296,13 +1290,6 @@ mod tests {
12961290
assert!(!requires_api_key_fallback("POST", "/api/v2/events/search"));
12971291
}
12981292

1299-
#[test]
1300-
fn test_fallback_for_events_post() {
1301-
// Posting an event (V1 intake) requires API keys; reading events does not.
1302-
assert!(requires_api_key_fallback("POST", "/api/v1/events"));
1303-
assert!(!requires_api_key_fallback("GET", "/api/v1/events"));
1304-
}
1305-
13061293
#[test]
13071294
fn test_no_fallback_for_standard_endpoints() {
13081295
assert!(!requires_api_key_fallback("GET", "/api/v1/monitor"));
@@ -1339,7 +1326,7 @@ mod tests {
13391326

13401327
#[test]
13411328
fn test_oauth_excluded_count() {
1342-
assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 55);
1329+
assert_eq!(OAUTH_EXCLUDED_ENDPOINTS.len(), 54);
13431330
}
13441331

13451332
#[test]

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+
}

src/filter.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
//! jq filter support via the [`jaq`](https://github.com/01mf02/jaq) engine.
24
//!
35
//! [`apply_jq`] is the sole public entry point; the jaq API is encapsulated

0 commit comments

Comments
 (0)