Skip to content

Commit 618c9fb

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

6 files changed

Lines changed: 45 additions & 12 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

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

services/reference_tables/src/v2/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export { BatchDeleteRowsRequestData } from "./models/BatchDeleteRowsRequestData"
1717
export { BatchUpsertRowsRequestArray } from "./models/BatchUpsertRowsRequestArray";
1818
export { BatchUpsertRowsRequestData } from "./models/BatchUpsertRowsRequestData";
1919
export { BatchUpsertRowsRequestDataAttributes } from "./models/BatchUpsertRowsRequestDataAttributes";
20+
export { BatchUpsertRowsRequestDataAttributesValue } from "./models/BatchUpsertRowsRequestDataAttributesValue";
2021
export { CreateTableRequest } from "./models/CreateTableRequest";
2122
export { CreateTableRequestData } from "./models/CreateTableRequestData";
2223
export { CreateTableRequestDataAttributes } from "./models/CreateTableRequestDataAttributes";

services/reference_tables/src/v2/models/BatchUpsertRowsRequestDataAttributes.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { AttributeTypeMap } from "@datadog/datadog-api-client";
22

3+
import { BatchUpsertRowsRequestDataAttributesValue } from "./BatchUpsertRowsRequestDataAttributesValue";
4+
35
/**
46
* Attributes containing row data values for row creation or update operations.
57
*/
68
export class BatchUpsertRowsRequestDataAttributes {
79
/**
8-
* Key-value pairs representing row data, where keys are field names from the schema.
10+
* Key-value pairs representing row data, where keys are schema field names and values match the corresponding column types.
911
*/
10-
"values": { [key: string]: any };
12+
"values": { [key: string]: BatchUpsertRowsRequestDataAttributesValue };
1113
/**
1214
* A container for additional, undeclared properties.
1315
* This is a holder for any undeclared properties as specified with
@@ -25,7 +27,7 @@ export class BatchUpsertRowsRequestDataAttributes {
2527
static readonly attributeTypeMap: AttributeTypeMap = {
2628
values: {
2729
baseName: "values",
28-
type: "{ [key: string]: any; }",
30+
type: "{ [key: string]: BatchUpsertRowsRequestDataAttributesValue; }",
2931
required: true,
3032
},
3133
additionalProperties: {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { UnparsedObject } from "@datadog/datadog-api-client";
2+
3+
/**
4+
* Types allowed for Reference Table row values.
5+
*/
6+
export type BatchUpsertRowsRequestDataAttributesValue =
7+
| string
8+
| number
9+
| UnparsedObject;

services/reference_tables/src/v2/models/TypingInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const TypingInfo: ModelTypingInfo = {
9090
TableRowResourceDataType: ["row"],
9191
},
9292
oneOfMap: {
93+
BatchUpsertRowsRequestDataAttributesValue: ["string", "number"],
9394
CreateTableRequestDataAttributesFileMetadata: [
9495
"CreateTableRequestDataAttributesFileMetadataCloudStorage",
9596
"CreateTableRequestDataAttributesFileMetadataLocalFile",

0 commit comments

Comments
 (0)