Skip to content

Commit 3208c01

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Row Update Endpoints to Reference Tables API spec (#2956)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 0004175 commit 3208c01

File tree

13 files changed

+663
-0
lines changed

13 files changed

+663
-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

docs/datadog_api_client.v2.model.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,41 @@ datadog\_api\_client.v2.model.azure\_uc\_configs\_response module
25102510
:members:
25112511
:show-inheritance:
25122512

2513+
datadog\_api\_client.v2.model.batch\_delete\_rows\_request\_array module
2514+
------------------------------------------------------------------------
2515+
2516+
.. automodule:: datadog_api_client.v2.model.batch_delete_rows_request_array
2517+
:members:
2518+
:show-inheritance:
2519+
2520+
datadog\_api\_client.v2.model.batch\_delete\_rows\_request\_data module
2521+
-----------------------------------------------------------------------
2522+
2523+
.. automodule:: datadog_api_client.v2.model.batch_delete_rows_request_data
2524+
:members:
2525+
:show-inheritance:
2526+
2527+
datadog\_api\_client.v2.model.batch\_upsert\_rows\_request\_array module
2528+
------------------------------------------------------------------------
2529+
2530+
.. automodule:: datadog_api_client.v2.model.batch_upsert_rows_request_array
2531+
:members:
2532+
:show-inheritance:
2533+
2534+
datadog\_api\_client.v2.model.batch\_upsert\_rows\_request\_data module
2535+
-----------------------------------------------------------------------
2536+
2537+
.. automodule:: datadog_api_client.v2.model.batch_upsert_rows_request_data
2538+
:members:
2539+
:show-inheritance:
2540+
2541+
datadog\_api\_client.v2.model.batch\_upsert\_rows\_request\_data\_attributes module
2542+
-----------------------------------------------------------------------------------
2543+
2544+
.. automodule:: datadog_api_client.v2.model.batch_upsert_rows_request_data_attributes
2545+
:members:
2546+
:show-inheritance:
2547+
25132548
datadog\_api\_client.v2.model.bill\_config module
25142549
-------------------------------------------------
25152550

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Delete rows returns "Rows deleted successfully" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.reference_tables_api import ReferenceTablesApi
7+
from datadog_api_client.v2.model.batch_delete_rows_request_array import BatchDeleteRowsRequestArray
8+
from datadog_api_client.v2.model.batch_delete_rows_request_data import BatchDeleteRowsRequestData
9+
from datadog_api_client.v2.model.table_row_resource_data_type import TableRowResourceDataType
10+
11+
body = BatchDeleteRowsRequestArray(
12+
data=[
13+
BatchDeleteRowsRequestData(
14+
id="primary_key_value",
15+
type=TableRowResourceDataType.ROW,
16+
),
17+
],
18+
)
19+
20+
configuration = Configuration()
21+
with ApiClient(configuration) as api_client:
22+
api_instance = ReferenceTablesApi(api_client)
23+
api_instance.delete_rows(id="id", body=body)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Upsert rows returns "Rows created or updated successfully" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.reference_tables_api import ReferenceTablesApi
7+
from datadog_api_client.v2.model.batch_upsert_rows_request_array import BatchUpsertRowsRequestArray
8+
from datadog_api_client.v2.model.batch_upsert_rows_request_data import BatchUpsertRowsRequestData
9+
from datadog_api_client.v2.model.batch_upsert_rows_request_data_attributes import BatchUpsertRowsRequestDataAttributes
10+
from datadog_api_client.v2.model.table_row_resource_data_type import TableRowResourceDataType
11+
12+
body = BatchUpsertRowsRequestArray(
13+
data=[
14+
BatchUpsertRowsRequestData(
15+
attributes=BatchUpsertRowsRequestDataAttributes(
16+
values=dict(
17+
example_key_value="primary_key_value",
18+
name="row_name",
19+
),
20+
),
21+
id="primary_key_value",
22+
type=TableRowResourceDataType.ROW,
23+
),
24+
],
25+
)
26+
27+
configuration = Configuration()
28+
with ApiClient(configuration) as api_client:
29+
api_instance = ReferenceTablesApi(api_client)
30+
api_instance.upsert_rows(id="id", body=body)

src/datadog_api_client/v2/api/reference_tables_api.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
from datadog_api_client.v2.model.table_result_v2 import TableResultV2
1717
from datadog_api_client.v2.model.create_table_request import CreateTableRequest
1818
from datadog_api_client.v2.model.patch_table_request import PatchTableRequest
19+
from datadog_api_client.v2.model.batch_delete_rows_request_array import BatchDeleteRowsRequestArray
1920
from datadog_api_client.v2.model.table_row_resource_array import TableRowResourceArray
21+
from datadog_api_client.v2.model.batch_upsert_rows_request_array import BatchUpsertRowsRequestArray
2022
from datadog_api_client.v2.model.create_upload_response import CreateUploadResponse
2123
from datadog_api_client.v2.model.create_upload_request import CreateUploadRequest
2224

@@ -71,6 +73,32 @@ def __init__(self, api_client=None):
7173
api_client=api_client,
7274
)
7375

