diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 364018c47..47cd94878 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -20406,9 +20406,20 @@ components: to this GCP metric namespace. example: true type: boolean + filters: + description: When enabled, Datadog applies these additional filters to limit + metric collection. A metric is collected only if it does not match all + exclusion filters and matches at least one allow filter. + example: + - snapshot.* + - '!*_by_region' + items: + description: A metric namespace filter + type: string + type: array id: description: The id of the GCP metric namespace. - example: aiplatform + example: pubsub type: string type: object GCPMonitoredResourceConfig: @@ -20570,6 +20581,10 @@ components: example: - disabled: true id: aiplatform + - filters: + - snapshot.* + - '!*_by_region' + id: pubsub items: $ref: '#/components/schemas/GCPMetricNamespaceConfig' type: array diff --git a/src/datadogV2/model/model_gcp_metric_namespace_config.rs b/src/datadogV2/model/model_gcp_metric_namespace_config.rs index 5c711fb24..940a69898 100644 --- a/src/datadogV2/model/model_gcp_metric_namespace_config.rs +++ b/src/datadogV2/model/model_gcp_metric_namespace_config.rs @@ -14,6 +14,9 @@ pub struct GCPMetricNamespaceConfig { /// When disabled, Datadog does not collect metrics that are related to this GCP metric namespace. #[serde(rename = "disabled")] pub disabled: Option, + /// When enabled, Datadog applies these additional filters to limit metric collection. A metric is collected only if it does not match all exclusion filters and matches at least one allow filter. + #[serde(rename = "filters")] + pub filters: Option>, /// The id of the GCP metric namespace. #[serde(rename = "id")] pub id: Option, @@ -28,6 +31,7 @@ impl GCPMetricNamespaceConfig { pub fn new() -> GCPMetricNamespaceConfig { GCPMetricNamespaceConfig { disabled: None, + filters: None, id: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, @@ -39,6 +43,11 @@ impl GCPMetricNamespaceConfig { self } + pub fn filters(mut self, value: Vec) -> Self { + self.filters = Some(value); + self + } + pub fn id(mut self, value: String) -> Self { self.id = Some(value); self @@ -77,6 +86,7 @@ impl<'de> Deserialize<'de> for GCPMetricNamespaceConfig { M: MapAccess<'a>, { let mut disabled: Option = None; + let mut filters: Option> = None; let mut id: Option = None; let mut additional_properties: std::collections::BTreeMap< String, @@ -92,6 +102,12 @@ impl<'de> Deserialize<'de> for GCPMetricNamespaceConfig { } disabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "filters" => { + if v.is_null() { + continue; + } + filters = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "id" => { if v.is_null() { continue; @@ -108,6 +124,7 @@ impl<'de> Deserialize<'de> for GCPMetricNamespaceConfig { let content = GCPMetricNamespaceConfig { disabled, + filters, id, additional_properties, _unparsed, diff --git a/tests/scenarios/features/v2/gcp_integration.feature b/tests/scenarios/features/v2/gcp_integration.feature index 935adb2d9..6d47a1508 100644 --- a/tests/scenarios/features/v2/gcp_integration.feature +++ b/tests/scenarios/features/v2/gcp_integration.feature @@ -34,14 +34,14 @@ Feature: GCP Integration @generated @skip @team:DataDog/gcp-integrations Scenario: Create a new entry for your service account returns "Bad Request" response Given new "CreateGCPSTSAccount" request - And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": ["$KEY:$VALUE"], "is_per_project_quota_enabled": true, "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}], "monitored_resource_configs": [{"filters": ["$KEY:$VALUE"], "type": "gce_instance"}]}, "type": "gcp_service_account"}} + And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": ["$KEY:$VALUE"], "is_per_project_quota_enabled": true, "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}, {"filters": ["snapshot.*", "!*_by_region"], "id": "pubsub"}], "monitored_resource_configs": [{"filters": ["$KEY:$VALUE"], "type": "gce_instance"}]}, "type": "gcp_service_account"}} When the request is sent Then the response status is 400 Bad Request @generated @skip @team:DataDog/gcp-integrations Scenario: Create a new entry for your service account returns "Conflict" response Given new "CreateGCPSTSAccount" request - And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": ["$KEY:$VALUE"], "is_per_project_quota_enabled": true, "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}], "monitored_resource_configs": [{"filters": ["$KEY:$VALUE"], "type": "gce_instance"}]}, "type": "gcp_service_account"}} + And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": ["$KEY:$VALUE"], "is_per_project_quota_enabled": true, "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}, {"filters": ["snapshot.*", "!*_by_region"], "id": "pubsub"}], "monitored_resource_configs": [{"filters": ["$KEY:$VALUE"], "type": "gce_instance"}]}, "type": "gcp_service_account"}} When the request is sent Then the response status is 409 Conflict @@ -151,7 +151,7 @@ Feature: GCP Integration Scenario: Update STS Service Account returns "Bad Request" response Given new "UpdateGCPSTSAccount" request And request contains "account_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": ["$KEY:$VALUE"], "is_per_project_quota_enabled": true, "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}], "monitored_resource_configs": [{"filters": ["$KEY:$VALUE"], "type": "gce_instance"}]}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} + And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": ["$KEY:$VALUE"], "is_per_project_quota_enabled": true, "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}, {"filters": ["snapshot.*", "!*_by_region"], "id": "pubsub"}], "monitored_resource_configs": [{"filters": ["$KEY:$VALUE"], "type": "gce_instance"}]}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} When the request is sent Then the response status is 400 Bad Request @@ -159,7 +159,7 @@ Feature: GCP Integration Scenario: Update STS Service Account returns "Not Found" response Given new "UpdateGCPSTSAccount" request And request contains "account_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": ["$KEY:$VALUE"], "is_per_project_quota_enabled": true, "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}], "monitored_resource_configs": [{"filters": ["$KEY:$VALUE"], "type": "gce_instance"}]}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} + And body with value {"data": {"attributes": {"account_tags": [], "client_email": "datadog-service-account@test-project.iam.gserviceaccount.com", "cloud_run_revision_filters": ["$KEY:$VALUE"], "host_filters": ["$KEY:$VALUE"], "is_per_project_quota_enabled": true, "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}, {"filters": ["snapshot.*", "!*_by_region"], "id": "pubsub"}], "monitored_resource_configs": [{"filters": ["$KEY:$VALUE"], "type": "gce_instance"}]}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} When the request is sent Then the response status is 404 Not Found