diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 3d27f6798ca1..17509b56882d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -6553,6 +6553,46 @@ components: description: The type of the object, must be `budget`. type: string type: object + BulkDeleteAppsDatastoreItemsRequest: + description: Request to delete items from a datastore. + properties: + data: + $ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestData' + type: object + BulkDeleteAppsDatastoreItemsRequestData: + description: Data wrapper containing the data needed to delete items from a + datastore. + properties: + attributes: + $ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestDataAttributes' + id: + description: ID for the datastore of the items to delete. + type: string + type: + $ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequestDataType' + required: + - type + type: object + BulkDeleteAppsDatastoreItemsRequestDataAttributes: + description: Attributes of request data to delete items from a datastore. + properties: + item_keys: + description: List of primary keys identifying items to delete from datastore. + Up to 100 items can be deleted in a single request. + items: + type: string + maxItems: 100 + type: array + type: object + BulkDeleteAppsDatastoreItemsRequestDataType: + default: items + description: Items resource type. + enum: + - items + example: items + type: string + x-enum-varnames: + - ITEMS BulkMuteFindingsRequest: description: The new bulk mute finding request. properties: @@ -14869,6 +14909,17 @@ components: data: $ref: '#/components/schemas/DeleteAppsDatastoreItemResponseData' type: object + DeleteAppsDatastoreItemResponseArray: + description: The definition of `DeleteAppsDatastoreItemResponseArray` object. + properties: + data: + description: The `DeleteAppsDatastoreItemResponseArray` `data`. + items: + $ref: '#/components/schemas/DeleteAppsDatastoreItemResponseData' + type: array + required: + - data + type: object DeleteAppsDatastoreItemResponseData: description: Data containing the identifier of the datastore item that was successfully deleted. @@ -51257,6 +51308,57 @@ paths: permissions: - apps_datastore_write /api/v2/actions-datastores/{datastore_id}/items/bulk: + delete: + description: Deletes multiple items from a datastore by their keys in a single + operation. + operationId: BulkDeleteDatastoreItems + parameters: + - description: The ID of the datastore. + in: path + name: datastore_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/BulkDeleteAppsDatastoreItemsRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeleteAppsDatastoreItemResponseArray' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Internal Server Error + summary: Bulk delete datastore items + tags: + - Actions Datastores + x-permission: + operator: OR + permissions: + - apps_datastore_write post: description: Creates or replaces multiple items in a datastore by their keys in a single operation. diff --git a/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Bad-Request-response_2512263051/frozen.json b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Bad-Request-response_2512263051/frozen.json new file mode 100644 index 000000000000..0684009e8712 --- /dev/null +++ b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Bad-Request-response_2512263051/frozen.json @@ -0,0 +1 @@ +"2025-09-29T19:31:22.205Z" diff --git a/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Bad-Request-response_2512263051/recording.har b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Bad-Request-response_2512263051/recording.har new file mode 100644 index 000000000000..7b9ddb095ace --- /dev/null +++ b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Bad-Request-response_2512263051/recording.har @@ -0,0 +1,163 @@ +{ + "log": { + "_recordingName": "Actions Datastores/Bulk delete datastore items returns \"Bad Request\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "6574cf7e1c5524e145d2b92f9fa74d2c", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 181, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 566, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"data\":{\"attributes\":{\"description\":\"\",\"name\":\"Test Datastore\",\"org_access\":\"contributor\",\"primary_column_name\":\"id\",\"primary_key_generation_strategy\":\"none\"},\"type\":\"datastores\"}}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/actions-datastores" + }, + "response": { + "bodySize": 74, + "content": { + "mimeType": "application/vnd.api+json", + "size": 74, + "text": "{\"data\":{\"id\":\"2b088869-d596-4103-9cff-038b5f81fc0c\",\"type\":\"datastores\"}}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 658, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-09-29T19:31:22.210Z", + "time": 127 + }, + { + "_id": "250acdecc02d6e90debb4e7c003fc3d3", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 55, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 624, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"data\":{\"attributes\":{\"item_keys\":[]},\"type\":\"items\"}}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/actions-datastores/2b088869-d596-4103-9cff-038b5f81fc0c/items/bulk" + }, + "response": { + "bodySize": 151, + "content": { + "mimeType": "application/vnd.api+json", + "size": 151, + "text": "{\"errors\":[{\"status\":\"400\",\"id\":\"61325aff-aaa7-4571-80e2-e87ed8ffb103\",\"title\":\"missing required field\",\"detail\":\"at least one item key is required\"}]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 941, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 400, + "statusText": "Bad Request" + }, + "startedDateTime": "2025-09-29T19:31:22.345Z", + "time": 108 + }, + { + "_id": "510e983293e08107932ce07babeb6246", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "*/*" + } + ], + "headersSize": 539, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/actions-datastores/2b088869-d596-4103-9cff-038b5f81fc0c" + }, + "response": { + "bodySize": 74, + "content": { + "mimeType": "application/vnd.api+json", + "size": 74, + "text": "{\"data\":{\"id\":\"2b088869-d596-4103-9cff-038b5f81fc0c\",\"type\":\"datastores\"}}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 658, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-09-29T19:31:22.459Z", + "time": 92 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Not-Found-response_516462796/frozen.json b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Not-Found-response_516462796/frozen.json new file mode 100644 index 000000000000..00a0db684eb1 --- /dev/null +++ b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Not-Found-response_516462796/frozen.json @@ -0,0 +1 @@ +"2025-09-29T19:31:56.639Z" diff --git a/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Not-Found-response_516462796/recording.har b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Not-Found-response_516462796/recording.har new file mode 100644 index 000000000000..520578f89001 --- /dev/null +++ b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-Not-Found-response_516462796/recording.har @@ -0,0 +1,67 @@ +{ + "log": { + "_recordingName": "Actions Datastores/Bulk delete datastore items returns \"Not Found\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "070d0045b9573b98f36116e1cdf72cf4", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 68, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 622, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"data\":{\"attributes\":{\"item_keys\":[\"nonexistent\"]},\"type\":\"items\"}}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/actions-datastores/c1eb5bb8-726a-4e59-9a61-ccbb26f95329/items/bulk" + }, + "response": { + "bodySize": 103, + "content": { + "mimeType": "application/vnd.api+json", + "size": 103, + "text": "{\"errors\":[{\"status\":\"404\",\"id\":\"d53325f5-a7f3-4075-ace7-f8e22a25b72f\",\"title\":\"datastore not found\"}]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 941, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 404, + "statusText": "Not Found" + }, + "startedDateTime": "2025-09-29T19:31:56.643Z", + "time": 116 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-OK-response_3955459455/frozen.json b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-OK-response_3955459455/frozen.json new file mode 100644 index 000000000000..a61b46b2f8a8 --- /dev/null +++ b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-OK-response_3955459455/frozen.json @@ -0,0 +1 @@ +"2025-09-29T19:32:10.669Z" diff --git a/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-OK-response_3955459455/recording.har b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-OK-response_3955459455/recording.har new file mode 100644 index 000000000000..7499cc6d898f --- /dev/null +++ b/cassettes/v2/Actions-Datastores_3792888034/Bulk-delete-datastore-items-returns-OK-response_3955459455/recording.har @@ -0,0 +1,216 @@ +{ + "log": { + "_recordingName": "Actions Datastores/Bulk delete datastore items returns \"OK\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "6574cf7e1c5524e145d2b92f9fa74d2c", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 181, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 568, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"data\":{\"attributes\":{\"description\":\"\",\"name\":\"Test Datastore\",\"org_access\":\"contributor\",\"primary_column_name\":\"id\",\"primary_key_generation_strategy\":\"none\"},\"type\":\"datastores\"}}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/actions-datastores" + }, + "response": { + "bodySize": 74, + "content": { + "mimeType": "application/vnd.api+json", + "size": 74, + "text": "{\"data\":{\"id\":\"c6bc5eee-04af-4d7e-97a5-57c9c4dc0b15\",\"type\":\"datastores\"}}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 659, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-09-29T19:32:10.673Z", + "time": 121 + }, + { + "_id": "2a614ad600e1ff3d075022e3d3852d18", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 124, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 624, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"data\":{\"attributes\":{\"conflict_mode\":\"fail_on_conflict\",\"values\":[{\"data\":\"test-value\",\"id\":\"test-key\"}]},\"type\":\"items\"}}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/actions-datastores/c6bc5eee-04af-4d7e-97a5-57c9c4dc0b15/items/bulk" + }, + "response": { + "bodySize": 71, + "content": { + "mimeType": "application/vnd.api+json", + "size": 71, + "text": "{\"data\":[{\"id\":\"8267c8c1-dfcd-4364-83e5-359c0ab302fc\",\"type\":\"items\"}]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 941, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-09-29T19:32:10.801Z", + "time": 131 + }, + { + "_id": "c67910b3d90bfdbc17579bd9f2b28fda", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 65, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 626, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"data\":{\"attributes\":{\"item_keys\":[\"test-key\"]},\"type\":\"items\"}}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/actions-datastores/c6bc5eee-04af-4d7e-97a5-57c9c4dc0b15/items/bulk" + }, + "response": { + "bodySize": 71, + "content": { + "mimeType": "application/vnd.api+json", + "size": 71, + "text": "{\"data\":[{\"id\":\"8267c8c1-dfcd-4364-83e5-359c0ab302fc\",\"type\":\"items\"}]}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 940, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-09-29T19:32:10.937Z", + "time": 144 + }, + { + "_id": "542bfff9e7fcbd103df43d492559ee8f", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "*/*" + } + ], + "headersSize": 541, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.datadoghq.com/api/v2/actions-datastores/c6bc5eee-04af-4d7e-97a5-57c9c4dc0b15" + }, + "response": { + "bodySize": 74, + "content": { + "mimeType": "application/vnd.api+json", + "size": 74, + "text": "{\"data\":{\"id\":\"c6bc5eee-04af-4d7e-97a5-57c9c4dc0b15\",\"type\":\"datastores\"}}" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/vnd.api+json" + } + ], + "headersSize": 658, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2025-09-29T19:32:11.091Z", + "time": 73 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/features/v2/actions_datastores.feature b/features/v2/actions_datastores.feature index ed19da3aec27..a8cd02fe0529 100644 --- a/features/v2/actions_datastores.feature +++ b/features/v2/actions_datastores.feature @@ -4,9 +4,36 @@ Feature: Actions Datastores datastores owned by your organization. Background: - Given an instance of "ActionsDatastores" API - And a valid "apiKeyAuth" key in the system + Given a valid "apiKeyAuth" key in the system And a valid "appKeyAuth" key in the system + And an instance of "ActionsDatastores" API + + @team:DataDog/app-builder-backend + Scenario: Bulk delete datastore items returns "Bad Request" response + Given new "BulkDeleteDatastoreItems" request + And there is a valid "datastore" in the system + And request contains "datastore_id" parameter from "datastore.data.id" + And body with value {"data": {"attributes": {"item_keys": []}, "type": "items"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/app-builder-backend + Scenario: Bulk delete datastore items returns "Not Found" response + Given new "BulkDeleteDatastoreItems" request + And request contains "datastore_id" parameter with value "c1eb5bb8-726a-4e59-9a61-ccbb26f95329" + And body with value {"data": {"attributes": {"item_keys": ["nonexistent"]}, "type": "items"}} + When the request is sent + Then the response status is 404 Not Found + + @skip-typescript @team:DataDog/app-builder-backend + Scenario: Bulk delete datastore items returns "OK" response + Given new "BulkDeleteDatastoreItems" request + And there is a valid "datastore" in the system + And there is a valid "datastore_item" in the system + And request contains "datastore_id" parameter from "datastore.data.id" + And body with value {"data": {"attributes": {"item_keys": ["test-key"]}, "type": "items"}} + When the request is sent + Then the response status is 200 OK @team:DataDog/app-builder-backend Scenario: Bulk write datastore items returns "Bad Request" response diff --git a/features/v2/undo.json b/features/v2/undo.json index 95d8a19dcbd2..c4c269d3cab9 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -54,6 +54,12 @@ "type": "idempotent" } }, + "BulkDeleteDatastoreItems": { + "tag": "Actions Datastores", + "undo": { + "type": "idempotent" + } + }, "BulkWriteDatastoreItems": { "tag": "Actions Datastores", "undo": { diff --git a/private/bdd_runner/src/support/scenarios_model_mapping.ts b/private/bdd_runner/src/support/scenarios_model_mapping.ts index f358c0669f4e..0689e2fae8b9 100644 --- a/private/bdd_runner/src/support/scenarios_model_mapping.ts +++ b/private/bdd_runner/src/support/scenarios_model_mapping.ts @@ -2445,6 +2445,17 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { }, operationResponseType: "PutAppsDatastoreItemResponseArray", }, + "ActionsDatastoresApi.V2.BulkDeleteDatastoreItems": { + datastoreId: { + type: "string", + format: "", + }, + body: { + type: "BulkDeleteAppsDatastoreItemsRequest", + format: "", + }, + operationResponseType: "DeleteAppsDatastoreItemResponseArray", + }, "ActionConnectionApi.V2.ListAppKeyRegistrations": { pageSize: { type: "number", diff --git a/services/actions_datastores/src/v2/ActionsDatastoresApi.ts b/services/actions_datastores/src/v2/ActionsDatastoresApi.ts index bdcea13225c6..733024ab7695 100644 --- a/services/actions_datastores/src/v2/ActionsDatastoresApi.ts +++ b/services/actions_datastores/src/v2/ActionsDatastoresApi.ts @@ -23,6 +23,7 @@ import { import { TypingInfo } from "./models/TypingInfo"; import { APIErrorResponse } from "./models/APIErrorResponse"; +import { BulkDeleteAppsDatastoreItemsRequest } from "./models/BulkDeleteAppsDatastoreItemsRequest"; import { BulkPutAppsDatastoreItemsRequest } from "./models/BulkPutAppsDatastoreItemsRequest"; import { CreateAppsDatastoreRequest } from "./models/CreateAppsDatastoreRequest"; import { CreateAppsDatastoreResponse } from "./models/CreateAppsDatastoreResponse"; @@ -30,6 +31,7 @@ import { Datastore } from "./models/Datastore"; import { DatastoreArray } from "./models/DatastoreArray"; import { DeleteAppsDatastoreItemRequest } from "./models/DeleteAppsDatastoreItemRequest"; import { DeleteAppsDatastoreItemResponse } from "./models/DeleteAppsDatastoreItemResponse"; +import { DeleteAppsDatastoreItemResponseArray } from "./models/DeleteAppsDatastoreItemResponseArray"; import { ItemApiPayload } from "./models/ItemApiPayload"; import { ItemApiPayloadArray } from "./models/ItemApiPayloadArray"; import { JSONAPIErrorResponse } from "./models/JSONAPIErrorResponse"; @@ -47,6 +49,66 @@ export class ActionsDatastoresApiRequestFactory extends BaseAPIRequestFactory { this.userAgent = buildUserAgent("actions-datastores", version); } } + public async bulkDeleteDatastoreItems( + datastoreId: string, + body: BulkDeleteAppsDatastoreItemsRequest, + _options?: Configuration, + ): Promise { + const _config = _options || this.configuration; + + // verify required parameter 'datastoreId' is not null or undefined + if (datastoreId === null || datastoreId === undefined) { + throw new RequiredError("datastoreId", "bulkDeleteDatastoreItems"); + } + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError("body", "bulkDeleteDatastoreItems"); + } + + // Path Params + const localVarPath = + "/api/v2/actions-datastores/{datastore_id}/items/bulk".replace( + "{datastore_id}", + encodeURIComponent(String(datastoreId)), + ); + + // Make Request Context + const { server, overrides } = _config.getServerAndOverrides( + "ActionsDatastoresApi.v2.bulkDeleteDatastoreItems", + ActionsDatastoresApi.operationServers, + ); + const requestContext = server.makeRequestContext( + localVarPath, + HttpMethod.DELETE, + overrides, + ); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Set User-Agent + if (this.userAgent) { + requestContext.setHeaderParam("User-Agent", this.userAgent); + } + + // Body Params + const contentType = getPreferredMediaType(["application/json"]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = stringify( + serialize(body, TypingInfo, "BulkDeleteAppsDatastoreItemsRequest", ""), + contentType, + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async bulkWriteDatastoreItems( datastoreId: string, body: BulkPutAppsDatastoreItemsRequest, @@ -548,6 +610,87 @@ export class ActionsDatastoresApiRequestFactory extends BaseAPIRequestFactory { } export class ActionsDatastoresApiResponseProcessor { + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to bulkDeleteDatastoreItems + * @throws ApiException if the response code was not in [200, 299] + */ + public async bulkDeleteDatastoreItems( + response: ResponseContext, + ): Promise { + const contentType = normalizeMediaType(response.headers["content-type"]); + if (response.httpStatusCode === 200) { + const body: DeleteAppsDatastoreItemResponseArray = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "DeleteAppsDatastoreItemResponseArray", + ) as DeleteAppsDatastoreItemResponseArray; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 404 || + response.httpStatusCode === 500 + ) { + const bodyText = parse(await response.body.text(), contentType); + let body: JSONAPIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "JSONAPIErrorResponse", + ) as JSONAPIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException( + response.httpStatusCode, + body, + ); + } + if (response.httpStatusCode === 429) { + const bodyText = parse(await response.body.text(), contentType); + let body: APIErrorResponse; + try { + body = deserialize( + bodyText, + TypingInfo, + "APIErrorResponse", + ) as APIErrorResponse; + } catch (error) { + logger.debug(`Got error deserializing error: ${error}`); + throw new ApiException( + response.httpStatusCode, + bodyText, + ); + } + throw new ApiException(response.httpStatusCode, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: DeleteAppsDatastoreItemResponseArray = deserialize( + parse(await response.body.text(), contentType), + TypingInfo, + "DeleteAppsDatastoreItemResponseArray", + "", + ) as DeleteAppsDatastoreItemResponseArray; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"', + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects @@ -1204,6 +1347,18 @@ export class ActionsDatastoresApiResponseProcessor { } } +export interface ActionsDatastoresApiBulkDeleteDatastoreItemsRequest { + /** + * The ID of the datastore. + * @type string + */ + datastoreId: string; + /** + * @type BulkDeleteAppsDatastoreItemsRequest + */ + body: BulkDeleteAppsDatastoreItemsRequest; +} + export interface ActionsDatastoresApiBulkWriteDatastoreItemsRequest { /** * The unique identifier of the datastore to retrieve. @@ -1328,6 +1483,30 @@ export class ActionsDatastoresApi { responseProcessor || new ActionsDatastoresApiResponseProcessor(); } + /** + * Deletes multiple items from a datastore by their keys in a single operation. + * @param param The request object + */ + public bulkDeleteDatastoreItems( + param: ActionsDatastoresApiBulkDeleteDatastoreItemsRequest, + options?: Configuration, + ): Promise { + const requestContextPromise = this.requestFactory.bulkDeleteDatastoreItems( + param.datastoreId, + param.body, + options, + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.bulkDeleteDatastoreItems( + responseContext, + ); + }); + }); + } + /** * Creates or replaces multiple items in a datastore by their keys in a single operation. * @param param The request object diff --git a/services/actions_datastores/src/v2/index.ts b/services/actions_datastores/src/v2/index.ts index 3d72e5b6ed96..d7cc446a3778 100644 --- a/services/actions_datastores/src/v2/index.ts +++ b/services/actions_datastores/src/v2/index.ts @@ -1,4 +1,5 @@ export { + ActionsDatastoresApiBulkDeleteDatastoreItemsRequest, ActionsDatastoresApiBulkWriteDatastoreItemsRequest, ActionsDatastoresApiCreateDatastoreRequest, ActionsDatastoresApiDeleteDatastoreRequest, @@ -11,6 +12,10 @@ export { } from "./ActionsDatastoresApi"; export { APIErrorResponse } from "./models/APIErrorResponse"; +export { BulkDeleteAppsDatastoreItemsRequest } from "./models/BulkDeleteAppsDatastoreItemsRequest"; +export { BulkDeleteAppsDatastoreItemsRequestData } from "./models/BulkDeleteAppsDatastoreItemsRequestData"; +export { BulkDeleteAppsDatastoreItemsRequestDataAttributes } from "./models/BulkDeleteAppsDatastoreItemsRequestDataAttributes"; +export { BulkDeleteAppsDatastoreItemsRequestDataType } from "./models/BulkDeleteAppsDatastoreItemsRequestDataType"; export { BulkPutAppsDatastoreItemsRequest } from "./models/BulkPutAppsDatastoreItemsRequest"; export { BulkPutAppsDatastoreItemsRequestData } from "./models/BulkPutAppsDatastoreItemsRequestData"; export { BulkPutAppsDatastoreItemsRequestDataAttributes } from "./models/BulkPutAppsDatastoreItemsRequestDataAttributes"; @@ -32,6 +37,7 @@ export { DeleteAppsDatastoreItemRequest } from "./models/DeleteAppsDatastoreItem export { DeleteAppsDatastoreItemRequestData } from "./models/DeleteAppsDatastoreItemRequestData"; export { DeleteAppsDatastoreItemRequestDataAttributes } from "./models/DeleteAppsDatastoreItemRequestDataAttributes"; export { DeleteAppsDatastoreItemResponse } from "./models/DeleteAppsDatastoreItemResponse"; +export { DeleteAppsDatastoreItemResponseArray } from "./models/DeleteAppsDatastoreItemResponseArray"; export { DeleteAppsDatastoreItemResponseData } from "./models/DeleteAppsDatastoreItemResponseData"; export { ItemApiPayload } from "./models/ItemApiPayload"; export { ItemApiPayloadArray } from "./models/ItemApiPayloadArray"; diff --git a/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequest.ts b/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequest.ts new file mode 100644 index 000000000000..4b542e5ec7cf --- /dev/null +++ b/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequest.ts @@ -0,0 +1,46 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { BulkDeleteAppsDatastoreItemsRequestData } from "./BulkDeleteAppsDatastoreItemsRequestData"; + +/** + * Request to delete items from a datastore. + */ +export class BulkDeleteAppsDatastoreItemsRequest { + /** + * Data wrapper containing the data needed to delete items from a datastore. + */ + "data"?: BulkDeleteAppsDatastoreItemsRequestData; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "BulkDeleteAppsDatastoreItemsRequestData", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return BulkDeleteAppsDatastoreItemsRequest.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestData.ts b/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestData.ts new file mode 100644 index 000000000000..c5defeccd610 --- /dev/null +++ b/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestData.ts @@ -0,0 +1,64 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { BulkDeleteAppsDatastoreItemsRequestDataAttributes } from "./BulkDeleteAppsDatastoreItemsRequestDataAttributes"; +import { BulkDeleteAppsDatastoreItemsRequestDataType } from "./BulkDeleteAppsDatastoreItemsRequestDataType"; + +/** + * Data wrapper containing the data needed to delete items from a datastore. + */ +export class BulkDeleteAppsDatastoreItemsRequestData { + /** + * Attributes of request data to delete items from a datastore. + */ + "attributes"?: BulkDeleteAppsDatastoreItemsRequestDataAttributes; + /** + * ID for the datastore of the items to delete. + */ + "id"?: string; + /** + * Items resource type. + */ + "type": BulkDeleteAppsDatastoreItemsRequestDataType; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + attributes: { + baseName: "attributes", + type: "BulkDeleteAppsDatastoreItemsRequestDataAttributes", + }, + id: { + baseName: "id", + type: "string", + }, + type: { + baseName: "type", + type: "BulkDeleteAppsDatastoreItemsRequestDataType", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return BulkDeleteAppsDatastoreItemsRequestData.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestDataAttributes.ts b/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestDataAttributes.ts new file mode 100644 index 000000000000..8678ef42ee16 --- /dev/null +++ b/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestDataAttributes.ts @@ -0,0 +1,44 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * Attributes of request data to delete items from a datastore. + */ +export class BulkDeleteAppsDatastoreItemsRequestDataAttributes { + /** + * List of primary keys identifying items to delete from datastore. Up to 100 items can be deleted in a single request. + */ + "itemKeys"?: Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + itemKeys: { + baseName: "item_keys", + type: "Array", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return BulkDeleteAppsDatastoreItemsRequestDataAttributes.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestDataType.ts b/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestDataType.ts new file mode 100644 index 000000000000..efb9637f81b3 --- /dev/null +++ b/services/actions_datastores/src/v2/models/BulkDeleteAppsDatastoreItemsRequestDataType.ts @@ -0,0 +1,9 @@ +import { UnparsedObject } from "@datadog/datadog-api-client"; + +/** + * Items resource type. + */ +export type BulkDeleteAppsDatastoreItemsRequestDataType = + | typeof ITEMS + | UnparsedObject; +export const ITEMS = "items"; diff --git a/services/actions_datastores/src/v2/models/DeleteAppsDatastoreItemResponseArray.ts b/services/actions_datastores/src/v2/models/DeleteAppsDatastoreItemResponseArray.ts new file mode 100644 index 000000000000..f734216764a2 --- /dev/null +++ b/services/actions_datastores/src/v2/models/DeleteAppsDatastoreItemResponseArray.ts @@ -0,0 +1,47 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +import { DeleteAppsDatastoreItemResponseData } from "./DeleteAppsDatastoreItemResponseData"; + +/** + * The definition of `DeleteAppsDatastoreItemResponseArray` object. + */ +export class DeleteAppsDatastoreItemResponseArray { + /** + * The `DeleteAppsDatastoreItemResponseArray` `data`. + */ + "data": Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + data: { + baseName: "data", + type: "Array", + required: true, + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return DeleteAppsDatastoreItemResponseArray.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/actions_datastores/src/v2/models/TypingInfo.ts b/services/actions_datastores/src/v2/models/TypingInfo.ts index 95eca1f851c1..f884a4716ee8 100644 --- a/services/actions_datastores/src/v2/models/TypingInfo.ts +++ b/services/actions_datastores/src/v2/models/TypingInfo.ts @@ -1,6 +1,9 @@ import { ModelTypingInfo } from "@datadog/datadog-api-client"; import { APIErrorResponse } from "./APIErrorResponse"; +import { BulkDeleteAppsDatastoreItemsRequest } from "./BulkDeleteAppsDatastoreItemsRequest"; +import { BulkDeleteAppsDatastoreItemsRequestData } from "./BulkDeleteAppsDatastoreItemsRequestData"; +import { BulkDeleteAppsDatastoreItemsRequestDataAttributes } from "./BulkDeleteAppsDatastoreItemsRequestDataAttributes"; import { BulkPutAppsDatastoreItemsRequest } from "./BulkPutAppsDatastoreItemsRequest"; import { BulkPutAppsDatastoreItemsRequestData } from "./BulkPutAppsDatastoreItemsRequestData"; import { BulkPutAppsDatastoreItemsRequestDataAttributes } from "./BulkPutAppsDatastoreItemsRequestDataAttributes"; @@ -17,6 +20,7 @@ import { DeleteAppsDatastoreItemRequest } from "./DeleteAppsDatastoreItemRequest import { DeleteAppsDatastoreItemRequestData } from "./DeleteAppsDatastoreItemRequestData"; import { DeleteAppsDatastoreItemRequestDataAttributes } from "./DeleteAppsDatastoreItemRequestDataAttributes"; import { DeleteAppsDatastoreItemResponse } from "./DeleteAppsDatastoreItemResponse"; +import { DeleteAppsDatastoreItemResponseArray } from "./DeleteAppsDatastoreItemResponseArray"; import { DeleteAppsDatastoreItemResponseData } from "./DeleteAppsDatastoreItemResponseData"; import { ItemApiPayload } from "./ItemApiPayload"; import { ItemApiPayloadArray } from "./ItemApiPayloadArray"; @@ -41,6 +45,7 @@ import { UpdateAppsDatastoreRequestDataAttributes } from "./UpdateAppsDatastoreR export const TypingInfo: ModelTypingInfo = { enumsMap: { + BulkDeleteAppsDatastoreItemsRequestDataType: ["items"], CreateAppsDatastoreRequestDataAttributesOrgAccess: [ "contributor", "viewer", @@ -55,6 +60,11 @@ export const TypingInfo: ModelTypingInfo = { oneOfMap: {}, typeMap: { APIErrorResponse: APIErrorResponse, + BulkDeleteAppsDatastoreItemsRequest: BulkDeleteAppsDatastoreItemsRequest, + BulkDeleteAppsDatastoreItemsRequestData: + BulkDeleteAppsDatastoreItemsRequestData, + BulkDeleteAppsDatastoreItemsRequestDataAttributes: + BulkDeleteAppsDatastoreItemsRequestDataAttributes, BulkPutAppsDatastoreItemsRequest: BulkPutAppsDatastoreItemsRequest, BulkPutAppsDatastoreItemsRequestData: BulkPutAppsDatastoreItemsRequestData, BulkPutAppsDatastoreItemsRequestDataAttributes: @@ -74,6 +84,7 @@ export const TypingInfo: ModelTypingInfo = { DeleteAppsDatastoreItemRequestDataAttributes: DeleteAppsDatastoreItemRequestDataAttributes, DeleteAppsDatastoreItemResponse: DeleteAppsDatastoreItemResponse, + DeleteAppsDatastoreItemResponseArray: DeleteAppsDatastoreItemResponseArray, DeleteAppsDatastoreItemResponseData: DeleteAppsDatastoreItemResponseData, ItemApiPayload: ItemApiPayload, ItemApiPayloadArray: ItemApiPayloadArray,