76+
self._delete_rows_endpoint = _Endpoint(
77+
settings={
78+
"response_type": None,
79+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
80+
"endpoint_path": "/api/v2/reference-tables/tables/{id}/rows",
81+
"operation_id": "delete_rows",
82+
"http_method": "DELETE",
83+
"version": "v2",
84+
},
85+
params_map={
86+
"id": {
87+
"required": True,
88+
"openapi_types": (str,),
89+
"attribute": "id",
90+
"location": "path",
91+
},
92+
"body": {
93+
"required": True,
94+
"openapi_types": (BatchDeleteRowsRequestArray,),
95+
"location": "body",
96+
},
97+
},
98+
headers_map={"accept": ["*/*"], "content_type": ["application/json"]},
99+
api_client=api_client,
100+
)
101+
74102
self._delete_table_endpoint = _Endpoint(
75103
settings={
76104
"response_type": None,
@@ -227,6 +255,32 @@ def __init__(self, api_client=None):
227255
api_client=api_client,
228256
)
229257

258+
self._upsert_rows_endpoint = _Endpoint(
259+
settings={
260+
"response_type": None,
261+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
262+
"endpoint_path": "/api/v2/reference-tables/tables/{id}/rows",
263+
"operation_id": "upsert_rows",
264+
"http_method": "POST",
265+
"version": "v2",
266+
},
267+
params_map={
268+
"id": {
269+
"required": True,
270+
"openapi_types": (str,),
271+
"attribute": "id",
272+
"location": "path",
273+
},
274+
"body": {
275+
"required": True,
276+
"openapi_types": (BatchUpsertRowsRequestArray,),
277+
"location": "body",
278+
},
279+
},
280+
headers_map={"accept": ["*/*"], "content_type": ["application/json"]},
281+
api_client=api_client,
282+
)
283+
230284
def create_reference_table(
231285
self,
232286
body: CreateTableRequest,
@@ -264,6 +318,27 @@ def create_reference_table_upload(
264318

265319
return self._create_reference_table_upload_endpoint.call_with_http_info(**kwargs)
266320

321+
def delete_rows(
322+
self,
323+
id: str,
324+
body: BatchDeleteRowsRequestArray,
325+
) -> None:
326+
"""Delete rows.
327+
328+
Delete multiple rows from a Reference Table by their primary key values.
329+
330+
:param id: Unique identifier of the reference table to delete rows from
331+
:type id: str
332+
:type body: BatchDeleteRowsRequestArray
333+
:rtype: None
334+
"""
335+
kwargs: Dict[str, Any] = {}
336+
kwargs["id"] = id
337+
338+
kwargs["body"] = body
339+
340+
return self._delete_rows_endpoint.call_with_http_info(**kwargs)
341+
267342
def delete_table(
268343
self,
269344
id: str,
@@ -389,3 +464,24 @@ def update_reference_table(
389464
kwargs["body"] = body
390465

391466
return self._update_reference_table_endpoint.call_with_http_info(**kwargs)
467+
468+
def upsert_rows(
469+
self,
470+
id: str,
471+
body: BatchUpsertRowsRequestArray,
472+
) -> None:
473+
"""Upsert rows.
474+
475+
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.
476+
477+
:param id: Unique identifier of the reference table to upsert rows into
478+
:type id: str
479+
:type body: BatchUpsertRowsRequestArray
480+
:rtype: None
481+
"""
482+
kwargs: Dict[str, Any] = {}
483+
kwargs["id"] = id
484+
485+
kwargs["body"] = body
486+
487+
return self._upsert_rows_endpoint.call_with_http_info(**kwargs)

0 commit comments

Comments
 (0)