Skip to content

Commit e508d76

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

File tree

3 files changed

+60
-6
lines changed

3 files changed

+60
-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

src/main/java/com/datadog/api/client/v2/model/GCPMetricNamespaceConfig.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
import com.fasterxml.jackson.annotation.JsonInclude;
1313
import com.fasterxml.jackson.annotation.JsonProperty;
1414
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
15+
import java.util.ArrayList;
1516
import java.util.HashMap;
17+
import java.util.List;
1618
import java.util.Map;
1719
import java.util.Objects;
1820

1921
/** Configuration for a GCP metric namespace. */
2022
@JsonPropertyOrder({
2123
GCPMetricNamespaceConfig.JSON_PROPERTY_DISABLED,
24+
GCPMetricNamespaceConfig.JSON_PROPERTY_FILTERS,
2225
GCPMetricNamespaceConfig.JSON_PROPERTY_ID
2326
})
2427
@jakarta.annotation.Generated(
@@ -28,6 +31,9 @@ public class GCPMetricNamespaceConfig {
2831
public static final String JSON_PROPERTY_DISABLED = "disabled";
2932
private Boolean disabled = false;
3033

34+
public static final String JSON_PROPERTY_FILTERS = "filters";
35+
private List<String> filters = null;
36+
3137
public static final String JSON_PROPERTY_ID = "id";
3238
private String id;
3339

@@ -52,6 +58,37 @@ public void setDisabled(Boolean disabled) {
5258
this.disabled = disabled;
5359
}
5460

61+
public GCPMetricNamespaceConfig filters(List<String> filters) {
62+
this.filters = filters;
63+
return this;
64+
}
65+
66+
public GCPMetricNamespaceConfig addFiltersItem(String filtersItem) {
67+
if (this.filters == null) {
68+
this.filters = new ArrayList<>();
69+
}
70+
this.filters.add(filtersItem);
71+
return this;
72+
}
73+
74+
/**
75+
* When enabled, Datadog applies these additional filters to limit metric collection. A metric is
76+
* collected only if it does not match all exclusion filters and matches at least one allow
77+
* filter.
78+
*
79+
* @return filters
80+
*/
81+
@jakarta.annotation.Nullable
82+
@JsonProperty(JSON_PROPERTY_FILTERS)
83+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
84+
public List<String> getFilters() {
85+
return filters;
86+
}
87+
88+
public void setFilters(List<String> filters) {
89+
this.filters = filters;
90+
}
91+
5592
public GCPMetricNamespaceConfig id(String id) {
5693
this.id = id;
5794
return this;
@@ -130,20 +167,22 @@ public boolean equals(Object o) {
130167
}
131168
GCPMetricNamespaceConfig gcpMetricNamespaceConfig = (GCPMetricNamespaceConfig) o;
132169
return Objects.equals(this.disabled, gcpMetricNamespaceConfig.disabled)
170+
&& Objects.equals(this.filters, gcpMetricNamespaceConfig.filters)
133171
&& Objects.equals(this.id, gcpMetricNamespaceConfig.id)
134172
&& Objects.equals(this.additionalProperties, gcpMetricNamespaceConfig.additionalProperties);
135173
}
136174

137175
@Override
138176
public int hashCode() {
139-
return Objects.hash(disabled, id, additionalProperties);
177+
return Objects.hash(disabled, filters, id, additionalProperties);
140178
}
141179

142180
@Override
143181
public String toString() {
144182
StringBuilder sb = new StringBuilder();
145183
sb.append("class GCPMetricNamespaceConfig {\n");
146184
sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n");
185+
sb.append(" filters: ").append(toIndentedString(filters)).append("\n");
147186
sb.append(" id: ").append(toIndentedString(id)).append("\n");
148187
sb.append(" additionalProperties: ")
149188
.append(toIndentedString(additionalProperties))

src/test/resources/com/datadog/api/client/v2/api/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

0 commit comments

Comments
 (0)