Skip to content

Commit 8aec44e

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Batch Rows Query Endpoint to Reference Tables API spec (#3618)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 21061ea commit 8aec44e

16 files changed

+1555
-31
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 135 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7475,23 +7475,89 @@ components:
74757475
properties:
74767476
data:
74777477
items:
7478-
$ref: '#/components/schemas/BatchDeleteRowsRequestData'
7478+
$ref: '#/components/schemas/TableRowResourceIdentifier'
74797479
maxItems: 200
74807480
type: array
74817481
required:
74827482
- data
74837483
type: object
7484-
BatchDeleteRowsRequestData:
7485-
description: Row resource containing a single row identifier for deletion.
7484+
BatchRowsQueryDataType:
7485+
default: reference-tables-batch-rows-query
7486+
description: Resource type identifier for batch queries of reference table rows.
7487+
enum:
7488+
- reference-tables-batch-rows-query
7489+
example: reference-tables-batch-rows-query
7490+
type: string
7491+
x-enum-varnames:
7492+
- REFERENCE_TABLES_BATCH_ROWS_QUERY
7493+
BatchRowsQueryRequest:
7494+
properties:
7495+
data:
7496+
$ref: '#/components/schemas/BatchRowsQueryRequestData'
7497+
type: object
7498+
BatchRowsQueryRequestData:
7499+
properties:
7500+
attributes:
7501+
$ref: '#/components/schemas/BatchRowsQueryRequestDataAttributes'
7502+
type:
7503+
$ref: '#/components/schemas/BatchRowsQueryDataType'
7504+
required:
7505+
- type
7506+
type: object
7507+
BatchRowsQueryRequestDataAttributes:
7508+
properties:
7509+
row_ids:
7510+
example:
7511+
- row_id_1
7512+
- row_id_2
7513+
items:
7514+
type: string
7515+
type: array
7516+
table_id:
7517+
example: 00000000-0000-0000-0000-000000000000
7518+
type: string
7519+
required:
7520+
- row_ids
7521+
- table_id
7522+
type: object
7523+
BatchRowsQueryResponse:
7524+
example:
7525+
data:
7526+
id: 00000000-0000-0000-0000-000000000000
7527+
relationships:
7528+
rows:
7529+
data:
7530+
- id: row_id_1
7531+
type: row
7532+
- id: row_id_2
7533+
type: row
7534+
type: reference-tables-batch-rows-query
7535+
properties:
7536+
data:
7537+
$ref: '#/components/schemas/BatchRowsQueryResponseData'
7538+
type: object
7539+
BatchRowsQueryResponseData:
74867540
properties:
74877541
id:
7488-
example: primary_key_value
74897542
type: string
7543+
relationships:
7544+
$ref: '#/components/schemas/BatchRowsQueryResponseDataRelationships'
74907545
type:
7491-
$ref: '#/components/schemas/TableRowResourceDataType'
7546+
$ref: '#/components/schemas/BatchRowsQueryDataType'
74927547
required:
74937548
- type
7494-
- id
7549+
type: object
7550+
BatchRowsQueryResponseDataRelationships:
7551+
properties:
7552+
rows:
7553+
$ref: '#/components/schemas/BatchRowsQueryResponseDataRelationshipsRows'
7554+
type: object
7555+
BatchRowsQueryResponseDataRelationshipsRows:
7556+
properties:
7557+
data:
7558+
items:
7559+
$ref: '#/components/schemas/TableRowResourceIdentifier'
7560+
type: array
74957561
type: object
74967562
BatchUpsertRowsRequestArray:
74977563
description: The request body for creating or updating multiple rows into a
@@ -66953,6 +67019,18 @@ components:
6695367019
type: string
6695467020
x-enum-varnames:
6695567021
- ROW
67022+
TableRowResourceIdentifier:
67023+
description: Row resource containing a single row identifier.
67024+
properties:
67025+
id:
67026+
example: primary_key_value
67027+
type: string
67028+
type:
67029+
$ref: '#/components/schemas/TableRowResourceDataType'
67030+
required:
67031+
- type
67032+
- id
67033+
type: object
6695667034
TagsEventAttribute:
6695767035
description: Array of tags associated with your event.
6695867036
example:
@@ -96388,6 +96466,57 @@ paths:
9638896466
operator: OR
9638996467
permissions:
9639096468
- timeseries_query
96469+
/api/v2/reference-tables/queries/batch-rows:
96470+
post:
96471+
description: Batch query reference table rows by their primary key values. Returns
96472+
only found rows in the included array.
96473+
operationId: BatchRowsQuery
96474+
requestBody:
96475+
content:
96476+
application/json:
96477+
examples:
96478+
happy_path:
96479+
summary: Batch query reference table rows by their primary key values.
96480+
value:
96481+
data:
96482+
attributes:
96483+
row_ids:
96484+
- row_id_1
96485+
- row_id_2
96486+
table_id: 00000000-0000-0000-0000-000000000000
96487+
type: reference-tables-batch-rows-query
96488+
schema:
96489+
$ref: '#/components/schemas/BatchRowsQueryRequest'
96490+
required: true
96491+
responses:
96492+
'200':
96493+
content:
96494+
application/json:
96495+
schema:
96496+
$ref: '#/components/schemas/BatchRowsQueryResponse'
96497+
description: Successfully retrieved rows. Some or all requested rows were
96498+
found. Response includes found rows in the included section.
96499+
'400':
96500+
$ref: '#/components/responses/BadRequestResponse'
96501+
'403':
96502+
$ref: '#/components/responses/ForbiddenResponse'
96503+
'404':
96504+
$ref: '#/components/responses/NotFoundResponse'
96505+
'429':
96506+
$ref: '#/components/responses/TooManyRequestsResponse'
96507+
'500':
96508+
content:
96509+
application/json:
96510+
schema:
96511+
$ref: '#/components/schemas/APIErrorResponse'
96512+
description: Internal Server Error
96513+
security:
96514+
- apiKeyAuth: []
96515+
appKeyAuth: []
96516+
- AuthZ: []
96517+
summary: Batch rows query
96518+
tags:
96519+
- Reference Tables
9639196520
/api/v2/reference-tables/tables:
9639296521
get:
9639396522
description: List all reference tables in this organization.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Batch rows query returns "Successfully retrieved rows. Some or all requested rows were found.
2+
// Response includes found
3+
// rows in the included section." response
4+
5+
import com.datadog.api.client.ApiClient;
6+
import com.datadog.api.client.ApiException;
7+
import com.datadog.api.client.v2.api.ReferenceTablesApi;
8+
import com.datadog.api.client.v2.model.BatchRowsQueryDataType;
9+
import com.datadog.api.client.v2.model.BatchRowsQueryRequest;
10+
import com.datadog.api.client.v2.model.BatchRowsQueryRequestData;
11+
import com.datadog.api.client.v2.model.BatchRowsQueryRequestDataAttributes;
12+
import com.datadog.api.client.v2.model.BatchRowsQueryResponse;
13+
import java.util.Arrays;
14+
15+
public class Example {
16+
public static void main(String[] args) {
17+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
18+
ReferenceTablesApi apiInstance = new ReferenceTablesApi(defaultClient);
19+
20+
BatchRowsQueryRequest body =
21+
new BatchRowsQueryRequest()
22+
.data(
23+
new BatchRowsQueryRequestData()
24+
.attributes(
25+
new BatchRowsQueryRequestDataAttributes()
26+
.rowIds(Arrays.asList("row_id_1", "row_id_2"))
27+
.tableId("00000000-0000-0000-0000-000000000000"))
28+
.type(BatchRowsQueryDataType.REFERENCE_TABLES_BATCH_ROWS_QUERY));
29+
30+
try {
31+
BatchRowsQueryResponse result = apiInstance.batchRowsQuery(body);
32+
System.out.println(result);
33+
} catch (ApiException e) {
34+
System.err.println("Exception when calling ReferenceTablesApi#batchRowsQuery");
35+
System.err.println("Status code: " + e.getCode());
36+
System.err.println("Reason: " + e.getResponseBody());
37+
System.err.println("Response headers: " + e.getResponseHeaders());
38+
e.printStackTrace();
39+
}
40+
}
41+
}

examples/v2/reference-tables/DeleteRows.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import com.datadog.api.client.ApiException;
55
import com.datadog.api.client.v2.api.ReferenceTablesApi;
66
import com.datadog.api.client.v2.model.BatchDeleteRowsRequestArray;
7-
import com.datadog.api.client.v2.model.BatchDeleteRowsRequestData;
87
import com.datadog.api.client.v2.model.TableRowResourceDataType;
8+
import com.datadog.api.client.v2.model.TableRowResourceIdentifier;
99
import java.util.Collections;
1010

1111
public class Example {
@@ -17,7 +17,7 @@ public static void main(String[] args) {
1717
new BatchDeleteRowsRequestArray()
1818
.data(
1919
Collections.singletonList(
20-
new BatchDeleteRowsRequestData()
20+
new TableRowResourceIdentifier()
2121
.id("primary_key_value")
2222
.type(TableRowResourceDataType.ROW)));
2323

src/main/java/com/datadog/api/client/v2/api/ReferenceTablesApi.java

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.datadog.api.client.ApiResponse;
66
import com.datadog.api.client.Pair;
77
import com.datadog.api.client.v2.model.BatchDeleteRowsRequestArray;
8+
import com.datadog.api.client.v2.model.BatchRowsQueryRequest;
9+
import com.datadog.api.client.v2.model.BatchRowsQueryResponse;
810
import com.datadog.api.client.v2.model.BatchUpsertRowsRequestArray;
911
import com.datadog.api.client.v2.model.CreateTableRequest;
1012
import com.datadog.api.client.v2.model.CreateUploadRequest;
@@ -53,6 +55,140 @@ public void setApiClient(ApiClient apiClient) {
5355
this.apiClient = apiClient;
5456
}
5557

58+
/**
59+
* Batch rows query.
60+
*
61+
* <p>See {@link #batchRowsQueryWithHttpInfo}.
62+
*
63+
* @param body (required)
64+
* @return BatchRowsQueryResponse
65+
* @throws ApiException if fails to make API call
66+
*/
67+
public BatchRowsQueryResponse batchRowsQuery(BatchRowsQueryRequest body) throws ApiException {
68+
return batchRowsQueryWithHttpInfo(body).getData();
69+
}
70+
71+
/**
72+
* Batch rows query.
73+
*
74+
* <p>See {@link #batchRowsQueryWithHttpInfoAsync}.
75+
*
76+
* @param body (required)
77+
* @return CompletableFuture&lt;BatchRowsQueryResponse&gt;
78+
*/
79+
public CompletableFuture<BatchRowsQueryResponse> batchRowsQueryAsync(BatchRowsQueryRequest body) {
80+
return batchRowsQueryWithHttpInfoAsync(body)
81+
.thenApply(
82+
response -> {
83+
return response.getData();
84+
});
85+
}
86+
87+
/**
88+
* Batch query reference table rows by their primary key values. Returns only found rows in the
89+
* included array.
90+
*
91+
* @param body (required)
92+
* @return ApiResponse&lt;BatchRowsQueryResponse&gt;
93+
* @throws ApiException if fails to make API call
94+
* @http.response.details
95+
* <table border="1">
96+
* <caption>Response details</caption>
97+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
98+
* <tr><td> 200 </td><td> Successfully retrieved rows. Some or all requested rows were found. Response includes found rows in the included section. </td><td> - </td></tr>
99+
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
100+
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
101+
* <tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
102+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
103+
* <tr><td> 500 </td><td> Internal Server Error </td><td> - </td></tr>
104+
* </table>
105+
*/
106+
public ApiResponse<BatchRowsQueryResponse> batchRowsQueryWithHttpInfo(BatchRowsQueryRequest body)
107+
throws ApiException {
108+
Object localVarPostBody = body;
109+
110+
// verify the required parameter 'body' is set
111+
if (body == null) {
112+
throw new ApiException(
113+
400, "Missing the required parameter 'body' when calling batchRowsQuery");
114+
}
115+
// create path and map variables
116+
String localVarPath = "/api/v2/reference-tables/queries/batch-rows";
117+
118+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
119+
120+
Invocation.Builder builder =
121+
apiClient.createBuilder(
122+
"v2.ReferenceTablesApi.batchRowsQuery",
123+
localVarPath,
124+
new ArrayList<Pair>(),
125+
localVarHeaderParams,
126+
new HashMap<String, String>(),
127+
new String[] {"application/json"},
128+
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
129+
return apiClient.invokeAPI(
130+
"POST",
131+
builder,
132+
localVarHeaderParams,
133+
new String[] {"application/json"},
134+
localVarPostBody,
135+
new HashMap<String, Object>(),
136+
false,
137+
new GenericType<BatchRowsQueryResponse>() {});
138+
}
139+
140+
/**
141+
* Batch rows query.
142+
*
143+
* <p>See {@link #batchRowsQueryWithHttpInfo}.
144+
*
145+
* @param body (required)
146+
* @return CompletableFuture&lt;ApiResponse&lt;BatchRowsQueryResponse&gt;&gt;
147+
*/
148+
public CompletableFuture<ApiResponse<BatchRowsQueryResponse>> batchRowsQueryWithHttpInfoAsync(
149+
BatchRowsQueryRequest body) {
150+
Object localVarPostBody = body;
151+
152+
// verify the required parameter 'body' is set
153+
if (body == null) {
154+
CompletableFuture<ApiResponse<BatchRowsQueryResponse>> result = new CompletableFuture<>();
155+
result.completeExceptionally(
156+
new ApiException(
157+
400, "Missing the required parameter 'body' when calling batchRowsQuery"));
158+
return result;
159+
}
160+
// create path and map variables
161+
String localVarPath = "/api/v2/reference-tables/queries/batch-rows";
162+
163+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
164+
165+
Invocation.Builder builder;
166+
try {
167+
builder =
168+
apiClient.createBuilder(
169+
"v2.ReferenceTablesApi.batchRowsQuery",
170+
localVarPath,
171+
new ArrayList<Pair>(),
172+
localVarHeaderParams,
173+
new HashMap<String, String>(),
174+
new String[] {"application/json"},
175+
new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
176+
} catch (ApiException ex) {
177+
CompletableFuture<ApiResponse<BatchRowsQueryResponse>> result = new CompletableFuture<>();
178+
result.completeExceptionally(ex);
179+
return result;
180+
}
181+
return apiClient.invokeAPIAsync(
182+
"POST",
183+
builder,
184+
localVarHeaderParams,
185+
new String[] {"application/json"},
186+
localVarPostBody,
187+
new HashMap<String, Object>(),
188+
false,
189+
new GenericType<BatchRowsQueryResponse>() {});
190+
}
191+
56192
/**
57193
* Create reference table.
58194
*

0 commit comments

Comments
 (0)