From e3fa0c13c94907ea0979203d036099e69b69a1e9 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 13 Jul 2026 15:05:30 +0000 Subject: [PATCH] Regenerate client from commit e81eb5b of spec repo --- .generator/schemas/v2/openapi.yaml | 323 ++++++++++++++++++ ...tegration_GetAWSMetricNameFilterPreview.rs | 19 ++ ...-integration_PreviewAWSMetricNameFilter.rs | 36 ++ src/datadog/configuration.rs | 2 + src/datadogV2/api/api_aws_integration.rs | 308 +++++++++++++++++ src/datadogV2/model/mod.rs | 28 ++ ..._aws_metric_name_filter_preview_dd_name.rs | 102 ++++++ ...metric_name_filter_preview_filter_match.rs | 104 ++++++ ...l_aws_metric_name_filter_preview_metric.rs | 107 ++++++ ...ws_metric_name_filter_preview_namespace.rs | 121 +++++++ ..._aws_metric_name_filter_preview_request.rs | 96 ++++++ ..._name_filter_preview_request_attributes.rs | 98 ++++++ ...metric_name_filter_preview_request_data.rs | 116 +++++++ ...aws_metric_name_filter_preview_response.rs | 96 ++++++ ...name_filter_preview_response_attributes.rs | 96 ++++++ ...etric_name_filter_preview_response_data.rs | 130 +++++++ ...del_aws_metric_name_filter_preview_type.rs | 48 +++ .../model/model_aws_metric_name_filters.rs | 44 +++ ...el_aws_metric_name_filters_exclude_only.rs | 104 ++++++ ...el_aws_metric_name_filters_include_only.rs | 104 ++++++ .../model/model_aws_metrics_config.rs | 24 ++ .../features/v2/aws_integration.feature | 43 +++ tests/scenarios/features/v2/undo.json | 12 + tests/scenarios/function_mappings.rs | 71 ++++ 24 files changed, 2232 insertions(+) create mode 100644 examples/v2_aws-integration_GetAWSMetricNameFilterPreview.rs create mode 100644 examples/v2_aws-integration_PreviewAWSMetricNameFilter.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_dd_name.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_filter_match.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_metric.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_namespace.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_request.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_request_attributes.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_request_data.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_response.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_response_attributes.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_response_data.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filter_preview_type.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filters.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filters_exclude_only.rs create mode 100644 src/datadogV2/model/model_aws_metric_name_filters_include_only.rs diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 188cceacbd..012a08bda0 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -3555,6 +3555,196 @@ components: type: string x-enum-varnames: - LOGS_SERVICES + AWSMetricNameFilterPreviewDDName: + description: A Datadog metric name and whether it is filtered. + properties: + filtered: + description: Whether this Datadog metric name is filtered out. + example: true + type: boolean + name: + description: The Datadog metric name. + example: "aws.ec2.network_in" + type: string + required: + - name + - filtered + type: object + AWSMetricNameFilterPreviewFilterMatch: + description: A metric name filter pattern and how many metrics it matched. + properties: + match_count: + description: The number of Datadog metric names matched by this pattern. + example: 1 + format: int64 + type: integer + pattern: + description: The metric name filter pattern. + example: "aws.ec2.network_in" + type: string + required: + - pattern + - match_count + type: object + AWSMetricNameFilterPreviewMetric: + description: A CloudWatch metric and the Datadog metric names it produces. + properties: + cw_name: + description: The CloudWatch metric name. + example: "NetworkIn" + type: string + dd_names: + description: The Datadog metric names produced from this CloudWatch metric. + items: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewDDName" + type: array + required: + - cw_name + - dd_names + type: object + AWSMetricNameFilterPreviewNamespace: + description: The metric name filter preview for a single namespace. + properties: + filters: + description: The metric name filter patterns evaluated for this namespace and how many metrics they matched. + items: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewFilterMatch" + type: array + metrics: + description: |- + The CloudWatch metrics collected for this namespace and whether each resulting + Datadog metric is filtered. + items: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewMetric" + type: array + namespace: + description: The AWS CloudWatch namespace. + example: "AWS/EC2" + type: string + required: + - namespace + - filters + - metrics + type: object + AWSMetricNameFilterPreviewRequest: + description: AWS metric name filter preview request body. + properties: + data: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewRequestData" + required: + - data + type: object + AWSMetricNameFilterPreviewRequestAttributes: + description: AWS metric name filter preview request attributes. + properties: + metric_name_filters: + description: The metric name filters to preview. + items: + $ref: "#/components/schemas/AWSMetricNameFilters" + type: array + required: + - metric_name_filters + type: object + AWSMetricNameFilterPreviewRequestData: + description: AWS metric name filter preview request data. + properties: + attributes: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewRequestAttributes" + type: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewType" + required: + - type + - attributes + type: object + AWSMetricNameFilterPreviewResponse: + description: AWS metric name filter preview response body. + properties: + data: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewResponseData" + required: + - data + type: object + AWSMetricNameFilterPreviewResponseAttributes: + description: AWS metric name filter preview response attributes. + properties: + namespaces: + description: The list of namespaces affected by the previewed metric name filters. + items: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewNamespace" + type: array + required: + - namespaces + type: object + AWSMetricNameFilterPreviewResponseData: + description: AWS metric name filter preview response data. + properties: + attributes: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewResponseAttributes" + id: + $ref: "#/components/schemas/AWSAccountConfigID" + type: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewType" + required: + - id + - type + - attributes + type: object + AWSMetricNameFilterPreviewType: + default: "metric_name_filter_preview" + description: The `AWSMetricNameFilterPreviewResponseData` `type`. + enum: + - metric_name_filter_preview + example: "metric_name_filter_preview" + type: string + x-enum-varnames: + - METRIC_NAME_FILTER_PREVIEW + AWSMetricNameFilters: + description: |- + AWS CloudWatch metric name filter for a single namespace. + Exactly one of `include_only` or `exclude_only` must be set. + oneOf: + - $ref: "#/components/schemas/AWSMetricNameFiltersIncludeOnly" + - $ref: "#/components/schemas/AWSMetricNameFiltersExcludeOnly" + AWSMetricNameFiltersExcludeOnly: + description: Exclude metric names matching one of these patterns for a single namespace. + properties: + exclude_only: + description: Exclude metric names matching one of these patterns. + example: + - "aws.ec2.network_in" + items: + description: A metric name pattern to exclude. + example: "aws.ec2.network_in" + type: string + type: array + namespace: + description: The AWS CloudWatch namespace to which this metric name filter applies. + example: "AWS/EC2" + type: string + required: + - namespace + - exclude_only + type: object + AWSMetricNameFiltersIncludeOnly: + description: Include only metric names matching one of these patterns for a single namespace. + properties: + include_only: + description: Include only metric names matching one of these patterns. + example: + - "aws.ec2.network_in" + items: + description: A metric name pattern to include. + example: "aws.ec2.network_in" + type: string + type: array + namespace: + description: The AWS CloudWatch namespace to which this metric name filter applies. + example: "AWS/EC2" + type: string + required: + - namespace + - include_only + type: object AWSMetricsConfig: description: AWS Metrics Collection config. properties: @@ -3574,6 +3764,13 @@ components: description: Enable AWS metrics collection. Defaults to `true`. example: true type: boolean + metric_name_filters: + description: |- + AWS CloudWatch metric name filters. Each filter applies to a single namespace. + Exactly one of `include_only` or `exclude_only` must be set on each filter. + items: + $ref: "#/components/schemas/AWSMetricNameFilters" + type: array namespace_filters: $ref: "#/components/schemas/AWSNamespaceFilters" tag_filters: @@ -141429,6 +141626,10 @@ paths: collect_cloudwatch_alarms: false collect_custom_metrics: false enabled: true + metric_name_filters: + - include_only: + - aws.ec2.network_in + namespace: AWS/EC2 tag_filters: - namespace: AWS/EC2 resources_config: @@ -141567,6 +141768,10 @@ paths: collect_cloudwatch_alarms: false collect_custom_metrics: false enabled: true + metric_name_filters: + - include_only: + - aws.ec2.network_in + namespace: AWS/EC2 tag_filters: - namespace: AWS/EC2 resources_config: @@ -141811,6 +142016,124 @@ paths: x-unstable: |- **Note**: This endpoint is in preview and may be subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/integration/aws/accounts/{aws_account_config_id}/metric_name_filter_preview: + get: + description: |- + Preview which collected CloudWatch metrics would be filtered by the account's saved metric name filters. + operationId: GetAWSMetricNameFilterPreview + parameters: + - $ref: "#/components/parameters/AWSAccountConfigIDPathParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + namespaces: + - filters: + - match_count: 1 + pattern: "aws.ec2.network_in" + metrics: + - cw_name: "NetworkIn" + dd_names: + - filtered: true + name: "aws.ec2.network_in" + namespace: "AWS/EC2" + id: "00000000-0000-0000-0000-000000000001" + type: metric_name_filter_preview + schema: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewResponse" + description: AWS metric name filter preview result + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get AWS metric name filter preview + tags: + - AWS Integration + "x-permission": + operator: OR + permissions: + - aws_configuration_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: |- + Preview which collected CloudWatch metrics would be filtered by the supplied metric name filters. + The filters are not persisted. + operationId: PreviewAWSMetricNameFilter + parameters: + - $ref: "#/components/parameters/AWSAccountConfigIDPathParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + metric_name_filters: + - exclude_only: + - "aws.ec2.network_in" + namespace: "AWS/EC2" + type: metric_name_filter_preview + schema: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewRequest" + description: The metric name filters to preview. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + namespaces: + - filters: + - match_count: 1 + pattern: "aws.ec2.network_in" + metrics: + - cw_name: "NetworkIn" + dd_names: + - filtered: true + name: "aws.ec2.network_in" + namespace: "AWS/EC2" + id: "00000000-0000-0000-0000-000000000001" + type: metric_name_filter_preview + schema: + $ref: "#/components/schemas/AWSMetricNameFilterPreviewResponse" + description: AWS metric name filter preview result + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Preview AWS metric name filter + tags: + - AWS Integration + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - aws_configuration_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/integration/aws/available_namespaces: get: description: Get a list of available AWS CloudWatch namespaces that can send metrics to Datadog. diff --git a/examples/v2_aws-integration_GetAWSMetricNameFilterPreview.rs b/examples/v2_aws-integration_GetAWSMetricNameFilterPreview.rs new file mode 100644 index 0000000000..a22566f59d --- /dev/null +++ b/examples/v2_aws-integration_GetAWSMetricNameFilterPreview.rs @@ -0,0 +1,19 @@ +// Get AWS metric name filter preview returns "AWS metric name filter preview +// result" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_aws_integration::AWSIntegrationAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetAWSMetricNameFilterPreview", true); + let api = AWSIntegrationAPI::with_config(configuration); + let resp = api + .get_aws_metric_name_filter_preview("aws_account_config_id".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_aws-integration_PreviewAWSMetricNameFilter.rs b/examples/v2_aws-integration_PreviewAWSMetricNameFilter.rs new file mode 100644 index 0000000000..71fe8abf3e --- /dev/null +++ b/examples/v2_aws-integration_PreviewAWSMetricNameFilter.rs @@ -0,0 +1,36 @@ +// Preview AWS metric name filter returns "AWS metric name filter preview result" +// response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_aws_integration::AWSIntegrationAPI; +use datadog_api_client::datadogV2::model::AWSMetricNameFilterPreviewRequest; +use datadog_api_client::datadogV2::model::AWSMetricNameFilterPreviewRequestAttributes; +use datadog_api_client::datadogV2::model::AWSMetricNameFilterPreviewRequestData; +use datadog_api_client::datadogV2::model::AWSMetricNameFilterPreviewType; +use datadog_api_client::datadogV2::model::AWSMetricNameFilters; +use datadog_api_client::datadogV2::model::AWSMetricNameFiltersIncludeOnly; + +#[tokio::main] +async fn main() { + let body = AWSMetricNameFilterPreviewRequest::new(AWSMetricNameFilterPreviewRequestData::new( + AWSMetricNameFilterPreviewRequestAttributes::new(vec![ + AWSMetricNameFilters::AWSMetricNameFiltersIncludeOnly(Box::new( + AWSMetricNameFiltersIncludeOnly::new( + vec!["aws.ec2.network_in".to_string()], + "AWS/EC2".to_string(), + ), + )), + ]), + AWSMetricNameFilterPreviewType::METRIC_NAME_FILTER_PREVIEW, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.PreviewAWSMetricNameFilter", true); + let api = AWSIntegrationAPI::with_config(configuration); + let resp = api + .preview_aws_metric_name_filter("aws_account_config_id".to_string(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 2a671e1309..15009edb8d 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -640,6 +640,8 @@ impl Default for Configuration { ("v2.create_aws_account_ccm_config".to_owned(), false), ("v2.delete_aws_account_ccm_config".to_owned(), false), ("v2.get_aws_account_ccm_config".to_owned(), false), + ("v2.get_aws_metric_name_filter_preview".to_owned(), false), + ("v2.preview_aws_metric_name_filter".to_owned(), false), ("v2.update_aws_account_ccm_config".to_owned(), false), ("v2.validate_awsccm_config".to_owned(), false), ("v2.create_jira_issue_template".to_owned(), false), diff --git a/src/datadogV2/api/api_aws_integration.rs b/src/datadogV2/api/api_aws_integration.rs index 5d88b4f1f1..8e47ee87c6 100644 --- a/src/datadogV2/api/api_aws_integration.rs +++ b/src/datadogV2/api/api_aws_integration.rs @@ -125,6 +125,14 @@ pub enum GetAWSIntegrationIAMPermissionsStandardError { UnknownValue(serde_json::Value), } +/// GetAWSMetricNameFilterPreviewError is a struct for typed errors of method [`AWSIntegrationAPI::get_aws_metric_name_filter_preview`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAWSMetricNameFilterPreviewError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListAWSAccountsError is a struct for typed errors of method [`AWSIntegrationAPI::list_aws_accounts`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -149,6 +157,15 @@ pub enum ListAWSNamespacesError { UnknownValue(serde_json::Value), } +/// PreviewAWSMetricNameFilterError is a struct for typed errors of method [`AWSIntegrationAPI::preview_aws_metric_name_filter`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PreviewAWSMetricNameFilterError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateAWSAccountError is a struct for typed errors of method [`AWSIntegrationAPI::update_aws_account`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1749,6 +1766,126 @@ impl AWSIntegrationAPI { } } + /// Preview which collected CloudWatch metrics would be filtered by the account's saved metric name filters. + pub async fn get_aws_metric_name_filter_preview( + &self, + aws_account_config_id: String, + ) -> Result< + crate::datadogV2::model::AWSMetricNameFilterPreviewResponse, + datadog::Error, + > { + match self + .get_aws_metric_name_filter_preview_with_http_info(aws_account_config_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), + } + } + + /// Preview which collected CloudWatch metrics would be filtered by the account's saved metric name filters. + pub async fn get_aws_metric_name_filter_preview_with_http_info( + &self, + aws_account_config_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_aws_metric_name_filter_preview"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_aws_metric_name_filter_preview' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/aws/accounts/{aws_account_config_id}/metric_name_filter_preview", + local_configuration.get_operation_host(operation_id), + aws_account_config_id = datadog::urlencode(aws_account_config_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 list of AWS Account Integration Configs. pub async fn list_aws_accounts( &self, @@ -2075,6 +2212,177 @@ impl AWSIntegrationAPI { } } + /// Preview which collected CloudWatch metrics would be filtered by the supplied metric name filters. + /// The filters are not persisted. + pub async fn preview_aws_metric_name_filter( + &self, + aws_account_config_id: String, + body: crate::datadogV2::model::AWSMetricNameFilterPreviewRequest, + ) -> Result< + crate::datadogV2::model::AWSMetricNameFilterPreviewResponse, + datadog::Error, + > { + match self + .preview_aws_metric_name_filter_with_http_info(aws_account_config_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), + } + } + + /// Preview which collected CloudWatch metrics would be filtered by the supplied metric name filters. + /// The filters are not persisted. + pub async fn preview_aws_metric_name_filter_with_http_info( + &self, + aws_account_config_id: String, + body: crate::datadogV2::model::AWSMetricNameFilterPreviewRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.preview_aws_metric_name_filter"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.preview_aws_metric_name_filter' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/aws/accounts/{aws_account_config_id}/metric_name_filter_preview", + local_configuration.get_operation_host(operation_id), + aws_account_config_id = datadog::urlencode(aws_account_config_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, 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 an AWS Account Integration Config by config ID. pub async fn update_aws_account( &self, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index b041c1f299..971f8cc86d 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -4852,6 +4852,12 @@ pub mod model_aws_log_source_tag_filter; pub use self::model_aws_log_source_tag_filter::AWSLogSourceTagFilter; pub mod model_aws_metrics_config; pub use self::model_aws_metrics_config::AWSMetricsConfig; +pub mod model_aws_metric_name_filters_include_only; +pub use self::model_aws_metric_name_filters_include_only::AWSMetricNameFiltersIncludeOnly; +pub mod model_aws_metric_name_filters_exclude_only; +pub use self::model_aws_metric_name_filters_exclude_only::AWSMetricNameFiltersExcludeOnly; +pub mod model_aws_metric_name_filters; +pub use self::model_aws_metric_name_filters::AWSMetricNameFilters; pub mod model_aws_namespace_filters_exclude_only; pub use self::model_aws_namespace_filters_exclude_only::AWSNamespaceFiltersExcludeOnly; pub mod model_aws_namespace_filters_include_only; @@ -4904,6 +4910,28 @@ pub mod model_aws_ccm_config_request_attributes; pub use self::model_aws_ccm_config_request_attributes::AWSCcmConfigRequestAttributes; pub mod model_aws_ccm_config; pub use self::model_aws_ccm_config::AWSCcmConfig; +pub mod model_aws_metric_name_filter_preview_response; +pub use self::model_aws_metric_name_filter_preview_response::AWSMetricNameFilterPreviewResponse; +pub mod model_aws_metric_name_filter_preview_response_data; +pub use self::model_aws_metric_name_filter_preview_response_data::AWSMetricNameFilterPreviewResponseData; +pub mod model_aws_metric_name_filter_preview_response_attributes; +pub use self::model_aws_metric_name_filter_preview_response_attributes::AWSMetricNameFilterPreviewResponseAttributes; +pub mod model_aws_metric_name_filter_preview_namespace; +pub use self::model_aws_metric_name_filter_preview_namespace::AWSMetricNameFilterPreviewNamespace; +pub mod model_aws_metric_name_filter_preview_filter_match; +pub use self::model_aws_metric_name_filter_preview_filter_match::AWSMetricNameFilterPreviewFilterMatch; +pub mod model_aws_metric_name_filter_preview_metric; +pub use self::model_aws_metric_name_filter_preview_metric::AWSMetricNameFilterPreviewMetric; +pub mod model_aws_metric_name_filter_preview_dd_name; +pub use self::model_aws_metric_name_filter_preview_dd_name::AWSMetricNameFilterPreviewDDName; +pub mod model_aws_metric_name_filter_preview_type; +pub use self::model_aws_metric_name_filter_preview_type::AWSMetricNameFilterPreviewType; +pub mod model_aws_metric_name_filter_preview_request; +pub use self::model_aws_metric_name_filter_preview_request::AWSMetricNameFilterPreviewRequest; +pub mod model_aws_metric_name_filter_preview_request_data; +pub use self::model_aws_metric_name_filter_preview_request_data::AWSMetricNameFilterPreviewRequestData; +pub mod model_aws_metric_name_filter_preview_request_attributes; +pub use self::model_aws_metric_name_filter_preview_request_attributes::AWSMetricNameFilterPreviewRequestAttributes; pub mod model_aws_namespaces_response; pub use self::model_aws_namespaces_response::AWSNamespacesResponse; pub mod model_aws_namespaces_response_data; diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_dd_name.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_dd_name.rs new file mode 100644 index 0000000000..9795663bf8 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_dd_name.rs @@ -0,0 +1,102 @@ +// 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}; + +/// A Datadog metric name and whether it is filtered. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewDDName { + /// Whether this Datadog metric name is filtered out. + #[serde(rename = "filtered")] + pub filtered: bool, + /// The Datadog metric name. + #[serde(rename = "name")] + pub name: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewDDName { + pub fn new(filtered: bool, name: String) -> AWSMetricNameFilterPreviewDDName { + AWSMetricNameFilterPreviewDDName { + filtered, + name, + 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 AWSMetricNameFilterPreviewDDName { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewDDNameVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewDDNameVisitor { + type Value = AWSMetricNameFilterPreviewDDName; + + 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 filtered: Option = None; + let mut name: 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() { + "filtered" => { + filtered = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = 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 filtered = filtered.ok_or_else(|| M::Error::missing_field("filtered"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = AWSMetricNameFilterPreviewDDName { + filtered, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewDDNameVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_filter_match.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_filter_match.rs new file mode 100644 index 0000000000..ca861d0ede --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_filter_match.rs @@ -0,0 +1,104 @@ +// 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}; + +/// A metric name filter pattern and how many metrics it matched. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewFilterMatch { + /// The number of Datadog metric names matched by this pattern. + #[serde(rename = "match_count")] + pub match_count: i64, + /// The metric name filter pattern. + #[serde(rename = "pattern")] + pub pattern: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewFilterMatch { + pub fn new(match_count: i64, pattern: String) -> AWSMetricNameFilterPreviewFilterMatch { + AWSMetricNameFilterPreviewFilterMatch { + match_count, + pattern, + 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 AWSMetricNameFilterPreviewFilterMatch { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewFilterMatchVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewFilterMatchVisitor { + type Value = AWSMetricNameFilterPreviewFilterMatch; + + 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 match_count: Option = None; + let mut pattern: 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() { + "match_count" => { + match_count = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "pattern" => { + pattern = 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 match_count = + match_count.ok_or_else(|| M::Error::missing_field("match_count"))?; + let pattern = pattern.ok_or_else(|| M::Error::missing_field("pattern"))?; + + let content = AWSMetricNameFilterPreviewFilterMatch { + match_count, + pattern, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewFilterMatchVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_metric.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_metric.rs new file mode 100644 index 0000000000..1dfc013cdb --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_metric.rs @@ -0,0 +1,107 @@ +// 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}; + +/// A CloudWatch metric and the Datadog metric names it produces. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewMetric { + /// The CloudWatch metric name. + #[serde(rename = "cw_name")] + pub cw_name: String, + /// The Datadog metric names produced from this CloudWatch metric. + #[serde(rename = "dd_names")] + pub dd_names: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewMetric { + pub fn new( + cw_name: String, + dd_names: Vec, + ) -> AWSMetricNameFilterPreviewMetric { + AWSMetricNameFilterPreviewMetric { + cw_name, + dd_names, + 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 AWSMetricNameFilterPreviewMetric { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewMetricVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewMetricVisitor { + type Value = AWSMetricNameFilterPreviewMetric; + + 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 cw_name: Option = None; + let mut dd_names: 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() { + "cw_name" => { + cw_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dd_names" => { + dd_names = 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 cw_name = cw_name.ok_or_else(|| M::Error::missing_field("cw_name"))?; + let dd_names = dd_names.ok_or_else(|| M::Error::missing_field("dd_names"))?; + + let content = AWSMetricNameFilterPreviewMetric { + cw_name, + dd_names, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewMetricVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_namespace.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_namespace.rs new file mode 100644 index 0000000000..b0934d3b5c --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_namespace.rs @@ -0,0 +1,121 @@ +// 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 metric name filter preview for a single namespace. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewNamespace { + /// The metric name filter patterns evaluated for this namespace and how many metrics they matched. + #[serde(rename = "filters")] + pub filters: Vec, + /// The CloudWatch metrics collected for this namespace and whether each resulting + /// Datadog metric is filtered. + #[serde(rename = "metrics")] + pub metrics: Vec, + /// The AWS CloudWatch namespace. + #[serde(rename = "namespace")] + pub namespace: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewNamespace { + pub fn new( + filters: Vec, + metrics: Vec, + namespace: String, + ) -> AWSMetricNameFilterPreviewNamespace { + AWSMetricNameFilterPreviewNamespace { + filters, + metrics, + namespace, + 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 AWSMetricNameFilterPreviewNamespace { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewNamespaceVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewNamespaceVisitor { + type Value = AWSMetricNameFilterPreviewNamespace; + + 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 filters: Option< + Vec, + > = None; + let mut metrics: Option< + Vec, + > = None; + let mut namespace: 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() { + "filters" => { + filters = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metrics" => { + metrics = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "namespace" => { + namespace = 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 filters = filters.ok_or_else(|| M::Error::missing_field("filters"))?; + let metrics = metrics.ok_or_else(|| M::Error::missing_field("metrics"))?; + let namespace = namespace.ok_or_else(|| M::Error::missing_field("namespace"))?; + + let content = AWSMetricNameFilterPreviewNamespace { + filters, + metrics, + namespace, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewNamespaceVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_request.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_request.rs new file mode 100644 index 0000000000..39a4be598d --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_request.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}; + +/// AWS metric name filter preview request body. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewRequest { + /// AWS metric name filter preview request data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AWSMetricNameFilterPreviewRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewRequest { + pub fn new( + data: crate::datadogV2::model::AWSMetricNameFilterPreviewRequestData, + ) -> AWSMetricNameFilterPreviewRequest { + AWSMetricNameFilterPreviewRequest { + 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 AWSMetricNameFilterPreviewRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewRequestVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewRequestVisitor { + type Value = AWSMetricNameFilterPreviewRequest; + + 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< + crate::datadogV2::model::AWSMetricNameFilterPreviewRequestData, + > = 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 = AWSMetricNameFilterPreviewRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_request_attributes.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_request_attributes.rs new file mode 100644 index 0000000000..b19ecdc242 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_request_attributes.rs @@ -0,0 +1,98 @@ +// 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}; + +/// AWS metric name filter preview request attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewRequestAttributes { + /// The metric name filters to preview. + #[serde(rename = "metric_name_filters")] + pub metric_name_filters: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewRequestAttributes { + pub fn new( + metric_name_filters: Vec, + ) -> AWSMetricNameFilterPreviewRequestAttributes { + AWSMetricNameFilterPreviewRequestAttributes { + metric_name_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 AWSMetricNameFilterPreviewRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewRequestAttributesVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewRequestAttributesVisitor { + type Value = AWSMetricNameFilterPreviewRequestAttributes; + + 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 metric_name_filters: 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() { + "metric_name_filters" => { + metric_name_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 metric_name_filters = metric_name_filters + .ok_or_else(|| M::Error::missing_field("metric_name_filters"))?; + + let content = AWSMetricNameFilterPreviewRequestAttributes { + metric_name_filters, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_request_data.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_request_data.rs new file mode 100644 index 0000000000..2bbc6abf01 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_request_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}; + +/// AWS metric name filter preview request data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewRequestData { + /// AWS metric name filter preview request attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AWSMetricNameFilterPreviewRequestAttributes, + /// The `AWSMetricNameFilterPreviewResponseData` `type`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSMetricNameFilterPreviewType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewRequestData { + pub fn new( + attributes: crate::datadogV2::model::AWSMetricNameFilterPreviewRequestAttributes, + type_: crate::datadogV2::model::AWSMetricNameFilterPreviewType, + ) -> AWSMetricNameFilterPreviewRequestData { + AWSMetricNameFilterPreviewRequestData { + 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 AWSMetricNameFilterPreviewRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewRequestDataVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewRequestDataVisitor { + type Value = AWSMetricNameFilterPreviewRequestData; + + 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::AWSMetricNameFilterPreviewRequestAttributes, + > = 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::AWSMetricNameFilterPreviewType::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 = AWSMetricNameFilterPreviewRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_response.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_response.rs new file mode 100644 index 0000000000..e90ded55a6 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_response.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}; + +/// AWS metric name filter preview response body. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewResponse { + /// AWS metric name filter preview response data. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AWSMetricNameFilterPreviewResponseData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewResponse { + pub fn new( + data: crate::datadogV2::model::AWSMetricNameFilterPreviewResponseData, + ) -> AWSMetricNameFilterPreviewResponse { + AWSMetricNameFilterPreviewResponse { + 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 AWSMetricNameFilterPreviewResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewResponseVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewResponseVisitor { + type Value = AWSMetricNameFilterPreviewResponse; + + 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< + crate::datadogV2::model::AWSMetricNameFilterPreviewResponseData, + > = 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 = AWSMetricNameFilterPreviewResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_response_attributes.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_response_attributes.rs new file mode 100644 index 0000000000..3989c2dffb --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_response_attributes.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}; + +/// AWS metric name filter preview response attributes. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewResponseAttributes { + /// The list of namespaces affected by the previewed metric name filters. + #[serde(rename = "namespaces")] + pub namespaces: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewResponseAttributes { + pub fn new( + namespaces: Vec, + ) -> AWSMetricNameFilterPreviewResponseAttributes { + AWSMetricNameFilterPreviewResponseAttributes { + namespaces, + 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 AWSMetricNameFilterPreviewResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewResponseAttributesVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewResponseAttributesVisitor { + type Value = AWSMetricNameFilterPreviewResponseAttributes; + + 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 namespaces: 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() { + "namespaces" => { + namespaces = 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 namespaces = namespaces.ok_or_else(|| M::Error::missing_field("namespaces"))?; + + let content = AWSMetricNameFilterPreviewResponseAttributes { + namespaces, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_response_data.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_response_data.rs new file mode 100644 index 0000000000..dffe2c19b7 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_response_data.rs @@ -0,0 +1,130 @@ +// 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}; + +/// AWS metric name filter preview response data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFilterPreviewResponseData { + /// AWS metric name filter preview response attributes. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AWSMetricNameFilterPreviewResponseAttributes, + /// Unique Datadog ID of the AWS Account Integration Config. + /// To get the config ID for an account, use the + /// [List all AWS integrations]() + /// endpoint and query by AWS Account ID. + #[serde(rename = "id")] + pub id: String, + /// The `AWSMetricNameFilterPreviewResponseData` `type`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AWSMetricNameFilterPreviewType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFilterPreviewResponseData { + pub fn new( + attributes: crate::datadogV2::model::AWSMetricNameFilterPreviewResponseAttributes, + id: String, + type_: crate::datadogV2::model::AWSMetricNameFilterPreviewType, + ) -> AWSMetricNameFilterPreviewResponseData { + AWSMetricNameFilterPreviewResponseData { + 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 AWSMetricNameFilterPreviewResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFilterPreviewResponseDataVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFilterPreviewResponseDataVisitor { + type Value = AWSMetricNameFilterPreviewResponseData; + + 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::AWSMetricNameFilterPreviewResponseAttributes, + > = 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::AWSMetricNameFilterPreviewType::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 = AWSMetricNameFilterPreviewResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFilterPreviewResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filter_preview_type.rs b/src/datadogV2/model/model_aws_metric_name_filter_preview_type.rs new file mode 100644 index 0000000000..6455dceae5 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filter_preview_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 AWSMetricNameFilterPreviewType { + METRIC_NAME_FILTER_PREVIEW, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AWSMetricNameFilterPreviewType { + fn to_string(&self) -> String { + match self { + Self::METRIC_NAME_FILTER_PREVIEW => String::from("metric_name_filter_preview"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AWSMetricNameFilterPreviewType { + 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 AWSMetricNameFilterPreviewType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "metric_name_filter_preview" => Self::METRIC_NAME_FILTER_PREVIEW, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filters.rs b/src/datadogV2/model/model_aws_metric_name_filters.rs new file mode 100644 index 0000000000..aa84380000 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filters.rs @@ -0,0 +1,44 @@ +// 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}; + +/// AWS CloudWatch metric name filter for a single namespace. +/// Exactly one of `include_only` or `exclude_only` must be set. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum AWSMetricNameFilters { + AWSMetricNameFiltersIncludeOnly(Box), + AWSMetricNameFiltersExcludeOnly(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for AWSMetricNameFilters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(AWSMetricNameFilters::AWSMetricNameFiltersIncludeOnly(_v)); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(AWSMetricNameFilters::AWSMetricNameFiltersExcludeOnly(_v)); + } + } + + return Ok(AWSMetricNameFilters::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filters_exclude_only.rs b/src/datadogV2/model/model_aws_metric_name_filters_exclude_only.rs new file mode 100644 index 0000000000..2d4a137a19 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filters_exclude_only.rs @@ -0,0 +1,104 @@ +// 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}; + +/// Exclude metric names matching one of these patterns for a single namespace. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFiltersExcludeOnly { + /// Exclude metric names matching one of these patterns. + #[serde(rename = "exclude_only")] + pub exclude_only: Vec, + /// The AWS CloudWatch namespace to which this metric name filter applies. + #[serde(rename = "namespace")] + pub namespace: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFiltersExcludeOnly { + pub fn new(exclude_only: Vec, namespace: String) -> AWSMetricNameFiltersExcludeOnly { + AWSMetricNameFiltersExcludeOnly { + exclude_only, + namespace, + 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 AWSMetricNameFiltersExcludeOnly { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFiltersExcludeOnlyVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFiltersExcludeOnlyVisitor { + type Value = AWSMetricNameFiltersExcludeOnly; + + 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 exclude_only: Option> = None; + let mut namespace: 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() { + "exclude_only" => { + exclude_only = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "namespace" => { + namespace = 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 exclude_only = + exclude_only.ok_or_else(|| M::Error::missing_field("exclude_only"))?; + let namespace = namespace.ok_or_else(|| M::Error::missing_field("namespace"))?; + + let content = AWSMetricNameFiltersExcludeOnly { + exclude_only, + namespace, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFiltersExcludeOnlyVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metric_name_filters_include_only.rs b/src/datadogV2/model/model_aws_metric_name_filters_include_only.rs new file mode 100644 index 0000000000..134a79a440 --- /dev/null +++ b/src/datadogV2/model/model_aws_metric_name_filters_include_only.rs @@ -0,0 +1,104 @@ +// 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}; + +/// Include only metric names matching one of these patterns for a single namespace. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AWSMetricNameFiltersIncludeOnly { + /// Include only metric names matching one of these patterns. + #[serde(rename = "include_only")] + pub include_only: Vec, + /// The AWS CloudWatch namespace to which this metric name filter applies. + #[serde(rename = "namespace")] + pub namespace: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AWSMetricNameFiltersIncludeOnly { + pub fn new(include_only: Vec, namespace: String) -> AWSMetricNameFiltersIncludeOnly { + AWSMetricNameFiltersIncludeOnly { + include_only, + namespace, + 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 AWSMetricNameFiltersIncludeOnly { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AWSMetricNameFiltersIncludeOnlyVisitor; + impl<'a> Visitor<'a> for AWSMetricNameFiltersIncludeOnlyVisitor { + type Value = AWSMetricNameFiltersIncludeOnly; + + 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 include_only: Option> = None; + let mut namespace: 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() { + "include_only" => { + include_only = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "namespace" => { + namespace = 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 include_only = + include_only.ok_or_else(|| M::Error::missing_field("include_only"))?; + let namespace = namespace.ok_or_else(|| M::Error::missing_field("namespace"))?; + + let content = AWSMetricNameFiltersIncludeOnly { + include_only, + namespace, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AWSMetricNameFiltersIncludeOnlyVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_metrics_config.rs b/src/datadogV2/model/model_aws_metrics_config.rs index f6f8219891..10aa31bdd6 100644 --- a/src/datadogV2/model/model_aws_metrics_config.rs +++ b/src/datadogV2/model/model_aws_metrics_config.rs @@ -23,6 +23,10 @@ pub struct AWSMetricsConfig { /// Enable AWS metrics collection. Defaults to `true`. #[serde(rename = "enabled")] pub enabled: Option, + /// AWS CloudWatch metric name filters. Each filter applies to a single namespace. + /// Exactly one of `include_only` or `exclude_only` must be set on each filter. + #[serde(rename = "metric_name_filters")] + pub metric_name_filters: Option>, /// AWS Metrics namespace filters. Defaults to `exclude_only`. #[serde(rename = "namespace_filters")] pub namespace_filters: Option, @@ -43,6 +47,7 @@ impl AWSMetricsConfig { collect_cloudwatch_alarms: None, collect_custom_metrics: None, enabled: None, + metric_name_filters: None, namespace_filters: None, tag_filters: None, additional_properties: std::collections::BTreeMap::new(), @@ -70,6 +75,14 @@ impl AWSMetricsConfig { self } + pub fn metric_name_filters( + mut self, + value: Vec, + ) -> Self { + self.metric_name_filters = Some(value); + self + } + pub fn namespace_filters( mut self, value: crate::datadogV2::model::AWSNamespaceFilters, @@ -122,6 +135,9 @@ impl<'de> Deserialize<'de> for AWSMetricsConfig { let mut collect_cloudwatch_alarms: Option = None; let mut collect_custom_metrics: Option = None; let mut enabled: Option = None; + let mut metric_name_filters: Option< + Vec, + > = None; let mut namespace_filters: Option = None; let mut tag_filters: Option> = @@ -161,6 +177,13 @@ impl<'de> Deserialize<'de> for AWSMetricsConfig { } enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "metric_name_filters" => { + if v.is_null() { + continue; + } + metric_name_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "namespace_filters" => { if v.is_null() { continue; @@ -196,6 +219,7 @@ impl<'de> Deserialize<'de> for AWSMetricsConfig { collect_cloudwatch_alarms, collect_custom_metrics, enabled, + metric_name_filters, namespace_filters, tag_filters, additional_properties, diff --git a/tests/scenarios/features/v2/aws_integration.feature b/tests/scenarios/features/v2/aws_integration.feature index dac51bb744..8d91676e64 100644 --- a/tests/scenarios/features/v2/aws_integration.feature +++ b/tests/scenarios/features/v2/aws_integration.feature @@ -185,6 +185,22 @@ Feature: AWS Integration When the request is sent Then the response status is 200 AWS integration standard IAM permissions. + @generated @skip @team:DataDog/aws-integrations + Scenario: Get AWS metric name filter preview returns "AWS metric name filter preview result" response + Given operation "GetAWSMetricNameFilterPreview" enabled + And new "GetAWSMetricNameFilterPreview" request + And request contains "aws_account_config_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 AWS metric name filter preview result + + @generated @skip @team:DataDog/aws-integrations + Scenario: Get AWS metric name filter preview returns "Not Found" response + Given operation "GetAWSMetricNameFilterPreview" enabled + And new "GetAWSMetricNameFilterPreview" request + And request contains "aws_account_config_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/aws-integrations Scenario: Get all Amazon EventBridge sources returns "Amazon EventBridge sources list." response Given new "ListAWSEventBridgeSources" request @@ -249,6 +265,33 @@ Feature: AWS Integration When the request is sent Then the response status is 200 AWS Namespaces List object + @generated @skip @team:DataDog/aws-integrations + Scenario: Preview AWS metric name filter returns "AWS metric name filter preview result" response + Given operation "PreviewAWSMetricNameFilter" enabled + And new "PreviewAWSMetricNameFilter" request + And request contains "aws_account_config_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"metric_name_filters": [{"include_only": ["aws.ec2.network_in"], "namespace": "AWS/EC2"}]}, "type": "metric_name_filter_preview"}} + When the request is sent + Then the response status is 200 AWS metric name filter preview result + + @generated @skip @team:DataDog/aws-integrations + Scenario: Preview AWS metric name filter returns "Bad Request" response + Given operation "PreviewAWSMetricNameFilter" enabled + And new "PreviewAWSMetricNameFilter" request + And request contains "aws_account_config_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"metric_name_filters": [{"include_only": ["aws.ec2.network_in"], "namespace": "AWS/EC2"}]}, "type": "metric_name_filter_preview"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aws-integrations + Scenario: Preview AWS metric name filter returns "Not Found" response + Given operation "PreviewAWSMetricNameFilter" enabled + And new "PreviewAWSMetricNameFilter" request + And request contains "aws_account_config_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"metric_name_filters": [{"include_only": ["aws.ec2.network_in"], "namespace": "AWS/EC2"}]}, "type": "metric_name_filter_preview"}} + When the request is sent + Then the response status is 404 Not Found + @skip @team:DataDog/aws-integrations Scenario: Update AWS CCM config returns "AWS CCM Config object" response Given operation "UpdateAWSAccountCCMConfig" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 1eaba52ee9..22089f0ece 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3363,6 +3363,18 @@ "type": "unsafe" } }, + "GetAWSMetricNameFilterPreview": { + "tag": "AWS Integration", + "undo": { + "type": "safe" + } + }, + "PreviewAWSMetricNameFilter": { + "tag": "AWS Integration", + "undo": { + "type": "safe" + } + }, "ListAWSNamespaces": { "tag": "AWS Integration", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 17934d0b8b..26024f8b3c 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -5196,6 +5196,14 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.CreateAWSAccountCCMConfig".into(), test_v2_create_aws_account_ccm_config, ); + world.function_mappings.insert( + "v2.GetAWSMetricNameFilterPreview".into(), + test_v2_get_aws_metric_name_filter_preview, + ); + world.function_mappings.insert( + "v2.PreviewAWSMetricNameFilter".into(), + test_v2_preview_aws_metric_name_filter, + ); world .function_mappings .insert("v2.ListAWSNamespaces".into(), test_v2_list_aws_namespaces); @@ -40019,6 +40027,69 @@ fn test_v2_create_aws_account_ccm_config( world.response.code = response.status.as_u16(); } +fn test_v2_get_aws_metric_name_filter_preview( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_integration + .as_ref() + .expect("api instance not found"); + let aws_account_config_id = + serde_json::from_value(_parameters.get("aws_account_config_id").unwrap().clone()).unwrap(); + let response = match block_on( + api.get_aws_metric_name_filter_preview_with_http_info(aws_account_config_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_preview_aws_metric_name_filter( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_integration + .as_ref() + .expect("api instance not found"); + let aws_account_config_id = + serde_json::from_value(_parameters.get("aws_account_config_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on( + api.preview_aws_metric_name_filter_with_http_info(aws_account_config_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_aws_namespaces(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances