From 789683df744bb0b097d56a94bb831856e922df22 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 15 Jul 2026 19:53:05 +0000 Subject: [PATCH] Regenerate client from commit 12253da of spec repo --- .generator/schemas/v2/openapi.yaml | 256 ++++++++++++++++ ...d-cost-management_GetCostAccountFilters.rs | 15 + ...ost-management_UpdateCostAccountFilters.rs | 31 ++ .../api/api_cloud_cost_management.rs | 289 ++++++++++++++++++ src/datadogV2/model/mod.rs | 20 +- src/datadogV2/model/model_account_filters.rs | 133 ++++++++ .../model/model_account_filters_attributes.rs | 144 +++++++++ .../model/model_account_filters_patch_data.rs | 116 +++++++ .../model_account_filters_patch_request.rs | 94 ++++++ ...ccount_filters_patch_request_attributes.rs | 97 ++++++ ...odel_account_filters_patch_request_type.rs | 48 +++ .../model/model_account_filters_response.rs | 105 +++++++ .../model/model_account_filters_type.rs | 48 +++ .../features/v2/cloud_cost_management.feature | 45 +++ tests/scenarios/features/v2/undo.json | 12 + tests/scenarios/function_mappings.rs | 68 +++++ 16 files changed, 1519 insertions(+), 2 deletions(-) create mode 100644 examples/v2_cloud-cost-management_GetCostAccountFilters.rs create mode 100644 examples/v2_cloud-cost-management_UpdateCostAccountFilters.rs create mode 100644 src/datadogV2/model/model_account_filters.rs create mode 100644 src/datadogV2/model/model_account_filters_attributes.rs create mode 100644 src/datadogV2/model/model_account_filters_patch_data.rs create mode 100644 src/datadogV2/model/model_account_filters_patch_request.rs create mode 100644 src/datadogV2/model/model_account_filters_patch_request_attributes.rs create mode 100644 src/datadogV2/model/model_account_filters_patch_request_type.rs create mode 100644 src/datadogV2/model/model_account_filters_response.rs create mode 100644 src/datadogV2/model/model_account_filters_type.rs diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index bf4011c15..053bf0343 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -4062,6 +4062,86 @@ components: type: string type: array type: object + AccountFilters: + description: The account filters for a cloud account. + properties: + attributes: + $ref: "#/components/schemas/AccountFiltersAttributes" + id: + description: The ID of the cloud account. + example: "123456789123" + type: string + type: + $ref: "#/components/schemas/AccountFiltersType" + required: + - attributes + - type + type: object + AccountFiltersAttributes: + description: Attributes for the account filters of a cloud account. + properties: + account_filters: + $ref: "#/components/schemas/AccountFilteringConfig" + account_id: + description: The cloud account ID. + example: "123456789123" + type: string + cloud: + description: The cloud provider of the account, for example `aws`, `aws_cur2`, or `oci`. + example: "aws_cur2" + type: string + type: object + AccountFiltersPatchData: + description: Account filters patch data. + properties: + attributes: + $ref: "#/components/schemas/AccountFiltersPatchRequestAttributes" + type: + $ref: "#/components/schemas/AccountFiltersPatchRequestType" + required: + - attributes + - type + type: object + AccountFiltersPatchRequest: + description: Account filters patch request. + properties: + data: + $ref: "#/components/schemas/AccountFiltersPatchData" + required: + - data + type: object + AccountFiltersPatchRequestAttributes: + description: Attributes for an account filters patch request. + properties: + account_filters: + $ref: "#/components/schemas/AccountFilteringConfig" + required: + - account_filters + type: object + AccountFiltersPatchRequestType: + default: account_filters_patch_request + description: Type of account filters patch request. + enum: + - account_filters_patch_request + example: account_filters_patch_request + type: string + x-enum-varnames: + - ACCOUNT_FILTERS_PATCH_REQUEST + AccountFiltersResponse: + description: Response containing the account filters for a cloud account. + properties: + data: + $ref: "#/components/schemas/AccountFilters" + type: object + AccountFiltersType: + default: account_filters + description: Type of account filters. + enum: + - account_filters + example: account_filters + type: string + x-enum-varnames: + - ACCOUNT_FILTERS ActionConnectionAttributes: description: The definition of `ActionConnectionAttributes` object. properties: @@ -126466,6 +126546,182 @@ paths: "x-permission": operator: OPEN permissions: [] + /api/v2/cost/account_filters/{cloud_account_id}: + get: + description: Get the account filters for a cloud account (AWS CUR 1.0/2.0, OCI, and other clouds). + operationId: GetCostAccountFilters + parameters: + - $ref: "#/components/parameters/CloudAccountID" + responses: + "200": + content: + application/json: + examples: + default: + summary: Include new accounts and exclude specific accounts + value: + data: + attributes: + account_filters: + excluded_accounts: + - "123456789123" + - "123456789143" + include_new_accounts: true + account_id: "123456789123" + cloud: aws_cur2 + id: "123" + type: account_filters + include_accounts: + summary: Exclude new accounts and include specific accounts + value: + data: + attributes: + account_filters: + include_new_accounts: false + included_accounts: + - "123456789123" + - "123456789143" + account_id: "123456789123" + cloud: aws_cur2 + id: "123" + type: account_filters + schema: + $ref: "#/components/schemas/AccountFiltersResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: Get account filters + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + patch: + description: Update the account filters for a cloud account (AWS CUR 1.0/2.0, OCI, and other clouds). + operationId: UpdateCostAccountFilters + parameters: + - $ref: "#/components/parameters/CloudAccountID" + requestBody: + content: + application/json: + examples: + default: + summary: Exclude new accounts and include specific accounts + value: + data: + attributes: + account_filters: + include_new_accounts: false + included_accounts: + - "123456789123" + - "123456789143" + type: account_filters_patch_request + exclude_accounts: + summary: Include new accounts and exclude specific accounts + value: + data: + attributes: + account_filters: + excluded_accounts: + - "123456789123" + - "123456789143" + include_new_accounts: true + type: account_filters_patch_request + schema: + $ref: "#/components/schemas/AccountFiltersPatchRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + summary: Exclude new accounts and include specific accounts + value: + data: + attributes: + account_filters: + include_new_accounts: false + included_accounts: + - "123456789123" + - "123456789143" + account_id: "123456789123" + cloud: aws_cur2 + id: "123" + type: account_filters + exclude_accounts: + summary: Include new accounts and exclude specific accounts + value: + data: + attributes: + account_filters: + excluded_accounts: + - "123456789123" + - "123456789143" + include_new_accounts: true + account_id: "123456789123" + cloud: aws_cur2 + id: "123" + type: account_filters + schema: + $ref: "#/components/schemas/AccountFiltersResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_write + summary: Update account filters + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_write /api/v2/cost/anomalies: get: description: List detected Cloud Cost Management anomalies for the organization. diff --git a/examples/v2_cloud-cost-management_GetCostAccountFilters.rs b/examples/v2_cloud-cost-management_GetCostAccountFilters.rs new file mode 100644 index 000000000..5f07a55f8 --- /dev/null +++ b/examples/v2_cloud-cost-management_GetCostAccountFilters.rs @@ -0,0 +1,15 @@ +// Get account filters returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = CloudCostManagementAPI::with_config(configuration); + let resp = api.get_cost_account_filters(9223372036854775807).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_cloud-cost-management_UpdateCostAccountFilters.rs b/examples/v2_cloud-cost-management_UpdateCostAccountFilters.rs new file mode 100644 index 000000000..32fe173e6 --- /dev/null +++ b/examples/v2_cloud-cost-management_UpdateCostAccountFilters.rs @@ -0,0 +1,31 @@ +// Update account filters returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI; +use datadog_api_client::datadogV2::model::AccountFilteringConfig; +use datadog_api_client::datadogV2::model::AccountFiltersPatchData; +use datadog_api_client::datadogV2::model::AccountFiltersPatchRequest; +use datadog_api_client::datadogV2::model::AccountFiltersPatchRequestAttributes; +use datadog_api_client::datadogV2::model::AccountFiltersPatchRequestType; + +#[tokio::main] +async fn main() { + let body = AccountFiltersPatchRequest::new(AccountFiltersPatchData::new( + AccountFiltersPatchRequestAttributes::new( + AccountFilteringConfig::new() + .excluded_accounts(vec!["123456789123".to_string(), "123456789143".to_string()]) + .include_new_accounts(Some(true)) + .included_accounts(vec!["123456789123".to_string(), "123456789143".to_string()]), + ), + AccountFiltersPatchRequestType::ACCOUNT_FILTERS_PATCH_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = CloudCostManagementAPI::with_config(configuration); + let resp = api + .update_cost_account_filters(9223372036854775807, body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_cloud_cost_management.rs b/src/datadogV2/api/api_cloud_cost_management.rs index bbe8dccdc..feee19fc4 100644 --- a/src/datadogV2/api/api_cloud_cost_management.rs +++ b/src/datadogV2/api/api_cloud_cost_management.rs @@ -823,6 +823,14 @@ pub enum GetCostAWSCURConfigError { UnknownValue(serde_json::Value), } +/// GetCostAccountFiltersError is a struct for typed errors of method [`CloudCostManagementAPI::get_cost_account_filters`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetCostAccountFiltersError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetCostAnomalyError is a struct for typed errors of method [`CloudCostManagementAPI::get_cost_anomaly`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1087,6 +1095,14 @@ pub enum UpdateCostAWSCURConfigError { UnknownValue(serde_json::Value), } +/// UpdateCostAccountFiltersError is a struct for typed errors of method [`CloudCostManagementAPI::update_cost_account_filters`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateCostAccountFiltersError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateCostAzureUCConfigsError is a struct for typed errors of method [`CloudCostManagementAPI::update_cost_azure_uc_configs`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -4378,6 +4394,118 @@ impl CloudCostManagementAPI { } } + /// Get the account filters for a cloud account (AWS CUR 1.0/2.0, OCI, and other clouds). + pub async fn get_cost_account_filters( + &self, + cloud_account_id: i64, + ) -> Result< + crate::datadogV2::model::AccountFiltersResponse, + datadog::Error, + > { + match self + .get_cost_account_filters_with_http_info(cloud_account_id) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the account filters for a cloud account (AWS CUR 1.0/2.0, OCI, and other clouds). + pub async fn get_cost_account_filters_with_http_info( + &self, + cloud_account_id: i64, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_cost_account_filters"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/cost/account_filters/{cloud_account_id}", + local_configuration.get_operation_host(operation_id), + cloud_account_id = cloud_account_id + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Get a detected Cloud Cost Management anomaly by UUID. pub async fn get_cost_anomaly( &self, @@ -8474,6 +8602,167 @@ impl CloudCostManagementAPI { } } + /// Update the account filters for a cloud account (AWS CUR 1.0/2.0, OCI, and other clouds). + pub async fn update_cost_account_filters( + &self, + cloud_account_id: i64, + body: crate::datadogV2::model::AccountFiltersPatchRequest, + ) -> Result< + crate::datadogV2::model::AccountFiltersResponse, + datadog::Error, + > { + match self + .update_cost_account_filters_with_http_info(cloud_account_id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Update the account filters for a cloud account (AWS CUR 1.0/2.0, OCI, and other clouds). + pub async fn update_cost_account_filters_with_http_info( + &self, + cloud_account_id: i64, + body: crate::datadogV2::model::AccountFiltersPatchRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_cost_account_filters"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/cost/account_filters/{cloud_account_id}", + local_configuration.get_operation_host(operation_id), + cloud_account_id = cloud_account_id + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Update the status of an Azure config (active/archived). pub async fn update_cost_azure_uc_configs( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index aece0525d..0c1fcd00d 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2640,6 +2640,24 @@ pub mod model_container_meta_page; pub use self::model_container_meta_page::ContainerMetaPage; pub mod model_container_meta_page_type; pub use self::model_container_meta_page_type::ContainerMetaPageType; +pub mod model_account_filters_response; +pub use self::model_account_filters_response::AccountFiltersResponse; +pub mod model_account_filters; +pub use self::model_account_filters::AccountFilters; +pub mod model_account_filters_attributes; +pub use self::model_account_filters_attributes::AccountFiltersAttributes; +pub mod model_account_filtering_config; +pub use self::model_account_filtering_config::AccountFilteringConfig; +pub mod model_account_filters_type; +pub use self::model_account_filters_type::AccountFiltersType; +pub mod model_account_filters_patch_request; +pub use self::model_account_filters_patch_request::AccountFiltersPatchRequest; +pub mod model_account_filters_patch_data; +pub use self::model_account_filters_patch_data::AccountFiltersPatchData; +pub mod model_account_filters_patch_request_attributes; +pub use self::model_account_filters_patch_request_attributes::AccountFiltersPatchRequestAttributes; +pub mod model_account_filters_patch_request_type; +pub use self::model_account_filters_patch_request_type::AccountFiltersPatchRequestType; pub mod model_cost_anomalies_response; pub use self::model_cost_anomalies_response::CostAnomaliesResponse; pub mod model_cost_anomalies_response_data; @@ -2724,8 +2742,6 @@ pub mod model_aws_cur_config; pub use self::model_aws_cur_config::AwsCURConfig; pub mod model_aws_cur_config_attributes; pub use self::model_aws_cur_config_attributes::AwsCURConfigAttributes; -pub mod model_account_filtering_config; -pub use self::model_account_filtering_config::AccountFilteringConfig; pub mod model_aws_cur_config_type; pub use self::model_aws_cur_config_type::AwsCURConfigType; pub mod model_aws_cur_config_post_request; diff --git a/src/datadogV2/model/model_account_filters.rs b/src/datadogV2/model/model_account_filters.rs new file mode 100644 index 000000000..ee2ecab6b --- /dev/null +++ b/src/datadogV2/model/model_account_filters.rs @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The account filters for a cloud account. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AccountFilters { + /// Attributes for the account filters of a cloud account. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AccountFiltersAttributes, + /// The ID of the cloud account. + #[serde(rename = "id")] + pub id: Option, + /// Type of account filters. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AccountFiltersType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AccountFilters { + pub fn new( + attributes: crate::datadogV2::model::AccountFiltersAttributes, + type_: crate::datadogV2::model::AccountFiltersType, + ) -> AccountFilters { + AccountFilters { + attributes, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AccountFilters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AccountFiltersVisitor; + impl<'a> Visitor<'a> for AccountFiltersVisitor { + type Value = AccountFilters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::AccountFiltersType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AccountFilters { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AccountFiltersVisitor) + } +} diff --git a/src/datadogV2/model/model_account_filters_attributes.rs b/src/datadogV2/model/model_account_filters_attributes.rs new file mode 100644 index 000000000..08419dfb8 --- /dev/null +++ b/src/datadogV2/model/model_account_filters_attributes.rs @@ -0,0 +1,144 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for the account filters of a cloud account. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AccountFiltersAttributes { + /// The account filtering configuration. + #[serde(rename = "account_filters")] + pub account_filters: Option, + /// The cloud account ID. + #[serde(rename = "account_id")] + pub account_id: Option, + /// The cloud provider of the account, for example `aws`, `aws_cur2`, or `oci`. + #[serde(rename = "cloud")] + pub cloud: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AccountFiltersAttributes { + pub fn new() -> AccountFiltersAttributes { + AccountFiltersAttributes { + account_filters: None, + account_id: None, + cloud: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn account_filters( + mut self, + value: crate::datadogV2::model::AccountFilteringConfig, + ) -> Self { + self.account_filters = Some(value); + self + } + + pub fn account_id(mut self, value: String) -> Self { + self.account_id = Some(value); + self + } + + pub fn cloud(mut self, value: String) -> Self { + self.cloud = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for AccountFiltersAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AccountFiltersAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AccountFiltersAttributesVisitor; + impl<'a> Visitor<'a> for AccountFiltersAttributesVisitor { + type Value = AccountFiltersAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut account_filters: Option = + None; + let mut account_id: Option = None; + let mut cloud: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "account_filters" => { + if v.is_null() { + continue; + } + account_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "account_id" => { + if v.is_null() { + continue; + } + account_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "cloud" => { + if v.is_null() { + continue; + } + cloud = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = AccountFiltersAttributes { + account_filters, + account_id, + cloud, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AccountFiltersAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_account_filters_patch_data.rs b/src/datadogV2/model/model_account_filters_patch_data.rs new file mode 100644 index 000000000..e46b3e621 --- /dev/null +++ b/src/datadogV2/model/model_account_filters_patch_data.rs @@ -0,0 +1,116 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Account filters patch data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AccountFiltersPatchData { + /// Attributes for an account filters patch request. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AccountFiltersPatchRequestAttributes, + /// Type of account filters patch request. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AccountFiltersPatchRequestType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AccountFiltersPatchData { + pub fn new( + attributes: crate::datadogV2::model::AccountFiltersPatchRequestAttributes, + type_: crate::datadogV2::model::AccountFiltersPatchRequestType, + ) -> AccountFiltersPatchData { + AccountFiltersPatchData { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AccountFiltersPatchData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AccountFiltersPatchDataVisitor; + impl<'a> Visitor<'a> for AccountFiltersPatchDataVisitor { + type Value = AccountFiltersPatchData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::AccountFiltersPatchRequestAttributes, + > = None; + let mut type_: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::AccountFiltersPatchRequestType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AccountFiltersPatchData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AccountFiltersPatchDataVisitor) + } +} diff --git a/src/datadogV2/model/model_account_filters_patch_request.rs b/src/datadogV2/model/model_account_filters_patch_request.rs new file mode 100644 index 000000000..99d59eeb8 --- /dev/null +++ b/src/datadogV2/model/model_account_filters_patch_request.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Account filters patch request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AccountFiltersPatchRequest { + /// Account filters patch data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AccountFiltersPatchData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AccountFiltersPatchRequest { + pub fn new( + data: crate::datadogV2::model::AccountFiltersPatchData, + ) -> AccountFiltersPatchRequest { + AccountFiltersPatchRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AccountFiltersPatchRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AccountFiltersPatchRequestVisitor; + impl<'a> Visitor<'a> for AccountFiltersPatchRequestVisitor { + type Value = AccountFiltersPatchRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = AccountFiltersPatchRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AccountFiltersPatchRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_account_filters_patch_request_attributes.rs b/src/datadogV2/model/model_account_filters_patch_request_attributes.rs new file mode 100644 index 000000000..2799633df --- /dev/null +++ b/src/datadogV2/model/model_account_filters_patch_request_attributes.rs @@ -0,0 +1,97 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for an account filters patch request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AccountFiltersPatchRequestAttributes { + /// The account filtering configuration. + #[serde(rename = "account_filters")] + pub account_filters: crate::datadogV2::model::AccountFilteringConfig, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AccountFiltersPatchRequestAttributes { + pub fn new( + account_filters: crate::datadogV2::model::AccountFilteringConfig, + ) -> AccountFiltersPatchRequestAttributes { + AccountFiltersPatchRequestAttributes { + account_filters, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AccountFiltersPatchRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AccountFiltersPatchRequestAttributesVisitor; + impl<'a> Visitor<'a> for AccountFiltersPatchRequestAttributesVisitor { + type Value = AccountFiltersPatchRequestAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut account_filters: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "account_filters" => { + account_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let account_filters = + account_filters.ok_or_else(|| M::Error::missing_field("account_filters"))?; + + let content = AccountFiltersPatchRequestAttributes { + account_filters, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AccountFiltersPatchRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_account_filters_patch_request_type.rs b/src/datadogV2/model/model_account_filters_patch_request_type.rs new file mode 100644 index 000000000..988ac1318 --- /dev/null +++ b/src/datadogV2/model/model_account_filters_patch_request_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AccountFiltersPatchRequestType { + ACCOUNT_FILTERS_PATCH_REQUEST, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AccountFiltersPatchRequestType { + fn to_string(&self) -> String { + match self { + Self::ACCOUNT_FILTERS_PATCH_REQUEST => String::from("account_filters_patch_request"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AccountFiltersPatchRequestType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for AccountFiltersPatchRequestType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "account_filters_patch_request" => Self::ACCOUNT_FILTERS_PATCH_REQUEST, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_account_filters_response.rs b/src/datadogV2/model/model_account_filters_response.rs new file mode 100644 index 000000000..00a2fcf05 --- /dev/null +++ b/src/datadogV2/model/model_account_filters_response.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing the account filters for a cloud account. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AccountFiltersResponse { + /// The account filters for a cloud account. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AccountFiltersResponse { + pub fn new() -> AccountFiltersResponse { + AccountFiltersResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::AccountFilters) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for AccountFiltersResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AccountFiltersResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AccountFiltersResponseVisitor; + impl<'a> Visitor<'a> for AccountFiltersResponseVisitor { + type Value = AccountFiltersResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = AccountFiltersResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AccountFiltersResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_account_filters_type.rs b/src/datadogV2/model/model_account_filters_type.rs new file mode 100644 index 000000000..cae78aeca --- /dev/null +++ b/src/datadogV2/model/model_account_filters_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AccountFiltersType { + ACCOUNT_FILTERS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AccountFiltersType { + fn to_string(&self) -> String { + match self { + Self::ACCOUNT_FILTERS => String::from("account_filters"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AccountFiltersType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for AccountFiltersType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "account_filters" => Self::ACCOUNT_FILTERS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/cloud_cost_management.feature b/tests/scenarios/features/v2/cloud_cost_management.feature index 028864461..a8693074a 100644 --- a/tests/scenarios/features/v2/cloud_cost_management.feature +++ b/tests/scenarios/features/v2/cloud_cost_management.feature @@ -408,6 +408,27 @@ Feature: Cloud Cost Management And the response "data.type" is equal to "ruleset" And the response "data.attributes.name" is equal to "EVP Cost Tags" + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get account filters returns "Bad Request" response + Given new "GetCostAccountFilters" request + And request contains "cloud_account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get account filters returns "Not Found" response + Given new "GetCostAccountFilters" request + And request contains "cloud_account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get account filters returns "OK" response + Given new "GetCostAccountFilters" request + And request contains "cloud_account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management Scenario: Get budget returns "Bad Request" response Given new "GetBudget" request @@ -962,6 +983,30 @@ Feature: Cloud Cost Management Then the response status is 200 OK And the response "data.attributes.account_id" is equal to "123456_A123BC_12AB34" + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Update account filters returns "Bad Request" response + Given new "UpdateCostAccountFilters" request + And request contains "cloud_account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"account_filters": {"excluded_accounts": ["123456789123", "123456789143"], "include_new_accounts": true, "included_accounts": ["123456789123", "123456789143"]}}, "type": "account_filters_patch_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Update account filters returns "Not Found" response + Given new "UpdateCostAccountFilters" request + And request contains "cloud_account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"account_filters": {"excluded_accounts": ["123456789123", "123456789143"], "include_new_accounts": true, "included_accounts": ["123456789123", "123456789143"]}}, "type": "account_filters_patch_request"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Update account filters returns "OK" response + Given new "UpdateCostAccountFilters" request + And request contains "cloud_account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"account_filters": {"excluded_accounts": ["123456789123", "123456789143"], "include_new_accounts": true, "included_accounts": ["123456789123", "123456789143"]}}, "type": "account_filters_patch_request"}} + When the request is sent + Then the response status is 200 OK + @replay-only @team:DataDog/cloud-cost-management Scenario: Update custom allocation rule returns "OK" response Given new "UpdateCustomAllocationRule" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 926167855..6551ae716 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1622,6 +1622,18 @@ "type": "safe" } }, + "GetCostAccountFilters": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, + "UpdateCostAccountFilters": { + "tag": "Cloud Cost Management", + "undo": { + "type": "idempotent" + } + }, "ListCostAnomalies": { "tag": "Cloud Cost Management", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index f3d378346..169ec4036 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -4132,6 +4132,14 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ListContainersWithPagination".into(), test_v2_list_containers_with_pagination, ); + world.function_mappings.insert( + "v2.GetCostAccountFilters".into(), + test_v2_get_cost_account_filters, + ); + world.function_mappings.insert( + "v2.UpdateCostAccountFilters".into(), + test_v2_update_cost_account_filters, + ); world .function_mappings .insert("v2.ListCostAnomalies".into(), test_v2_list_cost_anomalies); @@ -30925,6 +30933,66 @@ fn test_v2_list_containers_with_pagination( world.response.code = 200; } +fn test_v2_get_cost_account_filters( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_cloud_cost_management + .as_ref() + .expect("api instance not found"); + let cloud_account_id = + serde_json::from_value(_parameters.get("cloud_account_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_cost_account_filters_with_http_info(cloud_account_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_cost_account_filters( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_cloud_cost_management + .as_ref() + .expect("api instance not found"); + let cloud_account_id = + serde_json::from_value(_parameters.get("cloud_account_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = + match block_on(api.update_cost_account_filters_with_http_info(cloud_account_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_cost_anomalies(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances