From b821950e7bccb7db27dbf4dad397da25f3dc26f2 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 9 Nov 2026 21:47:15 +0000 Subject: [PATCH] Regenerate client from commit 036e64d of spec repo --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/client.rs | 26 +-- src/generated/datastores.rs | 370 ++++++++++++++++++++++++++++++++++++ src/generated/mod.rs | 11 ++ src/generated/surface.txt | 11 ++ src/generated/writes.rs | 7 + 7 files changed, 402 insertions(+), 27 deletions(-) create mode 100644 src/generated/datastores.rs diff --git a/Cargo.lock b/Cargo.lock index c07302dd..78db2555 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1100,7 +1100,7 @@ checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" [[package]] name = "datadog-api-client" version = "0.38.0" -source = "git+https://github.com/DataDog/datadog-api-client-rust?rev=a0148e35b714615060937e8ebde2711fe9906aae#a0148e35b714615060937e8ebde2711fe9906aae" +source = "git+https://github.com/DataDog/datadog-api-client-rust?rev=2c92f72a13ad39523f8fca3a069cd09f7c973d82#2c92f72a13ad39523f8fca3a069cd09f7c973d82" dependencies = [ "async-stream", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 7f508d68..6e4e9cab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -136,7 +136,7 @@ zip = { version = "9", 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 = "a0148e35b714615060937e8ebde2711fe9906aae", optional = true, default-features = false } +datadog-api-client = { git = "https://github.com/DataDog/datadog-api-client-rust", rev = "2c92f72a13ad39523f8fca3a069cd09f7c973d82", optional = true, default-features = false } # HTTP middleware (version-matched to DD client; compiles on all targets) reqwest-middleware = "0.5" diff --git a/src/client.rs b/src/client.rs index bded7a55..63459392 100644 --- a/src/client.rs +++ b/src/client.rs @@ -418,30 +418,6 @@ static UNSTABLE_OPS: &[&str] = &[ "v2.star_model_lab_project", "v2.unpin_model_lab_run", "v2.unstar_model_lab_project", - // Databricks Integration (5) - "v2.create_databricks_integration_account", - "v2.delete_databricks_integration_account", - "v2.get_databricks_integration_account", - "v2.list_databricks_integration_accounts", - "v2.update_databricks_integration_account", - // Elastic Cloud Integration (5) - "v2.create_elastic_cloud_integration_account", - "v2.delete_elastic_cloud_integration_account", - "v2.get_elastic_cloud_integration_account", - "v2.list_elastic_cloud_integration_accounts", - "v2.update_elastic_cloud_integration_account", - // Snowflake Integration (5) - "v2.create_snowflake_integration_account", - "v2.delete_snowflake_integration_account", - "v2.get_snowflake_integration_account", - "v2.list_snowflake_integration_accounts", - "v2.update_snowflake_integration_account", - // Twilio Integration (5) - "v2.create_twilio_integration_account", - "v2.delete_twilio_integration_account", - "v2.get_twilio_integration_account", - "v2.list_twilio_integration_accounts", - "v2.update_twilio_integration_account", ]; #[cfg(test)] @@ -563,7 +539,7 @@ mod tests { #[test] fn test_unstable_ops_count() { - assert_eq!(UNSTABLE_OPS.len(), 207); + assert_eq!(UNSTABLE_OPS.len(), 187); } #[test] diff --git a/src/generated/datastores.rs b/src/generated/datastores.rs new file mode 100644 index 00000000..ba2a001c --- /dev/null +++ b/src/generated/datastores.rs @@ -0,0 +1,370 @@ +// Code generated by openapi-transformer. DO NOT EDIT. + +use anyhow::Result; +use datadog_api_client::datadogV2::api_actions_datastores::{ + ActionsDatastoresAPI, ListDatastoreItemsOptionalParams, +}; +use datadog_api_client::datadogV2::model::{ + BulkDeleteAppsDatastoreItemsRequest, BulkPutAppsDatastoreItemsRequest, + CreateAppsDatastoreRequest, DeleteAppsDatastoreItemRequest, UpdateAppsDatastoreItemRequest, + UpdateAppsDatastoreRequest, +}; + +use crate::config::Config; +use crate::formatter; +use crate::util; + +#[derive(clap::Subcommand)] +pub enum Command { + /// Bulk delete datastore items + /// + /// Deletes multiple items from a datastore by their keys in a single operation. + DeleteItems { + /// The ID of the datastore. + datastore_id: String, + #[arg(long = "file")] + file: String, + }, + /// Bulk write datastore items + /// + /// Creates or replaces multiple items in a datastore by their keys in a single operation. + WriteItems { + /// The unique identifier of the datastore to retrieve. + datastore_id: String, + #[arg(long = "file")] + file: String, + }, + /// Create datastore + /// + /// Creates a new datastore. + Create { + #[arg(long = "file")] + file: String, + }, + /// Delete datastore + /// + /// Deletes a datastore by its unique identifier. + Delete { + /// The unique identifier of the datastore to retrieve. + datastore_id: String, + }, + /// Delete datastore item + /// + /// Deletes an item from a datastore by its key. + DeleteItem { + /// The unique identifier of the datastore to retrieve. + datastore_id: String, + #[arg(long = "file")] + file: String, + }, + /// Get datastore + /// + /// Retrieves a specific datastore by its ID. + Get { + /// The unique identifier of the datastore to retrieve. + datastore_id: String, + }, + /// List datastore items + /// + /// Lists items from a datastore. You can filter the results by specifying either an item key or a filter query parameter, but not both at the same time. Supports server-side pagination for large datasets. + ListItems { + /// The unique identifier of the datastore to retrieve. + datastore_id: String, + /// Optional query filter to search items using the [logs search syntax](https://docs.datadoghq.com/logs/explorer/search_syntax/). + #[arg(long = "filter")] + filter: Option, + /// Optional primary key value to retrieve a specific item. Cannot be used together with the filter parameter. + #[arg(long = "item-key")] + item_key: Option, + /// Optional field to limit the number of items to return per page for pagination. Up to 100 items can be returned per page. + #[arg(long = "page-limit")] + page_limit: Option, + /// Optional field to offset the number of items to skip from the beginning of the result set for pagination. + #[arg(long = "page-offset")] + page_offset: Option, + /// Optional field to sort results by. Prefix with '-' for descending order (e.g., '-created_at'). + #[arg(long = "sort")] + sort: Option, + }, + /// List datastores + /// + /// Lists all datastores for the organization. + List {}, + /// Update datastore + /// + /// Updates an existing datastore's attributes. + Update { + /// The unique identifier of the datastore to retrieve. + datastore_id: String, + #[arg(long = "file")] + file: String, + }, + /// Update datastore item + /// + /// Partially updates an item in a datastore by its key. + UpdateItem { + /// The unique identifier of the datastore to retrieve. + datastore_id: String, + #[arg(long = "file")] + file: String, + }, +} + +pub async fn run(cfg: &Config, command: Command) -> Result<()> { + match command { + Command::DeleteItems { datastore_id, file } => delete_items(cfg, datastore_id, &file).await, + Command::WriteItems { datastore_id, file } => write_items(cfg, datastore_id, &file).await, + Command::Create { file } => create(cfg, &file).await, + Command::Delete { datastore_id } => delete(cfg, datastore_id).await, + Command::DeleteItem { datastore_id, file } => delete_item(cfg, datastore_id, &file).await, + Command::Get { datastore_id } => get(cfg, datastore_id).await, + Command::ListItems { + datastore_id, + filter, + item_key, + page_limit, + page_offset, + sort, + } => { + list_items( + cfg, + datastore_id, + filter, + item_key, + page_limit, + page_offset, + sort, + ) + .await + } + Command::List {} => list(cfg).await, + Command::Update { datastore_id, file } => update(cfg, datastore_id, &file).await, + Command::UpdateItem { datastore_id, file } => update_item(cfg, datastore_id, &file).await, + } +} + +/// Bulk delete datastore items +/// +/// Deletes multiple items from a datastore by their keys in a single operation. +pub async fn delete_items(cfg: &Config, datastore_id: String, file: &str) -> Result<()> { + let body: BulkDeleteAppsDatastoreItemsRequest = util::read_json_file(file)?; + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let resp = api + .bulk_delete_datastore_items(datastore_id, body) + .await + .map_err(|e| anyhow::anyhow!("failed to bulk_delete_datastore_items: {:?}", e))?; + let count = resp.data.len(); + let meta = formatter::Metadata { + count: Some(count), + command: Some("datastores delete-items".to_string()), + ..Default::default() + }; + formatter::output_with_meta(cfg, &resp, &meta) +} + +/// Bulk write datastore items +/// +/// Creates or replaces multiple items in a datastore by their keys in a single operation. +pub async fn write_items(cfg: &Config, datastore_id: String, file: &str) -> Result<()> { + let body: BulkPutAppsDatastoreItemsRequest = util::read_json_file(file)?; + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let resp = api + .bulk_write_datastore_items(datastore_id, body) + .await + .map_err(|e| anyhow::anyhow!("failed to bulk_write_datastore_items: {:?}", e))?; + let count = resp.data.len(); + let meta = formatter::Metadata { + count: Some(count), + command: Some("datastores write-items".to_string()), + ..Default::default() + }; + formatter::output_with_meta(cfg, &resp, &meta) +} + +/// Create datastore +/// +/// Creates a new datastore. +pub async fn create(cfg: &Config, file: &str) -> Result<()> { + let body: CreateAppsDatastoreRequest = util::read_json_file(file)?; + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let resp = api + .create_datastore(body) + .await + .map_err(|e| anyhow::anyhow!("failed to create_datastore: {:?}", e))?; + formatter::output(cfg, &resp) +} + +/// Delete datastore +/// +/// Deletes a datastore by its unique identifier. +pub async fn delete(cfg: &Config, datastore_id: String) -> Result<()> { + let resource_label = datastore_id.to_string(); + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + api.delete_datastore(datastore_id) + .await + .map_err(|e| anyhow::anyhow!("failed to delete_datastore: {:?}", e))?; + formatter::output_no_content(cfg, "datastores delete", Some(&resource_label)) +} + +/// Delete datastore item +/// +/// Deletes an item from a datastore by its key. +pub async fn delete_item(cfg: &Config, datastore_id: String, file: &str) -> Result<()> { + let body: DeleteAppsDatastoreItemRequest = util::read_json_file(file)?; + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let resp = api + .delete_datastore_item(datastore_id, body) + .await + .map_err(|e| anyhow::anyhow!("failed to delete_datastore_item: {:?}", e))?; + formatter::output(cfg, &resp) +} + +/// Get datastore +/// +/// Retrieves a specific datastore by its ID. +pub async fn get(cfg: &Config, datastore_id: String) -> Result<()> { + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let resp = api + .get_datastore(datastore_id) + .await + .map_err(|e| anyhow::anyhow!("failed to get_datastore: {:?}", e))?; + formatter::output(cfg, &resp) +} + +/// List datastore items +/// +/// Lists items from a datastore. You can filter the results by specifying either an item key or a filter query parameter, but not both at the same time. Supports server-side pagination for large datasets. +pub async fn list_items( + cfg: &Config, + datastore_id: String, + filter: Option, + item_key: Option, + page_limit: Option, + page_offset: Option, + sort: Option, +) -> Result<()> { + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let mut params = ListDatastoreItemsOptionalParams::default(); + if let Some(v) = filter { + params = params.filter(v); + } + if let Some(v) = item_key { + params = params.item_key(v); + } + if let Some(v) = page_limit { + params = params.page_limit(v); + } + if let Some(v) = page_offset { + params = params.page_offset(v); + } + if let Some(v) = sort { + params = params.sort(v); + } + let resp = api + .list_datastore_items(datastore_id, params) + .await + .map_err(|e| anyhow::anyhow!("failed to list_datastore_items: {:?}", e))?; + let count = resp.data.len(); + let truncated = page_limit.is_some_and(|l| count >= l as usize); + let next_action = if truncated { + page_limit.map(|l| { + format!( + "Results may be truncated at {l}. Use --page-limit={} or narrow the filters", + l + 1 + ) + }) + } else { + None + }; + let meta = formatter::Metadata { + count: Some(count), + truncated, + command: Some("datastores list-items".to_string()), + next_action, + ..Default::default() + }; + formatter::output_with_meta(cfg, &resp, &meta) +} + +/// List datastores +/// +/// Lists all datastores for the organization. +pub async fn list(cfg: &Config) -> Result<()> { + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let resp = api + .list_datastores() + .await + .map_err(|e| anyhow::anyhow!("failed to list_datastores: {:?}", e))?; + let count = resp.data.len(); + let meta = formatter::Metadata { + count: Some(count), + command: Some("datastores list".to_string()), + ..Default::default() + }; + formatter::output_with_meta(cfg, &resp, &meta) +} + +/// Update datastore +/// +/// Updates an existing datastore's attributes. +pub async fn update(cfg: &Config, datastore_id: String, file: &str) -> Result<()> { + let body: UpdateAppsDatastoreRequest = util::read_json_file(file)?; + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let resp = api + .update_datastore(datastore_id, body) + .await + .map_err(|e| anyhow::anyhow!("failed to update_datastore: {:?}", e))?; + formatter::output(cfg, &resp) +} + +/// Update datastore item +/// +/// Partially updates an item in a datastore by its key. +pub async fn update_item(cfg: &Config, datastore_id: String, file: &str) -> Result<()> { + let body: UpdateAppsDatastoreItemRequest = util::read_json_file(file)?; + let api = crate::make_api!(ActionsDatastoresAPI, cfg); + let resp = api + .update_datastore_item(datastore_id, body) + .await + .map_err(|e| anyhow::anyhow!("failed to update_datastore_item: {:?}", 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_at": "2024-01-01T00:00:00+00:00", "description": "A sample datastore", "modified_at": "2024-01-01T00:00:00+00:00", "name": "Example Datastore", "org_id": 123, "primary_column_name": "id", "primary_key_generation_strategy": "none"}, "id": "00000000-0000-0000-0000-000000000003", "type": "datastores"}}"##).await; + let result = super::get(&cfg, "test".to_string()).await; + assert!(result.is_ok(), "get failed: {:?}", result.err()); + cleanup_env(); + } + + #[tokio::test] + async fn test_list_items_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_at": "2024-01-01T00:00:00+00:00", "modified_at": "2024-01-01T00:00:00+00:00", "org_id": 123, "primary_column_name": "id", "store_id": "00000000-0000-0000-0000-000000000006", "value": {"key": "example-value"}}, "id": "00000000-0000-0000-0000-000000000005", "type": "items"}]}"##).await; + let result = + super::list_items(&cfg, "test".to_string(), None, None, None, None, None).await; + assert!(result.is_ok(), "list_items 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_at": "2024-01-01T00:00:00+00:00", "description": "A sample datastore", "modified_at": "2024-01-01T00:00:00+00:00", "name": "Example Datastore", "org_id": 123, "primary_column_name": "id", "primary_key_generation_strategy": "none"}, "id": "00000000-0000-0000-0000-000000000001", "type": "datastores"}]}"##).await; + let result = super::list(&cfg).await; + assert!(result.is_ok(), "list failed: {:?}", result.err()); + cleanup_env(); + } +} diff --git a/src/generated/mod.rs b/src/generated/mod.rs index ba771ea5..641e11c1 100644 --- a/src/generated/mod.rs +++ b/src/generated/mod.rs @@ -1,6 +1,11 @@ // Code generated by openapi-transformer. DO NOT EDIT. +// pup CI denies clippy warnings, and the spec's size, not the generator, drives these two: +// operations with many params make long handler signatures and large command variants. +#![allow(clippy::too_many_arguments, clippy::large_enum_variant)] + pub mod authn_mappings; +pub mod datastores; pub mod domain_allowlist; pub mod downtime; pub mod writes; @@ -15,6 +20,11 @@ use crate::config::Config; /// for new commands. #[derive(clap::Subcommand)] pub enum GeneratedCommand { + /// Manage datastores resources + Datastores { + #[command(subcommand)] + action: datastores::Command, + }, /// Manage domain_allowlist resources DomainAllowlist { #[command(subcommand)] @@ -24,6 +34,7 @@ pub enum GeneratedCommand { pub async fn run(cfg: &Config, command: GeneratedCommand) -> Result<()> { match command { + GeneratedCommand::Datastores { action } => datastores::run(cfg, action).await, GeneratedCommand::DomainAllowlist { action } => domain_allowlist::run(cfg, action).await, } } diff --git a/src/generated/surface.txt b/src/generated/surface.txt index 7a296027..09c1e16d 100644 --- a/src/generated/surface.txt +++ b/src/generated/surface.txt @@ -4,6 +4,17 @@ authn-mappings.delete authn-mappings.get authn-mappings.list authn-mappings.update +datastores +datastores.create +datastores.delete +datastores.delete-item +datastores.delete-items +datastores.get +datastores.list +datastores.list-items +datastores.update +datastores.update-item +datastores.write-items domain-allowlist domain-allowlist.get downtime diff --git a/src/generated/writes.rs b/src/generated/writes.rs index 73d3f182..aedfae27 100644 --- a/src/generated/writes.rs +++ b/src/generated/writes.rs @@ -5,6 +5,13 @@ pub const WRITE_COMMANDS: &[&str] = &[ "authn-mappings create", "authn-mappings delete", "authn-mappings update", + "datastores create", + "datastores delete", + "datastores delete-item", + "datastores delete-items", + "datastores update", + "datastores update-item", + "datastores write-items", "downtime cancel", "downtime create", ];