Skip to content

Commit c05ca65

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add BulkDeleteDatastoreItems to Datastore API spec (#3162)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent a3ef6f3 commit c05ca65

22 files changed

+1315
-8
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6553,6 +6553,46 @@ components:
65536553
description: The type of the object, must be `budget`.
65546554
type: string
65556555
type: object
6556+
BulkDeleteAppsDatastoreItemsRequest:
6557+
description: Request to delete items from a datastore.
6558+
properties:
6559+
data:
6560+
$ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestData'
6561+
type: object
6562+
BulkDeleteAppsDatastoreItemsRequestData:
6563+
description: Data wrapper containing the data needed to delete items from a
6564+
datastore.
6565+
properties:
6566+
attributes:
6567+
$ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestDataAttributes'
6568+
id:
6569+
description: ID for the datastore of the items to delete.
6570+
type: string
6571+
type:
6572+
$ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestDataType'
6573+
required:
6574+
- type
6575+
type: object
6576+
BulkDeleteAppsDatastoreItemsRequestDataAttributes:
6577+
description: Attributes of request data to delete items from a datastore.
6578+
properties:
6579+
item_keys:
6580+
description: List of primary keys identifying items to delete from datastore.
6581+
Up to 100 items can be deleted in a single request.
6582+
items:
6583+
type: string
6584+
maxItems: 100
6585+
type: array
6586+
type: object
6587+
BulkDeleteAppsDatastoreItemsRequestDataType:
6588+
default: items
6589+
description: Items resource type.
6590+
enum:
6591+
- items
6592+
example: items
6593+
type: string
6594+
x-enum-varnames:
6595+
- ITEMS
65566596
BulkMuteFindingsRequest:
65576597
description: The new bulk mute finding request.
65586598
properties:
@@ -14869,6 +14909,17 @@ components:
1486914909
data:
1487014910
$ref: '#/components/schemas/DeleteAppsDatastoreItemResponseData'
1487114911
type: object
14912+
DeleteAppsDatastoreItemResponseArray:
14913+
description: The definition of `DeleteAppsDatastoreItemResponseArray` object.
14914+
properties:
14915+
data:
14916+
description: The `DeleteAppsDatastoreItemResponseArray` `data`.
14917+
items:
14918+
$ref: '#/components/schemas/DeleteAppsDatastoreItemResponseData'
14919+
type: array
14920+
required:
14921+
- data
14922+
type: object
1487214923
DeleteAppsDatastoreItemResponseData:
1487314924
description: Data containing the identifier of the datastore item that was successfully
1487414925
deleted.
@@ -51257,6 +51308,57 @@ paths:
5125751308
permissions:
5125851309
- apps_datastore_write
5125951310
/api/v2/actions-datastores/{datastore_id}/items/bulk:
51311+
delete:
51312+
description: Deletes multiple items from a datastore by their keys in a single
51313+
operation.
51314+
operationId: BulkDeleteDatastoreItems
51315+
parameters:
51316+
- description: The ID of the datastore.
51317+
in: path
51318+
name: datastore_id
51319+
required: true
51320+
schema:
51321+
type: string
51322+
requestBody:
51323+
content:
51324+
application/json:
51325+
schema:
51326+
$ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequest'
51327+
required: true
51328+
responses:
51329+
'200':
51330+
content:
51331+
application/json:
51332+
schema:
51333+
$ref: '#/components/schemas/DeleteAppsDatastoreItemResponseArray'
51334+
description: OK
51335+
'400':
51336+
content:
51337+
application/json:
51338+
schema:
51339+
$ref: '#/components/schemas/JSONAPIErrorResponse'
51340+
description: Bad Request
51341+
'404':
51342+
content:
51343+
application/json:
51344+
schema:
51345+
$ref: '#/components/schemas/JSONAPIErrorResponse'
51346+
description: Not Found
51347+
'429':
51348+
$ref: '#/components/responses/TooManyRequestsResponse'
51349+
'500':
51350+
content:
51351+
application/json:
51352+
schema:
51353+
$ref: '#/components/schemas/JSONAPIErrorResponse'
51354+
description: Internal Server Error
51355+
summary: Bulk delete datastore items
51356+
tags:
51357+
- Actions Datastores
51358+
x-permission:
51359+
operator: OR
51360+
permissions:
51361+
- apps_datastore_write
5126051362
post:
5126151363
description: Creates or replaces multiple items in a datastore by their keys
5126251364
in a single operation.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Bulk delete datastore items returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v2.api.ActionsDatastoresApi;
6+
import com.datadog.api.client.v2.model.BulkDeleteAppsDatastoreItemsRequest;
7+
import com.datadog.api.client.v2.model.BulkDeleteAppsDatastoreItemsRequestData;
8+
import com.datadog.api.client.v2.model.BulkDeleteAppsDatastoreItemsRequestDataAttributes;
9+
import com.datadog.api.client.v2.model.BulkDeleteAppsDatastoreItemsRequestDataType;
10+
import com.datadog.api.client.v2.model.DeleteAppsDatastoreItemResponseArray;
11+
import java.util.Collections;
12+
13+
public class Example {
14+
public static void main(String[] args) {
15+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
16+
ActionsDatastoresApi apiInstance = new ActionsDatastoresApi(defaultClient);
17+
18+
// there is a valid "datastore" in the system
19+
String DATASTORE_DATA_ID = System.getenv("DATASTORE_DATA_ID");
20+
21+
BulkDeleteAppsDatastoreItemsRequest body =
22+
new BulkDeleteAppsDatastoreItemsRequest()
23+
.data(
24+
new BulkDeleteAppsDatastoreItemsRequestData()
25+
.attributes(
26+
new BulkDeleteAppsDatastoreItemsRequestDataAttributes()
27+
.itemKeys(Collections.singletonList("test-key")))
28+
.type(BulkDeleteAppsDatastoreItemsRequestDataType.ITEMS));
29+
30+
try {
31+
DeleteAppsDatastoreItemResponseArray result =
32+
apiInstance.bulkDeleteDatastoreItems(DATASTORE_DATA_ID, body);
33+
System.out.println(result);
34+
} catch (ApiException e) {
35+
System.err.println("Exception when calling ActionsDatastoresApi#bulkDeleteDatastoreItems");
36+
System.err.println("Status code: " + e.getCode());
37+
System.err.println("Reason: " + e.getResponseBody());
38+
System.err.println("Response headers: " + e.getResponseHeaders());
39+
e.printStackTrace();
40+
}
41+
}
42+
}

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

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import com.datadog.api.client.ApiException;
55
import com.datadog.api.client.ApiResponse;
66
import com.datadog.api.client.Pair;
7+
import com.datadog.api.client.v2.model.BulkDeleteAppsDatastoreItemsRequest;
78
import com.datadog.api.client.v2.model.BulkPutAppsDatastoreItemsRequest;
89
import com.datadog.api.client.v2.model.CreateAppsDatastoreRequest;
910
import com.datadog.api.client.v2.model.CreateAppsDatastoreResponse;
1011
import com.datadog.api.client.v2.model.Datastore;
1112
import com.datadog.api.client.v2.model.DatastoreArray;
1213
import com.datadog.api.client.v2.model.DeleteAppsDatastoreItemRequest;
1314
import com.datadog.api.client.v2.model.DeleteAppsDatastoreItemResponse;
15+
import com.datadog.api.client.v2.model.DeleteAppsDatastoreItemResponseArray;
1416
import com.datadog.api.client.v2.model.ItemApiPayload;
1517
import com.datadog.api.client.v2.model.ItemApiPayloadArray;
1618
import com.datadog.api.client.v2.model.PutAppsDatastoreItemResponseArray;
@@ -55,6 +57,172 @@ public void setApiClient(ApiClient apiClient) {
5557
this.apiClient = apiClient;
5658
}
5759

60+
/**
61+
* Bulk delete datastore items.
62+
*
63+
* <p>See {@link #bulkDeleteDatastoreItemsWithHttpInfo}.
64+
*
65+
* @param datastoreId The ID of the datastore. (required)
66+
* @param body (required)
67+
* @return DeleteAppsDatastoreItemResponseArray
68+
* @throws ApiException if fails to make API call
69+
*/
70+
public DeleteAppsDatastoreItemResponseArray bulkDeleteDatastoreItems(
71+
String datastoreId, BulkDeleteAppsDatastoreItemsRequest body) throws ApiException {
72+
return bulkDeleteDatastoreItemsWithHttpInfo(datastoreId, body).getData();
73+
}
74+
75+
/**
76+
* Bulk delete datastore items.
77+
*
78+
* <p>See {@link #bulkDeleteDatastoreItemsWithHttpInfoAsync}.
79+
*
80+
* @param datastoreId The ID of the datastore. (required)
81+
* @param body (required)
82+
* @return CompletableFuture&lt;DeleteAppsDatastoreItemResponseArray&gt;
83+
*/
84+
public CompletableFuture<DeleteAppsDatastoreItemResponseArray> bulkDeleteDatastoreItemsAsync(
85+
String datastoreId, BulkDeleteAppsDatastoreItemsRequest body) {
86+
return bulkDeleteDatastoreItemsWithHttpInfoAsync(datastoreId, body)
87+
.thenApply(
88+
response -> {
89+
return response.getData();
90+
});
91+
}
92+
93+
/**
94+
* Deletes multiple items from a datastore by their keys in a single operation.
95+
*
96+
* @param datastoreId The ID of the datastore. (required)
97+
* @param body (required)
98+
* @return ApiResponse&lt;DeleteAppsDatastoreItemResponseArray&gt;
99+
* @throws ApiException if fails to make API call
100+
* @http.response.details
101+
* <table border="1">
102+
* <caption>Response details</caption>
103+
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
104+
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
105+
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
106+
* <tr><td> 404 </td><td> Not Found </td><td> - </td></tr>
107+
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
108+
* <tr><td> 500 </td><td> Internal Server Error </td><td> - </td></tr>
109+
* </table>
110+
*/
111+
public ApiResponse<DeleteAppsDatastoreItemResponseArray> bulkDeleteDatastoreItemsWithHttpInfo(
112+
String datastoreId, BulkDeleteAppsDatastoreItemsRequest body) throws ApiException {
113+
Object localVarPostBody = body;
114+
115+
// verify the required parameter 'datastoreId' is set
116+
if (datastoreId == null) {
117+
throw new ApiException(
118+
400,
119+
"Missing the required parameter 'datastoreId' when calling bulkDeleteDatastoreItems");
120+
}
121+
122+
// verify the required parameter 'body' is set
123+
if (body == null) {
124+
throw new ApiException(
125+
400, "Missing the required parameter 'body' when calling bulkDeleteDatastoreItems");
126+
}
127+
// create path and map variables
128+
String localVarPath =
129+
"/api/v2/actions-datastores/{datastore_id}/items/bulk"
130+
.replaceAll(
131+
"\\{" + "datastore_id" + "\\}", apiClient.escapeString(datastoreId.toString()));
132+
133+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
134+
135+
Invocation.Builder builder =
136+
apiClient.createBuilder(
137+
"v2.ActionsDatastoresApi.bulkDeleteDatastoreItems",
138+
localVarPath,
139+
new ArrayList<Pair>(),
140+
localVarHeaderParams,
141+
new HashMap<String, String>(),
142+
new String[] {"application/json"},
143+
new String[] {"apiKeyAuth", "appKeyAuth"});
144+
return apiClient.invokeAPI(
145+
"DELETE",
146+
builder,
147+
localVarHeaderParams,
148+
new String[] {"application/json"},
149+
localVarPostBody,
150+
new HashMap<String, Object>(),
151+
false,
152+
new GenericType<DeleteAppsDatastoreItemResponseArray>() {});
153+
}
154+
155+
/**
156+
* Bulk delete datastore items.
157+
*
158+
* <p>See {@link #bulkDeleteDatastoreItemsWithHttpInfo}.
159+
*
160+
* @param datastoreId The ID of the datastore. (required)
161+
* @param body (required)
162+
* @return CompletableFuture&lt;ApiResponse&lt;DeleteAppsDatastoreItemResponseArray&gt;&gt;
163+
*/
164+
public CompletableFuture<ApiResponse<DeleteAppsDatastoreItemResponseArray>>
165+
bulkDeleteDatastoreItemsWithHttpInfoAsync(
166+
String datastoreId, BulkDeleteAppsDatastoreItemsRequest body) {
167+
Object localVarPostBody = body;
168+
169+
// verify the required parameter 'datastoreId' is set
170+
if (datastoreId == null) {
171+
CompletableFuture<ApiResponse<DeleteAppsDatastoreItemResponseArray>> result =
172+
new CompletableFuture<>();
173+
result.completeExceptionally(
174+
new ApiException(
175+
400,
176+
"Missing the required parameter 'datastoreId' when calling"
177+
+ " bulkDeleteDatastoreItems"));
178+
return result;
179+
}
180+
181+
// verify the required parameter 'body' is set
182+
if (body == null) {
183+
CompletableFuture<ApiResponse<DeleteAppsDatastoreItemResponseArray>> result =
184+
new CompletableFuture<>();
185+
result.completeExceptionally(
186+
new ApiException(
187+
400, "Missing the required parameter 'body' when calling bulkDeleteDatastoreItems"));
188+
return result;
189+
}
190+
// create path and map variables
191+
String localVarPath =
192+
"/api/v2/actions-datastores/{datastore_id}/items/bulk"
193+
.replaceAll(
194+
"\\{" + "datastore_id" + "\\}", apiClient.escapeString(datastoreId.toString()));
195+
196+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
197+
198+
Invocation.Builder builder;
199+
try {
200+
builder =
201+
apiClient.createBuilder(
202+
"v2.ActionsDatastoresApi.bulkDeleteDatastoreItems",
203+
localVarPath,
204+
new ArrayList<Pair>(),
205+
localVarHeaderParams,
206+
new HashMap<String, String>(),
207+
new String[] {"application/json"},
208+
new String[] {"apiKeyAuth", "appKeyAuth"});
209+
} catch (ApiException ex) {
210+
CompletableFuture<ApiResponse<DeleteAppsDatastoreItemResponseArray>> result =
211+
new CompletableFuture<>();
212+
result.completeExceptionally(ex);
213+
return result;
214+
}
215+
return apiClient.invokeAPIAsync(
216+
"DELETE",
217+
builder,
218+
localVarHeaderParams,
219+
new String[] {"application/json"},
220+
localVarPostBody,
221+
new HashMap<String, Object>(),
222+
false,
223+
new GenericType<DeleteAppsDatastoreItemResponseArray>() {});
224+
}
225+
58226
/**
59227
* Bulk write datastore items.
60228
*

0 commit comments

Comments
 (0)