Skip to content

Commit 30f9481

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add Public Delete Dora Events Endpoints (#3330)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent df4670f commit 30f9481

7 files changed

Lines changed: 321 additions & 4 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56843,6 +56843,40 @@ paths:
5684356843
tags:
5684456844
- DORA Metrics
5684556845
x-codegen-request-body-name: body
56846+
/api/v2/dora/deployment/{deployment_id}:
56847+
delete:
56848+
description: Use this API endpoint to delete a deployment event.
56849+
operationId: DeleteDORADeployment
56850+
parameters:
56851+
- description: The ID of the deployment event to delete.
56852+
in: path
56853+
name: deployment_id
56854+
required: true
56855+
schema:
56856+
type: string
56857+
responses:
56858+
'202':
56859+
description: Accepted
56860+
'400':
56861+
content:
56862+
application/json:
56863+
schema:
56864+
$ref: '#/components/schemas/JSONAPIErrorResponse'
56865+
description: Bad Request
56866+
'403':
56867+
$ref: '#/components/responses/NotAuthorizedResponse'
56868+
'429':
56869+
$ref: '#/components/responses/TooManyRequestsResponse'
56870+
security:
56871+
- apiKeyAuth: []
56872+
- appKeyAuth: []
56873+
summary: Delete a deployment event
56874+
tags:
56875+
- DORA Metrics
56876+
x-permission:
56877+
operator: OR
56878+
permissions:
56879+
- dora_metrics_write
5684656880
/api/v2/dora/deployments:
5684756881
post:
5684856882
description: Use this API endpoint to get a list of deployment events.
@@ -56966,6 +57000,40 @@ paths:
5696657000
tags:
5696757001
- DORA Metrics
5696857002
x-codegen-request-body-name: body
57003+
/api/v2/dora/failure/{failure_id}:
57004+
delete:
57005+
description: Use this API endpoint to delete a failure event.
57006+
operationId: DeleteDORAFailure
57007+
parameters:
57008+
- description: The ID of the failure event to delete.
57009+
in: path
57010+
name: failure_id
57011+
required: true
57012+
schema:
57013+
type: string
57014+
responses:
57015+
'202':
57016+
description: Accepted
57017+
'400':
57018+
content:
57019+
application/json:
57020+
schema:
57021+
$ref: '#/components/schemas/JSONAPIErrorResponse'
57022+
description: Bad Request
57023+
'403':
57024+
$ref: '#/components/responses/NotAuthorizedResponse'
57025+
'429':
57026+
$ref: '#/components/responses/TooManyRequestsResponse'
57027+
security:
57028+
- apiKeyAuth: []
57029+
- appKeyAuth: []
57030+
summary: Delete a failure event
57031+
tags:
57032+
- DORA Metrics
57033+
x-permission:
57034+
operator: OR
57035+
permissions:
57036+
- dora_metrics_write
5696957037
/api/v2/dora/failures:
5697057038
post:
5697157039
description: Use this API endpoint to get a list of failure events.
@@ -75655,8 +75723,8 @@ tags:
7565575723
See the [Container Monitoring page](https://docs.datadoghq.com/containers/) for
7565675724
more information.
7565775725
name: Containers
75658-
- description: 'Search or send events for DORA Metrics to measure and improve your
75659-
software delivery performance. See the [DORA Metrics page](https://docs.datadoghq.com/dora_metrics/)
75726+
- description: 'Search, send, or delete events for DORA Metrics to measure and improve
75727+
your software delivery performance. See the [DORA Metrics page](https://docs.datadoghq.com/dora_metrics/)
7566075728
for more information.
7566175729

7566275730

api/datadogV2/api_dora_metrics.go

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,160 @@ func (a *DORAMetricsApi) CreateDORAIncident(ctx _context.Context, body DORAFailu
278278
return localVarReturnValue, localVarHTTPResponse, nil
279279
}
280280

281+
// DeleteDORADeployment Delete a deployment event.
282+
// Use this API endpoint to delete a deployment event.
283+
func (a *DORAMetricsApi) DeleteDORADeployment(ctx _context.Context, deploymentId string) (*_nethttp.Response, error) {
284+
var (
285+
localVarHTTPMethod = _nethttp.MethodDelete
286+
localVarPostBody interface{}
287+
)
288+
289+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DORAMetricsApi.DeleteDORADeployment")
290+
if err != nil {
291+
return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
292+
}
293+
294+
localVarPath := localBasePath + "/api/v2/dora/deployment/{deployment_id}"
295+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{deployment_id}", _neturl.PathEscape(datadog.ParameterToString(deploymentId, "")))
296+
297+
localVarHeaderParams := make(map[string]string)
298+
localVarQueryParams := _neturl.Values{}
299+
localVarFormParams := _neturl.Values{}
300+
localVarHeaderParams["Accept"] = "*/*"
301+
302+
if a.Client.Cfg.DelegatedTokenConfig != nil {
303+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
304+
if err != nil {
305+
return nil, err
306+
}
307+
} else {
308+
datadog.SetAuthKeys(
309+
ctx,
310+
&localVarHeaderParams,
311+
[2]string{"apiKeyAuth", "DD-API-KEY"},
312+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
313+
)
314+
}
315+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
316+
if err != nil {
317+
return nil, err
318+
}
319+
320+
localVarHTTPResponse, err := a.Client.CallAPI(req)
321+
if err != nil || localVarHTTPResponse == nil {
322+
return localVarHTTPResponse, err
323+
}
324+
325+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
326+
if err != nil {
327+
return localVarHTTPResponse, err
328+
}
329+
330+
if localVarHTTPResponse.StatusCode >= 300 {
331+
newErr := datadog.GenericOpenAPIError{
332+
ErrorBody: localVarBody,
333+
ErrorMessage: localVarHTTPResponse.Status,
334+
}
335+
if localVarHTTPResponse.StatusCode == 400 {
336+
var v JSONAPIErrorResponse
337+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
338+
if err != nil {
339+
return localVarHTTPResponse, newErr
340+
}
341+
newErr.ErrorModel = v
342+
return localVarHTTPResponse, newErr
343+
}
344+
if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 {
345+
var v APIErrorResponse
346+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
347+
if err != nil {
348+
return localVarHTTPResponse, newErr
349+
}
350+
newErr.ErrorModel = v
351+
}
352+
return localVarHTTPResponse, newErr
353+
}
354+
355+
return localVarHTTPResponse, nil
356+
}
357+
358+
// DeleteDORAFailure Delete a failure event.
359+
// Use this API endpoint to delete a failure event.
360+
func (a *DORAMetricsApi) DeleteDORAFailure(ctx _context.Context, failureId string) (*_nethttp.Response, error) {
361+
var (
362+
localVarHTTPMethod = _nethttp.MethodDelete
363+
localVarPostBody interface{}
364+
)
365+
366+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DORAMetricsApi.DeleteDORAFailure")
367+
if err != nil {
368+
return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
369+
}
370+
371+
localVarPath := localBasePath + "/api/v2/dora/failure/{failure_id}"
372+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{failure_id}", _neturl.PathEscape(datadog.ParameterToString(failureId, "")))
373+
374+
localVarHeaderParams := make(map[string]string)
375+
localVarQueryParams := _neturl.Values{}
376+
localVarFormParams := _neturl.Values{}
377+
localVarHeaderParams["Accept"] = "*/*"
378+
379+
if a.Client.Cfg.DelegatedTokenConfig != nil {
380+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
381+
if err != nil {
382+
return nil, err
383+
}
384+
} else {
385+
datadog.SetAuthKeys(
386+
ctx,
387+
&localVarHeaderParams,
388+
[2]string{"apiKeyAuth", "DD-API-KEY"},
389+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
390+
)
391+
}
392+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
393+
if err != nil {
394+
return nil, err
395+
}
396+
397+
localVarHTTPResponse, err := a.Client.CallAPI(req)
398+
if err != nil || localVarHTTPResponse == nil {
399+
return localVarHTTPResponse, err
400+
}
401+
402+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
403+
if err != nil {
404+
return localVarHTTPResponse, err
405+
}
406+
407+
if localVarHTTPResponse.StatusCode >= 300 {
408+
newErr := datadog.GenericOpenAPIError{
409+
ErrorBody: localVarBody,
410+
ErrorMessage: localVarHTTPResponse.Status,
411+
}
412+
if localVarHTTPResponse.StatusCode == 400 {
413+
var v JSONAPIErrorResponse
414+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
415+
if err != nil {
416+
return localVarHTTPResponse, newErr
417+
}
418+
newErr.ErrorModel = v
419+
return localVarHTTPResponse, newErr
420+
}
421+
if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 {
422+
var v APIErrorResponse
423+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
424+
if err != nil {
425+
return localVarHTTPResponse, newErr
426+
}
427+
newErr.ErrorModel = v
428+
}
429+
return localVarHTTPResponse, newErr
430+
}
431+
432+
return localVarHTTPResponse, nil
433+
}
434+
281435
// GetDORADeployment Get a deployment event.
282436
// Use this API endpoint to get a deployment event.
283437
func (a *DORAMetricsApi) GetDORADeployment(ctx _context.Context, deploymentId string) (DORAFetchResponse, *_nethttp.Response, error) {

api/datadogV2/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@
174174
// - [DORAMetricsApi.CreateDORADeployment]
175175
// - [DORAMetricsApi.CreateDORAFailure]
176176
// - [DORAMetricsApi.CreateDORAIncident]
177+
// - [DORAMetricsApi.DeleteDORADeployment]
178+
// - [DORAMetricsApi.DeleteDORAFailure]
177179
// - [DORAMetricsApi.GetDORADeployment]
178180
// - [DORAMetricsApi.GetDORAFailure]
179181
// - [DORAMetricsApi.ListDORADeployments]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Delete a deployment event returns "Accepted" response
2+
3+
package main
4+
5+
import (
6+
"context"
7+
"fmt"
8+
"os"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
12+
)
13+
14+
func main() {
15+
ctx := datadog.NewDefaultContext(context.Background())
16+
configuration := datadog.NewConfiguration()
17+
apiClient := datadog.NewAPIClient(configuration)
18+
api := datadogV2.NewDORAMetricsApi(apiClient)
19+
r, err := api.DeleteDORADeployment(ctx, "NO_VALUE")
20+
21+
if err != nil {
22+
fmt.Fprintf(os.Stderr, "Error when calling `DORAMetricsApi.DeleteDORADeployment`: %v\n", err)
23+
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Delete a failure event returns "Accepted" response
2+
3+
package main
4+
5+
import (
6+
"context"
7+
"fmt"
8+
"os"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
12+
)
13+
14+
func main() {
15+
ctx := datadog.NewDefaultContext(context.Background())
16+
configuration := datadog.NewConfiguration()
17+
apiClient := datadog.NewAPIClient(configuration)
18+
api := datadogV2.NewDORAMetricsApi(apiClient)
19+
r, err := api.DeleteDORAFailure(ctx, "NO_VALUE")
20+
21+
if err != nil {
22+
fmt.Fprintf(os.Stderr, "Error when calling `DORAMetricsApi.DeleteDORAFailure`: %v\n", err)
23+
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
24+
}
25+
}

tests/scenarios/features/v2/dora_metrics.feature

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,45 @@
11
@endpoint(dora-metrics) @endpoint(dora-metrics-v2)
22
Feature: DORA Metrics
3-
Search or send events for DORA Metrics to measure and improve your
4-
software delivery performance. See the [DORA Metrics
3+
Search, send, or delete events for DORA Metrics to measure and improve
4+
your software delivery performance. See the [DORA Metrics
55
page](https://docs.datadoghq.com/dora_metrics/) for more information.
66
**Note**: DORA Metrics are not available in the US1-FED site.
77

88
Background:
99
Given a valid "apiKeyAuth" key in the system
1010
And an instance of "DORAMetrics" API
1111

12+
@skip @team:DataDog/ci-app-backend
13+
Scenario: Delete a deployment event returns "Accepted" response
14+
Given new "DeleteDORADeployment" request
15+
And a valid "appKeyAuth" key in the system
16+
And request contains "deployment_id" parameter with value "NO_VALUE"
17+
When the request is sent
18+
Then the response status is 202 Accepted
19+
20+
@skip @team:DataDog/ci-app-backend
21+
Scenario: Delete a deployment event returns "Bad Request" response
22+
Given new "DeleteDORADeployment" request
23+
And request contains "deployment_id" parameter from "REPLACE.ME"
24+
When the request is sent
25+
Then the response status is 400 Bad Request
26+
27+
@skip @team:DataDog/ci-app-backend
28+
Scenario: Delete a failure event returns "Accepted" response
29+
Given new "DeleteDORAFailure" request
30+
And a valid "appKeyAuth" key in the system
31+
And request contains "failure_id" parameter with value "NO_VALUE"
32+
When the request is sent
33+
Then the response status is 202 Accepted
34+
35+
@skip @team:DataDog/ci-app-backend
36+
Scenario: Delete a failure event returns "Bad Request" response
37+
Given new "DeleteDORAFailure" request
38+
And a valid "appKeyAuth" key in the system
39+
And request contains "failure_id" parameter from "REPLACE.ME"
40+
When the request is sent
41+
Then the response status is 400 Bad Request
42+
1243
@generated @skip @team:DataDog/ci-app-backend
1344
Scenario: Get a deployment event returns "Bad Request" response
1445
Given new "GetDORADeployment" request

tests/scenarios/features/v2/undo.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,12 @@
10641064
"type": "idempotent"
10651065
}
10661066
},
1067+
"DeleteDORADeployment": {
1068+
"tag": "DORA Metrics",
1069+
"undo": {
1070+
"type": "idempotent"
1071+
}
1072+
},
10671073
"ListDORADeployments": {
10681074
"tag": "DORA Metrics",
10691075
"undo": {
@@ -1082,6 +1088,12 @@
10821088
"type": "idempotent"
10831089
}
10841090
},
1091+
"DeleteDORAFailure": {
1092+
"tag": "DORA Metrics",
1093+
"undo": {
1094+
"type": "idempotent"
1095+
}
1096+
},
10851097
"ListDORAFailures": {
10861098
"tag": "DORA Metrics",
10871099
"undo": {

0 commit comments

Comments
 (0)