diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 0fb2ea89432..a2cda6f2d6e 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -17239,6 +17239,89 @@ components: - started_at - finished_at type: object + DORADeploymentPatchRemediation: + description: Remediation details for the deployment. + properties: + id: + description: The ID of the remediation action. + example: eG42zNIkVjM + type: string + type: + $ref: '#/components/schemas/DORADeploymentPatchRemediationType' + required: + - id + - type + type: object + DORADeploymentPatchRemediationType: + description: The type of remediation action taken. + enum: + - rollback + - rollforward + example: rollback + type: string + x-enum-varnames: + - ROLLBACK + - ROLLFORWARD + DORADeploymentPatchRequest: + description: Request to patch a DORA deployment event. + example: + data: + attributes: + change_failure: true + remediation: + id: eG42zNIkVjM + type: rollback + id: z_RwVLi7v4Y + type: dora_deployment_patch_request + properties: + data: + $ref: '#/components/schemas/DORADeploymentPatchRequestData' + required: + - data + type: object + DORADeploymentPatchRequestAttributes: + description: Attributes for patching a DORA deployment event. + properties: + change_failure: + description: Indicates whether the deployment resulted in a change failure. + example: true + type: boolean + remediation: + $ref: '#/components/schemas/DORADeploymentPatchRemediation' + type: object + DORADeploymentPatchRequestData: + description: The JSON:API data for patching a deployment. + example: + attributes: + change_failure: true + remediation: + id: eG42zNIkVjM + type: rollback + id: z_RwVLi7v4Y + type: dora_deployment_patch_request + properties: + attributes: + $ref: '#/components/schemas/DORADeploymentPatchRequestAttributes' + id: + description: The ID of the deployment to patch. + example: z_RwVLi7v4Y + type: string + type: + $ref: '#/components/schemas/DORADeploymentPatchRequestDataType' + required: + - type + - id + - attributes + type: object + DORADeploymentPatchRequestDataType: + default: dora_deployment_patch_request + description: JSON:API type for DORA deployment patch request. + enum: + - dora_deployment_patch_request + example: dora_deployment_patch_request + type: string + x-enum-varnames: + - DORA_DEPLOYMENT_PATCH_REQUEST DORADeploymentRequest: description: Request to create a DORA deployment event. properties: @@ -74974,6 +75057,46 @@ paths: operator: OR permissions: - dora_metrics_read + patch: + description: Use this API endpoint to patch a deployment event. + operationId: PatchDORADeployment + parameters: + - description: The ID of the deployment event. + in: path + name: deployment_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DORADeploymentPatchRequest' + required: true + 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: Patch a deployment event + tags: + - DORA Metrics + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - dora_metrics_write /api/v2/dora/failure: post: description: 'Use this API endpoint to provide failure data. diff --git a/api/datadogV2/api_dora_metrics.go b/api/datadogV2/api_dora_metrics.go index 639e2340b02..ead46bf7d25 100644 --- a/api/datadogV2/api_dora_metrics.go +++ b/api/datadogV2/api_dora_metrics.go @@ -784,6 +784,86 @@ func (a *DORAMetricsApi) ListDORAFailures(ctx _context.Context, body DORAListFai return localVarReturnValue, localVarHTTPResponse, nil } +// PatchDORADeployment Patch a deployment event. +// Use this API endpoint to patch a deployment event. +func (a *DORAMetricsApi) PatchDORADeployment(ctx _context.Context, deploymentId string, body DORADeploymentPatchRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DORAMetricsApi.PatchDORADeployment") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/dora/deployments/{deployment_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{deployment_id}", _neturl.PathEscape(datadog.ParameterToString(deploymentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // NewDORAMetricsApi Returns NewDORAMetricsApi. func NewDORAMetricsApi(client *datadog.APIClient) *DORAMetricsApi { return &DORAMetricsApi{ diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 97f4465d68e..bfd10e6523f 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -217,6 +217,7 @@ // - [DORAMetricsApi.GetDORAFailure] // - [DORAMetricsApi.ListDORADeployments] // - [DORAMetricsApi.ListDORAFailures] +// - [DORAMetricsApi.PatchDORADeployment] // - [DashboardListsApi.CreateDashboardListItems] // - [DashboardListsApi.DeleteDashboardListItems] // - [DashboardListsApi.GetDashboardListItems] diff --git a/api/datadogV2/model_dora_deployment_patch_remediation.go b/api/datadogV2/model_dora_deployment_patch_remediation.go new file mode 100644 index 00000000000..5ee361f0ab3 --- /dev/null +++ b/api/datadogV2/model_dora_deployment_patch_remediation.go @@ -0,0 +1,143 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DORADeploymentPatchRemediation Remediation details for the deployment. +type DORADeploymentPatchRemediation struct { + // The ID of the remediation action. + Id string `json:"id"` + // The type of remediation action taken. + Type DORADeploymentPatchRemediationType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDORADeploymentPatchRemediation instantiates a new DORADeploymentPatchRemediation object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDORADeploymentPatchRemediation(id string, typeVar DORADeploymentPatchRemediationType) *DORADeploymentPatchRemediation { + this := DORADeploymentPatchRemediation{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewDORADeploymentPatchRemediationWithDefaults instantiates a new DORADeploymentPatchRemediation object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDORADeploymentPatchRemediationWithDefaults() *DORADeploymentPatchRemediation { + this := DORADeploymentPatchRemediation{} + return &this +} + +// GetId returns the Id field value. +func (o *DORADeploymentPatchRemediation) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *DORADeploymentPatchRemediation) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *DORADeploymentPatchRemediation) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *DORADeploymentPatchRemediation) GetType() DORADeploymentPatchRemediationType { + if o == nil { + var ret DORADeploymentPatchRemediationType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *DORADeploymentPatchRemediation) GetTypeOk() (*DORADeploymentPatchRemediationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DORADeploymentPatchRemediation) SetType(v DORADeploymentPatchRemediationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DORADeploymentPatchRemediation) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DORADeploymentPatchRemediation) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *DORADeploymentPatchRemediationType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_dora_deployment_patch_remediation_type.go b/api/datadogV2/model_dora_deployment_patch_remediation_type.go new file mode 100644 index 00000000000..031f9e71d03 --- /dev/null +++ b/api/datadogV2/model_dora_deployment_patch_remediation_type.go @@ -0,0 +1,66 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DORADeploymentPatchRemediationType The type of remediation action taken. +type DORADeploymentPatchRemediationType string + +// List of DORADeploymentPatchRemediationType. +const ( + DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLBACK DORADeploymentPatchRemediationType = "rollback" + DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLFORWARD DORADeploymentPatchRemediationType = "rollforward" +) + +var allowedDORADeploymentPatchRemediationTypeEnumValues = []DORADeploymentPatchRemediationType{ + DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLBACK, + DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLFORWARD, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DORADeploymentPatchRemediationType) GetAllowedValues() []DORADeploymentPatchRemediationType { + return allowedDORADeploymentPatchRemediationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DORADeploymentPatchRemediationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DORADeploymentPatchRemediationType(value) + return nil +} + +// NewDORADeploymentPatchRemediationTypeFromValue returns a pointer to a valid DORADeploymentPatchRemediationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDORADeploymentPatchRemediationTypeFromValue(v string) (*DORADeploymentPatchRemediationType, error) { + ev := DORADeploymentPatchRemediationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DORADeploymentPatchRemediationType: valid values are %v", v, allowedDORADeploymentPatchRemediationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DORADeploymentPatchRemediationType) IsValid() bool { + for _, existing := range allowedDORADeploymentPatchRemediationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DORADeploymentPatchRemediationType value. +func (v DORADeploymentPatchRemediationType) Ptr() *DORADeploymentPatchRemediationType { + return &v +} diff --git a/api/datadogV2/model_dora_deployment_patch_request.go b/api/datadogV2/model_dora_deployment_patch_request.go new file mode 100644 index 00000000000..d0950a44bf4 --- /dev/null +++ b/api/datadogV2/model_dora_deployment_patch_request.go @@ -0,0 +1,110 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DORADeploymentPatchRequest Request to patch a DORA deployment event. +type DORADeploymentPatchRequest struct { + // The JSON:API data for patching a deployment. + Data DORADeploymentPatchRequestData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDORADeploymentPatchRequest instantiates a new DORADeploymentPatchRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDORADeploymentPatchRequest(data DORADeploymentPatchRequestData) *DORADeploymentPatchRequest { + this := DORADeploymentPatchRequest{} + this.Data = data + return &this +} + +// NewDORADeploymentPatchRequestWithDefaults instantiates a new DORADeploymentPatchRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDORADeploymentPatchRequestWithDefaults() *DORADeploymentPatchRequest { + this := DORADeploymentPatchRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *DORADeploymentPatchRequest) GetData() DORADeploymentPatchRequestData { + if o == nil { + var ret DORADeploymentPatchRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *DORADeploymentPatchRequest) GetDataOk() (*DORADeploymentPatchRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *DORADeploymentPatchRequest) SetData(v DORADeploymentPatchRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DORADeploymentPatchRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DORADeploymentPatchRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DORADeploymentPatchRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_dora_deployment_patch_request_attributes.go b/api/datadogV2/model_dora_deployment_patch_request_attributes.go new file mode 100644 index 00000000000..000b1046f68 --- /dev/null +++ b/api/datadogV2/model_dora_deployment_patch_request_attributes.go @@ -0,0 +1,146 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DORADeploymentPatchRequestAttributes Attributes for patching a DORA deployment event. +type DORADeploymentPatchRequestAttributes struct { + // Indicates whether the deployment resulted in a change failure. + ChangeFailure *bool `json:"change_failure,omitempty"` + // Remediation details for the deployment. + Remediation *DORADeploymentPatchRemediation `json:"remediation,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDORADeploymentPatchRequestAttributes instantiates a new DORADeploymentPatchRequestAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDORADeploymentPatchRequestAttributes() *DORADeploymentPatchRequestAttributes { + this := DORADeploymentPatchRequestAttributes{} + return &this +} + +// NewDORADeploymentPatchRequestAttributesWithDefaults instantiates a new DORADeploymentPatchRequestAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDORADeploymentPatchRequestAttributesWithDefaults() *DORADeploymentPatchRequestAttributes { + this := DORADeploymentPatchRequestAttributes{} + return &this +} + +// GetChangeFailure returns the ChangeFailure field value if set, zero value otherwise. +func (o *DORADeploymentPatchRequestAttributes) GetChangeFailure() bool { + if o == nil || o.ChangeFailure == nil { + var ret bool + return ret + } + return *o.ChangeFailure +} + +// GetChangeFailureOk returns a tuple with the ChangeFailure field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DORADeploymentPatchRequestAttributes) GetChangeFailureOk() (*bool, bool) { + if o == nil || o.ChangeFailure == nil { + return nil, false + } + return o.ChangeFailure, true +} + +// HasChangeFailure returns a boolean if a field has been set. +func (o *DORADeploymentPatchRequestAttributes) HasChangeFailure() bool { + return o != nil && o.ChangeFailure != nil +} + +// SetChangeFailure gets a reference to the given bool and assigns it to the ChangeFailure field. +func (o *DORADeploymentPatchRequestAttributes) SetChangeFailure(v bool) { + o.ChangeFailure = &v +} + +// GetRemediation returns the Remediation field value if set, zero value otherwise. +func (o *DORADeploymentPatchRequestAttributes) GetRemediation() DORADeploymentPatchRemediation { + if o == nil || o.Remediation == nil { + var ret DORADeploymentPatchRemediation + return ret + } + return *o.Remediation +} + +// GetRemediationOk returns a tuple with the Remediation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DORADeploymentPatchRequestAttributes) GetRemediationOk() (*DORADeploymentPatchRemediation, bool) { + if o == nil || o.Remediation == nil { + return nil, false + } + return o.Remediation, true +} + +// HasRemediation returns a boolean if a field has been set. +func (o *DORADeploymentPatchRequestAttributes) HasRemediation() bool { + return o != nil && o.Remediation != nil +} + +// SetRemediation gets a reference to the given DORADeploymentPatchRemediation and assigns it to the Remediation field. +func (o *DORADeploymentPatchRequestAttributes) SetRemediation(v DORADeploymentPatchRemediation) { + o.Remediation = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DORADeploymentPatchRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ChangeFailure != nil { + toSerialize["change_failure"] = o.ChangeFailure + } + if o.Remediation != nil { + toSerialize["remediation"] = o.Remediation + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DORADeploymentPatchRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ChangeFailure *bool `json:"change_failure,omitempty"` + Remediation *DORADeploymentPatchRemediation `json:"remediation,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"change_failure", "remediation"}) + } else { + return err + } + + hasInvalidField := false + o.ChangeFailure = all.ChangeFailure + if all.Remediation != nil && all.Remediation.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Remediation = all.Remediation + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_dora_deployment_patch_request_data.go b/api/datadogV2/model_dora_deployment_patch_request_data.go new file mode 100644 index 00000000000..d955c874f21 --- /dev/null +++ b/api/datadogV2/model_dora_deployment_patch_request_data.go @@ -0,0 +1,180 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DORADeploymentPatchRequestData The JSON:API data for patching a deployment. +type DORADeploymentPatchRequestData struct { + // Attributes for patching a DORA deployment event. + Attributes DORADeploymentPatchRequestAttributes `json:"attributes"` + // The ID of the deployment to patch. + Id string `json:"id"` + // JSON:API type for DORA deployment patch request. + Type DORADeploymentPatchRequestDataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDORADeploymentPatchRequestData instantiates a new DORADeploymentPatchRequestData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDORADeploymentPatchRequestData(attributes DORADeploymentPatchRequestAttributes, id string, typeVar DORADeploymentPatchRequestDataType) *DORADeploymentPatchRequestData { + this := DORADeploymentPatchRequestData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewDORADeploymentPatchRequestDataWithDefaults instantiates a new DORADeploymentPatchRequestData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDORADeploymentPatchRequestDataWithDefaults() *DORADeploymentPatchRequestData { + this := DORADeploymentPatchRequestData{} + var typeVar DORADeploymentPatchRequestDataType = DORADEPLOYMENTPATCHREQUESTDATATYPE_DORA_DEPLOYMENT_PATCH_REQUEST + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *DORADeploymentPatchRequestData) GetAttributes() DORADeploymentPatchRequestAttributes { + if o == nil { + var ret DORADeploymentPatchRequestAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *DORADeploymentPatchRequestData) GetAttributesOk() (*DORADeploymentPatchRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *DORADeploymentPatchRequestData) SetAttributes(v DORADeploymentPatchRequestAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *DORADeploymentPatchRequestData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *DORADeploymentPatchRequestData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *DORADeploymentPatchRequestData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *DORADeploymentPatchRequestData) GetType() DORADeploymentPatchRequestDataType { + if o == nil { + var ret DORADeploymentPatchRequestDataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *DORADeploymentPatchRequestData) GetTypeOk() (*DORADeploymentPatchRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DORADeploymentPatchRequestData) SetType(v DORADeploymentPatchRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DORADeploymentPatchRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DORADeploymentPatchRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *DORADeploymentPatchRequestAttributes `json:"attributes"` + Id *string `json:"id"` + Type *DORADeploymentPatchRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_dora_deployment_patch_request_data_type.go b/api/datadogV2/model_dora_deployment_patch_request_data_type.go new file mode 100644 index 00000000000..d64c295bf44 --- /dev/null +++ b/api/datadogV2/model_dora_deployment_patch_request_data_type.go @@ -0,0 +1,64 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DORADeploymentPatchRequestDataType JSON:API type for DORA deployment patch request. +type DORADeploymentPatchRequestDataType string + +// List of DORADeploymentPatchRequestDataType. +const ( + DORADEPLOYMENTPATCHREQUESTDATATYPE_DORA_DEPLOYMENT_PATCH_REQUEST DORADeploymentPatchRequestDataType = "dora_deployment_patch_request" +) + +var allowedDORADeploymentPatchRequestDataTypeEnumValues = []DORADeploymentPatchRequestDataType{ + DORADEPLOYMENTPATCHREQUESTDATATYPE_DORA_DEPLOYMENT_PATCH_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DORADeploymentPatchRequestDataType) GetAllowedValues() []DORADeploymentPatchRequestDataType { + return allowedDORADeploymentPatchRequestDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DORADeploymentPatchRequestDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DORADeploymentPatchRequestDataType(value) + return nil +} + +// NewDORADeploymentPatchRequestDataTypeFromValue returns a pointer to a valid DORADeploymentPatchRequestDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDORADeploymentPatchRequestDataTypeFromValue(v string) (*DORADeploymentPatchRequestDataType, error) { + ev := DORADeploymentPatchRequestDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DORADeploymentPatchRequestDataType: valid values are %v", v, allowedDORADeploymentPatchRequestDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DORADeploymentPatchRequestDataType) IsValid() bool { + for _, existing := range allowedDORADeploymentPatchRequestDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DORADeploymentPatchRequestDataType value. +func (v DORADeploymentPatchRequestDataType) Ptr() *DORADeploymentPatchRequestDataType { + return &v +} diff --git a/examples/v2/dora-metrics/PatchDORADeployment.go b/examples/v2/dora-metrics/PatchDORADeployment.go new file mode 100644 index 00000000000..f6924362091 --- /dev/null +++ b/examples/v2/dora-metrics/PatchDORADeployment.go @@ -0,0 +1,38 @@ +// Patch a deployment event returns "Accepted" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.DORADeploymentPatchRequest{ + Data: datadogV2.DORADeploymentPatchRequestData{ + Attributes: datadogV2.DORADeploymentPatchRequestAttributes{ + ChangeFailure: datadog.PtrBool(true), + Remediation: &datadogV2.DORADeploymentPatchRemediation{ + Id: "eG42zNIkVjM", + Type: datadogV2.DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLBACK, + }, + }, + Id: "z_RwVLi7v4Y", + Type: datadogV2.DORADEPLOYMENTPATCHREQUESTDATATYPE_DORA_DEPLOYMENT_PATCH_REQUEST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewDORAMetricsApi(apiClient) + r, err := api.PatchDORADeployment(ctx, "deployment_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DORAMetricsApi.PatchDORADeployment`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Accepted_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Accepted_response.freeze new file mode 100644 index 00000000000..53c8b2fcbba --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Accepted_response.freeze @@ -0,0 +1 @@ +2026-01-29T09:25:52.032Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Accepted_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Accepted_response.yaml new file mode 100644 index 00000000000..cffcb6c37ff --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Accepted_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"finished_at":1769678752000000000,"git":{"commit_sha":"66adc9350f2cc9b250b69abddab733dd55e1a588","repository_url":"https://github.com/organization/example-repository"},"id":"08a3dbc57bb781a5","service":"shopist","started_at":1769675152000000000,"version":"v1.12.07"}}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/dora/deployment + response: + body: '{"data":{"id":"08a3dbc57bb781a5","type":"dora_deployment"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: | + {"data":{"attributes":{"change_failure":true,"remediation":{"id":"eG42zNIkVjM","type":"rollback"}},"id":"08a3dbc57bb781a5","type":"dora_deployment_patch_request"}} + form: {} + headers: + Accept: + - '*/*' + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/dora/deployments/08a3dbc57bb781a5 + response: + body: '{"data":null}' + code: 202 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 202 Accepted +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..52bae6cfe7f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2026-01-29T09:25:52.758Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..e4ee889fd72 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_DORA_Metrics/Scenario_Patch_a_deployment_event_returns_Bad_Request_response.yaml @@ -0,0 +1,43 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"finished_at":1769678752000000000,"git":{"commit_sha":"66adc9350f2cc9b250b69abddab733dd55e1a588","repository_url":"https://github.com/organization/example-repository"},"id":"bf100f167795c925","service":"shopist","started_at":1769675152000000000,"version":"v1.12.07"}}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/dora/deployment + response: + body: '{"data":{"id":"bf100f167795c925","type":"dora_deployment"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: | + {"data":{"attributes":{"change_failure":true,"remediation":{"id":"eG42zNIkVjM","type":"wrong_type"}},"id":"bf100f167795c925","type":"dora_deployment_patch_request"}} + form: {} + headers: + Accept: + - '*/*' + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/dora/deployments/bf100f167795c925 + response: + body: '{"errors":[{"status":"400","title":"Bad Request","detail":"attribute \"type\" + must be one of \"rollback rollforward\""}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Create_a_team_link_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Create_a_team_link_returns_OK_response.freeze index 5e31001e436..631b268503a 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Create_a_team_link_returns_OK_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Create_a_team_link_returns_OK_response.freeze @@ -1 +1 @@ -2023-08-21T19:44:43.622Z \ No newline at end of file +2026-01-23T11:00:10.582Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Create_a_team_link_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Create_a_team_link_returns_OK_response.yaml index 0ae3459fcc4..01304c64acc 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Create_a_team_link_returns_OK_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Create_a_team_link_returns_OK_response.yaml @@ -1,7 +1,7 @@ interactions: - request: body: | - {"data":{"attributes":{"handle":"test-handle-95c34d7fe6d963ff","name":"test-name-95c34d7fe6d963ff"},"type":"team"}} + {"data":{"attributes":{"handle":"test-handle-5e6a036c358c6bff","name":"test-name-5e6a036c358c6bff"},"type":"team"}} form: {} headers: Accept: @@ -12,14 +12,12 @@ interactions: method: POST url: https://api.datadoghq.com/api/v2/team response: - body: '{"data":{"type":"team","id":"2d0e6d4e-405b-11ee-84bc-da7ad0900002","attributes":{"name":"test-name-95c34d7fe6d963ff","handle":"test-handle-95c34d7fe6d963ff","summary":null,"description":null,"avatar":null,"banner":null,"visible_modules":[],"hidden_modules":[],"created_at":"2023-08-21T19:44:43.718259+00:00","modified_at":"2023-08-21T19:44:43.718264+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/2d0e6d4e-405b-11ee-84bc-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/2d0e6d4e-405b-11ee-84bc-da7ad0900002/permission-settings"}}}}} - - ' + body: '{"data":{"id":"66d6e3d2-f7ea-4946-bc93-b11db5b9bed4","type":"team","attributes":{"avatar":null,"banner":12,"created_at":"2026-01-23T11:00:12.132142+00:00","description":null,"handle":"test-handle-5e6a036c358c6bff","hidden_modules":null,"is_managed":false,"link_count":0,"modified_at":"2026-01-23T11:00:12.132142+00:00","name":"test-name-5e6a036c358c6bff","summary":null,"user_count":0,"visible_modules":null},"relationships":{"team_links":{"data":[],"links":{"related":"/api/v2/team/66d6e3d2-f7ea-4946-bc93-b11db5b9bed4/links"}},"user_team_permissions":{"data":null,"links":{"related":"/api/v2/team/66d6e3d2-f7ea-4946-bc93-b11db5b9bed4/permission-settings"}}}}}' code: 201 duration: 0ms headers: Content-Type: - - application/json + - application/vnd.api+json status: 201 Created - request: body: | @@ -32,9 +30,9 @@ interactions: - application/json id: 1 method: POST - url: https://api.datadoghq.com/api/v2/team/2d0e6d4e-405b-11ee-84bc-da7ad0900002/links + url: https://api.datadoghq.com/api/v2/team/66d6e3d2-f7ea-4946-bc93-b11db5b9bed4/links response: - body: '{"data":{"type":"team_links","id":"2d348dee-405b-11ee-b5db-da7ad0900002","attributes":{"team_id":"2d0e6d4e-405b-11ee-84bc-da7ad0900002","label":"Link + body: '{"data":{"type":"team_links","id":"b0c50a40-f84a-11f0-a7c6-da7ad0900002","attributes":{"team_id":"66d6e3d2-f7ea-4946-bc93-b11db5b9bed4","label":"Link label","url":"https://example.com","position":0}}} ' @@ -52,7 +50,7 @@ interactions: - '*/*' id: 2 method: DELETE - url: https://api.datadoghq.com/api/v2/team/2d0e6d4e-405b-11ee-84bc-da7ad0900002/links/2d348dee-405b-11ee-b5db-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/66d6e3d2-f7ea-4946-bc93-b11db5b9bed4/links/b0c50a40-f84a-11f0-a7c6-da7ad0900002 response: body: '' code: 204 @@ -67,7 +65,7 @@ interactions: - '*/*' id: 3 method: DELETE - url: https://api.datadoghq.com/api/v2/team/2d0e6d4e-405b-11ee-84bc-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/66d6e3d2-f7ea-4946-bc93-b11db5b9bed4 response: body: '' code: 204 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Get_a_team_link_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Get_a_team_link_returns_OK_response.freeze index 9bd719325e2..4a7b92f84ed 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Get_a_team_link_returns_OK_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Get_a_team_link_returns_OK_response.freeze @@ -1 +1 @@ -2023-08-21T19:44:45.969Z \ No newline at end of file +2026-01-23T11:00:13.515Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Get_a_team_link_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Get_a_team_link_returns_OK_response.yaml index c2930439756..da19c4380c5 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Get_a_team_link_returns_OK_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Get_a_team_link_returns_OK_response.yaml @@ -1,7 +1,7 @@ interactions: - request: body: | - {"data":{"attributes":{"handle":"test-handle-17f710cc6491a98e","name":"test-name-17f710cc6491a98e"},"type":"team"}} + {"data":{"attributes":{"handle":"test-handle-94cf752f98fda23c","name":"test-name-94cf752f98fda23c"},"type":"team"}} form: {} headers: Accept: @@ -12,18 +12,16 @@ interactions: method: POST url: https://api.datadoghq.com/api/v2/team response: - body: '{"data":{"type":"team","id":"2e757196-405b-11ee-bc70-da7ad0900002","attributes":{"name":"test-name-17f710cc6491a98e","handle":"test-handle-17f710cc6491a98e","summary":null,"description":null,"avatar":null,"banner":null,"visible_modules":[],"hidden_modules":[],"created_at":"2023-08-21T19:44:46.071074+00:00","modified_at":"2023-08-21T19:44:46.071080+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/2e757196-405b-11ee-bc70-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/2e757196-405b-11ee-bc70-da7ad0900002/permission-settings"}}}}} - - ' + body: '{"data":{"id":"35d819d9-918b-4d29-838d-ed8507398b21","type":"team","attributes":{"avatar":null,"banner":10,"created_at":"2026-01-23T11:00:13.808835+00:00","description":null,"handle":"test-handle-94cf752f98fda23c","hidden_modules":null,"is_managed":false,"link_count":0,"modified_at":"2026-01-23T11:00:13.808835+00:00","name":"test-name-94cf752f98fda23c","summary":null,"user_count":0,"visible_modules":null},"relationships":{"team_links":{"data":[],"links":{"related":"/api/v2/team/35d819d9-918b-4d29-838d-ed8507398b21/links"}},"user_team_permissions":{"data":null,"links":{"related":"/api/v2/team/35d819d9-918b-4d29-838d-ed8507398b21/permission-settings"}}}}}' code: 201 duration: 0ms headers: Content-Type: - - application/json + - application/vnd.api+json status: 201 Created - request: body: | - {"data":{"attributes":{"label":"Test-Get_a_team_link_returns_OK_response-1692647085","position":0,"url":"https://example.com"},"type":"team_links"}} + {"data":{"attributes":{"label":"Test-Get_a_team_link_returns_OK_response-1769166013","position":0,"url":"https://example.com"},"type":"team_links"}} form: {} headers: Accept: @@ -32,9 +30,9 @@ interactions: - application/json id: 1 method: POST - url: https://api.datadoghq.com/api/v2/team/2e757196-405b-11ee-bc70-da7ad0900002/links + url: https://api.datadoghq.com/api/v2/team/35d819d9-918b-4d29-838d-ed8507398b21/links response: - body: '{"data":{"type":"team_links","id":"2e91164e-405b-11ee-9f5b-da7ad0900002","attributes":{"team_id":"2e757196-405b-11ee-bc70-da7ad0900002","label":"Test-Get_a_team_link_returns_OK_response-1692647085","url":"https://example.com","position":0}}} + body: '{"data":{"type":"team_links","id":"b1c355f0-f84a-11f0-8d16-da7ad0900002","attributes":{"team_id":"35d819d9-918b-4d29-838d-ed8507398b21","label":"Test-Get_a_team_link_returns_OK_response-1769166013","url":"https://example.com","position":0}}} ' code: 200 @@ -51,16 +49,14 @@ interactions: - application/json id: 2 method: GET - url: https://api.datadoghq.com/api/v2/team/2e757196-405b-11ee-bc70-da7ad0900002/links/2e91164e-405b-11ee-9f5b-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/35d819d9-918b-4d29-838d-ed8507398b21/links/b1c355f0-f84a-11f0-8d16-da7ad0900002 response: - body: '{"data":{"type":"team_links","id":"2e91164e-405b-11ee-9f5b-da7ad0900002","attributes":{"team_id":"2e757196-405b-11ee-bc70-da7ad0900002","label":"Test-Get_a_team_link_returns_OK_response-1692647085","url":"https://example.com","position":0}}} - - ' + body: '{"data":{"id":"b1c355f0-f84a-11f0-8d16-da7ad0900002","type":"team_links","attributes":{"label":"Test-Get_a_team_link_returns_OK_response-1769166013","position":0,"team_id":"35d819d9-918b-4d29-838d-ed8507398b21","url":"https://example.com"}}}' code: 200 duration: 0ms headers: Content-Type: - - application/json + - application/vnd.api+json status: 200 OK - request: body: '' @@ -70,7 +66,7 @@ interactions: - '*/*' id: 3 method: DELETE - url: https://api.datadoghq.com/api/v2/team/2e757196-405b-11ee-bc70-da7ad0900002/links/2e91164e-405b-11ee-9f5b-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/35d819d9-918b-4d29-838d-ed8507398b21/links/b1c355f0-f84a-11f0-8d16-da7ad0900002 response: body: '' code: 204 @@ -85,7 +81,7 @@ interactions: - '*/*' id: 4 method: DELETE - url: https://api.datadoghq.com/api/v2/team/2e757196-405b-11ee-bc70-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/35d819d9-918b-4d29-838d-ed8507398b21 response: body: '' code: 204 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Remove_a_team_link_returns_No_Content_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Remove_a_team_link_returns_No_Content_response.freeze index d6c4862f1f5..e97109a744f 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Remove_a_team_link_returns_No_Content_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Remove_a_team_link_returns_No_Content_response.freeze @@ -1 +1 @@ -2023-08-21T19:44:50.990Z \ No newline at end of file +2026-01-23T11:00:15.520Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Remove_a_team_link_returns_No_Content_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Remove_a_team_link_returns_No_Content_response.yaml index 77a90e0ac0c..42c24b366cc 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Remove_a_team_link_returns_No_Content_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Remove_a_team_link_returns_No_Content_response.yaml @@ -1,7 +1,7 @@ interactions: - request: body: | - {"data":{"attributes":{"handle":"test-handle-174fbe08316e4419","name":"test-name-174fbe08316e4419"},"type":"team"}} + {"data":{"attributes":{"handle":"test-handle-5e7e3d924d3cf03e","name":"test-name-5e7e3d924d3cf03e"},"type":"team"}} form: {} headers: Accept: @@ -12,18 +12,16 @@ interactions: method: POST url: https://api.datadoghq.com/api/v2/team response: - body: '{"data":{"type":"team","id":"3174aa4c-405b-11ee-9d78-da7ad0900002","attributes":{"name":"test-name-174fbe08316e4419","handle":"test-handle-174fbe08316e4419","summary":null,"description":null,"avatar":null,"banner":null,"visible_modules":[],"hidden_modules":[],"created_at":"2023-08-21T19:44:51.098613+00:00","modified_at":"2023-08-21T19:44:51.098619+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/3174aa4c-405b-11ee-9d78-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/3174aa4c-405b-11ee-9d78-da7ad0900002/permission-settings"}}}}} - - ' + body: '{"data":{"id":"59e1efcf-eb13-4a2b-8fcf-64590d56007f","type":"team","attributes":{"avatar":null,"banner":7,"created_at":"2026-01-23T11:00:15.837894+00:00","description":null,"handle":"test-handle-5e7e3d924d3cf03e","hidden_modules":null,"is_managed":false,"link_count":0,"modified_at":"2026-01-23T11:00:15.837894+00:00","name":"test-name-5e7e3d924d3cf03e","summary":null,"user_count":0,"visible_modules":null},"relationships":{"team_links":{"data":[],"links":{"related":"/api/v2/team/59e1efcf-eb13-4a2b-8fcf-64590d56007f/links"}},"user_team_permissions":{"data":null,"links":{"related":"/api/v2/team/59e1efcf-eb13-4a2b-8fcf-64590d56007f/permission-settings"}}}}}' code: 201 duration: 0ms headers: Content-Type: - - application/json + - application/vnd.api+json status: 201 Created - request: body: | - {"data":{"attributes":{"label":"Test-Remove_a_team_link_returns_No_Content_response-1692647090","position":0,"url":"https://example.com"},"type":"team_links"}} + {"data":{"attributes":{"label":"Test-Remove_a_team_link_returns_No_Content_response-1769166015","position":0,"url":"https://example.com"},"type":"team_links"}} form: {} headers: Accept: @@ -32,9 +30,9 @@ interactions: - application/json id: 1 method: POST - url: https://api.datadoghq.com/api/v2/team/3174aa4c-405b-11ee-9d78-da7ad0900002/links + url: https://api.datadoghq.com/api/v2/team/59e1efcf-eb13-4a2b-8fcf-64590d56007f/links response: - body: '{"data":{"type":"team_links","id":"3194a5c2-405b-11ee-b009-da7ad0900002","attributes":{"team_id":"3174aa4c-405b-11ee-9d78-da7ad0900002","label":"Test-Remove_a_team_link_returns_No_Content_response-1692647090","url":"https://example.com","position":0}}} + body: '{"data":{"type":"team_links","id":"b2fba45e-f84a-11f0-9d5d-da7ad0900002","attributes":{"team_id":"59e1efcf-eb13-4a2b-8fcf-64590d56007f","label":"Test-Remove_a_team_link_returns_No_Content_response-1769166015","url":"https://example.com","position":0}}} ' code: 200 @@ -51,7 +49,7 @@ interactions: - '*/*' id: 2 method: DELETE - url: https://api.datadoghq.com/api/v2/team/3174aa4c-405b-11ee-9d78-da7ad0900002/links/3194a5c2-405b-11ee-b009-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/59e1efcf-eb13-4a2b-8fcf-64590d56007f/links/b2fba45e-f84a-11f0-9d5d-da7ad0900002 response: body: '' code: 204 @@ -66,9 +64,9 @@ interactions: - '*/*' id: 3 method: DELETE - url: https://api.datadoghq.com/api/v2/team/3174aa4c-405b-11ee-9d78-da7ad0900002/links/3194a5c2-405b-11ee-b009-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/59e1efcf-eb13-4a2b-8fcf-64590d56007f/links/b2fba45e-f84a-11f0-9d5d-da7ad0900002 response: - body: '{"errors":["Link for ID 3194a5c2-405b-11ee-b009-da7ad0900002 not found"]}' + body: '{"errors":["Link for ID b2fba45e-f84a-11f0-9d5d-da7ad0900002 not found"]}' code: 404 duration: 0ms headers: @@ -83,7 +81,7 @@ interactions: - '*/*' id: 4 method: DELETE - url: https://api.datadoghq.com/api/v2/team/3174aa4c-405b-11ee-9d78-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/59e1efcf-eb13-4a2b-8fcf-64590d56007f response: body: '' code: 204 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Update_a_team_link_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Update_a_team_link_returns_OK_response.freeze index 272098258dc..050e95d3408 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Update_a_team_link_returns_OK_response.freeze +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Update_a_team_link_returns_OK_response.freeze @@ -1 +1 @@ -2023-08-21T19:44:53.594Z \ No newline at end of file +2026-01-23T11:00:17.594Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Update_a_team_link_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Update_a_team_link_returns_OK_response.yaml index dcac51fca5e..7ff6fa6d0c7 100644 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Update_a_team_link_returns_OK_response.yaml +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Teams/Scenario_Update_a_team_link_returns_OK_response.yaml @@ -1,7 +1,7 @@ interactions: - request: body: | - {"data":{"attributes":{"handle":"test-handle-9503f929e485f83e","name":"test-name-9503f929e485f83e"},"type":"team"}} + {"data":{"attributes":{"handle":"test-handle-98fa6b5d3df15a52","name":"test-name-98fa6b5d3df15a52"},"type":"team"}} form: {} headers: Accept: @@ -12,18 +12,16 @@ interactions: method: POST url: https://api.datadoghq.com/api/v2/team response: - body: '{"data":{"type":"team","id":"3301859c-405b-11ee-aedf-da7ad0900002","attributes":{"name":"test-name-9503f929e485f83e","handle":"test-handle-9503f929e485f83e","summary":null,"description":null,"avatar":null,"banner":null,"visible_modules":[],"hidden_modules":[],"created_at":"2023-08-21T19:44:53.699451+00:00","modified_at":"2023-08-21T19:44:53.699457+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/3301859c-405b-11ee-aedf-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/3301859c-405b-11ee-aedf-da7ad0900002/permission-settings"}}}}} - - ' + body: '{"data":{"id":"ec95ccd2-5cf4-494a-971c-84a604f7dde5","type":"team","attributes":{"avatar":null,"banner":0,"created_at":"2026-01-23T11:00:17.893904+00:00","description":null,"handle":"test-handle-98fa6b5d3df15a52","hidden_modules":null,"is_managed":false,"link_count":0,"modified_at":"2026-01-23T11:00:17.893904+00:00","name":"test-name-98fa6b5d3df15a52","summary":null,"user_count":0,"visible_modules":null},"relationships":{"team_links":{"data":[],"links":{"related":"/api/v2/team/ec95ccd2-5cf4-494a-971c-84a604f7dde5/links"}},"user_team_permissions":{"data":null,"links":{"related":"/api/v2/team/ec95ccd2-5cf4-494a-971c-84a604f7dde5/permission-settings"}}}}}' code: 201 duration: 0ms headers: Content-Type: - - application/json + - application/vnd.api+json status: 201 Created - request: body: | - {"data":{"attributes":{"label":"Test-Update_a_team_link_returns_OK_response-1692647093","position":0,"url":"https://example.com"},"type":"team_links"}} + {"data":{"attributes":{"label":"Test-Update_a_team_link_returns_OK_response-1769166017","position":0,"url":"https://example.com"},"type":"team_links"}} form: {} headers: Accept: @@ -32,9 +30,9 @@ interactions: - application/json id: 1 method: POST - url: https://api.datadoghq.com/api/v2/team/3301859c-405b-11ee-aedf-da7ad0900002/links + url: https://api.datadoghq.com/api/v2/team/ec95ccd2-5cf4-494a-971c-84a604f7dde5/links response: - body: '{"data":{"type":"team_links","id":"331f8b00-405b-11ee-bdcc-da7ad0900002","attributes":{"team_id":"3301859c-405b-11ee-aedf-da7ad0900002","label":"Test-Update_a_team_link_returns_OK_response-1692647093","url":"https://example.com","position":0}}} + body: '{"data":{"type":"team_links","id":"b433501a-f84a-11f0-9cd8-da7ad0900002","attributes":{"team_id":"ec95ccd2-5cf4-494a-971c-84a604f7dde5","label":"Test-Update_a_team_link_returns_OK_response-1769166017","url":"https://example.com","position":0}}} ' code: 200 @@ -54,9 +52,9 @@ interactions: - application/json id: 2 method: PATCH - url: https://api.datadoghq.com/api/v2/team/3301859c-405b-11ee-aedf-da7ad0900002/links/331f8b00-405b-11ee-bdcc-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/ec95ccd2-5cf4-494a-971c-84a604f7dde5/links/b433501a-f84a-11f0-9cd8-da7ad0900002 response: - body: '{"data":{"type":"team_links","id":"331f8b00-405b-11ee-bdcc-da7ad0900002","attributes":{"team_id":"3301859c-405b-11ee-aedf-da7ad0900002","label":"New + body: '{"data":{"type":"team_links","id":"b433501a-f84a-11f0-9cd8-da7ad0900002","attributes":{"team_id":"ec95ccd2-5cf4-494a-971c-84a604f7dde5","label":"New Label","url":"https://example.com","position":0}}} ' @@ -74,7 +72,7 @@ interactions: - '*/*' id: 3 method: DELETE - url: https://api.datadoghq.com/api/v2/team/3301859c-405b-11ee-aedf-da7ad0900002/links/331f8b00-405b-11ee-bdcc-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/ec95ccd2-5cf4-494a-971c-84a604f7dde5/links/b433501a-f84a-11f0-9cd8-da7ad0900002 response: body: '' code: 204 @@ -89,7 +87,7 @@ interactions: - '*/*' id: 4 method: DELETE - url: https://api.datadoghq.com/api/v2/team/3301859c-405b-11ee-aedf-da7ad0900002 + url: https://api.datadoghq.com/api/v2/team/ec95ccd2-5cf4-494a-971c-84a604f7dde5 response: body: '' code: 204 diff --git a/tests/scenarios/features/v2/dora_metrics.feature b/tests/scenarios/features/v2/dora_metrics.feature index b11b0fc74df..7a3275b54bf 100644 --- a/tests/scenarios/features/v2/dora_metrics.feature +++ b/tests/scenarios/features/v2/dora_metrics.feature @@ -104,6 +104,24 @@ Feature: DORA Metrics When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/ci-app-backend + Scenario: Patch a deployment event returns "Accepted" response + Given a valid "appKeyAuth" key in the system + And new "PatchDORADeployment" request + And request contains "deployment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"change_failure": true, "remediation": {"id": "eG42zNIkVjM", "type": "rollback"}}, "id": "z_RwVLi7v4Y", "type": "dora_deployment_patch_request"}} + When the request is sent + Then the response status is 202 Accepted + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Patch a deployment event returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And new "PatchDORADeployment" request + And request contains "deployment_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"change_failure": true, "remediation": {"id": "eG42zNIkVjM", "type": "rollback"}}, "id": "z_RwVLi7v4Y", "type": "dora_deployment_patch_request"}} + When the request is sent + Then the response status is 400 Bad Request + @skip @team:DataDog/ci-app-backend Scenario: Send a deployment event returns "Bad Request" response Given new "CreateDORADeployment" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 6387dae5fac..f77f242ff34 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1489,6 +1489,12 @@ "type": "safe" } }, + "PatchDORADeployment": { + "tag": "DORA Metrics", + "undo": { + "type": "idempotent" + } + }, "CreateDORAFailure": { "tag": "DORA Metrics", "undo": { @@ -5221,7 +5227,8 @@ "parameters": [ { "name": "team_id", - "source": "data.attributes.team_id" + "origin": "path", + "source": "team_id" }, { "name": "link_id",