Skip to content

Commit 6394fef

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Row Update Endpoints to Reference Tables API spec (#3021)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 48ecc08 commit 6394fef

File tree

14 files changed

+876
-0
lines changed

14 files changed

+876
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6900,6 +6900,72 @@ components:
69006900
required:
69016901
- data
69026902
type: object
6903+
BatchDeleteRowsRequestArray:
6904+
description: The request body for deleting multiple rows from a reference table.
6905+
properties:
6906+
data:
6907+
items:
6908+
$ref: '#/components/schemas/BatchDeleteRowsRequestData'
6909+
maxItems: 200
6910+
type: array
6911+
required:
6912+
- data
6913+
type: object
6914+
BatchDeleteRowsRequestData:
6915+
description: Row resource containing a single row identifier for deletion.
6916+
properties:
6917+
id:
6918+
example: primary_key_value
6919+
type: string
6920+
type:
6921+
$ref: '#/components/schemas/TableRowResourceDataType'
6922+
required:
6923+
- type
6924+
- id
6925+
type: object
6926+
BatchUpsertRowsRequestArray:
6927+
description: The request body for creating or updating multiple rows into a
6928+
reference table.
6929+
properties:
6930+
data:
6931+
items:
6932+
$ref: '#/components/schemas/BatchUpsertRowsRequestData'
6933+
maxItems: 200
6934+
type: array
6935+
required:
6936+
- data
6937+
type: object
6938+
BatchUpsertRowsRequestData:
6939+
description: Row resource containing a single row identifier and its column
6940+
values.
6941+
properties:
6942+
attributes:
6943+
$ref: '#/components/schemas/BatchUpsertRowsRequestDataAttributes'
6944+
id:
6945+
example: primary_key_value
6946+
type: string
6947+
type:
6948+
$ref: '#/components/schemas/TableRowResourceDataType'
6949+
required:
6950+
- type
6951+
- id
6952+
type: object
6953+
BatchUpsertRowsRequestDataAttributes:
6954+
description: Attributes containing row data values for row creation or update
6955+
operations.
6956+
properties:
6957+
values:
6958+
additionalProperties:
6959+
x-required-field: true
6960+
description: Key-value pairs representing row data, where keys are field
6961+
names from the schema.
6962+
example:
6963+
example_key_value: primary_key_value
6964+
name: row_name
6965+
type: object
6966+
required:
6967+
- values
6968+
type: object
69036969
BillConfig:
69046970
description: Bill config.
69056971
properties:
@@ -76823,6 +76889,47 @@ paths:
7682376889
tags:
7682476890
- Reference Tables
7682576891
/api/v2/reference-tables/tables/{id}/rows:
76892+
delete:
76893+
description: Delete multiple rows from a Reference Table by their primary key
76894+
values.
76895+
operationId: DeleteRows
76896+
parameters:
76897+
- description: Unique identifier of the reference table to delete rows from
76898+
in: path
76899+
name: id
76900+
required: true
76901+
schema:
76902+
type: string
76903+
requestBody:
76904+
content:
76905+
application/json:
76906+
schema:
76907+
$ref: '#/components/schemas/BatchDeleteRowsRequestArray'
76908+
required: true
76909+
responses:
76910+
'200':
76911+
description: Rows deleted successfully
76912+
'400':
76913+
$ref: '#/components/responses/BadRequestResponse'
76914+
'403':
76915+
$ref: '#/components/responses/ForbiddenResponse'
76916+
'404':
76917+
$ref: '#/components/responses/NotFoundResponse'
76918+
'429':
76919+
$ref: '#/components/responses/TooManyRequestsResponse'
76920+
'500':
76921+
content:
76922+
application/json:
76923+
schema:
76924+
$ref: '#/components/schemas/APIErrorResponse'
76925+
description: Internal Server Error
76926+
security:
76927+
- apiKeyAuth: []
76928+
appKeyAuth: []
76929+
- AuthZ: []
76930+
summary: Delete rows
76931+
tags:
76932+
- Reference Tables
7682676933
get:
7682776934
description: Get reference table rows by their primary key values.
7682876935
operationId: GetRowsByID
@@ -76867,6 +76974,48 @@ paths:
7686776974
summary: Get rows by id
7686876975
tags:
7686976976
- Reference Tables
76977+
post:
76978+
description: Create or update rows in a Reference Table by their primary key
76979+
values. If a row with the specified primary key exists, it is updated; otherwise,
76980+
a new row is created.
76981+
operationId: UpsertRows
76982+
parameters:
76983+
- description: Unique identifier of the reference table to upsert rows into
76984+
in: path
76985+
name: id
76986+
required: true
76987+
schema:
76988+
type: string
76989+
requestBody:
76990+
content:
76991+
application/json:
76992+
schema:
76993+
$ref: '#/components/schemas/BatchUpsertRowsRequestArray'
76994+
required: true
76995+
responses:
76996+
'200':
76997+
description: Rows created or updated successfully
76998+
'400':
76999+
$ref: '#/components/responses/BadRequestResponse'
77000+
'403':
77001+
$ref: '#/components/responses/ForbiddenResponse'
77002+
'404':
77003+
$ref: '#/components/responses/NotFoundResponse'
77004+
'429':
77005+
$ref: '#/components/responses/TooManyRequestsResponse'
77006+
'500':
77007+
content:
77008+
application/json:
77009+
schema:
77010+
$ref: '#/components/schemas/APIErrorResponse'
77011+
description: Internal Server Error
77012+
security:
77013+
- apiKeyAuth: []
77014+
appKeyAuth: []
77015+
- AuthZ: []
77016+
summary: Upsert rows
77017+
tags:
77018+
- Reference Tables
7687077019
/api/v2/reference-tables/uploads:
7687177020
post:
7687277021
description: Create a reference table upload for bulk data ingestion
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Delete rows returns "Rows deleted successfully" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.ReferenceTablesApi(configuration);
9+
10+
const params: v2.ReferenceTablesApiDeleteRowsRequest = {
11+
body: {
12+
data: [
13+
{
14+
id: "primary_key_value",
15+
type: "row",
16+
},
17+
],
18+
},
19+
id: "id",
20+
};
21+
22+
apiInstance
23+
.deleteRows(params)
24+
.then((data: any) => {
25+
console.log(
26+
"API called successfully. Returned data: " + JSON.stringify(data)
27+
);
28+
})
29+
.catch((error: any) => console.error(error));
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Upsert rows returns "Rows created or updated successfully" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.ReferenceTablesApi(configuration);
9+
10+
const params: v2.ReferenceTablesApiUpsertRowsRequest = {
11+
body: {
12+
data: [
13+
{
14+
attributes: {
15+
values: {
16+
example_key_value: "primary_key_value",
17+
name: "row_name",
18+
},
19+
},
20+
id: "primary_key_value",
21+
type: "row",
22+
},
23+
],
24+
},
25+
id: "id",
26+
};
27+
28+
apiInstance
29+
.upsertRows(params)
30+
.then((data: any) => {
31+
console.log(
32+
"API called successfully. Returned data: " + JSON.stringify(data)
33+
);
34+
})
35+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7973,6 +7973,28 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
79737973
},
79747974
"operationResponseType": "TableRowResourceArray",
79757975
},
7976+
"v2.UpsertRows": {
7977+
"id": {
7978+
"type": "string",
7979+
"format": "",
7980+
},
7981+
"body": {
7982+
"type": "BatchUpsertRowsRequestArray",
7983+
"format": "",
7984+
},
7985+
"operationResponseType": "{}",
7986+
},
7987+
"v2.DeleteRows": {
7988+
"id": {
7989+
"type": "string",
7990+
"format": "",
7991+
},
7992+
"body": {
7993+
"type": "BatchDeleteRowsRequestArray",
7994+
"format": "",
7995+
},
7996+
"operationResponseType": "{}",
7997+
},
79767998
"v2.CreateReferenceTableUpload": {
79777999
"body": {
79788000
"type": "CreateUploadRequest",

features/v2/reference_tables.feature

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,30 @@ Feature: Reference Tables
5353
When the request is sent
5454
Then the response status is 400 Bad Request
5555

56+
@generated @skip @team:DataDog/redapl-experiences
57+
Scenario: Delete rows returns "Bad Request" response
58+
Given new "DeleteRows" request
59+
And request contains "id" parameter from "REPLACE.ME"
60+
And body with value {"data": [{"id": "primary_key_value", "type": "row"}]}
61+
When the request is sent
62+
Then the response status is 400 Bad Request
63+
64+
@generated @skip @team:DataDog/redapl-experiences
65+
Scenario: Delete rows returns "Not Found" response
66+
Given new "DeleteRows" request
67+
And request contains "id" parameter from "REPLACE.ME"
68+
And body with value {"data": [{"id": "primary_key_value", "type": "row"}]}
69+
When the request is sent
70+
Then the response status is 404 Not Found
71+
72+
@generated @skip @team:DataDog/redapl-experiences
73+
Scenario: Delete rows returns "Rows deleted successfully" response
74+
Given new "DeleteRows" request
75+
And request contains "id" parameter from "REPLACE.ME"
76+
And body with value {"data": [{"id": "primary_key_value", "type": "row"}]}
77+
When the request is sent
78+
Then the response status is 200 Rows deleted successfully
79+
5680
@generated @skip @team:DataDog/redapl-experiences
5781
Scenario: Delete table returns "Not Found" response
5882
Given new "DeleteTable" request
@@ -119,3 +143,27 @@ Feature: Reference Tables
119143
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"}}
120144
When the request is sent
121145
Then the response status is 200 OK
146+
147+
@generated @skip @team:DataDog/redapl-experiences
148+
Scenario: Upsert rows returns "Bad Request" response
149+
Given new "UpsertRows" request
150+
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"}]}
152+
When the request is sent
153+
Then the response status is 400 Bad Request
154+
155+
@generated @skip @team:DataDog/redapl-experiences
156+
Scenario: Upsert rows returns "Not Found" response
157+
Given new "UpsertRows" request
158+
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"}]}
160+
When the request is sent
161+
Then the response status is 404 Not Found
162+
163+
@generated @skip @team:DataDog/redapl-experiences
164+
Scenario: Upsert rows returns "Rows created or updated successfully" response
165+
Given new "UpsertRows" request
166+
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"}]}
168+
When the request is sent
169+
Then the response status is 200 Rows created or updated successfully

features/v2/undo.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3174,12 +3174,26 @@
31743174
"type": "idempotent"
31753175
}
31763176
},
3177+
"DeleteRows": {
3178+
"tag": "Reference Tables",
3179+
"undo": {
3180+
"type": "idempotent"
3181+
}
3182+
},
31773183
"GetRowsByID": {
31783184
"tag": "Reference Tables",
31793185
"undo": {
31803186
"type": "safe"
31813187
}
31823188
},
3189+
"UpsertRows": {
3190+
"tag": "Reference Tables",
3191+
"undo": {
3192+
"operationId": "DeleteRows",
3193+
"parameters": [],
3194+
"type": "unsafe"
3195+
}
3196+
},
31833197
"CreateReferenceTableUpload": {
31843198
"tag": "Reference Tables",
31853199
"undo": {

0 commit comments

Comments
 (0)