Skip to content

Commit 4ccb78d

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add metric namespace config filters to V2 GCP API (#2729)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 56fae8e commit 4ccb78d

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20582,9 +20582,20 @@ components:
2058220582
to this GCP metric namespace.
2058320583
example: true
2058420584
type: boolean
20585+
filters:
20586+
description: When enabled, Datadog applies these additional filters to limit
20587+
metric collection. A metric is collected only if it does not match all
20588+
exclusion filters and matches at least one allow filter.
20589+
example:
20590+
- snapshot.*
20591+
- '!*_by_region'
20592+
items:
20593+
description: A metric namespace filter
20594+
type: string
20595+
type: array
2058520596
id:
2058620597
description: The id of the GCP metric namespace.
20587-
example: aiplatform
20598+
example: pubsub
2058820599
type: string
2058920600
type: object
2059020601
GCPMonitoredResourceConfig:
@@ -20746,6 +20757,10 @@ components:
2074620757
example:
2074720758
- disabled: true
2074820759
id: aiplatform
20760+
- filters:
20761+
- snapshot.*
20762+
- '!*_by_region'
20763+
id: pubsub
2074920764
items:
2075020765
$ref: '#/components/schemas/GCPMetricNamespaceConfig'
2075120766
type: array

features/v2/gcp_integration.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ Feature: GCP Integration
3434
@generated @skip @team:DataDog/gcp-integrations
3535
Scenario: Create a new entry for your service account returns "Bad Request" response
3636
Given new "CreateGCPSTSAccount" request
37-
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"}}
37+
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"}}
3838
When the request is sent
3939
Then the response status is 400 Bad Request
4040

4141
@generated @skip @team:DataDog/gcp-integrations
4242
Scenario: Create a new entry for your service account returns "Conflict" response
4343
Given new "CreateGCPSTSAccount" request
44-
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"}}
44+
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"}}
4545
When the request is sent
4646
Then the response status is 409 Conflict
4747

@@ -151,15 +151,15 @@ Feature: GCP Integration
151151
Scenario: Update STS Service Account returns "Bad Request" response
152152
Given new "UpdateGCPSTSAccount" request
153153
And request contains "account_id" parameter from "REPLACE.ME"
154-
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"}}
154+
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"}}
155155
When the request is sent
156156
Then the response status is 400 Bad Request
157157

158158
@generated @skip @team:DataDog/gcp-integrations
159159
Scenario: Update STS Service Account returns "Not Found" response
160160
Given new "UpdateGCPSTSAccount" request
161161
And request contains "account_id" parameter from "REPLACE.ME"
162-
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"}}
162+
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"}}
163163
When the request is sent
164164
Then the response status is 404 Not Found
165165

lib/datadog_api_client/v2/models/gcp_metric_namespace_config.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class GCPMetricNamespaceConfig
2424
# When disabled, Datadog does not collect metrics that are related to this GCP metric namespace.
2525
attr_accessor :disabled
2626

27+
# 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.
28+
attr_accessor :filters
29+
2730
# The id of the GCP metric namespace.
2831
attr_accessor :id
2932

@@ -34,6 +37,7 @@ class GCPMetricNamespaceConfig
3437
def self.attribute_map
3538
{
3639
:'disabled' => :'disabled',
40+
:'filters' => :'filters',
3741
:'id' => :'id'
3842
}
3943
end
@@ -43,6 +47,7 @@ def self.attribute_map
4347
def self.openapi_types
4448
{
4549
:'disabled' => :'Boolean',
50+
:'filters' => :'Array<String>',
4651
:'id' => :'String'
4752
}
4853
end
@@ -69,6 +74,12 @@ def initialize(attributes = {})
6974
self.disabled = attributes[:'disabled']
7075
end
7176

77+
if attributes.key?(:'filters')
78+
if (value = attributes[:'filters']).is_a?(Array)
79+
self.filters = value
80+
end
81+
end
82+
7283
if attributes.key?(:'id')
7384
self.id = attributes[:'id']
7485
end
@@ -101,6 +112,7 @@ def ==(o)
101112
return true if self.equal?(o)
102113
self.class == o.class &&
103114
disabled == o.disabled &&
115+
filters == o.filters &&
104116
id == o.id &&
105117
additional_properties == o.additional_properties
106118
end
@@ -109,7 +121,7 @@ def ==(o)
109121
# @return [Integer] Hash code
110122
# @!visibility private
111123
def hash
112-
[disabled, id, additional_properties].hash
124+
[disabled, filters, id, additional_properties].hash
113125
end
114126
end
115127
end

0 commit comments

Comments
 (0)