Patch a deployment event by version

Note: This endpoint is in preview and is subject to change. If you have any feedback, contact Datadog support.

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

Overview

Update a deployment’s change failure status, identifying the deployment by its service, environment, and version instead of its ID. 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. If multiple deployments match the given service, environment, and version, the most recently finished one is updated. This endpoint requires the dora_metrics_write permission.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

The JSON:API data for patching a deployment identified by service, environment, and version.

attributes [required]

object

Attributes for patching a DORA deployment event identified by service, environment, and version.

change_failure [required]

boolean

Indicates whether the deployment resulted in a change failure.

env [required]

string

The environment the deployment was performed in.

remediation

 <oneOf>

Remediation details for the deployment. Optional, but required to calculate failed deployment recovery time. Specify either id or version to identify the remediation deployment, but not both.

Object 1

object

Remediation details identified by the ID of the remediation deployment.

id [required]

string

The ID of the remediation deployment.

type [required]

enum

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

Object 2

object

Remediation details identified by the version of the remediation deployment, matched against the same service and environment as the failed deployment.

type [required]

enum

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

version [required]

string

The version of the remediation deployment.

service [required]

string

The name of the service that was deployed.

version [required]

string

The version deployed. This can be seen in the Service Catalog or in the APM Deployment Tracking.

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,
      "env": "prod",
      "remediation": {
        "id": "eG42zNIkVjM",
        "type": "rollback"
      },
      "service": "my-service",
      "version": "v1.2.3"
    },
    "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
# 

