From 8360a87368335e0a99b17c4edcb6b5bc49ff62c2 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:02:58 +0000 Subject: [PATCH] Add metric_namespace_configs to GCP v2 API (#2087) Co-authored-by: ci.datadog-api-spec --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 22 ++++ features/v2/gcp_integration.feature | 8 +- lib/datadog_api_client/inflector.rb | 1 + .../v2/models/gcp_metric_namespace_config.rb | 115 ++++++++++++++++++ .../gcpsts_service_account_attributes.rb | 14 ++- 6 files changed, 159 insertions(+), 9 deletions(-) create mode 100644 lib/datadog_api_client/v2/models/gcp_metric_namespace_config.rb diff --git a/.apigentools-info b/.apigentools-info index db05ce20d56..e8d7068507b 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-05 21:07:13.880957", - "spec_repo_commit": "6c0fa1b6" + "regenerated": "2024-11-05 22:28:17.976412", + "spec_repo_commit": "2db17c21" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-05 21:07:13.899409", - "spec_repo_commit": "6c0fa1b6" + "regenerated": "2024-11-05 22:28:17.995053", + "spec_repo_commit": "2db17c21" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 925dfca233a..ce1fe2fc60d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -9623,6 +9623,20 @@ components: nullable: true type: array type: object + GCPMetricNamespaceConfig: + description: Configuration for a GCP metric namespace. + properties: + disabled: + default: false + description: When disabled, Datadog does not collect metrics that are related + to this GCP metric namespace. + example: true + type: boolean + id: + description: The id of the GCP metric namespace. + example: aiplatform + type: string + type: object GCPSTSDelegateAccount: description: Datadog principal service account info. properties: @@ -9725,6 +9739,14 @@ components: account.' example: true type: boolean + metric_namespace_configs: + description: Configurations for GCP metric namespaces. + example: + - disabled: true + id: aiplatform + items: + $ref: '#/components/schemas/GCPMetricNamespaceConfig' + type: array resource_collection_enabled: description: When enabled, Datadog scans for all resources in your GCP environment. type: boolean diff --git a/features/v2/gcp_integration.feature b/features/v2/gcp_integration.feature index 7ab3ec0b0eb..18749b0a6d0 100644 --- a/features/v2/gcp_integration.feature +++ b/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": [], "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true}, "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": [], "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}]}, "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": [], "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true}, "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": [], "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}]}, "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": [], "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true}, "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": [], "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}]}, "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": [], "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true}, "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": [], "is_resource_change_collection_enabled": true, "is_security_command_center_enabled": true, "metric_namespace_configs": [{"disabled": true, "id": "aiplatform"}]}, "id": "d291291f-12c2-22g4-j290-123456678897", "type": "gcp_service_account"}} When the request is sent Then the response status is 404 Not Found diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 512f2e34deb..930683134a0 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1454,6 +1454,7 @@ def overrides "v2.full_api_key_attributes" => "FullAPIKeyAttributes", "v2.full_application_key" => "FullApplicationKey", "v2.full_application_key_attributes" => "FullApplicationKeyAttributes", + "v2.gcp_metric_namespace_config" => "GCPMetricNamespaceConfig", "v2.gcp_service_account_meta" => "GCPServiceAccountMeta", "v2.gcp_service_account_type" => "GCPServiceAccountType", "v2.gcpsts_delegate_account" => "GCPSTSDelegateAccount", diff --git a/lib/datadog_api_client/v2/models/gcp_metric_namespace_config.rb b/lib/datadog_api_client/v2/models/gcp_metric_namespace_config.rb new file mode 100644 index 00000000000..f6615f8d658 --- /dev/null +++ b/lib/datadog_api_client/v2/models/gcp_metric_namespace_config.rb @@ -0,0 +1,115 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Configuration for a GCP metric namespace. + class GCPMetricNamespaceConfig + include BaseGenericModel + + # When disabled, Datadog does not collect metrics that are related to this GCP metric namespace. + attr_accessor :disabled + + # The id of the GCP metric namespace. + attr_accessor :id + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'disabled' => :'disabled', + :'id' => :'id' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'disabled' => :'Boolean', + :'id' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::GCPMetricNamespaceConfig` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'disabled') + self.disabled = attributes[:'disabled'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + disabled == o.disabled && + id == o.id + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [disabled, id].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/gcpsts_service_account_attributes.rb b/lib/datadog_api_client/v2/models/gcpsts_service_account_attributes.rb index 6e2a951f852..552a1b1facb 100644 --- a/lib/datadog_api_client/v2/models/gcpsts_service_account_attributes.rb +++ b/lib/datadog_api_client/v2/models/gcpsts_service_account_attributes.rb @@ -46,6 +46,9 @@ class GCPSTSServiceAccountAttributes # When enabled, Datadog will attempt to collect Security Command Center Findings. Note: This requires additional permissions on the service account. attr_accessor :is_security_command_center_enabled + # Configurations for GCP metric namespaces. + attr_accessor :metric_namespace_configs + # When enabled, Datadog scans for all resources in your GCP environment. attr_accessor :resource_collection_enabled @@ -63,6 +66,7 @@ def self.attribute_map :'is_cspm_enabled' => :'is_cspm_enabled', :'is_resource_change_collection_enabled' => :'is_resource_change_collection_enabled', :'is_security_command_center_enabled' => :'is_security_command_center_enabled', + :'metric_namespace_configs' => :'metric_namespace_configs', :'resource_collection_enabled' => :'resource_collection_enabled' } end @@ -79,6 +83,7 @@ def self.openapi_types :'is_cspm_enabled' => :'Boolean', :'is_resource_change_collection_enabled' => :'Boolean', :'is_security_command_center_enabled' => :'Boolean', + :'metric_namespace_configs' => :'Array', :'resource_collection_enabled' => :'Boolean' } end @@ -139,6 +144,12 @@ def initialize(attributes = {}) self.is_security_command_center_enabled = attributes[:'is_security_command_center_enabled'] end + if attributes.key?(:'metric_namespace_configs') + if (value = attributes[:'metric_namespace_configs']).is_a?(Array) + self.metric_namespace_configs = value + end + end + if attributes.key?(:'resource_collection_enabled') self.resource_collection_enabled = attributes[:'resource_collection_enabled'] end @@ -178,6 +189,7 @@ def ==(o) is_cspm_enabled == o.is_cspm_enabled && is_resource_change_collection_enabled == o.is_resource_change_collection_enabled && is_security_command_center_enabled == o.is_security_command_center_enabled && + metric_namespace_configs == o.metric_namespace_configs && resource_collection_enabled == o.resource_collection_enabled additional_properties == o.additional_properties end @@ -186,7 +198,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [account_tags, automute, client_email, cloud_run_revision_filters, host_filters, is_cspm_enabled, is_resource_change_collection_enabled, is_security_command_center_enabled, resource_collection_enabled].hash + [account_tags, automute, client_email, cloud_run_revision_filters, host_filters, is_cspm_enabled, is_resource_change_collection_enabled, is_security_command_center_enabled, metric_namespace_configs, resource_collection_enabled].hash end end end