Skip to content

Commit 07458ab

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add metric namespace config filters to V2 GCP API (#3417)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 36b0761 commit 07458ab

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
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

api/datadogV2/model_gcp_metric_namespace_config.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
type GCPMetricNamespaceConfig struct {
1313
// When disabled, Datadog does not collect metrics that are related to this GCP metric namespace.
1414
Disabled *bool `json:"disabled,omitempty"`
15+
// 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.
16+
Filters []string `json:"filters,omitempty"`
1517
// The id of the GCP metric namespace.
1618
Id *string `json:"id,omitempty"`
1719
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
@@ -68,6 +70,34 @@ func (o *GCPMetricNamespaceConfig) SetDisabled(v bool) {
6870
o.Disabled = &v
6971
}
7072

73+
// GetFilters returns the Filters field value if set, zero value otherwise.
74+
func (o *GCPMetricNamespaceConfig) GetFilters() []string {
75+
if o == nil || o.Filters == nil {
76+
var ret []string
77+
return ret
78+
}
79+
return o.Filters
80+
}
81+
82+
// GetFiltersOk returns a tuple with the Filters field value if set, nil otherwise
83+
// and a boolean to check if the value has been set.
84+
func (o *GCPMetricNamespaceConfig) GetFiltersOk() (*[]string, bool) {
85+
if o == nil || o.Filters == nil {
86+
return nil, false
87+
}
88+
return &o.Filters, true
89+
}
90+
91+
// HasFilters returns a boolean if a field has been set.
92+
func (o *GCPMetricNamespaceConfig) HasFilters() bool {
93+
return o != nil && o.Filters != nil
94+
}
95+
96+
// SetFilters gets a reference to the given []string and assigns it to the Filters field.
97+
func (o *GCPMetricNamespaceConfig) SetFilters(v []string) {
98+
o.Filters = v
99+
}
100+
71101
// GetId returns the Id field value if set, zero value otherwise.
72102
func (o *GCPMetricNamespaceConfig) GetId() string {
73103
if o == nil || o.Id == nil {
@@ -105,6 +135,9 @@ func (o GCPMetricNamespaceConfig) MarshalJSON() ([]byte, error) {
105135
if o.Disabled != nil {
106136
toSerialize["disabled"] = o.Disabled
107137
}
138+
if o.Filters != nil {
139+
toSerialize["filters"] = o.Filters
140+
}
108141
if o.Id != nil {
109142
toSerialize["id"] = o.Id
110143
}
@@ -118,19 +151,21 @@ func (o GCPMetricNamespaceConfig) MarshalJSON() ([]byte, error) {
118151
// UnmarshalJSON deserializes the given payload.
119152
func (o *GCPMetricNamespaceConfig) UnmarshalJSON(bytes []byte) (err error) {
120153
all := struct {
121-
Disabled *bool `json:"disabled,omitempty"`
122-
Id *string `json:"id,omitempty"`
154+
Disabled *bool `json:"disabled,omitempty"`
155+
Filters []string `json:"filters,omitempty"`
156+
Id *string `json:"id,omitempty"`
123157
}{}
124158
if err = datadog.Unmarshal(bytes, &all); err != nil {
125159
return datadog.Unmarshal(bytes, &o.UnparsedObject)
126160
}
127161
additionalProperties := make(map[string]interface{})
128162
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
129-
datadog.DeleteKeys(additionalProperties, &[]string{"disabled", "id"})
163+
datadog.DeleteKeys(additionalProperties, &[]string{"disabled", "filters", "id"})
130164
} else {
131165
return err
132166
}
133167
o.Disabled = all.Disabled
168+
o.Filters = all.Filters
134169
o.Id = all.Id
135170

136171
if len(additionalProperties) > 0 {

tests/scenarios/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": "[email protected]", "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": "[email protected]", "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": "[email protected]", "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": "[email protected]", "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": "[email protected]", "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": "[email protected]", "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": "[email protected]", "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": "[email protected]", "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

0 commit comments

Comments
 (0)