diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6e4cbaacff9..aba68e52a57 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -6806,6 +6806,72 @@ components: required: - data type: object + BatchDeleteRowsRequestArray: + description: The request body for deleting multiple rows from a reference table. + properties: + data: + items: + $ref: '#/components/schemas/BatchDeleteRowsRequestData' + maxItems: 200 + type: array + required: + - data + type: object + BatchDeleteRowsRequestData: + description: Row resource containing a single row identifier for deletion. + properties: + id: + example: primary_key_value + type: string + type: + $ref: '#/components/schemas/TableRowResourceDataType' + required: + - type + - id + type: object + BatchUpsertRowsRequestArray: + description: The request body for creating or updating multiple rows into a + reference table. + properties: + data: + items: + $ref: '#/components/schemas/BatchUpsertRowsRequestData' + maxItems: 200 + type: array + required: + - data + type: object + BatchUpsertRowsRequestData: + description: Row resource containing a single row identifier and its column + values. + properties: + attributes: + $ref: '#/components/schemas/BatchUpsertRowsRequestDataAttributes' + id: + example: primary_key_value + type: string + type: + $ref: '#/components/schemas/TableRowResourceDataType' + required: + - type + - id + type: object + BatchUpsertRowsRequestDataAttributes: + description: Attributes containing row data values for row creation or update + operations. + properties: + values: + additionalProperties: + x-required-field: true + description: Key-value pairs representing row data, where keys are field + names from the schema. + example: + example_key_value: primary_key_value + name: row_name + type: object + required: + - values + type: object BillConfig: description: Bill config. properties: @@ -74549,6 +74615,47 @@ paths: tags: - Reference Tables /api/v2/reference-tables/tables/{id}/rows: + delete: + description: Delete multiple rows from a Reference Table by their primary key + values. + operationId: DeleteRows + parameters: + - description: Unique identifier of the reference table to delete rows from + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/BatchDeleteRowsRequestArray' + required: true + responses: + '200': + description: Rows deleted successfully + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Delete rows + tags: + - Reference Tables get: description: Get reference table rows by their primary key values. operationId: GetRowsByID @@ -74593,6 +74700,48 @@ paths: summary: Get rows by id tags: - Reference Tables + post: + description: Create or update rows in a Reference Table by their primary key + values. If a row with the specified primary key exists, it is updated; otherwise, + a new row is created. + operationId: UpsertRows + parameters: + - description: Unique identifier of the reference table to upsert rows into + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/BatchUpsertRowsRequestArray' + required: true + responses: + '200': + description: Rows created or updated successfully + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Upsert rows + tags: + - Reference Tables /api/v2/reference-tables/uploads: post: description: Create a reference table upload for bulk data ingestion diff --git a/examples/v2/reference-tables/DeleteRows.rb b/examples/v2/reference-tables/DeleteRows.rb new file mode 100644 index 00000000000..15d9ef0bca3 --- /dev/null +++ b/examples/v2/reference-tables/DeleteRows.rb @@ -0,0 +1,14 @@ +# Delete rows returns "Rows deleted successfully" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ReferenceTablesAPI.new + +body = DatadogAPIClient::V2::BatchDeleteRowsRequestArray.new({ + data: [ + DatadogAPIClient::V2::BatchDeleteRowsRequestData.new({ + id: "primary_key_value", + type: DatadogAPIClient::V2::TableRowResourceDataType::ROW, + }), + ], +}) +p api_instance.delete_rows("id", body) diff --git a/examples/v2/reference-tables/UpsertRows.rb b/examples/v2/reference-tables/UpsertRows.rb new file mode 100644 index 00000000000..2be0aa5d10a --- /dev/null +++ b/examples/v2/reference-tables/UpsertRows.rb @@ -0,0 +1,19 @@ +# Upsert rows returns "Rows created or updated successfully" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ReferenceTablesAPI.new + +body = DatadogAPIClient::V2::BatchUpsertRowsRequestArray.new({ + data: [ + DatadogAPIClient::V2::BatchUpsertRowsRequestData.new({ + attributes: DatadogAPIClient::V2::BatchUpsertRowsRequestDataAttributes.new({ + values: { + example_key_value: "primary_key_value", name: "row_name", + }, + }), + id: "primary_key_value", + type: DatadogAPIClient::V2::TableRowResourceDataType::ROW, + }), + ], +}) +p api_instance.upsert_rows("id", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 15e1897d6c5..778a9ced238 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2752,10 +2752,18 @@ "id" => "String", "body" => "PatchTableRequest", }, + "v2.DeleteRows" => { + "id" => "String", + "body" => "BatchDeleteRowsRequestArray", + }, "v2.GetRowsByID" => { "id" => "String", "row_id" => "Array", }, + "v2.UpsertRows" => { + "id" => "String", + "body" => "BatchUpsertRowsRequestArray", + }, "v2.CreateReferenceTableUpload" => { "body" => "CreateUploadRequest", }, diff --git a/features/v2/reference_tables.feature b/features/v2/reference_tables.feature index fa3ea42360a..45a2861c15b 100644 --- a/features/v2/reference_tables.feature +++ b/features/v2/reference_tables.feature @@ -53,6 +53,30 @@ Feature: Reference Tables When the request is sent Then the response status is 400 Bad Request + @generated @skip @team:DataDog/redapl-experiences + Scenario: Delete rows returns "Bad Request" response + Given new "DeleteRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Delete rows returns "Not Found" response + Given new "DeleteRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Delete rows returns "Rows deleted successfully" response + Given new "DeleteRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 200 Rows deleted successfully + @generated @skip @team:DataDog/redapl-experiences Scenario: Delete table returns "Not Found" response Given new "DeleteTable" request @@ -119,3 +143,27 @@ Feature: Reference Tables And body with value {"data": {"attributes": {"description": "this is a cloud table generated via a cloud bucket sync", "file_metadata": {"access_details": {"aws_detail": {"aws_account_id": "test-account-id", "aws_bucket_name": "test-bucket", "file_path": "test_rt.csv"}}, "sync_enabled": true}, "schema": {"fields": [{"name": "id", "type": "INT32"}, {"name": "name", "type": "STRING"}], "primary_keys": ["id"]}, "sync_enabled": false, "tags": ["test_tag"]}, "type": "reference_table"}} When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Upsert rows returns "Bad Request" response + Given new "UpsertRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Upsert rows returns "Not Found" response + Given new "UpsertRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/redapl-experiences + Scenario: Upsert rows returns "Rows created or updated successfully" response + Given new "UpsertRows" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]} + When the request is sent + Then the response status is 200 Rows created or updated successfully diff --git a/features/v2/undo.json b/features/v2/undo.json index 3799e64e630..35580ed3fcd 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -3089,12 +3089,26 @@ "type": "idempotent" } }, + "DeleteRows": { + "tag": "Reference Tables", + "undo": { + "type": "idempotent" + } + }, "GetRowsByID": { "tag": "Reference Tables", "undo": { "type": "safe" } }, + "UpsertRows": { + "tag": "Reference Tables", + "undo": { + "operationId": "DeleteRows", + "parameters": [], + "type": "unsafe" + } + }, "CreateReferenceTableUpload": { "tag": "Reference Tables", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 427fdcf8659..3f62eaac177 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1305,6 +1305,11 @@ def overrides "v2.azure_uc_config_post_request_attributes" => "AzureUCConfigPostRequestAttributes", "v2.azure_uc_config_post_request_type" => "AzureUCConfigPostRequestType", "v2.azure_uc_configs_response" => "AzureUCConfigsResponse", + "v2.batch_delete_rows_request_array" => "BatchDeleteRowsRequestArray", + "v2.batch_delete_rows_request_data" => "BatchDeleteRowsRequestData", + "v2.batch_upsert_rows_request_array" => "BatchUpsertRowsRequestArray", + "v2.batch_upsert_rows_request_data" => "BatchUpsertRowsRequestData", + "v2.batch_upsert_rows_request_data_attributes" => "BatchUpsertRowsRequestDataAttributes", "v2.bill_config" => "BillConfig", "v2.billing_dimensions_mapping_body_item" => "BillingDimensionsMappingBodyItem", "v2.billing_dimensions_mapping_body_item_attributes" => "BillingDimensionsMappingBodyItemAttributes", diff --git a/lib/datadog_api_client/v2/api/reference_tables_api.rb b/lib/datadog_api_client/v2/api/reference_tables_api.rb index 42e2634de58..3d9c49d3da9 100644 --- a/lib/datadog_api_client/v2/api/reference_tables_api.rb +++ b/lib/datadog_api_client/v2/api/reference_tables_api.rb @@ -161,6 +161,78 @@ def create_reference_table_upload_with_http_info(body, opts = {}) return data, status_code, headers end + # Delete rows. + # + # @see #delete_rows_with_http_info + def delete_rows(id, body, opts = {}) + delete_rows_with_http_info(id, body, opts) + nil + end + + # Delete rows. + # + # Delete multiple rows from a Reference Table by their primary key values. + # + # @param id [String] Unique identifier of the reference table to delete rows from + # @param body [BatchDeleteRowsRequestArray] + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_rows_with_http_info(id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ReferenceTablesAPI.delete_rows ...' + end + # verify the required parameter 'id' is set + if @api_client.config.client_side_validation && id.nil? + fail ArgumentError, "Missing the required parameter 'id' when calling ReferenceTablesAPI.delete_rows" + 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 ReferenceTablesAPI.delete_rows" + end + # resource path + local_var_path = '/api/v2/reference-tables/tables/{id}/rows'.sub('{id}', CGI.escape(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(['*/*']) + # 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] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :delete_rows, + :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::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ReferenceTablesAPI#delete_rows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete table. # # @see #delete_table_with_http_info @@ -519,5 +591,77 @@ def update_reference_table_with_http_info(id, body, opts = {}) end return data, status_code, headers end + + # Upsert rows. + # + # @see #upsert_rows_with_http_info + def upsert_rows(id, body, opts = {}) + upsert_rows_with_http_info(id, body, opts) + nil + end + + # Upsert rows. + # + # Create or update rows in a Reference Table by their primary key values. If a row with the specified primary key exists, it is updated; otherwise, a new row is created. + # + # @param id [String] Unique identifier of the reference table to upsert rows into + # @param body [BatchUpsertRowsRequestArray] + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def upsert_rows_with_http_info(id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ReferenceTablesAPI.upsert_rows ...' + end + # verify the required parameter 'id' is set + if @api_client.config.client_side_validation && id.nil? + fail ArgumentError, "Missing the required parameter 'id' when calling ReferenceTablesAPI.upsert_rows" + 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 ReferenceTablesAPI.upsert_rows" + end + # resource path + local_var_path = '/api/v2/reference-tables/tables/{id}/rows'.sub('{id}', CGI.escape(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(['*/*']) + # 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] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :upsert_rows, + :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::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ReferenceTablesAPI#upsert_rows\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/batch_delete_rows_request_array.rb b/lib/datadog_api_client/v2/models/batch_delete_rows_request_array.rb new file mode 100644 index 00000000000..e2603d2db05 --- /dev/null +++ b/lib/datadog_api_client/v2/models/batch_delete_rows_request_array.rb @@ -0,0 +1,129 @@ +=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 + # The request body for deleting multiple rows from a reference table. + class BatchDeleteRowsRequestArray + include BaseGenericModel + + # + 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' => :'Array' + } + 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::BatchDeleteRowsRequestArray` 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') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + 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? + return false if @data.length > 200 + 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 + if data.length > 200 + fail ArgumentError, 'invalid value for "data", number of items must be less than or equal to 200.' + 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/batch_delete_rows_request_data.rb b/lib/datadog_api_client/v2/models/batch_delete_rows_request_data.rb new file mode 100644 index 00000000000..887085c067c --- /dev/null +++ b/lib/datadog_api_client/v2/models/batch_delete_rows_request_data.rb @@ -0,0 +1,144 @@ +=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 + # Row resource containing a single row identifier for deletion. + class BatchDeleteRowsRequestData + include BaseGenericModel + + # + attr_reader :id + + # Row resource type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'String', + :'type' => :'TableRowResourceDataType' + } + 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::BatchDeleteRowsRequestData` 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?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + 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 @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + 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 && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/batch_upsert_rows_request_array.rb b/lib/datadog_api_client/v2/models/batch_upsert_rows_request_array.rb new file mode 100644 index 00000000000..684fe7f83ee --- /dev/null +++ b/lib/datadog_api_client/v2/models/batch_upsert_rows_request_array.rb @@ -0,0 +1,129 @@ +=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 + # The request body for creating or updating multiple rows into a reference table. + class BatchUpsertRowsRequestArray + include BaseGenericModel + + # + 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' => :'Array' + } + 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::BatchUpsertRowsRequestArray` 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') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + 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? + return false if @data.length > 200 + 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 + if data.length > 200 + fail ArgumentError, 'invalid value for "data", number of items must be less than or equal to 200.' + 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/batch_upsert_rows_request_data.rb b/lib/datadog_api_client/v2/models/batch_upsert_rows_request_data.rb new file mode 100644 index 00000000000..ceac19ced44 --- /dev/null +++ b/lib/datadog_api_client/v2/models/batch_upsert_rows_request_data.rb @@ -0,0 +1,154 @@ +=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 + # Row resource containing a single row identifier and its column values. + class BatchUpsertRowsRequestData + include BaseGenericModel + + # Attributes containing row data values for row creation or update operations. + attr_accessor :attributes + + # + attr_reader :id + + # Row resource type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'BatchUpsertRowsRequestDataAttributes', + :'id' => :'String', + :'type' => :'TableRowResourceDataType' + } + 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::BatchUpsertRowsRequestData` 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?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + 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 @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + 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 && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/batch_upsert_rows_request_data_attributes.rb b/lib/datadog_api_client/v2/models/batch_upsert_rows_request_data_attributes.rb new file mode 100644 index 00000000000..e98f807a8b9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/batch_upsert_rows_request_data_attributes.rb @@ -0,0 +1,123 @@ +=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 + # Attributes containing row data values for row creation or update operations. + class BatchUpsertRowsRequestDataAttributes + include BaseGenericModel + + # Key-value pairs representing row data, where keys are field names from the schema. + attr_reader :values + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'values' => :'values' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'values' => :'Hash' + } + 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::BatchUpsertRowsRequestDataAttributes` 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?(:'values') + self.values = attributes[:'values'] + 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 @values.nil? + true + end + + # Custom attribute writer method with validation + # @param values [Object] Object to be assigned + # @!visibility private + def values=(values) + if values.nil? + fail ArgumentError, 'invalid value for "values", values cannot be nil.' + end + @values = values + 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 && + values == o.values && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [values, additional_properties].hash + end + end +end