diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6c5ab8350..8b2d78090 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -6353,6 +6353,62 @@ components: type: string x-enum-varnames: - ARBITRARY_RULE + ArbitraryRuleStatusResponseArray: + description: Processing statuses for all custom allocation rules in the specified organization. + example: + data: + - attributes: + processing_status: processing + id: "123" + type: arbitrary_rule_status + - attributes: + processing_status: done + id: "456" + type: arbitrary_rule_status + properties: + data: + description: Processing status for a custom allocation rule. + items: + $ref: "#/components/schemas/ArbitraryRuleStatusResponseData" + type: array + required: + - data + type: object + ArbitraryRuleStatusResponseData: + description: Processing status for a custom allocation rule. + properties: + attributes: + $ref: "#/components/schemas/ArbitraryRuleStatusResponseDataAttributes" + id: + description: The unique identifier of the custom allocation rule. + example: "123" + type: string + type: + $ref: "#/components/schemas/ArbitraryRuleStatusResponseDataType" + required: + - id + - type + - attributes + type: object + ArbitraryRuleStatusResponseDataAttributes: + description: Processing status for a custom allocation rule. + properties: + processing_status: + description: The processing status of the custom allocation rule. + example: processing + type: string + required: + - processing_status + type: object + ArbitraryRuleStatusResponseDataType: + default: arbitrary_rule_status + description: Custom allocation rule status resource type. + enum: + - arbitrary_rule_status + example: arbitrary_rule_status + type: string + x-enum-varnames: + - ARBITRARY_RULE_STATUS Argument: description: A named argument for a custom static analysis rule. properties: @@ -60251,6 +60307,62 @@ components: type: string x-enum-varnames: - RULESET + RulesetStatusRespArray: + description: Processing statuses for all tag pipeline rulesets in the specified organization. + example: + data: + - attributes: + processing_status: processing + id: 55ef2385-9ae1-4410-90c4-5ac1b60fec10 + type: ruleset_status + - attributes: + processing_status: done + id: a7b8c9d0-1234-5678-9abc-def012345678 + type: ruleset_status + properties: + data: + description: Processing status for a tag pipeline ruleset. + items: + $ref: "#/components/schemas/RulesetStatusRespData" + type: array + required: + - data + type: object + RulesetStatusRespData: + description: Processing status for a tag pipeline ruleset. + properties: + attributes: + $ref: "#/components/schemas/RulesetStatusRespDataAttributes" + id: + description: The unique identifier of the ruleset. + example: 55ef2385-9ae1-4410-90c4-5ac1b60fec10 + type: string + type: + $ref: "#/components/schemas/RulesetStatusRespDataType" + required: + - id + - type + - attributes + type: object + RulesetStatusRespDataAttributes: + description: Processing status for a tag pipeline ruleset. + properties: + processing_status: + description: The processing status of the ruleset. + example: processing + type: string + required: + - processing_status + type: object + RulesetStatusRespDataType: + default: ruleset_status + description: Ruleset status resource type. + enum: + - ruleset_status + example: ruleset_status + type: string + x-enum-varnames: + - RULESET_STATUS RumCrossProductSampling: description: The configuration for cross-product retention filters. properties: @@ -94692,6 +94804,39 @@ paths: summary: Reorder custom allocation rules tags: - Cloud Cost Management + /api/v2/cost/arbitrary_rule/status: + get: + description: List the processing status of all custom allocation rules. Returns only the ID and processing status for each rule. + operationId: ListCustomAllocationRulesStatus + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + processing_status: processing + id: "123" + type: arbitrary_rule_status + - attributes: + processing_status: done + id: "456" + type: arbitrary_rule_status + schema: + $ref: "#/components/schemas/ArbitraryRuleStatusResponseArray" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: List custom allocation rule statuses + tags: + - Cloud Cost Management /api/v2/cost/arbitrary_rule/{rule_id}: delete: description: Delete a custom allocation rule - Delete an existing custom allocation rule by its ID @@ -140761,6 +140906,39 @@ paths: summary: Reorder tag pipeline rulesets tags: - Cloud Cost Management + /api/v2/tags/enrichment/status: + get: + description: List the processing status of all tag pipeline rulesets. Returns only the ID and processing status for each ruleset. + operationId: ListTagPipelinesRulesetsStatus + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + processing_status: processing + id: 55ef2385-9ae1-4410-90c4-5ac1b60fec10 + type: ruleset_status + - attributes: + processing_status: done + id: a7b8c9d0-1234-5678-9abc-def012345678 + type: ruleset_status + schema: + $ref: "#/components/schemas/RulesetStatusRespArray" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: List tag pipeline ruleset statuses + tags: + - Cloud Cost Management /api/v2/tags/enrichment/validate-query: post: description: Validate a tag pipeline query - Validate the syntax and structure of a tag pipeline query diff --git a/examples/v2_cloud-cost-management_ListCustomAllocationRulesStatus.rs b/examples/v2_cloud-cost-management_ListCustomAllocationRulesStatus.rs new file mode 100644 index 000000000..35d8936dc --- /dev/null +++ b/examples/v2_cloud-cost-management_ListCustomAllocationRulesStatus.rs @@ -0,0 +1,15 @@ +// List custom allocation rule statuses 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.list_custom_allocation_rules_status().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_cloud-cost-management_ListTagPipelinesRulesetsStatus.rs b/examples/v2_cloud-cost-management_ListTagPipelinesRulesetsStatus.rs new file mode 100644 index 000000000..6ee789acf --- /dev/null +++ b/examples/v2_cloud-cost-management_ListTagPipelinesRulesetsStatus.rs @@ -0,0 +1,15 @@ +// List tag pipeline ruleset statuses 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.list_tag_pipelines_rulesets_status().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 657132e4b..254625b97 100644 --- a/src/datadogV2/api/api_cloud_cost_management.rs +++ b/src/datadogV2/api/api_cloud_cost_management.rs @@ -261,6 +261,14 @@ pub enum ListCustomAllocationRulesError { UnknownValue(serde_json::Value), } +/// ListCustomAllocationRulesStatusError is a struct for typed errors of method [`CloudCostManagementAPI::list_custom_allocation_rules_status`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListCustomAllocationRulesStatusError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListCustomCostsFilesError is a struct for typed errors of method [`CloudCostManagementAPI::list_custom_costs_files`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -277,6 +285,14 @@ pub enum ListTagPipelinesRulesetsError { UnknownValue(serde_json::Value), } +/// ListTagPipelinesRulesetsStatusError is a struct for typed errors of method [`CloudCostManagementAPI::list_tag_pipelines_rulesets_status`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListTagPipelinesRulesetsStatusError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ReorderCustomAllocationRulesError is a struct for typed errors of method [`CloudCostManagementAPI::reorder_custom_allocation_rules`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -3272,6 +3288,115 @@ impl CloudCostManagementAPI { } } + /// List the processing status of all custom allocation rules. Returns only the ID and processing status for each rule. + pub async fn list_custom_allocation_rules_status( + &self, + ) -> Result< + crate::datadogV2::model::ArbitraryRuleStatusResponseArray, + datadog::Error, + > { + match self + .list_custom_allocation_rules_status_with_http_info() + .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), + } + } + + /// List the processing status of all custom allocation rules. Returns only the ID and processing status for each rule. + pub async fn list_custom_allocation_rules_status_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_custom_allocation_rules_status"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/cost/arbitrary_rule/status", + local_configuration.get_operation_host(operation_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)) + } + } + /// List the Custom Costs files. pub async fn list_custom_costs_files( &self, @@ -3520,6 +3645,115 @@ impl CloudCostManagementAPI { } } + /// List the processing status of all tag pipeline rulesets. Returns only the ID and processing status for each ruleset. + pub async fn list_tag_pipelines_rulesets_status( + &self, + ) -> Result< + crate::datadogV2::model::RulesetStatusRespArray, + datadog::Error, + > { + match self + .list_tag_pipelines_rulesets_status_with_http_info() + .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), + } + } + + /// List the processing status of all tag pipeline rulesets. Returns only the ID and processing status for each ruleset. + pub async fn list_tag_pipelines_rulesets_status_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_tag_pipelines_rulesets_status"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/tags/enrichment/status", + local_configuration.get_operation_host(operation_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)) + } + } + /// Reorder custom allocation rules - Change the execution order of custom allocation rules. /// /// **Important**: You must provide the **complete list** of all rule IDs in the desired execution order. The API will reorder ALL rules according to the provided sequence. diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 2b1b837fa..6a0e64d92 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2408,6 +2408,14 @@ pub mod model_reorder_rule_resource_data; pub use self::model_reorder_rule_resource_data::ReorderRuleResourceData; pub mod model_reorder_rule_resource_data_type; pub use self::model_reorder_rule_resource_data_type::ReorderRuleResourceDataType; +pub mod model_arbitrary_rule_status_response_array; +pub use self::model_arbitrary_rule_status_response_array::ArbitraryRuleStatusResponseArray; +pub mod model_arbitrary_rule_status_response_data; +pub use self::model_arbitrary_rule_status_response_data::ArbitraryRuleStatusResponseData; +pub mod model_arbitrary_rule_status_response_data_attributes; +pub use self::model_arbitrary_rule_status_response_data_attributes::ArbitraryRuleStatusResponseDataAttributes; +pub mod model_arbitrary_rule_status_response_data_type; +pub use self::model_arbitrary_rule_status_response_data_type::ArbitraryRuleStatusResponseDataType; pub mod model_aws_cur_configs_response; pub use self::model_aws_cur_configs_response::AwsCURConfigsResponse; pub mod model_aws_cur_config; @@ -9852,6 +9860,14 @@ pub mod model_reorder_ruleset_resource_data; pub use self::model_reorder_ruleset_resource_data::ReorderRulesetResourceData; pub mod model_reorder_ruleset_resource_data_type; pub use self::model_reorder_ruleset_resource_data_type::ReorderRulesetResourceDataType; +pub mod model_ruleset_status_resp_array; +pub use self::model_ruleset_status_resp_array::RulesetStatusRespArray; +pub mod model_ruleset_status_resp_data; +pub use self::model_ruleset_status_resp_data::RulesetStatusRespData; +pub mod model_ruleset_status_resp_data_attributes; +pub use self::model_ruleset_status_resp_data_attributes::RulesetStatusRespDataAttributes; +pub mod model_ruleset_status_resp_data_type; +pub use self::model_ruleset_status_resp_data_type::RulesetStatusRespDataType; pub mod model_rules_validate_query_request; pub use self::model_rules_validate_query_request::RulesValidateQueryRequest; pub mod model_rules_validate_query_request_data; diff --git a/src/datadogV2/model/model_arbitrary_rule_status_response_array.rs b/src/datadogV2/model/model_arbitrary_rule_status_response_array.rs new file mode 100644 index 000000000..c02377877 --- /dev/null +++ b/src/datadogV2/model/model_arbitrary_rule_status_response_array.rs @@ -0,0 +1,96 @@ +// 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}; + +/// Processing statuses for all custom allocation rules in the specified organization. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ArbitraryRuleStatusResponseArray { + /// Processing status for a custom allocation rule. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ArbitraryRuleStatusResponseArray { + pub fn new( + data: Vec, + ) -> ArbitraryRuleStatusResponseArray { + ArbitraryRuleStatusResponseArray { + 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 ArbitraryRuleStatusResponseArray { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ArbitraryRuleStatusResponseArrayVisitor; + impl<'a> Visitor<'a> for ArbitraryRuleStatusResponseArrayVisitor { + type Value = ArbitraryRuleStatusResponseArray; + + 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< + Vec, + > = 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 = ArbitraryRuleStatusResponseArray { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ArbitraryRuleStatusResponseArrayVisitor) + } +} diff --git a/src/datadogV2/model/model_arbitrary_rule_status_response_data.rs b/src/datadogV2/model/model_arbitrary_rule_status_response_data.rs new file mode 100644 index 000000000..ca37fe333 --- /dev/null +++ b/src/datadogV2/model/model_arbitrary_rule_status_response_data.rs @@ -0,0 +1,128 @@ +// 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}; + +/// Processing status for a custom allocation rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ArbitraryRuleStatusResponseData { + /// Processing status for a custom allocation rule. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::ArbitraryRuleStatusResponseDataAttributes, + /// The unique identifier of the custom allocation rule. + #[serde(rename = "id")] + pub id: String, + /// Custom allocation rule status resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ArbitraryRuleStatusResponseDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ArbitraryRuleStatusResponseData { + pub fn new( + attributes: crate::datadogV2::model::ArbitraryRuleStatusResponseDataAttributes, + id: String, + type_: crate::datadogV2::model::ArbitraryRuleStatusResponseDataType, + ) -> ArbitraryRuleStatusResponseData { + ArbitraryRuleStatusResponseData { + attributes, + id, + 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 ArbitraryRuleStatusResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ArbitraryRuleStatusResponseDataVisitor; + impl<'a> Visitor<'a> for ArbitraryRuleStatusResponseDataVisitor { + type Value = ArbitraryRuleStatusResponseData; + + 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::ArbitraryRuleStatusResponseDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::ArbitraryRuleStatusResponseDataType, + > = 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" => { + 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::ArbitraryRuleStatusResponseDataType::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 id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ArbitraryRuleStatusResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ArbitraryRuleStatusResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_arbitrary_rule_status_response_data_attributes.rs b/src/datadogV2/model/model_arbitrary_rule_status_response_data_attributes.rs new file mode 100644 index 000000000..7aa878671 --- /dev/null +++ b/src/datadogV2/model/model_arbitrary_rule_status_response_data_attributes.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}; + +/// Processing status for a custom allocation rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ArbitraryRuleStatusResponseDataAttributes { + /// The processing status of the custom allocation rule. + #[serde(rename = "processing_status")] + pub processing_status: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ArbitraryRuleStatusResponseDataAttributes { + pub fn new(processing_status: String) -> ArbitraryRuleStatusResponseDataAttributes { + ArbitraryRuleStatusResponseDataAttributes { + processing_status, + 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 ArbitraryRuleStatusResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ArbitraryRuleStatusResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for ArbitraryRuleStatusResponseDataAttributesVisitor { + type Value = ArbitraryRuleStatusResponseDataAttributes; + + 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 processing_status: 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() { + "processing_status" => { + processing_status = + 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 processing_status = processing_status + .ok_or_else(|| M::Error::missing_field("processing_status"))?; + + let content = ArbitraryRuleStatusResponseDataAttributes { + processing_status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ArbitraryRuleStatusResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_arbitrary_rule_status_response_data_type.rs b/src/datadogV2/model/model_arbitrary_rule_status_response_data_type.rs new file mode 100644 index 000000000..ece525dfb --- /dev/null +++ b/src/datadogV2/model/model_arbitrary_rule_status_response_data_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 ArbitraryRuleStatusResponseDataType { + ARBITRARY_RULE_STATUS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ArbitraryRuleStatusResponseDataType { + fn to_string(&self) -> String { + match self { + Self::ARBITRARY_RULE_STATUS => String::from("arbitrary_rule_status"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ArbitraryRuleStatusResponseDataType { + 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 ArbitraryRuleStatusResponseDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "arbitrary_rule_status" => Self::ARBITRARY_RULE_STATUS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_ruleset_status_resp_array.rs b/src/datadogV2/model/model_ruleset_status_resp_array.rs new file mode 100644 index 000000000..e4fbf567c --- /dev/null +++ b/src/datadogV2/model/model_ruleset_status_resp_array.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}; + +/// Processing statuses for all tag pipeline rulesets in the specified organization. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RulesetStatusRespArray { + /// Processing status for a tag pipeline ruleset. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RulesetStatusRespArray { + pub fn new( + data: Vec, + ) -> RulesetStatusRespArray { + RulesetStatusRespArray { + 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 RulesetStatusRespArray { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RulesetStatusRespArrayVisitor; + impl<'a> Visitor<'a> for RulesetStatusRespArrayVisitor { + type Value = RulesetStatusRespArray; + + 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 = RulesetStatusRespArray { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RulesetStatusRespArrayVisitor) + } +} diff --git a/src/datadogV2/model/model_ruleset_status_resp_data.rs b/src/datadogV2/model/model_ruleset_status_resp_data.rs new file mode 100644 index 000000000..c1a3837e2 --- /dev/null +++ b/src/datadogV2/model/model_ruleset_status_resp_data.rs @@ -0,0 +1,126 @@ +// 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}; + +/// Processing status for a tag pipeline ruleset. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RulesetStatusRespData { + /// Processing status for a tag pipeline ruleset. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::RulesetStatusRespDataAttributes, + /// The unique identifier of the ruleset. + #[serde(rename = "id")] + pub id: String, + /// Ruleset status resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::RulesetStatusRespDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RulesetStatusRespData { + pub fn new( + attributes: crate::datadogV2::model::RulesetStatusRespDataAttributes, + id: String, + type_: crate::datadogV2::model::RulesetStatusRespDataType, + ) -> RulesetStatusRespData { + RulesetStatusRespData { + attributes, + id, + 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 RulesetStatusRespData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RulesetStatusRespDataVisitor; + impl<'a> Visitor<'a> for RulesetStatusRespDataVisitor { + type Value = RulesetStatusRespData; + + 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::RulesetStatusRespDataAttributes, + > = 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" => { + 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::RulesetStatusRespDataType::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 id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = RulesetStatusRespData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RulesetStatusRespDataVisitor) + } +} diff --git a/src/datadogV2/model/model_ruleset_status_resp_data_attributes.rs b/src/datadogV2/model/model_ruleset_status_resp_data_attributes.rs new file mode 100644 index 000000000..994fcfc73 --- /dev/null +++ b/src/datadogV2/model/model_ruleset_status_resp_data_attributes.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}; + +/// Processing status for a tag pipeline ruleset. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RulesetStatusRespDataAttributes { + /// The processing status of the ruleset. + #[serde(rename = "processing_status")] + pub processing_status: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RulesetStatusRespDataAttributes { + pub fn new(processing_status: String) -> RulesetStatusRespDataAttributes { + RulesetStatusRespDataAttributes { + processing_status, + 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 RulesetStatusRespDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RulesetStatusRespDataAttributesVisitor; + impl<'a> Visitor<'a> for RulesetStatusRespDataAttributesVisitor { + type Value = RulesetStatusRespDataAttributes; + + 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 processing_status: 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() { + "processing_status" => { + processing_status = + 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 processing_status = processing_status + .ok_or_else(|| M::Error::missing_field("processing_status"))?; + + let content = RulesetStatusRespDataAttributes { + processing_status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RulesetStatusRespDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_ruleset_status_resp_data_type.rs b/src/datadogV2/model/model_ruleset_status_resp_data_type.rs new file mode 100644 index 000000000..f6d7b703e --- /dev/null +++ b/src/datadogV2/model/model_ruleset_status_resp_data_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 RulesetStatusRespDataType { + RULESET_STATUS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for RulesetStatusRespDataType { + fn to_string(&self) -> String { + match self { + Self::RULESET_STATUS => String::from("ruleset_status"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for RulesetStatusRespDataType { + 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 RulesetStatusRespDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "ruleset_status" => Self::RULESET_STATUS, + _ => 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 c5fc0adc0..1e9f5de20 100644 --- a/tests/scenarios/features/v2/cloud_cost_management.feature +++ b/tests/scenarios/features/v2/cloud_cost_management.feature @@ -351,6 +351,12 @@ Feature: Cloud Cost Management When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management + Scenario: List custom allocation rule statuses returns "OK" response + Given new "ListCustomAllocationRulesStatus" request + When the request is sent + Then the response status is 200 OK + @replay-only @team:DataDog/cloud-cost-management Scenario: List custom allocation rules returns "OK" response Given new "ListCustomAllocationRules" request @@ -358,6 +364,12 @@ Feature: Cloud Cost Management Then the response status is 200 OK And the response "data[0].attributes.rule_name" is equal to "example-arbitrary-cost-rule" + @generated @skip @team:DataDog/cloud-cost-management + Scenario: List tag pipeline ruleset statuses returns "OK" response + Given new "ListTagPipelinesRulesetsStatus" request + When the request is sent + Then the response status is 200 OK + @replay-only @team:DataDog/cloud-cost-management Scenario: List tag pipeline rulesets returns "OK" response Given new "ListTagPipelinesRulesets" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index a3e509a0b..edc876907 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1283,6 +1283,12 @@ "type": "idempotent" } }, + "ListCustomAllocationRulesStatus": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, "DeleteCustomAllocationRule": { "tag": "Cloud Cost Management", "undo": { @@ -6703,6 +6709,12 @@ "type": "idempotent" } }, + "ListTagPipelinesRulesetsStatus": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, "ValidateQuery": { "tag": "Cloud Cost Management", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 1e3332b19..4ebd2aad1 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -3320,6 +3320,10 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ReorderCustomAllocationRules".into(), test_v2_reorder_custom_allocation_rules, ); + world.function_mappings.insert( + "v2.ListCustomAllocationRulesStatus".into(), + test_v2_list_custom_allocation_rules_status, + ); world.function_mappings.insert( "v2.DeleteCustomAllocationRule".into(), test_v2_delete_custom_allocation_rule, @@ -3442,6 +3446,10 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ReorderTagPipelinesRulesets".into(), test_v2_reorder_tag_pipelines_rulesets, ); + world.function_mappings.insert( + "v2.ListTagPipelinesRulesetsStatus".into(), + test_v2_list_tag_pipelines_rulesets_status, + ); world .function_mappings .insert("v2.ValidateQuery".into(), test_v2_validate_query); @@ -24519,6 +24527,33 @@ fn test_v2_reorder_custom_allocation_rules( world.response.code = response.status.as_u16(); } +fn test_v2_list_custom_allocation_rules_status( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_cloud_cost_management + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.list_custom_allocation_rules_status_with_http_info()) { + 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_delete_custom_allocation_rule( world: &mut DatadogWorld, _parameters: &HashMap, @@ -25423,6 +25458,33 @@ fn test_v2_reorder_tag_pipelines_rulesets( world.response.code = response.status.as_u16(); } +fn test_v2_list_tag_pipelines_rulesets_status( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_cloud_cost_management + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.list_tag_pipelines_rulesets_status_with_http_info()) { + 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_validate_query(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances