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/examples/v2/actions-datastores/BulkDeleteDatastoreItems.ts b/examples/v2/actions-datastores/BulkDeleteDatastoreItems.ts new file mode 100644 index 000000000000..9cf4c5b298c5 --- /dev/null +++ b/examples/v2/actions-datastores/BulkDeleteDatastoreItems.ts @@ -0,0 +1,32 @@ +/** + * Bulk delete datastore items returns "OK" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +const apiInstance = new v2.ActionsDatastoresApi(configuration); + +// there is a valid "datastore" in the system +const DATASTORE_DATA_ID = process.env.DATASTORE_DATA_ID as string; + +const params: v2.ActionsDatastoresApiBulkDeleteDatastoreItemsRequest = { + body: { + data: { + attributes: { + itemKeys: ["test-key"], + }, + type: "items", + }, + }, + datastoreId: DATASTORE_DATA_ID, +}; + +apiInstance + .bulkDeleteDatastoreItems(params) + .then((data: v2.DeleteAppsDatastoreItemResponseArray) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/features/support/scenarios_model_mapping.ts b/features/support/scenarios_model_mapping.ts index e6200674a6aa..76bdc128c1dd 100644 --- a/features/support/scenarios_model_mapping.ts +++ b/features/support/scenarios_model_mapping.ts @@ -2435,6 +2435,17 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = { }, "operationResponseType": "PutAppsDatastoreItemResponseArray", }, + "v2.BulkDeleteDatastoreItems": { + "datastoreId": { + "type": "string", + "format": "", + }, + "body": { + "type": "BulkDeleteAppsDatastoreItemsRequest", + "format": "", + }, + "operationResponseType": "DeleteAppsDatastoreItemResponseArray", + }, "v2.ListAppKeyRegistrations": { "pageSize": { "type": "number", 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/packages/datadog-api-client-v2/apis/ActionsDatastoresApi.ts b/packages/datadog-api-client-v2/apis/ActionsDatastoresApi.ts index 24a2bd6ed142..0e08086a9686 100644 --- a/packages/datadog-api-client-v2/apis/ActionsDatastoresApi.ts +++ b/packages/datadog-api-client-v2/apis/ActionsDatastoresApi.ts @@ -17,6 +17,7 @@ import { ObjectSerializer } from "../models/ObjectSerializer"; import { ApiException } from "../../datadog-api-client-common/exception"; 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"; @@ -24,6 +25,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"; @@ -32,6 +34,61 @@ import { UpdateAppsDatastoreItemRequest } from "../models/UpdateAppsDatastoreIte import { UpdateAppsDatastoreRequest } from "../models/UpdateAppsDatastoreRequest"; export class ActionsDatastoresApiRequestFactory extends BaseAPIRequestFactory { + 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 requestContext = _config + .getServer("v2.ActionsDatastoresApi.bulkDeleteDatastoreItems") + .makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json"); + requestContext.setHttpConfig(_config.httpConfig); + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize( + body, + "BulkDeleteAppsDatastoreItemsRequest", + "" + ), + contentType + ); + requestContext.setBody(serializedBody); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async bulkWriteDatastoreItems( datastoreId: string, body: BulkPutAppsDatastoreItemsRequest, @@ -444,6 +501,93 @@ 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 = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 200) { + const body: DeleteAppsDatastoreItemResponseArray = + ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "DeleteAppsDatastoreItemResponseArray" + ) as DeleteAppsDatastoreItemResponseArray; + return body; + } + if ( + response.httpStatusCode === 400 || + response.httpStatusCode === 404 || + response.httpStatusCode === 500 + ) { + const bodyText = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: JSONAPIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "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 = ObjectSerializer.parse( + await response.body.text(), + contentType + ); + let body: APIErrorResponse; + try { + body = ObjectSerializer.deserialize( + bodyText, + "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 = + ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "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 @@ -1140,6 +1284,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. @@ -1261,6 +1417,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/packages/datadog-api-client-v2/index.ts b/packages/datadog-api-client-v2/index.ts index 57e340706a4c..e52d5d78768c 100644 --- a/packages/datadog-api-client-v2/index.ts +++ b/packages/datadog-api-client-v2/index.ts @@ -40,6 +40,7 @@ export { } from "./apis/ActionConnectionApi"; export { + ActionsDatastoresApiBulkDeleteDatastoreItemsRequest, ActionsDatastoresApiBulkWriteDatastoreItemsRequest, ActionsDatastoresApiCreateDatastoreRequest, ActionsDatastoresApiDeleteDatastoreRequest, @@ -1184,6 +1185,10 @@ export { BudgetAttributes } from "./models/BudgetAttributes"; export { BudgetEntry } from "./models/BudgetEntry"; export { BudgetWithEntries } from "./models/BudgetWithEntries"; export { BudgetWithEntriesData } from "./models/BudgetWithEntriesData"; +export { BulkDeleteAppsDatastoreItemsRequest } from "./models/BulkDeleteAppsDatastoreItemsRequest"; +export { BulkDeleteAppsDatastoreItemsRequestData } from "./models/BulkDeleteAppsDatastoreItemsRequestData"; +export { BulkDeleteAppsDatastoreItemsRequestDataAttributes } from "./models/BulkDeleteAppsDatastoreItemsRequestDataAttributes"; +export { BulkDeleteAppsDatastoreItemsRequestDataType } from "./models/BulkDeleteAppsDatastoreItemsRequestDataType"; export { BulkMuteFindingsRequest } from "./models/BulkMuteFindingsRequest"; export { BulkMuteFindingsRequestAttributes } from "./models/BulkMuteFindingsRequestAttributes"; export { BulkMuteFindingsRequestData } from "./models/BulkMuteFindingsRequestData"; @@ -1672,6 +1677,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 { DeleteAppsRequest } from "./models/DeleteAppsRequest"; export { DeleteAppsRequestDataItems } from "./models/DeleteAppsRequestDataItems"; diff --git a/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequest.ts b/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequest.ts new file mode 100644 index 000000000000..eee5dab9b653 --- /dev/null +++ b/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequest.ts @@ -0,0 +1,53 @@ +/** + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2020-Present Datadog, Inc. + */ +import { BulkDeleteAppsDatastoreItemsRequestData } from "./BulkDeleteAppsDatastoreItemsRequestData"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * 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/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestData.ts b/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestData.ts new file mode 100644 index 000000000000..9690fa2788aa --- /dev/null +++ b/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestData.ts @@ -0,0 +1,71 @@ +/** + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2020-Present Datadog, Inc. + */ +import { BulkDeleteAppsDatastoreItemsRequestDataAttributes } from "./BulkDeleteAppsDatastoreItemsRequestDataAttributes"; +import { BulkDeleteAppsDatastoreItemsRequestDataType } from "./BulkDeleteAppsDatastoreItemsRequestDataType"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * 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/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestDataAttributes.ts b/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestDataAttributes.ts new file mode 100644 index 000000000000..3c085d164d13 --- /dev/null +++ b/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestDataAttributes.ts @@ -0,0 +1,52 @@ +/** + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2020-Present Datadog, Inc. + */ + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * 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/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestDataType.ts b/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestDataType.ts new file mode 100644 index 000000000000..aa5f6128079b --- /dev/null +++ b/packages/datadog-api-client-v2/models/BulkDeleteAppsDatastoreItemsRequestDataType.ts @@ -0,0 +1,16 @@ +/** + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2020-Present Datadog, Inc. + */ + +import { UnparsedObject } from "../../datadog-api-client-common/util"; + +/** + * Items resource type. + */ + +export type BulkDeleteAppsDatastoreItemsRequestDataType = + | typeof ITEMS + | UnparsedObject; +export const ITEMS = "items"; diff --git a/packages/datadog-api-client-v2/models/DeleteAppsDatastoreItemResponseArray.ts b/packages/datadog-api-client-v2/models/DeleteAppsDatastoreItemResponseArray.ts new file mode 100644 index 000000000000..36aac2703225 --- /dev/null +++ b/packages/datadog-api-client-v2/models/DeleteAppsDatastoreItemResponseArray.ts @@ -0,0 +1,54 @@ +/** + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2020-Present Datadog, Inc. + */ +import { DeleteAppsDatastoreItemResponseData } from "./DeleteAppsDatastoreItemResponseData"; + +import { AttributeTypeMap } from "../../datadog-api-client-common/util"; + +/** + * 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/packages/datadog-api-client-v2/models/ObjectSerializer.ts b/packages/datadog-api-client-v2/models/ObjectSerializer.ts index d8ee5e143d44..a8e40bc9aa72 100644 --- a/packages/datadog-api-client-v2/models/ObjectSerializer.ts +++ b/packages/datadog-api-client-v2/models/ObjectSerializer.ts @@ -247,6 +247,9 @@ import { BudgetAttributes } from "./BudgetAttributes"; import { BudgetEntry } from "./BudgetEntry"; import { BudgetWithEntries } from "./BudgetWithEntries"; import { BudgetWithEntriesData } from "./BudgetWithEntriesData"; +import { BulkDeleteAppsDatastoreItemsRequest } from "./BulkDeleteAppsDatastoreItemsRequest"; +import { BulkDeleteAppsDatastoreItemsRequestData } from "./BulkDeleteAppsDatastoreItemsRequestData"; +import { BulkDeleteAppsDatastoreItemsRequestDataAttributes } from "./BulkDeleteAppsDatastoreItemsRequestDataAttributes"; import { BulkMuteFindingsRequest } from "./BulkMuteFindingsRequest"; import { BulkMuteFindingsRequestAttributes } from "./BulkMuteFindingsRequestAttributes"; import { BulkMuteFindingsRequestData } from "./BulkMuteFindingsRequestData"; @@ -637,6 +640,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 { DeleteAppsRequest } from "./DeleteAppsRequest"; import { DeleteAppsRequestDataItems } from "./DeleteAppsRequestDataItems"; @@ -2563,6 +2567,7 @@ const enumsMap: { [key: string]: any[] } = { "OK", "NOT_FOUND", ], + BulkDeleteAppsDatastoreItemsRequestDataType: ["items"], CIAppAggregateSortType: ["alphabetical", "measure"], CIAppAggregationFunction: [ "count", @@ -4210,6 +4215,11 @@ const typeMap: { [index: string]: any } = { BudgetEntry: BudgetEntry, BudgetWithEntries: BudgetWithEntries, BudgetWithEntriesData: BudgetWithEntriesData, + BulkDeleteAppsDatastoreItemsRequest: BulkDeleteAppsDatastoreItemsRequest, + BulkDeleteAppsDatastoreItemsRequestData: + BulkDeleteAppsDatastoreItemsRequestData, + BulkDeleteAppsDatastoreItemsRequestDataAttributes: + BulkDeleteAppsDatastoreItemsRequestDataAttributes, BulkMuteFindingsRequest: BulkMuteFindingsRequest, BulkMuteFindingsRequestAttributes: BulkMuteFindingsRequestAttributes, BulkMuteFindingsRequestData: BulkMuteFindingsRequestData, @@ -4674,6 +4684,7 @@ const typeMap: { [index: string]: any } = { DeleteAppsDatastoreItemRequestDataAttributes: DeleteAppsDatastoreItemRequestDataAttributes, DeleteAppsDatastoreItemResponse: DeleteAppsDatastoreItemResponse, + DeleteAppsDatastoreItemResponseArray: DeleteAppsDatastoreItemResponseArray, DeleteAppsDatastoreItemResponseData: DeleteAppsDatastoreItemResponseData, DeleteAppsRequest: DeleteAppsRequest, DeleteAppsRequestDataItems: DeleteAppsRequestDataItems,