Skip to content

Commit 9d68eec

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Specify accepted types for UpsertRows values (#3219)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent e04acc4 commit 9d68eec

7 files changed

Lines changed: 52 additions & 16 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7075,19 +7075,27 @@ components:
70757075
BatchUpsertRowsRequestDataAttributes:
70767076
description: Attributes containing row data values for row creation or update
70777077
operations.
7078+
example:
7079+
values: {}
70787080
properties:
70797081
values:
70807082
additionalProperties:
7081-
x-required-field: true
7082-
description: Key-value pairs representing row data, where keys are field
7083-
names from the schema.
7084-
example:
7085-
example_key_value: primary_key_value
7086-
name: row_name
7083+
$ref: '#/components/schemas/BatchUpsertRowsRequestDataAttributesValue'
7084+
description: Key-value pairs representing row data, where keys are schema
7085+
field names and values match the corresponding column types.
70877086
type: object
70887087
required:
70897088
- values
70907089
type: object
7090+
BatchUpsertRowsRequestDataAttributesValue:
7091+
description: Types allowed for Reference Table row values.
7092+
oneOf:
7093+
- example: row_name
7094+
type: string
7095+
- example: 25
7096+
format: int32
7097+
maximum: 2147483647
7098+
type: integer
70917099
BillConfig:
70927100
description: Bill config.
70937101
properties:
@@ -79483,6 +79491,18 @@ paths:
7948379491
requestBody:
7948479492
content:
7948579493
application/json:
79494+
examples:
79495+
happy_path:
79496+
summary: Upsert a row with mixed string and int values
79497+
value:
79498+
data:
79499+
- attributes:
79500+
values:
79501+
age: 25
79502+
example_key_value: primary_key_value
79503+
name: row_name
79504+
id: primary_key_value
79505+
type: row
7948679506
schema:
7948779507
$ref: '#/components/schemas/BatchUpsertRowsRequestArray'
7948879508
required: true

examples/v2/reference-tables/UpsertRows.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ const params: v2.ReferenceTablesApiUpsertRowsRequest = {
1212
data: [
1313
{
1414
attributes: {
15-
values: {
16-
example_key_value: "primary_key_value",
17-
name: "row_name",
18-
},
15+
values: {},
1916
},
2017
id: "primary_key_value",
2118
type: "row",

features/v2/reference_tables.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,22 @@ Feature: Reference Tables
148148
Scenario: Upsert rows returns "Bad Request" response
149149
Given new "UpsertRows" request
150150
And request contains "id" parameter from "REPLACE.ME"
151-
And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]}
151+
And body with value {"data": [{"attributes": {"values": {}}, "id": "primary_key_value", "type": "row"}]}
152152
When the request is sent
153153
Then the response status is 400 Bad Request
154154

155155
@generated @skip @team:DataDog/redapl-experiences
156156
Scenario: Upsert rows returns "Not Found" response
157157
Given new "UpsertRows" request
158158
And request contains "id" parameter from "REPLACE.ME"
159-
And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]}
159+
And body with value {"data": [{"attributes": {"values": {}}, "id": "primary_key_value", "type": "row"}]}
160160
When the request is sent
161161
Then the response status is 404 Not Found
162162

163163
@generated @skip @team:DataDog/redapl-experiences
164164
Scenario: Upsert rows returns "Rows created or updated successfully" response
165165
Given new "UpsertRows" request
166166
And request contains "id" parameter from "REPLACE.ME"
167-
And body with value {"data": [{"attributes": {"values": {"example_key_value": "primary_key_value", "name": "row_name"}}, "id": "primary_key_value", "type": "row"}]}
167+
And body with value {"data": [{"attributes": {"values": {}}, "id": "primary_key_value", "type": "row"}]}
168168
When the request is sent
169169
Then the response status is 200 Rows created or updated successfully

packages/datadog-api-client-v2/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,7 @@ export { BatchDeleteRowsRequestData } from "./models/BatchDeleteRowsRequestData"
13631363
export { BatchUpsertRowsRequestArray } from "./models/BatchUpsertRowsRequestArray";
13641364
export { BatchUpsertRowsRequestData } from "./models/BatchUpsertRowsRequestData";
13651365
export { BatchUpsertRowsRequestDataAttributes } from "./models/BatchUpsertRowsRequestDataAttributes";
1366+
export { BatchUpsertRowsRequestDataAttributesValue } from "./models/BatchUpsertRowsRequestDataAttributesValue";
13661367
export { BillConfig } from "./models/BillConfig";
13671368
export { BillingDimensionsMappingBodyItem } from "./models/BillingDimensionsMappingBodyItem";
13681369
export { BillingDimensionsMappingBodyItemAttributes } from "./models/BillingDimensionsMappingBodyItemAttributes";

packages/datadog-api-client-v2/models/BatchUpsertRowsRequestDataAttributes.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* This product includes software developed at Datadog (https://www.datadoghq.com/).
44
* Copyright 2020-Present Datadog, Inc.
55
*/
6+
import { BatchUpsertRowsRequestDataAttributesValue } from "./BatchUpsertRowsRequestDataAttributesValue";
67

78
import { AttributeTypeMap } from "../../datadog-api-client-common/util";
89

@@ -11,9 +12,9 @@ import { AttributeTypeMap } from "../../datadog-api-client-common/util";
1112
*/
1213
export class BatchUpsertRowsRequestDataAttributes {
1314
/**
14-
* Key-value pairs representing row data, where keys are field names from the schema.
15+
* Key-value pairs representing row data, where keys are schema field names and values match the corresponding column types.
1516
*/
16-
"values": { [key: string]: any };
17+
"values": { [key: string]: BatchUpsertRowsRequestDataAttributesValue };
1718

1819
/**
1920
* A container for additional, undeclared properties.
@@ -33,7 +34,7 @@ export class BatchUpsertRowsRequestDataAttributes {
3334
static readonly attributeTypeMap: AttributeTypeMap = {
3435
values: {
3536
baseName: "values",
36-
type: "{ [key: string]: any; }",
37+
type: "{ [key: string]: BatchUpsertRowsRequestDataAttributesValue; }",
3738
required: true,
3839
},
3940
additionalProperties: {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
7+
import { UnparsedObject } from "../../datadog-api-client-common/util";
8+
9+
/**
10+
* Types allowed for Reference Table row values.
11+
*/
12+
13+
export type BatchUpsertRowsRequestDataAttributesValue =
14+
| string
15+
| number
16+
| UnparsedObject;

packages/datadog-api-client-v2/models/ObjectSerializer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7965,6 +7965,7 @@ const oneOfMap: { [index: string]: string[] } = {
79657965
],
79667966
AzureCredentials: ["AzureTenant"],
79677967
AzureCredentialsUpdate: ["AzureTenantUpdate"],
7968+
BatchUpsertRowsRequestDataAttributesValue: ["string", "number"],
79687969
CIAppAggregateBucketValue: [
79697970
"string",
79707971
"number",

0 commit comments

Comments
 (0)