Skip to content

Commit 5116240

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add public patch DORA deployment endpoint (#3641)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 51c00e7 commit 5116240

16 files changed

Lines changed: 1062 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17239,6 +17239,89 @@ components:
1723917239
- started_at
1724017240
- finished_at
1724117241
type: object
17242+
DORADeploymentPatchRemediation:
17243+
description: Remediation details for the deployment.
17244+
properties:
17245+
id:
17246+
description: The ID of the remediation action.
17247+
example: eG42zNIkVjM
17248+
type: string
17249+
type:
17250+
$ref: '#/components/schemas/DORADeploymentPatchRemediationType'
17251+
required:
17252+
- id
17253+
- type
17254+
type: object
17255+
DORADeploymentPatchRemediationType:
17256+
description: The type of remediation action taken.
17257+
enum:
17258+
- rollback
17259+
- rollforward
17260+
example: rollback
17261+
type: string
17262+
x-enum-varnames:
17263+
- ROLLBACK
17264+
- ROLLFORWARD
17265+
DORADeploymentPatchRequest:
17266+
description: Request to patch a DORA deployment event.
17267+
example:
17268+
data:
17269+
attributes:
17270+
change_failure: true
17271+
remediation:
17272+
id: eG42zNIkVjM
17273+
type: rollback
17274+
id: z_RwVLi7v4Y
17275+
type: dora_deployment_patch_request
17276+
properties:
17277+
data:
17278+
$ref: '#/components/schemas/DORADeploymentPatchRequestData'
17279+
required:
17280+
- data
17281+
type: object
17282+
DORADeploymentPatchRequestAttributes:
17283+
description: Attributes for patching a DORA deployment event.
17284+
properties:
17285+
change_failure:
17286+
description: Indicates whether the deployment resulted in a change failure.
17287+
example: true
17288+
type: boolean
17289+
remediation:
17290+
$ref: '#/components/schemas/DORADeploymentPatchRemediation'
17291+
type: object
17292+
DORADeploymentPatchRequestData:
17293+
description: The JSON:API data for patching a deployment.
17294+
example:
17295+
attributes:
17296+
change_failure: true
17297+
remediation:
17298+
id: eG42zNIkVjM
17299+
type: rollback
17300+
id: z_RwVLi7v4Y
17301+
type: dora_deployment_patch_request
17302+
properties:
17303+
attributes:
17304+
$ref: '#/components/schemas/DORADeploymentPatchRequestAttributes'
17305+
id:
17306+
description: The ID of the deployment to patch.
17307+
example: z_RwVLi7v4Y
17308+
type: string
17309+
type:
17310+
$ref: '#/components/schemas/DORADeploymentPatchRequestDataType'
17311+
required:
17312+
- type
17313+
- id
17314+
- attributes
17315+
type: object
17316+
DORADeploymentPatchRequestDataType:
17317+
default: dora_deployment_patch_request
17318+
description: JSON:API type for DORA deployment patch request.
17319+
enum:
17320+
- dora_deployment_patch_request
17321+
example: dora_deployment_patch_request
17322+
type: string
17323+
x-enum-varnames:
17324+
- DORA_DEPLOYMENT_PATCH_REQUEST
1724217325
DORADeploymentRequest:
1724317326
description: Request to create a DORA deployment event.
1724417327
properties:
@@ -74974,6 +75057,46 @@ paths:
7497475057
operator: OR
7497575058
permissions:
7497675059
- dora_metrics_read
75060+
patch:
75061+
description: Use this API endpoint to patch a deployment event.
75062+
operationId: PatchDORADeployment
75063+
parameters:
75064+
- description: The ID of the deployment event.
75065+
in: path
75066+
name: deployment_id
75067+
required: true
75068+
schema:
75069+
type: string
75070+
requestBody:
75071+
content:
75072+
application/json:
75073+
schema:
75074+
$ref: '#/components/schemas/DORADeploymentPatchRequest'
75075+
required: true
75076+
responses:
75077+
'202':
75078+
description: Accepted
75079+
'400':
75080+
content:
75081+
application/json:
75082+
schema:
75083+
$ref: '#/components/schemas/JSONAPIErrorResponse'
75084+
description: Bad Request
75085+
'403':
75086+
$ref: '#/components/responses/NotAuthorizedResponse'
75087+
'429':
75088+
$ref: '#/components/responses/TooManyRequestsResponse'
75089+
security:
75090+
- apiKeyAuth: []
75091+
appKeyAuth: []
75092+
summary: Patch a deployment event
75093+
tags:
75094+
- DORA Metrics
75095+
x-codegen-request-body-name: body
75096+
x-permission:
75097+
operator: OR
75098+
permissions:
75099+
- dora_metrics_write
7497775100
/api/v2/dora/failure:
7497875101
post:
7497975102
description: 'Use this API endpoint to provide failure data.

api/datadogV2/api_dora_metrics.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,86 @@ func (a *DORAMetricsApi) ListDORAFailures(ctx _context.Context, body DORAListFai
784784
return localVarReturnValue, localVarHTTPResponse, nil
785785
}
786786

787+
// PatchDORADeployment Patch a deployment event.
788+
// Use this API endpoint to patch a deployment event.
789+
func (a *DORAMetricsApi) PatchDORADeployment(ctx _context.Context, deploymentId string, body DORADeploymentPatchRequest) (*_nethttp.Response, error) {
790+
var (
791+
localVarHTTPMethod = _nethttp.MethodPatch
792+
localVarPostBody interface{}
793+
)
794+
795+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DORAMetricsApi.PatchDORADeployment")
796+
if err != nil {
797+
return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
798+
}
799+
800+
localVarPath := localBasePath + "/api/v2/dora/deployments/{deployment_id}"
801+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{deployment_id}", _neturl.PathEscape(datadog.ParameterToString(deploymentId, "")))
802+
803+
localVarHeaderParams := make(map[string]string)
804+
localVarQueryParams := _neturl.Values{}
805+
localVarFormParams := _neturl.Values{}
806+
localVarHeaderParams["Content-Type"] = "application/json"
807+
localVarHeaderParams["Accept"] = "*/*"
808+
809+
// body params
810+
localVarPostBody = &body
811+
if a.Client.Cfg.DelegatedTokenConfig != nil {
812+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
813+
if err != nil {
814+
return nil, err
815+
}
816+
} else {
817+
datadog.SetAuthKeys(
818+
ctx,
819+
&localVarHeaderParams,
820+
[2]string{"apiKeyAuth", "DD-API-KEY"},
821+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
822+
)
823+
}
824+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
825+
if err != nil {
826+
return nil, err
827+
}
828+
829+
localVarHTTPResponse, err := a.Client.CallAPI(req)
830+
if err != nil || localVarHTTPResponse == nil {
831+
return localVarHTTPResponse, err
832+
}
833+
834+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
835+
if err != nil {
836+
return localVarHTTPResponse, err
837+
}
838+
839+
if localVarHTTPResponse.StatusCode >= 300 {
840+
newErr := datadog.GenericOpenAPIError{
841+
ErrorBody: localVarBody,
842+
ErrorMessage: localVarHTTPResponse.Status,
843+
}
844+
if localVarHTTPResponse.StatusCode == 400 {
845+
var v JSONAPIErrorResponse
846+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
847+
if err != nil {
848+
return localVarHTTPResponse, newErr
849+
}
850+
newErr.ErrorModel = v
851+
return localVarHTTPResponse, newErr
852+
}
853+
if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 {
854+
var v APIErrorResponse
855+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
856+
if err != nil {
857+
return localVarHTTPResponse, newErr
858+
}
859+
newErr.ErrorModel = v
860+
}
861+
return localVarHTTPResponse, newErr
862+
}
863+
864+
return localVarHTTPResponse, nil
865+
}
866+
787867
// NewDORAMetricsApi Returns NewDORAMetricsApi.
788868
func NewDORAMetricsApi(client *datadog.APIClient) *DORAMetricsApi {
789869
return &DORAMetricsApi{

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
// - [DORAMetricsApi.GetDORAFailure]
218218
// - [DORAMetricsApi.ListDORADeployments]
219219
// - [DORAMetricsApi.ListDORAFailures]
220+
// - [DORAMetricsApi.PatchDORADeployment]
220221
// - [DashboardListsApi.CreateDashboardListItems]
221222
// - [DashboardListsApi.DeleteDashboardListItems]
222223
// - [DashboardListsApi.GetDashboardListItems]
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// DORADeploymentPatchRemediation Remediation details for the deployment.
14+
type DORADeploymentPatchRemediation struct {
15+
// The ID of the remediation action.
16+
Id string `json:"id"`
17+
// The type of remediation action taken.
18+
Type DORADeploymentPatchRemediationType `json:"type"`
19+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
20+
UnparsedObject map[string]interface{} `json:"-"`
21+
AdditionalProperties map[string]interface{} `json:"-"`
22+
}
23+
24+
// NewDORADeploymentPatchRemediation instantiates a new DORADeploymentPatchRemediation object.
25+
// This constructor will assign default values to properties that have it defined,
26+
// and makes sure properties required by API are set, but the set of arguments
27+
// will change when the set of required properties is changed.
28+
func NewDORADeploymentPatchRemediation(id string, typeVar DORADeploymentPatchRemediationType) *DORADeploymentPatchRemediation {
29+
this := DORADeploymentPatchRemediation{}
30+
this.Id = id
31+
this.Type = typeVar
32+
return &this
33+
}
34+
35+
// NewDORADeploymentPatchRemediationWithDefaults instantiates a new DORADeploymentPatchRemediation object.
36+
// This constructor will only assign default values to properties that have it defined,
37+
// but it doesn't guarantee that properties required by API are set.
38+
func NewDORADeploymentPatchRemediationWithDefaults() *DORADeploymentPatchRemediation {
39+
this := DORADeploymentPatchRemediation{}
40+
return &this
41+
}
42+
43+
// GetId returns the Id field value.
44+
func (o *DORADeploymentPatchRemediation) GetId() string {
45+
if o == nil {
46+
var ret string
47+
return ret
48+
}
49+
return o.Id
50+
}
51+
52+
// GetIdOk returns a tuple with the Id field value
53+
// and a boolean to check if the value has been set.
54+
func (o *DORADeploymentPatchRemediation) GetIdOk() (*string, bool) {
55+
if o == nil {
56+
return nil, false
57+
}
58+
return &o.Id, true
59+
}
60+
61+
// SetId sets field value.
62+
func (o *DORADeploymentPatchRemediation) SetId(v string) {
63+
o.Id = v
64+
}
65+
66+
// GetType returns the Type field value.
67+
func (o *DORADeploymentPatchRemediation) GetType() DORADeploymentPatchRemediationType {
68+
if o == nil {
69+
var ret DORADeploymentPatchRemediationType
70+
return ret
71+
}
72+
return o.Type
73+
}
74+
75+
// GetTypeOk returns a tuple with the Type field value
76+
// and a boolean to check if the value has been set.
77+
func (o *DORADeploymentPatchRemediation) GetTypeOk() (*DORADeploymentPatchRemediationType, bool) {
78+
if o == nil {
79+
return nil, false
80+
}
81+
return &o.Type, true
82+
}
83+
84+
// SetType sets field value.
85+
func (o *DORADeploymentPatchRemediation) SetType(v DORADeploymentPatchRemediationType) {
86+
o.Type = v
87+
}
88+
89+
// MarshalJSON serializes the struct using spec logic.
90+
func (o DORADeploymentPatchRemediation) MarshalJSON() ([]byte, error) {
91+
toSerialize := map[string]interface{}{}
92+
if o.UnparsedObject != nil {
93+
return datadog.Marshal(o.UnparsedObject)
94+
}
95+
toSerialize["id"] = o.Id
96+
toSerialize["type"] = o.Type
97+
98+
for key, value := range o.AdditionalProperties {
99+
toSerialize[key] = value
100+
}
101+
return datadog.Marshal(toSerialize)
102+
}
103+
104+
// UnmarshalJSON deserializes the given payload.
105+
func (o *DORADeploymentPatchRemediation) UnmarshalJSON(bytes []byte) (err error) {
106+
all := struct {
107+
Id *string `json:"id"`
108+
Type *DORADeploymentPatchRemediationType `json:"type"`
109+
}{}
110+
if err = datadog.Unmarshal(bytes, &all); err != nil {
111+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
112+
}
113+
if all.Id == nil {
114+
return fmt.Errorf("required field id missing")
115+
}
116+
if all.Type == nil {
117+
return fmt.Errorf("required field type missing")
118+
}
119+
additionalProperties := make(map[string]interface{})
120+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
121+
datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"})
122+
} else {
123+
return err
124+
}
125+
126+
hasInvalidField := false
127+
o.Id = *all.Id
128+
if !all.Type.IsValid() {
129+
hasInvalidField = true
130+
} else {
131+
o.Type = *all.Type
132+
}
133+
134+
if len(additionalProperties) > 0 {
135+
o.AdditionalProperties = additionalProperties
136+
}
137+
138+
if hasInvalidField {
139+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
140+
}
141+
142+
return nil
143+
}

0 commit comments

Comments
 (0)