Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/auth/callback.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

#[cfg(not(target_arch = "wasm32"))]
use anyhow::bail;
use anyhow::Result;
Expand Down
2 changes: 2 additions & 0 deletions src/auth/dcr.rs
Original file line number Diff line number Diff line change
@@ -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"))]
Expand Down
2 changes: 2 additions & 0 deletions src/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

pub mod callback;
pub mod dcr;
pub mod pkce;
Expand Down
2 changes: 2 additions & 0 deletions src/auth/pkce.rs
Original file line number Diff line number Diff line change
@@ -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"))]
Expand Down
2 changes: 2 additions & 0 deletions src/auth/storage.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

use anyhow::{Context, Result};
use std::path::PathBuf;

Expand Down
2 changes: 2 additions & 0 deletions src/auth/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

use chrono::Utc;
use serde::{Deserialize, Serialize};

Expand Down
2 changes: 2 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};

#[cfg(not(target_arch = "wasm32"))]
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

use anyhow::{bail, Result};
#[cfg(not(feature = "browser"))]
use serde::Deserialize;
Expand Down
59 changes: 59 additions & 0 deletions src/downtime.rs
Original file line number Diff line number Diff line change
@@ -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<String>,
},
}

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<String>) -> 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();
}
}
2 changes: 2 additions & 0 deletions src/formatter.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

use anyhow::Result;
use serde::Serialize;

Expand Down
27 changes: 27 additions & 0 deletions src/generated.rs
Original file line number Diff line number Diff line change
@@ -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,
}
}
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -2859,6 +2860,8 @@ enum Commands {
#[command(subcommand)]
action: WorkflowActions,
},
#[command(flatten)]
Generated(generated::GeneratedCommand),
}

// ---- Extensions ----
Expand Down Expand Up @@ -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()?;
Expand Down
2 changes: 2 additions & 0 deletions src/useragent.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

use crate::version;

#[allow(dead_code)]
Expand Down
2 changes: 2 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Code generated by openapi-transformer. DO NOT EDIT.

use anyhow::{bail, Result};
use chrono::Utc;
use regex::Regex;
Expand Down
2 changes: 2 additions & 0 deletions src/version.rs
Original file line number Diff line number Diff line change
@@ -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");

Expand Down
Loading