# 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.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/dora/deployments" \ -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, "env": "production", "service": "my-service", "version": "v1.2.3" }, "type": "dora_deployment_patch_request" } } EOF
"""
Patch a deployment event by version 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_by_version_remediation_by_version import (
    DORADeploymentPatchByVersionRemediationByVersion,
)
from datadog_api_client.v2.model.dora_deployment_patch_by_version_request import DORADeploymentPatchByVersionRequest
from datadog_api_client.v2.model.dora_deployment_patch_by_version_request_attributes import (
    DORADeploymentPatchByVersionRequestAttributes,
)
from datadog_api_client.v2.model.dora_deployment_patch_by_version_request_data import (
    DORADeploymentPatchByVersionRequestData,
)
from datadog_api_client.v2.model.dora_deployment_patch_remediation_type import DORADeploymentPatchRemediationType
from datadog_api_client.v2.model.dora_deployment_patch_request_data_type import DORADeploymentPatchRequestDataType

body = DORADeploymentPatchByVersionRequest(
    data=DORADeploymentPatchByVersionRequestData(
        attributes=DORADeploymentPatchByVersionRequestAttributes(
            change_failure=True,
            env="production",
            remediation=DORADeploymentPatchByVersionRemediationByVersion(
                type=DORADeploymentPatchRemediationType.ROLLBACK,
                version="v1.2.2",
            ),
            service="my-service",
            version="v1.2.3",
        ),
        type=DORADeploymentPatchRequestDataType.DORA_DEPLOYMENT_PATCH_REQUEST,
    ),
)

configuration = Configuration()
configuration.unstable_operations["patch_dora_deployment_by_version"] = True
with ApiClient(configuration) as api_client:
    api_instance = DORAMetricsApi(api_client)
    api_instance.patch_dora_deployment_by_version(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.comuk1.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 by version returns "Accepted" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.patch_dora_deployment_by_version".to_sym] = true
end
api_instance = DatadogAPIClient::V2::DORAMetricsAPI.new

body = DatadogAPIClient::V2::DORADeploymentPatchByVersionRequest.new({
  data: DatadogAPIClient::V2::DORADeploymentPatchByVersionRequestData.new({
    attributes: DatadogAPIClient::V2::DORADeploymentPatchByVersionRequestAttributes.new({
      change_failure: true,
      env: "production",
      remediation: DatadogAPIClient::V2::DORADeploymentPatchByVersionRemediationByVersion.new({
        type: DatadogAPIClient::V2::DORADeploymentPatchRemediationType::ROLLBACK,
        version: "v1.2.2",
      }),
      service: "my-service",
      version: "v1.2.3",
    }),
    type: DatadogAPIClient::V2::DORADeploymentPatchRequestDataType::DORA_DEPLOYMENT_PATCH_REQUEST,
  }),
})
p api_instance.patch_dora_deployment_by_version(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.comuk1.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 by version 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.DORADeploymentPatchByVersionRequest{
		Data: datadogV2.DORADeploymentPatchByVersionRequestData{
			Attributes: datadogV2.DORADeploymentPatchByVersionRequestAttributes{
				ChangeFailure: true,
				Env:           "production",
				Remediation: &datadogV2.DORADeploymentPatchByVersionRemediation{
					DORADeploymentPatchByVersionRemediationByVersion: &datadogV2.DORADeploymentPatchByVersionRemediationByVersion{
						Type:    datadogV2.DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLBACK,
						Version: "v1.2.2",
					}},
				Service: "my-service",
				Version: "v1.2.3",
			},
			Type: datadogV2.DORADEPLOYMENTPATCHREQUESTDATATYPE_DORA_DEPLOYMENT_PATCH_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.PatchDORADeploymentByVersion", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewDORAMetricsApi(apiClient)
	r, err := api.PatchDORADeploymentByVersion(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DORAMetricsApi.PatchDORADeploymentByVersion`: %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.comuk1.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 by version 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.DORADeploymentPatchByVersionRemediation;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRemediationByVersion;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRequest;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRequestAttributes;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRequestData;
import com.datadog.api.client.v2.model.DORADeploymentPatchRemediationType;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequestDataType;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.patchDORADeploymentByVersion", true);
    DoraMetricsApi apiInstance = new DoraMetricsApi(defaultClient);

    DORADeploymentPatchByVersionRequest body =
        new DORADeploymentPatchByVersionRequest()
            .data(
                new DORADeploymentPatchByVersionRequestData()
                    .attributes(
                        new DORADeploymentPatchByVersionRequestAttributes()
                            .changeFailure(true)
                            .env("production")
                            .remediation(
                                new DORADeploymentPatchByVersionRemediation(
                                    new DORADeploymentPatchByVersionRemediationByVersion()
                                        .type(DORADeploymentPatchRemediationType.ROLLBACK)
                                        .version("v1.2.2")))
                            .service("my-service")
                            .version("v1.2.3"))
                    .type(DORADeploymentPatchRequestDataType.DORA_DEPLOYMENT_PATCH_REQUEST));

    try {
      apiInstance.patchDORADeploymentByVersion(body);
    } catch (ApiException e) {
      System.err.println("Exception when calling DoraMetricsApi#patchDORADeploymentByVersion");
      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.comuk1.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 by version returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dora_metrics::DORAMetricsAPI;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRemediation;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRemediationByVersion;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRequest;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRequestAttributes;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRequestData;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRemediationType;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequestDataType;

#[tokio::main]
async fn main() {
    let body =
        DORADeploymentPatchByVersionRequest::new(
            DORADeploymentPatchByVersionRequestData::new(
                DORADeploymentPatchByVersionRequestAttributes::new(
                    true,
                    "production".to_string(),
                    "my-service".to_string(),
                    "v1.2.3".to_string(),
                ).remediation(
                    DORADeploymentPatchByVersionRemediation::DORADeploymentPatchByVersionRemediationByVersion(
                        Box::new(
                            DORADeploymentPatchByVersionRemediationByVersion::new(
                                DORADeploymentPatchRemediationType::ROLLBACK,
                                "v1.2.2".to_string(),
                            ),
                        ),
                    ),
                ),
                DORADeploymentPatchRequestDataType::DORA_DEPLOYMENT_PATCH_REQUEST,
            ),
        );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.PatchDORADeploymentByVersion", true);
    let api = DORAMetricsAPI::with_config(configuration);
    let resp = api.patch_dora_deployment_by_version(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.comuk1.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 by version returns "Accepted" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.patchDORADeploymentByVersion"] = true;
const apiInstance = new v2.DORAMetricsApi(configuration);

const params: v2.DORAMetricsApiPatchDORADeploymentByVersionRequest = {
  body: {
    data: {
      attributes: {
        changeFailure: true,
        env: "production",
        remediation: {
          type: "rollback",
          version: "v1.2.2",
        },
        service: "my-service",
        version: "v1.2.3",
      },
      type: "dora_deployment_patch_request",
    },
  },
};

apiInstance
  .patchDORADeploymentByVersion(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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"