diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5f50db2f7a57..d3d603bec261 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -56843,6 +56843,40 @@ paths: tags: - DORA Metrics x-codegen-request-body-name: body + /api/v2/dora/deployment/{deployment_id}: + delete: + description: Use this API endpoint to delete a deployment event. + operationId: DeleteDORADeployment + parameters: + - description: The ID of the deployment event to delete. + in: path + name: deployment_id + required: true + schema: + type: string + responses: + '202': + description: Accepted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + - appKeyAuth: [] + summary: Delete a deployment event + tags: + - DORA Metrics + x-permission: + operator: OR + permissions: + - dora_metrics_write /api/v2/dora/deployments: post: description: Use this API endpoint to get a list of deployment events. @@ -56966,6 +57000,40 @@ paths: tags: - DORA Metrics x-codegen-request-body-name: body + /api/v2/dora/failure/{failure_id}: + delete: + description: Use this API endpoint to delete a failure event. + operationId: DeleteDORAFailure + parameters: + - description: The ID of the failure event to delete. + in: path + name: failure_id + required: true + schema: + type: string + responses: + '202': + description: Accepted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + - appKeyAuth: [] + summary: Delete a failure event + tags: + - DORA Metrics + x-permission: + operator: OR + permissions: + - dora_metrics_write /api/v2/dora/failures: post: description: Use this API endpoint to get a list of failure events. @@ -75655,8 +75723,8 @@ tags: See the [Container Monitoring page](https://docs.datadoghq.com/containers/) for more information. name: Containers -- description: 'Search or send events for DORA Metrics to measure and improve your - software delivery performance. See the [DORA Metrics page](https://docs.datadoghq.com/dora_metrics/) +- description: 'Search, send, or delete events for DORA Metrics to measure and improve + your software delivery performance. See the [DORA Metrics page](https://docs.datadoghq.com/dora_metrics/) for more information. diff --git a/examples/v2/dora-metrics/DeleteDORADeployment.ts b/examples/v2/dora-metrics/DeleteDORADeployment.ts new file mode 100644 index 000000000000..67af0424807e --- /dev/null +++ b/examples/v2/dora-metrics/DeleteDORADeployment.ts @@ -0,0 +1,21 @@ +/** + * Delete a deployment event returns "Accepted" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +const apiInstance = new v2.DORAMetricsApi(configuration); + +const params: v2.DORAMetricsApiDeleteDORADeploymentRequest = { + deploymentId: "NO_VALUE", +}; + +apiInstance + .deleteDORADeployment(params) + .then((data: any) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); diff --git a/examples/v2/dora-metrics/DeleteDORAFailure.ts b/examples/v2/dora-metrics/DeleteDORAFailure.ts new file mode 100644 index 000000000000..eaf1a1fa185f --- /dev/null +++ b/examples/v2/dora-metrics/DeleteDORAFailure.ts @@ -0,0 +1,21 @@ +/** + * Delete a failure event returns "Accepted" response + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +const apiInstance = new v2.DORAMetricsApi(configuration); + +const params: v2.DORAMetricsApiDeleteDORAFailureRequest = { + failureId: "NO_VALUE", +}; + +apiInstance + .deleteDORAFailure(params) + .then((data: any) => { + 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 8d1da14f9516..9cc4178c6988 100644 --- a/features/support/scenarios_model_mapping.ts +++ b/features/support/scenarios_model_mapping.ts @@ -4994,6 +4994,13 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = { }, "operationResponseType": "DORADeploymentResponse", }, + "v2.DeleteDORADeployment": { + "deploymentId": { + "type": "string", + "format": "", + }, + "operationResponseType": "{}", + }, "v2.ListDORADeployments": { "body": { "type": "DORAListDeploymentsRequest", @@ -5015,6 +5022,13 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = { }, "operationResponseType": "DORAFailureResponse", }, + "v2.DeleteDORAFailure": { + "failureId": { + "type": "string", + "format": "", + }, + "operationResponseType": "{}", + }, "v2.ListDORAFailures": { "body": { "type": "DORAListFailuresRequest", diff --git a/features/v2/dora_metrics.feature b/features/v2/dora_metrics.feature index acc8230e3616..e34092056ca5 100644 --- a/features/v2/dora_metrics.feature +++ b/features/v2/dora_metrics.feature @@ -1,7 +1,7 @@ @endpoint(dora-metrics) @endpoint(dora-metrics-v2) Feature: DORA Metrics - Search or send events for DORA Metrics to measure and improve your - software delivery performance. See the [DORA Metrics + Search, send, or delete events for DORA Metrics to measure and improve + your software delivery performance. See the [DORA Metrics page](https://docs.datadoghq.com/dora_metrics/) for more information. **Note**: DORA Metrics are not available in the US1-FED site. @@ -9,6 +9,37 @@ Feature: DORA Metrics Given a valid "apiKeyAuth" key in the system And an instance of "DORAMetrics" API + @skip @team:DataDog/ci-app-backend + Scenario: Delete a deployment event returns "Accepted" response + Given new "DeleteDORADeployment" request + And a valid "appKeyAuth" key in the system + And request contains "deployment_id" parameter with value "NO_VALUE" + When the request is sent + Then the response status is 202 Accepted + + @skip @team:DataDog/ci-app-backend + Scenario: Delete a deployment event returns "Bad Request" response + Given new "DeleteDORADeployment" request + And request contains "deployment_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/ci-app-backend + Scenario: Delete a failure event returns "Accepted" response + Given new "DeleteDORAFailure" request + And a valid "appKeyAuth" key in the system + And request contains "failure_id" parameter with value "NO_VALUE" + When the request is sent + Then the response status is 202 Accepted + + @skip @team:DataDog/ci-app-backend + Scenario: Delete a failure event returns "Bad Request" response + Given new "DeleteDORAFailure" request + And a valid "appKeyAuth" key in the system + And request contains "failure_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + @generated @skip @team:DataDog/ci-app-backend Scenario: Get a deployment event returns "Bad Request" response Given new "GetDORADeployment" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 7f8336d494c4..d864e99bb626 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -1064,6 +1064,12 @@ "type": "idempotent" } }, + "DeleteDORADeployment": { + "tag": "DORA Metrics", + "undo": { + "type": "idempotent" + } + }, "ListDORADeployments": { "tag": "DORA Metrics", "undo": { @@ -1082,6 +1088,12 @@ "type": "idempotent" } }, + "DeleteDORAFailure": { + "tag": "DORA Metrics", + "undo": { + "type": "idempotent" + } + }, "ListDORAFailures": { "tag": "DORA Metrics", "undo": { diff --git a/packages/datadog-api-client-v2/apis/DORAMetricsApi.ts b/packages/datadog-api-client-v2/apis/DORAMetricsApi.ts index 8a190b833726..b566db9f2ab7 100644 --- a/packages/datadog-api-client-v2/apis/DORAMetricsApi.ts +++ b/packages/datadog-api-client-v2/apis/DORAMetricsApi.ts @@ -142,6 +142,72 @@ export class DORAMetricsApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + public async deleteDORADeployment( + deploymentId: string, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + // verify required parameter 'deploymentId' is not null or undefined + if (deploymentId === null || deploymentId === undefined) { + throw new RequiredError("deploymentId", "deleteDORADeployment"); + } + + // Path Params + const localVarPath = "/api/v2/dora/deployment/{deployment_id}".replace( + "{deployment_id}", + encodeURIComponent(String(deploymentId)) + ); + + // Make Request Context + const requestContext = _config + .getServer("v2.DORAMetricsApi.deleteDORADeployment") + .makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "*/*"); + requestContext.setHttpConfig(_config.httpConfig); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + + public async deleteDORAFailure( + failureId: string, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + // verify required parameter 'failureId' is not null or undefined + if (failureId === null || failureId === undefined) { + throw new RequiredError("failureId", "deleteDORAFailure"); + } + + // Path Params + const localVarPath = "/api/v2/dora/failure/{failure_id}".replace( + "{failure_id}", + encodeURIComponent(String(failureId)) + ); + + // Make Request Context + const requestContext = _config + .getServer("v2.DORAMetricsApi.deleteDORAFailure") + .makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "*/*"); + requestContext.setHttpConfig(_config.httpConfig); + + // Apply auth methods + applySecurityAuthentication(_config, requestContext, [ + "apiKeyAuth", + "appKeyAuth", + ]); + + return requestContext; + } + public async getDORADeployment( deploymentId: string, _options?: Configuration @@ -535,6 +601,146 @@ export class DORAMetricsApiResponseProcessor { ); } + /** + * 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 deleteDORADeployment + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteDORADeployment(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 202) { + return; + } + if (response.httpStatusCode === 400) { + 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 === 403 || 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) { + return; + } + + 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 + * + * @params response Response returned by the server for a request to deleteDORAFailure + * @throws ApiException if the response code was not in [200, 299] + */ + public async deleteDORAFailure(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (response.httpStatusCode === 202) { + return; + } + if (response.httpStatusCode === 400) { + 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 === 403 || 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) { + return; + } + + 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 @@ -881,6 +1087,22 @@ export interface DORAMetricsApiCreateDORAIncidentRequest { body: DORAFailureRequest; } +export interface DORAMetricsApiDeleteDORADeploymentRequest { + /** + * The ID of the deployment event to delete. + * @type string + */ + deploymentId: string; +} + +export interface DORAMetricsApiDeleteDORAFailureRequest { + /** + * The ID of the failure event to delete. + * @type string + */ + failureId: string; +} + export interface DORAMetricsApiGetDORADeploymentRequest { /** * The ID of the deployment event. @@ -1006,6 +1228,48 @@ export class DORAMetricsApi { }); } + /** + * Use this API endpoint to delete a deployment event. + * @param param The request object + */ + public deleteDORADeployment( + param: DORAMetricsApiDeleteDORADeploymentRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.deleteDORADeployment( + param.deploymentId, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.deleteDORADeployment(responseContext); + }); + }); + } + + /** + * Use this API endpoint to delete a failure event. + * @param param The request object + */ + public deleteDORAFailure( + param: DORAMetricsApiDeleteDORAFailureRequest, + options?: Configuration + ): Promise { + const requestContextPromise = this.requestFactory.deleteDORAFailure( + param.failureId, + options + ); + return requestContextPromise.then((requestContext) => { + return this.configuration.httpApi + .send(requestContext) + .then((responseContext) => { + return this.responseProcessor.deleteDORAFailure(responseContext); + }); + }); + } + /** * Use this API endpoint to get a deployment event. * @param param The request object diff --git a/packages/datadog-api-client-v2/index.ts b/packages/datadog-api-client-v2/index.ts index f9e2ce36b98e..b38c21d96ed8 100644 --- a/packages/datadog-api-client-v2/index.ts +++ b/packages/datadog-api-client-v2/index.ts @@ -232,6 +232,8 @@ export { DORAMetricsApiCreateDORADeploymentRequest, DORAMetricsApiCreateDORAFailureRequest, DORAMetricsApiCreateDORAIncidentRequest, + DORAMetricsApiDeleteDORADeploymentRequest, + DORAMetricsApiDeleteDORAFailureRequest, DORAMetricsApiGetDORADeploymentRequest, DORAMetricsApiGetDORAFailureRequest, DORAMetricsApiListDORADeploymentsRequest,