diff --git a/src/client.rs b/src/client.rs index e7253d00..a2ada8e5 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 f0b55653..d6e9d06a 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/formatter.rs b/src/formatter.rs index da48c545..fa1fa517 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/domain_allowlist.rs b/src/generated/domain_allowlist.rs new file mode 100644 index 00000000..665e3a8c --- /dev/null +++ b/src/generated/domain_allowlist.rs @@ -0,0 +1,49 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + +use anyhow::Result; +use datadog_api_client::datadogV2::api_domain_allowlist::DomainAllowlistAPI; + +use crate::config::Config; +use crate::formatter; + +#[derive(clap::Subcommand)] +pub enum Command { + /// Get Domain Allowlist + /// + /// Get the domain allowlist for an organization. + Get {}, +} + +pub async fn run(cfg: &Config, command: Command) -> Result<()> { + match command { + Command::Get {} => get(cfg).await, + } +} + +/// Get Domain Allowlist +/// +/// Get the domain allowlist for an organization. +pub async fn get(cfg: &Config) -> Result<()> { + let api = crate::make_api!(DomainAllowlistAPI, cfg); + let resp = api + .get_domain_allowlist() + .await + .map_err(|e| anyhow::anyhow!("failed to get_domain_allowlist: {:?}", 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": {"domains": ["@example.com"], "enabled": false}, "id": "00000000-0000-0000-0000-000000000002", "type": "domain_allowlist"}}"##).await; + let result = super::get(&cfg).await; + assert!(result.is_ok(), "get failed: {:?}", result.err()); + cleanup_env(); + } +} diff --git a/src/generated/mod.rs b/src/generated/mod.rs index a9c96d15..a4267230 100644 --- a/src/generated/mod.rs +++ b/src/generated/mod.rs @@ -1,15 +1,26 @@ -// Stable integration point for openapi-transformer-generated pup commands. -// -// Future regenerations add variants to `GeneratedCommand` and modules within -// this directory in place; main.rs never needs to change again. +// Code generated by openapi-transformer. DO NOT EDIT. + +pub mod domain_allowlist; 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 {} +pub enum GeneratedCommand { + /// Manage domain_allowlist resources + DomainAllowlist { + #[command(subcommand)] + action: domain_allowlist::Command, + }, +} -pub async fn run(_cfg: &Config, command: GeneratedCommand) -> Result<()> { - match command {} +pub async fn run(cfg: &Config, command: GeneratedCommand) -> Result<()> { + match command { + GeneratedCommand::DomainAllowlist { action } => domain_allowlist::run(cfg, action).await, + } } diff --git a/src/util.rs b/src/util.rs index 785be68c..29f9c954 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,3 +1,5 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + use anyhow::Result; /// Read a JSON file and deserialize into the specified type.