Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7075,19 +7075,27 @@ components:
BatchUpsertRowsRequestDataAttributes:
description: Attributes containing row data values for row creation or update
operations.
example:
values: {}
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
$ref: '#/components/schemas/BatchUpsertRowsRequestDataAttributesValue'
description: Key-value pairs representing row data, where keys are schema
field names and values match the corresponding column types.
type: object
required:
- values
type: object
BatchUpsertRowsRequestDataAttributesValue:
description: Types allowed for Reference Table row values.
oneOf:
- example: row_name
type: string
- example: 25
format: int32
maximum: 2147483647
type: integer
BillConfig:
description: Bill config.
properties:
Expand Down Expand Up @@ -79331,6 +79339,18 @@ paths:
requestBody:
content:
application/json:
examples:
happy_path:
summary: Upsert a row with mixed string and int values
value:
data:
- attributes:
values:
age: 25
example_key_value: primary_key_value
name: row_name
id: primary_key_value
type: row
schema:
$ref: '#/components/schemas/BatchUpsertRowsRequestArray'
required: true
Expand Down
4 changes: 1 addition & 3 deletions examples/v2/reference-tables/UpsertRows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
data: [
DatadogAPIClient::V2::BatchUpsertRowsRequestData.new({
attributes: DatadogAPIClient::V2::BatchUpsertRowsRequestDataAttributes.new({
values: {
example_key_value: "primary_key_value", name: "row_name",
},
values: {},
}),
id: "primary_key_value",
type: DatadogAPIClient::V2::TableRowResourceDataType::ROW,
Expand Down
6 changes: 3 additions & 3 deletions features/v2/reference_tables.feature
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,22 @@ Feature: Reference Tables
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"}]}
And body with value {"data": [{"attributes": {"values": {}}, "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"}]}
And body with value {"data": [{"attributes": {"values": {}}, "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"}]}
And body with value {"data": [{"attributes": {"values": {}}, "id": "primary_key_value", "type": "row"}]}
When the request is sent
Then the response status is 200 Rows created or updated successfully
1 change: 1 addition & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,7 @@ def overrides
"v2.batch_upsert_rows_request_array" => "BatchUpsertRowsRequestArray",
"v2.batch_upsert_rows_request_data" => "BatchUpsertRowsRequestData",
"v2.batch_upsert_rows_request_data_attributes" => "BatchUpsertRowsRequestDataAttributes",
"v2.batch_upsert_rows_request_data_attributes_value" => "BatchUpsertRowsRequestDataAttributesValue",
"v2.bill_config" => "BillConfig",
"v2.billing_dimensions_mapping_body_item" => "BillingDimensionsMappingBodyItem",
"v2.billing_dimensions_mapping_body_item_attributes" => "BillingDimensionsMappingBodyItemAttributes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module DatadogAPIClient::V2
class BatchUpsertRowsRequestDataAttributes
include BaseGenericModel

# Key-value pairs representing row data, where keys are field names from the schema.
# Key-value pairs representing row data, where keys are schema field names and values match the corresponding column types.
attr_reader :values

attr_accessor :additional_properties
Expand All @@ -38,7 +38,7 @@ def self.attribute_map
# @!visibility private
def self.openapi_types
{
:'values' => :'Hash<String, Object>'
:'values' => :'Hash<String, BatchUpsertRowsRequestDataAttributesValue>'
}
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
=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
# Types allowed for Reference Table row values.
module BatchUpsertRowsRequestDataAttributesValue
class << self
include BaseOneOfModel
include BaseOneOfModelNoDiscriminator

# List of class defined in oneOf (OpenAPI v3)
def openapi_one_of
[
:'String',
:'Integer'
]
end
# Builds the object
# @param data [Mixed] Data to be matched against the list of oneOf items
# @return [Object] Returns the model or the data itself
def build(data)
# Go through the list of oneOf items and attempt to identify the appropriate one.
# Note:
# - We do not attempt to check whether exactly one item matches.
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
# - TODO: scalar values are de facto behaving as if they were nullable.
# - TODO: logging when debugging is set.
openapi_one_of.each do |klass|
begin
next if klass == :AnyType # "nullable: true"
typed_data = find_and_cast_into_type(klass, data)
next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed
return typed_data if typed_data
rescue # rescue all errors so we keep iterating even if the current item lookup raises
end
end

if openapi_one_of.include?(:AnyType)
data
else
self._unparsed = true
DatadogAPIClient::UnparsedObject.new(data)
end
end
end
end
end
Loading