Patch a deployment event

PATCH https://api.ap1.datadoghq.com/api/v2/dora/deployments/{deployment_id}https://api.ap2.datadoghq.com/api/v2/dora/deployments/{deployment_id}https://api.datadoghq.eu/api/v2/dora/deployments/{deployment_id}https://api.ddog-gov.com/api/v2/dora/deployments/{deployment_id}https://api.us2.ddog-gov.com/api/v2/dora/deployments/{deployment_id}https://api.datadoghq.com/api/v2/dora/deployments/{deployment_id}https://api.us3.datadoghq.com/api/v2/dora/deployments/{deployment_id}https://api.us5.datadoghq.com/api/v2/dora/deployments/{deployment_id}

Overview

Update a deployment’s change failure status. Use this to mark a deployment as a change failure or back to stable. You can optionally include remediation details to enable failed deployment recovery time calculation. This endpoint requires the dora_metrics_write permission.

Arguments

Path Parameters

Name

Type

Description

deployment_id [required]

string

The ID of the deployment event.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

The JSON:API data for patching a deployment.

attributes [required]

object

Attributes for patching a DORA deployment event.

change_failure

boolean

Indicates whether the deployment resulted in a change failure.

remediation

object

Remediation details for the deployment. Optional, but required to calculate failed deployment recovery time.

id

string

The ID of the remediation deployment. Required when the failed deployment must be linked to a remediation deployment.

type

enum

The type of remediation action taken. Required when the failed deployment must be linked to a remediation deployment. Allowed enum values: rollback,rollforward

id [required]

string

The ID of the deployment to patch.

type [required]

enum

JSON:API type for DORA deployment patch request. Allowed enum values: dora_deployment_patch_request

default: dora_deployment_patch_request

{
  "data": {
    "attributes": {
      "change_failure": true,
      "remediation": {
        "id": "eG42zNIkVjM",
        "type": "rollback"
      }
    },
    "id": "z_RwVLi7v4Y",
    "type": "dora_deployment_patch_request"
  }
}

Response

Accepted

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Not Authorized

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

                  ## default
# 

# Path parameters
export deployment_id="CHANGE_ME"
# Curl command
curl -X PATCH "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/dora/deployments/${deployment_id}" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "change_failure": true, "remediation": { "id": "eG42zNIkVjM", "type": "rollback" } }, "id": "z_RwVLi7v4Y", "type": "dora_deployment_patch_request" } } EOF
"""
Patch a deployment event returns "Accepted" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.dora_metrics_api import DORAMetricsApi
from datadog_api_client.v2.model.dora_deployment_patch_remediation import DORADeploymentPatchRemediation
from datadog_api_client.v2.model.dora_deployment_patch_remediation_type import DORADeploymentPatchRemediationType
from datadog_api_client.v2.model.dora_deployment_patch_request import DORADeploymentPatchRequest
from datadog_api_client.v2.model.dora_deployment_patch_request_attributes import DORADeploymentPatchRequestAttributes
from datadog_api_client.v2.model.dora_deployment_patch_request_data import DORADeploymentPatchRequestData
from datadog_api_client.v2.model.dora_deployment_patch_request_data_type import DORADeploymentPatchRequestDataType

body = DORADeploymentPatchRequest(
    data=DORADeploymentPatchRequestData(
        attributes=DORADeploymentPatchRequestAttributes(
            change_failure=True,
            remediation=DORADeploymentPatchRemediation(
                id="eG42zNIkVjM",
                type=DORADeploymentPatchRemediationType.ROLLBACK,
            ),
        ),
        id="z_RwVLi7v4Y",
        type=DORADeploymentPatchRequestDataType.DORA_DEPLOYMENT_PATCH_REQUEST,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DORAMetricsApi(api_client)
    api_instance.patch_dora_deployment(deployment_id="deployment_id", body=body)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# Patch a deployment event returns "Accepted" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::DORAMetricsAPI.new

body = DatadogAPIClient::V2::DORADeploymentPatchRequest.new({
  data: DatadogAPIClient::V2::DORADeploymentPatchRequestData.new({
    attributes: DatadogAPIClient::V2::DORADeploymentPatchRequestAttributes.new({
      change_failure: true,
      remediation: DatadogAPIClient::V2::DORADeploymentPatchRemediation.new({
        id: "eG42zNIkVjM",
        type: DatadogAPIClient::V2::DORADeploymentPatchRemediationType::ROLLBACK,
      }),
    }),
    id: "z_RwVLi7v4Y",
    type: DatadogAPIClient::V2::DORADeploymentPatchRequestDataType::DORA_DEPLOYMENT_PATCH_REQUEST,
  }),
})
p api_instance.patch_dora_deployment("deployment_id", body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// 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:   datadog.PtrString("eG42zNIkVjM"),
					Type: datadogV2.DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLBACK.Ptr(),
				},
			},
			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)
	}
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// Patch a deployment event returns "Accepted" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.DoraMetricsApi;
import com.datadog.api.client.v2.model.DORADeploymentPatchRemediation;
import com.datadog.api.client.v2.model.DORADeploymentPatchRemediationType;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequest;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequestAttributes;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequestData;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequestDataType;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DoraMetricsApi apiInstance = new DoraMetricsApi(defaultClient);

    DORADeploymentPatchRequest body =
        new DORADeploymentPatchRequest()
            .data(
                new DORADeploymentPatchRequestData()
                    .attributes(
                        new DORADeploymentPatchRequestAttributes()
                            .changeFailure(true)
                            .remediation(
                                new DORADeploymentPatchRemediation()
                                    .id("eG42zNIkVjM")
                                    .type(DORADeploymentPatchRemediationType.ROLLBACK)))
                    .id("z_RwVLi7v4Y")
                    .type(DORADeploymentPatchRequestDataType.DORA_DEPLOYMENT_PATCH_REQUEST));

    try {
      apiInstance.patchDORADeployment("deployment_id", body);
    } catch (ApiException e) {
      System.err.println("Exception when calling DoraMetricsApi#patchDORADeployment");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// Patch a deployment event returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dora_metrics::DORAMetricsAPI;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRemediation;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRemediationType;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequest;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequestAttributes;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequestData;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequestDataType;

#[tokio::main]
async fn main() {
    let body = DORADeploymentPatchRequest::new(DORADeploymentPatchRequestData::new(
        DORADeploymentPatchRequestAttributes::new()
            .change_failure(true)
            .remediation(
                DORADeploymentPatchRemediation::new()
                    .id("eG42zNIkVjM".to_string())
                    .type_(DORADeploymentPatchRemediationType::ROLLBACK),
            ),
        "z_RwVLi7v4Y".to_string(),
        DORADeploymentPatchRequestDataType::DORA_DEPLOYMENT_PATCH_REQUEST,
    ));
    let configuration = datadog::Configuration::new();
    let api = DORAMetricsAPI::with_config(configuration);
    let resp = api
        .patch_dora_deployment("deployment_id".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Patch 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.DORAMetricsApiPatchDORADeploymentRequest = {
  body: {
    data: {
      attributes: {
        changeFailure: true,
        remediation: {
          id: "eG42zNIkVjM",
          type: "rollback",
        },
      },
      id: "z_RwVLi7v4Y",
      type: "dora_deployment_patch_request",
    },
  },
  deploymentId: "deployment_id",
};

apiInstance
  .patchDORADeployment(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"