From ad254c90ca758ded7c7ec9c2bea1a4143a138534 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Fri, 25 Jul 2025 18:45:25 +0000 Subject: [PATCH] Uncomment edit dataset block, add dataset limitations into endpoint descriptions (#2559) Co-authored-by: ci.datadog-api-spec --- .generated-info | 4 +- .generator/schemas/v2/openapi.yaml | 60 +++++++- examples/v2/datasets/UpdateDataset.rb | 27 ++++ features/scenarios_model_mapping.rb | 4 + features/v2/datasets.feature | 24 ++++ features/v2/undo.json | 6 + lib/datadog_api_client/inflector.rb | 1 + lib/datadog_api_client/v2/api/datasets_api.rb | 72 ++++++++++ lib/datadog_api_client/v2/models/dataset.rb | 12 ++ .../v2/models/dataset_create_request.rb | 12 ++ .../v2/models/dataset_response_single.rb | 12 ++ .../v2/models/dataset_update_request.rb | 135 ++++++++++++++++++ .../v2/models/filters_per_product.rb | 4 +- 13 files changed, 365 insertions(+), 8 deletions(-) create mode 100644 examples/v2/datasets/UpdateDataset.rb create mode 100644 lib/datadog_api_client/v2/models/dataset_update_request.rb diff --git a/.generated-info b/.generated-info index 1a9005895097..db2daa7bdddb 100644 --- a/.generated-info +++ b/.generated-info @@ -1,4 +1,4 @@ { - "spec_repo_commit": "d51e9a8", - "generated": "2025-07-25 13:23:07.308" + "spec_repo_commit": "e4f653f", + "generated": "2025-07-25 14:07:18.059" } diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index db8036425c49..64cfcb7b7c4d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -12478,7 +12478,14 @@ components: - type type: object Dataset: - description: Dataset object. + description: "Dataset object.\n\n### Datasets Constraints\n- **Tag Limit per + Dataset**:\n - Each restricted dataset supports a maximum of 10 key:value + pairs per product.\n\n- **Tag Key Rules per Telemetry Type**:\n - Only one + tag key or attribute may be used to define access within a single telemetry + type.\n - The same or different tag key may be used across different telemetry + types.\n\n- **Tag Value Uniqueness**:\n - Tag values must be unique within + a single dataset.\n - A tag value used in one dataset cannot be reused in + another dataset of the same telemetry type." properties: attributes: $ref: '#/components/schemas/DatasetAttributes' @@ -12556,6 +12563,14 @@ components: required: - data type: object + DatasetUpdateRequest: + description: Edit request for a dataset. + properties: + data: + $ref: '#/components/schemas/Dataset' + required: + - data + type: object Date: description: Date as Unix timestamp in milliseconds. example: 1722439510282 @@ -16083,10 +16098,9 @@ components: type: array product: description: 'Name of the product the dataset is for. Possible values are - ''apm'', ''rum'', ''synthetics'', + ''apm'', ''rum'', - ''metrics'', ''logs'', ''sd_repoinfo'', ''error_tracking'', ''cloud_cost'', - and ''ml_obs''.' + ''metrics'', ''logs'', ''error_tracking'', and ''cloud_cost''.' example: logs type: string required: @@ -48282,6 +48296,44 @@ paths: x-permission: operator: OPEN permissions: [] + put: + description: Edits the dataset associated with the ID. + operationId: UpdateDataset + parameters: + - $ref: '#/components/parameters/DatasetID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DatasetUpdateRequest' + description: Dataset payload + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DatasetResponseSingle' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Edit a dataset + tags: + - Datasets + x-codegen-request-body-name: body + x-permission: + operator: OPEN + permissions: [] /api/v2/deletion/data/{product}: post: description: Creates a data deletion request by providing a query and a timeframe diff --git a/examples/v2/datasets/UpdateDataset.rb b/examples/v2/datasets/UpdateDataset.rb new file mode 100644 index 000000000000..fc90783fd15e --- /dev/null +++ b/examples/v2/datasets/UpdateDataset.rb @@ -0,0 +1,27 @@ +# Edit a dataset returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::DatasetsAPI.new + +body = DatadogAPIClient::V2::DatasetUpdateRequest.new({ + data: DatadogAPIClient::V2::Dataset.new({ + attributes: DatadogAPIClient::V2::DatasetAttributes.new({ + created_at: nil, + name: "Security Audit Dataset", + principals: [ + "role:86245fce-0a4e-11f0-92bd-da7ad0900002", + ], + product_filters: [ + DatadogAPIClient::V2::FiltersPerProduct.new({ + filters: [ + "@application.id:ABCD", + ], + product: "logs", + }), + ], + }), + id: "123e4567-e89b-12d3-a456-426614174000", + type: "dataset", + }), +}) +p api_instance.update_dataset("dataset_id", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 44a43ef961fe..b7f116247c7b 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -1598,6 +1598,10 @@ "v2.GetDataset" => { "dataset_id" => "String", }, + "v2.UpdateDataset" => { + "dataset_id" => "String", + "body" => "DatasetUpdateRequest", + }, "v2.CreateDataDeletionRequest" => { "product" => "String", "body" => "CreateDataDeletionRequestBody", diff --git a/features/v2/datasets.feature b/features/v2/datasets.feature index 7ce2e160a374..4a220a3c8450 100644 --- a/features/v2/datasets.feature +++ b/features/v2/datasets.feature @@ -53,6 +53,30 @@ Feature: Datasets When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/aaa-granular-access + Scenario: Edit a dataset returns "Bad Request" response + Given new "UpdateDataset" request + And request contains "dataset_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"created_at": null, "name": "Security Audit Dataset", "principals": ["role:86245fce-0a4e-11f0-92bd-da7ad0900002"], "product_filters": [{"filters": ["@application.id:ABCD"], "product": "logs"}]}, "id": "123e4567-e89b-12d3-a456-426614174000", "type": "dataset"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-granular-access + Scenario: Edit a dataset returns "Not Found" response + Given new "UpdateDataset" request + And request contains "dataset_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"created_at": null, "name": "Security Audit Dataset", "principals": ["role:86245fce-0a4e-11f0-92bd-da7ad0900002"], "product_filters": [{"filters": ["@application.id:ABCD"], "product": "logs"}]}, "id": "123e4567-e89b-12d3-a456-426614174000", "type": "dataset"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/aaa-granular-access + Scenario: Edit a dataset returns "OK" response + Given new "UpdateDataset" request + And request contains "dataset_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"created_at": null, "name": "Security Audit Dataset", "principals": ["role:86245fce-0a4e-11f0-92bd-da7ad0900002"], "product_filters": [{"filters": ["@application.id:ABCD"], "product": "logs"}]}, "id": "123e4567-e89b-12d3-a456-426614174000", "type": "dataset"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/aaa-granular-access Scenario: Get a single dataset by ID returns "Bad Request" response Given new "GetDataset" request diff --git a/features/v2/undo.json b/features/v2/undo.json index a75ff96853d2..a1fe13fed9d0 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -888,6 +888,12 @@ "type": "safe" } }, + "UpdateDataset": { + "tag": "Datasets", + "undo": { + "type": "idempotent" + } + }, "CreateDataDeletionRequest": { "tag": "Data Deletion", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 1b48b4d5f240..373ba37f102c 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1623,6 +1623,7 @@ def overrides "v2.dataset_create_request" => "DatasetCreateRequest", "v2.dataset_response_multi" => "DatasetResponseMulti", "v2.dataset_response_single" => "DatasetResponseSingle", + "v2.dataset_update_request" => "DatasetUpdateRequest", "v2.data_transform" => "DataTransform", "v2.data_transform_properties" => "DataTransformProperties", "v2.data_transform_type" => "DataTransformType", diff --git a/lib/datadog_api_client/v2/api/datasets_api.rb b/lib/datadog_api_client/v2/api/datasets_api.rb index b7e57a9d3611..54ff85eef6e2 100644 --- a/lib/datadog_api_client/v2/api/datasets_api.rb +++ b/lib/datadog_api_client/v2/api/datasets_api.rb @@ -279,5 +279,77 @@ def get_dataset_with_http_info(dataset_id, opts = {}) end return data, status_code, headers end + + # Edit a dataset. + # + # @see #update_dataset_with_http_info + def update_dataset(dataset_id, body, opts = {}) + data, _status_code, _headers = update_dataset_with_http_info(dataset_id, body, opts) + data + end + + # Edit a dataset. + # + # Edits the dataset associated with the ID. + # + # @param dataset_id [String] The ID of a defined dataset. + # @param body [DatasetUpdateRequest] Dataset payload + # @param opts [Hash] the optional parameters + # @return [Array<(DatasetResponseSingle, Integer, Hash)>] DatasetResponseSingle data, response status code and response headers + def update_dataset_with_http_info(dataset_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: DatasetsAPI.update_dataset ...' + end + # verify the required parameter 'dataset_id' is set + if @api_client.config.client_side_validation && dataset_id.nil? + fail ArgumentError, "Missing the required parameter 'dataset_id' when calling DatasetsAPI.update_dataset" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling DatasetsAPI.update_dataset" + end + # resource path + local_var_path = '/api/v2/datasets/{dataset_id}'.sub('{dataset_id}', CGI.escape(dataset_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'DatasetResponseSingle' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :update_dataset, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: DatasetsAPI#update_dataset\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/dataset.rb b/lib/datadog_api_client/v2/models/dataset.rb index f079937a77ce..4a59d5e62b6c 100644 --- a/lib/datadog_api_client/v2/models/dataset.rb +++ b/lib/datadog_api_client/v2/models/dataset.rb @@ -18,6 +18,18 @@ module DatadogAPIClient::V2 # Dataset object. + # + # ### Datasets Constraints + # - **Tag Limit per Dataset**: + # - Each restricted dataset supports a maximum of 10 key:value pairs per product. + # + # - **Tag Key Rules per Telemetry Type**: + # - Only one tag key or attribute may be used to define access within a single telemetry type. + # - The same or different tag key may be used across different telemetry types. + # + # - **Tag Value Uniqueness**: + # - Tag values must be unique within a single dataset. + # - A tag value used in one dataset cannot be reused in another dataset of the same telemetry type. class Dataset include BaseGenericModel diff --git a/lib/datadog_api_client/v2/models/dataset_create_request.rb b/lib/datadog_api_client/v2/models/dataset_create_request.rb index b73c81bf6b42..640d21d4a5d2 100644 --- a/lib/datadog_api_client/v2/models/dataset_create_request.rb +++ b/lib/datadog_api_client/v2/models/dataset_create_request.rb @@ -22,6 +22,18 @@ class DatasetCreateRequest include BaseGenericModel # Dataset object. + # + # ### Datasets Constraints + # - **Tag Limit per Dataset**: + # - Each restricted dataset supports a maximum of 10 key:value pairs per product. + # + # - **Tag Key Rules per Telemetry Type**: + # - Only one tag key or attribute may be used to define access within a single telemetry type. + # - The same or different tag key may be used across different telemetry types. + # + # - **Tag Value Uniqueness**: + # - Tag values must be unique within a single dataset. + # - A tag value used in one dataset cannot be reused in another dataset of the same telemetry type. attr_reader :data attr_accessor :additional_properties diff --git a/lib/datadog_api_client/v2/models/dataset_response_single.rb b/lib/datadog_api_client/v2/models/dataset_response_single.rb index a358d950714d..51baf44c264c 100644 --- a/lib/datadog_api_client/v2/models/dataset_response_single.rb +++ b/lib/datadog_api_client/v2/models/dataset_response_single.rb @@ -22,6 +22,18 @@ class DatasetResponseSingle include BaseGenericModel # Dataset object. + # + # ### Datasets Constraints + # - **Tag Limit per Dataset**: + # - Each restricted dataset supports a maximum of 10 key:value pairs per product. + # + # - **Tag Key Rules per Telemetry Type**: + # - Only one tag key or attribute may be used to define access within a single telemetry type. + # - The same or different tag key may be used across different telemetry types. + # + # - **Tag Value Uniqueness**: + # - Tag values must be unique within a single dataset. + # - A tag value used in one dataset cannot be reused in another dataset of the same telemetry type. attr_reader :data attr_accessor :additional_properties diff --git a/lib/datadog_api_client/v2/models/dataset_update_request.rb b/lib/datadog_api_client/v2/models/dataset_update_request.rb new file mode 100644 index 000000000000..f6cdd4697106 --- /dev/null +++ b/lib/datadog_api_client/v2/models/dataset_update_request.rb @@ -0,0 +1,135 @@ +=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 + # Edit request for a dataset. + class DatasetUpdateRequest + include BaseGenericModel + + # Dataset object. + # + # ### Datasets Constraints + # - **Tag Limit per Dataset**: + # - Each restricted dataset supports a maximum of 10 key:value pairs per product. + # + # - **Tag Key Rules per Telemetry Type**: + # - Only one tag key or attribute may be used to define access within a single telemetry type. + # - The same or different tag key may be used across different telemetry types. + # + # - **Tag Value Uniqueness**: + # - Tag values must be unique within a single dataset. + # - A tag value used in one dataset cannot be reused in another dataset of the same telemetry type. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Dataset' + } + 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::DatasetUpdateRequest` 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?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + 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 && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/filters_per_product.rb b/lib/datadog_api_client/v2/models/filters_per_product.rb index 5fa5015c7cab..8946daa0cc7b 100644 --- a/lib/datadog_api_client/v2/models/filters_per_product.rb +++ b/lib/datadog_api_client/v2/models/filters_per_product.rb @@ -27,8 +27,8 @@ class FiltersPerProduct # per telemetry type. attr_reader :filters - # Name of the product the dataset is for. Possible values are 'apm', 'rum', 'synthetics', - # 'metrics', 'logs', 'sd_repoinfo', 'error_tracking', 'cloud_cost', and 'ml_obs'. + # Name of the product the dataset is for. Possible values are 'apm', 'rum', + # 'metrics', 'logs', 'error_tracking', and 'cloud_cost'. attr_reader :product attr_accessor :additional_properties