Create a change request
https://api.datadoghq.com/api/v2/change-management/change-requesthttps://api.us3.datadoghq.com/api/v2/change-management/change-requesthttps://api.us5.datadoghq.com/api/v2/change-management/change-requesthttps://api.datadoghq.eu/api/v2/change-management/change-requesthttps://api.ap1.datadoghq.com/api/v2/change-management/change-requesthttps://api.ap2.datadoghq.com/api/v2/change-management/change-requesthttps://api.uk1.datadoghq.com/api/v2/change-management/change-requesthttps://api.ddog-gov.com/api/v2/change-management/change-requesthttps://api.us2.ddog-gov.com/api/v2/change-management/change-requestOverview
Create a new change request.
OAuth apps require the cases_write authorization scope to access this endpoint.
Request
Body Data (required)
Change request payload.
data [required]Data object to create a change request.
attributes [required]Attributes for creating a change request.
change_request_linked_incident_uuidThe UUID of an incident to link to the change request.
change_request_maintenance_window_queryThe maintenance window query for the change request.
change_request_planThe plan associated with the change request.
change_request_riskThe risk level of the change request.
UNDEFINED, LOW, MEDIUM, HIGHchange_request_typeThe type of the change request.
NORMAL, STANDARD, EMERGENCYdescriptionThe description of the change request.
end_dateThe planned end date of the change request.
project_idThe project UUID to associate with the change request.
requested_teamsA list of team handles to request decisions from.
start_dateThe planned start date of the change request.
title [required]The title of the change request.
type [required]Change request resource type.
change_request{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}Response
Created
Response object for a change request.
data [required]Data object for a change request response.
attributes [required]Attributes of a change request response.
archived_atTimestamp of when the change request was archived.
attributes [required]Custom attributes of the change request as key-value pairs.
<any-key>change_request_linked_incident_uuid [required]The UUID of the linked incident.
change_request_maintenance_window_query [required]The maintenance window query for the change request.
change_request_plan [required]The plan associated with the change request.
change_request_risk [required]The risk level of the change request.
UNDEFINED, LOW, MEDIUM, HIGHchange_request_type [required]The type of the change request.
NORMAL, STANDARD, EMERGENCYclosed_atTimestamp of when the change request was closed.
created_at [required]Timestamp of when the change request was created.
creation_source [required]The source from which the change request was created.
description [required]The description of the change request.
end_dateThe planned end date of the change request.
key [required]The human-readable key of the change request.
modified_at [required]Timestamp of when the change request was last modified.
plan_notebook_id [required]The notebook ID associated with the change request plan.
priority [required]The priority of the change request.
project_id [required]The project UUID associated with the change request.
start_dateThe planned start date of the change request.
status [required]The current status of the change request.
title [required]The title of the change request.
type [required]The case type.
id [required]The identifier of the change request.
relationshipsRelationships of a change request.
change_request_decisions [required]Relationship to change request decisions.
data [required]Array of decision relationship data.
id [required]The decision UUID.
type [required]Change request decision resource type.
change_request_decisioncreated_by [required]Relationship to a user.
data [required]User relationship data.
id [required]The user UUID.
type [required]The user resource type.
modified_by [required]Relationship to a user.
data [required]User relationship data.
id [required]The user UUID.
type [required]The user resource type.
type [required]Change request resource type.
change_requestincludedIncluded resources related to the change request.
Object 1An included user resource.
attributes [required]Attributes of an included user.
email [required]The email of the user.
handle [required]The handle of the user.
name [required]The name of the user.
id [required]The user UUID.
type [required]The resource type.
Object 2An included change request decision resource.
attributes [required]Attributes of a change request decision in a response.
change_request_status [required]The status of a change request decision.
REQUESTED, APPROVED, DECLINEDdecided_at [required]Timestamp of when the decision was made.
decision_reason [required]The reason for the decision.
deleted_at [required]Timestamp of when the decision was deleted.
request_reason [required]The reason for requesting the decision.
requested_at [required]Timestamp of when the decision was requested.
id [required]The decision UUID.
relationshipsRelationships of a change request decision.
modified_by [required]Relationship to a user.
data [required]User relationship data.
id [required]The user UUID.
type [required]The user resource type.
requested_by_user [required]Relationship to a user.
data [required]User relationship data.
id [required]The user UUID.
type [required]The user resource type.
requested_user [required]Relationship to a user.
data [required]User relationship data.
id [required]The user UUID.
type [required]The user resource type.
type [required]Change request decision resource type.
change_request_decision{
"data": {
"attributes": {
"archived_at": "2019-09-19T10:00:00.000Z",
"attributes": {
"<any-key>": []
},
"change_request_linked_incident_uuid": "",
"change_request_maintenance_window_query": "",
"change_request_plan": "",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"closed_at": "2019-09-19T10:00:00.000Z",
"created_at": "2024-01-01T00:00:00Z",
"creation_source": "CS_MANUAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"key": "CHM-1234",
"modified_at": "2024-01-01T00:00:00Z",
"plan_notebook_id": 0,
"priority": "NOT_DEFINED",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"start_date": "2024-01-01T03:00:00Z",
"status": "OPEN",
"title": "Deploy new payment service",
"type": "CHANGE_REQUEST"
},
"id": "CHM-1234",
"relationships": {
"change_request_decisions": {
"data": [
{
"id": "decision-id-0",
"type": "change_request_decision"
}
]
},
"created_by": {
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "user"
}
},
"modified_by": {
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "user"
}
}
},
"type": "change_request"
},
"included": [
{
"attributes": {
"email": "john.doe@example.com",
"handle": "john.doe@example.com",
"name": "John Doe"
},
"id": "00000000-0000-0000-0000-000000000000",
"type": "user"
}
]
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort 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"
}
]
}Forbidden
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort 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"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Code Example
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/change-management/change-request" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"change_request_linked_incident_uuid": "00000000-0000-0000-0000-000000000000",
"change_request_maintenance_window_query": "",
"change_request_plan": "1. Deploy to staging 2. Run tests 3. Deploy to production",
"change_request_risk": "LOW",
"change_request_type": "NORMAL",
"description": "Deploying new payment service v2.1",
"end_date": "2024-01-02T15:00:00Z",
"project_id": "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
"requested_teams": [
"team-handle-1"
],
"start_date": "2024-01-01T03:00:00Z",
"title": "Deploy new payment service"
},
"type": "change_request"
}
}
EOF// Create a change request returns "Created" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.ChangeRequestCreateRequest{
Data: datadogV2.ChangeRequestCreateData{
Attributes: datadogV2.ChangeRequestCreateAttributes{
ChangeRequestLinkedIncidentUuid: datadog.PtrString("00000000-0000-0000-0000-000000000000"),
ChangeRequestMaintenanceWindowQuery: datadog.PtrString(""),
ChangeRequestPlan: datadog.PtrString("1. Deploy to staging 2. Run tests 3. Deploy to production"),
ChangeRequestRisk: datadogV2.CHANGEREQUESTRISKLEVEL_LOW.Ptr(),
ChangeRequestType: datadogV2.CHANGEREQUESTCHANGETYPE_NORMAL.Ptr(),
Description: datadog.PtrString("Deploying new payment service v2.1"),
EndDate: datadog.PtrTime(time.Date(2024, 1, 2, 15, 0, 0, 0, time.UTC)),
ProjectId: datadog.PtrString("d4bbe1af-f36e-42f1-87c1-493ca35c320e"),
RequestedTeams: []string{
"team-handle-1",
},
StartDate: datadog.PtrTime(time.Date(2024, 1, 1, 3, 0, 0, 0, time.UTC)),
Title: "Deploy new payment service",
},
Type: datadogV2.CHANGEREQUESTRESOURCETYPE_CHANGE_REQUEST,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateChangeRequest", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewChangeManagementApi(apiClient)
resp, r, err := api.CreateChangeRequest(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ChangeManagementApi.CreateChangeRequest`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ChangeManagementApi.CreateChangeRequest`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create a change request returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ChangeManagementApi;
import com.datadog.api.client.v2.model.ChangeRequestChangeType;
import com.datadog.api.client.v2.model.ChangeRequestCreateAttributes;
import com.datadog.api.client.v2.model.ChangeRequestCreateData;
import com.datadog.api.client.v2.model.ChangeRequestCreateRequest;
import com.datadog.api.client.v2.model.ChangeRequestResourceType;
import com.datadog.api.client.v2.model.ChangeRequestResponse;
import com.datadog.api.client.v2.model.ChangeRequestRiskLevel;
import java.time.OffsetDateTime;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createChangeRequest", true);
ChangeManagementApi apiInstance = new ChangeManagementApi(defaultClient);
ChangeRequestCreateRequest body =
new ChangeRequestCreateRequest()
.data(
new ChangeRequestCreateData()
.attributes(
new ChangeRequestCreateAttributes()
.changeRequestLinkedIncidentUuid("00000000-0000-0000-0000-000000000000")
.changeRequestMaintenanceWindowQuery("")
.changeRequestPlan(
"1. Deploy to staging 2. Run tests 3. Deploy to production")
.changeRequestRisk(ChangeRequestRiskLevel.LOW)
.changeRequestType(ChangeRequestChangeType.NORMAL)
.description("Deploying new payment service v2.1")
.endDate(OffsetDateTime.parse("2024-01-02T15:00:00Z"))
.projectId("d4bbe1af-f36e-42f1-87c1-493ca35c320e")
.requestedTeams(Collections.singletonList("team-handle-1"))
.startDate(OffsetDateTime.parse("2024-01-01T03:00:00Z"))
.title("Deploy new payment service"))
.type(ChangeRequestResourceType.CHANGE_REQUEST));
try {
ChangeRequestResponse result = apiInstance.createChangeRequest(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ChangeManagementApi#createChangeRequest");
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create a change request returns "Created" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.change_management_api import ChangeManagementApi
from datadog_api_client.v2.model.change_request_change_type import ChangeRequestChangeType
from datadog_api_client.v2.model.change_request_create_attributes import ChangeRequestCreateAttributes
from datadog_api_client.v2.model.change_request_create_data import ChangeRequestCreateData
from datadog_api_client.v2.model.change_request_create_request import ChangeRequestCreateRequest
from datadog_api_client.v2.model.change_request_resource_type import ChangeRequestResourceType
from datadog_api_client.v2.model.change_request_risk_level import ChangeRequestRiskLevel
from datetime import datetime
from dateutil.tz import tzutc
body = ChangeRequestCreateRequest(
data=ChangeRequestCreateData(
attributes=ChangeRequestCreateAttributes(
change_request_linked_incident_uuid="00000000-0000-0000-0000-000000000000",
change_request_maintenance_window_query="",
change_request_plan="1. Deploy to staging 2. Run tests 3. Deploy to production",
change_request_risk=ChangeRequestRiskLevel.LOW,
change_request_type=ChangeRequestChangeType.NORMAL,
description="Deploying new payment service v2.1",
end_date=datetime(2024, 1, 2, 15, 0, tzinfo=tzutc()),
project_id="d4bbe1af-f36e-42f1-87c1-493ca35c320e",
requested_teams=[
"team-handle-1",
],
start_date=datetime(2024, 1, 1, 3, 0, tzinfo=tzutc()),
title="Deploy new payment service",
),
type=ChangeRequestResourceType.CHANGE_REQUEST,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_change_request"] = True
with ApiClient(configuration) as api_client:
api_instance = ChangeManagementApi(api_client)
response = api_instance.create_change_request(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create a change request returns "Created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_change_request".to_sym] = true
end
api_instance = DatadogAPIClient::V2::ChangeManagementAPI.new
body = DatadogAPIClient::V2::ChangeRequestCreateRequest.new({
data: DatadogAPIClient::V2::ChangeRequestCreateData.new({
attributes: DatadogAPIClient::V2::ChangeRequestCreateAttributes.new({
change_request_linked_incident_uuid: "00000000-0000-0000-0000-000000000000",
change_request_maintenance_window_query: "",
change_request_plan: "1. Deploy to staging 2. Run tests 3. Deploy to production",
change_request_risk: DatadogAPIClient::V2::ChangeRequestRiskLevel::LOW,
change_request_type: DatadogAPIClient::V2::ChangeRequestChangeType::NORMAL,
description: "Deploying new payment service v2.1",
end_date: "2024-01-02T15:00:00Z",
project_id: "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
requested_teams: [
"team-handle-1",
],
start_date: "2024-01-01T03:00:00Z",
title: "Deploy new payment service",
}),
type: DatadogAPIClient::V2::ChangeRequestResourceType::CHANGE_REQUEST,
}),
})
p api_instance.create_change_request(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create a change request returns "Created" response
use chrono::{DateTime, Utc};
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_change_management::ChangeManagementAPI;
use datadog_api_client::datadogV2::model::ChangeRequestChangeType;
use datadog_api_client::datadogV2::model::ChangeRequestCreateAttributes;
use datadog_api_client::datadogV2::model::ChangeRequestCreateData;
use datadog_api_client::datadogV2::model::ChangeRequestCreateRequest;
use datadog_api_client::datadogV2::model::ChangeRequestResourceType;
use datadog_api_client::datadogV2::model::ChangeRequestRiskLevel;
#[tokio::main]
async fn main() {
let body = ChangeRequestCreateRequest::new(ChangeRequestCreateData::new(
ChangeRequestCreateAttributes::new("Deploy new payment service".to_string())
.change_request_linked_incident_uuid("00000000-0000-0000-0000-000000000000".to_string())
.change_request_maintenance_window_query("".to_string())
.change_request_plan(
"1. Deploy to staging 2. Run tests 3. Deploy to production".to_string(),
)
.change_request_risk(ChangeRequestRiskLevel::LOW)
.change_request_type(ChangeRequestChangeType::NORMAL)
.description("Deploying new payment service v2.1".to_string())
.end_date(
DateTime::parse_from_rfc3339("2024-01-02T15:00:00+00:00")
.expect("Failed to parse datetime")
.with_timezone(&Utc),
)
.project_id("d4bbe1af-f36e-42f1-87c1-493ca35c320e".to_string())
.requested_teams(vec!["team-handle-1".to_string()])
.start_date(
DateTime::parse_from_rfc3339("2024-01-01T03:00:00+00:00")
.expect("Failed to parse datetime")
.with_timezone(&Utc),
),
ChangeRequestResourceType::CHANGE_REQUEST,
));
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.create_change_request", true);
let api = ChangeManagementAPI::with_config(configuration);
let resp = api.create_change_request(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.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Create a change request returns "Created" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
configuration.unstableOperations["v2.createChangeRequest"] = true;
const apiInstance = new v2.ChangeManagementApi(configuration);
const params: v2.ChangeManagementApiCreateChangeRequestRequest = {
body: {
data: {
attributes: {
changeRequestLinkedIncidentUuid: "00000000-0000-0000-0000-000000000000",
changeRequestMaintenanceWindowQuery: "",
changeRequestPlan:
"1. Deploy to staging 2. Run tests 3. Deploy to production",
changeRequestRisk: "LOW",
changeRequestType: "NORMAL",
description: "Deploying new payment service v2.1",
endDate: new Date(2024, 1, 2, 15, 0, 0, 0),
projectId: "d4bbe1af-f36e-42f1-87c1-493ca35c320e",
requestedTeams: ["team-handle-1"],
startDate: new Date(2024, 1, 1, 3, 0, 0, 0),
title: "Deploy new payment service",
},
type: "change_request",
},
},
};
apiInstance
.createChangeRequest(params)
.then((data: v2.ChangeRequestResponse) => {
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"