인시던트 첨부 파일 생성
https://api.datadoghq.com/api/v2/incidents/{incident_id}/attachmentshttps://api.us3.datadoghq.com/api/v2/incidents/{incident_id}/attachmentshttps://api.us5.datadoghq.com/api/v2/incidents/{incident_id}/attachmentshttps://api.datadoghq.eu/api/v2/incidents/{incident_id}/attachmentshttps://api.ap1.datadoghq.com/api/v2/incidents/{incident_id}/attachmentshttps://api.ap2.datadoghq.com/api/v2/incidents/{incident_id}/attachmentshttps://api.uk1.datadoghq.com/api/v2/incidents/{incident_id}/attachmentshttps://api.ddog-gov.com/api/v2/incidents/{incident_id}/attachmentshttps://api.us2.ddog-gov.com/api/v2/incidents/{incident_id}/attachments개요
인시던트 첨부 파일을 생성합니다.
OAuth apps require the incident_write authorization scope to access this endpoint.
인수
경로 파라미터
incident_id [required]The UUID of the incident.
쿼리 문자열
includeResource to include in the response. Supported value: last_modified_by_user.
요청
Body Data (required)
data첨부 파일 생성 요청입니다.
attributesThe attributes for creating an attachment.
attachmentThe attachment object for creating an attachment.
documentUrlThe URL of the attachment.
titleThe title of the attachment.
attachment_typeThe type of the attachment.
postmortem, linkidThe unique identifier of the attachment.
type [required]The incident attachment resource type.
incident_attachmentsincident_attachments{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}응답
Created
An attachment response containing the attachment data and related objects.
dataAttachment data from a response.
attributes [required]The attachment's attributes.
attachmentThe attachment object.
documentUrlThe URL of the attachment.
titleThe title of the attachment.
attachment_typeThe type of the attachment.
postmortem, linkmodifiedTimestamp when the attachment was last modified.
id [required]The unique identifier of the attachment.
relationships [required]The attachment's resource relationships.
incidentRelationship to incident.
data [required]Relationship to incident object.
id [required]A unique identifier that represents the incident.
type [required]Incident resource type.
incidentsincidentslast_modified_by_userRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersuserstype [required]The incident attachment resource type.
incident_attachmentsincident_attachmentsincludedA list of related objects included in the response.
<type=users>User object returned by the API.
attributesAttributes of user object returned by the API.
emailEmail of the user.
handleHandle of the user.
iconURL of the user's icon.
nameName of the user.
uuidUUID of the user.
idID of the user.
typeUsers resource type.
usersusers{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/123/Postmortem-IR-123",
"title": "Postmortem IR-123"
},
"attachment_type": "postmortem",
"modified": "2025-01-01T01:01:01.000000001Z"
},
"id": "00000000-abcd-0002-0000-000000000000",
"relationships": {
"incident": {
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents"
}
},
"last_modified_by_user": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
}
},
"type": "incident_attachments"
},
"included": [
{
"attributes": {
"email": "string",
"handle": "string",
"icon": "string",
"name": "string",
"uuid": "string"
},
"id": "string",
"type": "users"
}
]
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Forbidden
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}코드 예시
# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF# Path parameters
export incident_id="CHANGE_ME"
# 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/incidents/${incident_id}/attachments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"attachment": {
"documentUrl": "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
"title": "Example-Incident"
},
"attachment_type": "postmortem"
},
"type": "incident_attachments"
}
}
EOF// Create incident attachment returns "Created" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
// there is a valid "incident" in the system
IncidentDataID := os.Getenv("INCIDENT_DATA_ID")
body := datadogV2.CreateAttachmentRequest{
Data: &datadogV2.CreateAttachmentRequestData{
Attributes: &datadogV2.CreateAttachmentRequestDataAttributes{
Attachment: &datadogV2.CreateAttachmentRequestDataAttributesAttachment{
DocumentUrl: datadog.PtrString("https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident"),
Title: datadog.PtrString("Example-Incident"),
},
AttachmentType: datadogV2.ATTACHMENTDATAATTRIBUTESATTACHMENTTYPE_POSTMORTEM.Ptr(),
},
Type: datadogV2.INCIDENTATTACHMENTTYPE_INCIDENT_ATTACHMENTS,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateIncidentAttachment", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewIncidentsApi(apiClient)
resp, r, err := api.CreateIncidentAttachment(ctx, IncidentDataID, body, *datadogV2.NewCreateIncidentAttachmentOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.CreateIncidentAttachment`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.CreateIncidentAttachment`:\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 incident attachment returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.IncidentsApi;
import com.datadog.api.client.v2.model.Attachment;
import com.datadog.api.client.v2.model.AttachmentDataAttributesAttachmentType;
import com.datadog.api.client.v2.model.CreateAttachmentRequest;
import com.datadog.api.client.v2.model.CreateAttachmentRequestData;
import com.datadog.api.client.v2.model.CreateAttachmentRequestDataAttributes;
import com.datadog.api.client.v2.model.CreateAttachmentRequestDataAttributesAttachment;
import com.datadog.api.client.v2.model.IncidentAttachmentType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createIncidentAttachment", true);
IncidentsApi apiInstance = new IncidentsApi(defaultClient);
// there is a valid "incident" in the system
String INCIDENT_DATA_ID = System.getenv("INCIDENT_DATA_ID");
CreateAttachmentRequest body =
new CreateAttachmentRequest()
.data(
new CreateAttachmentRequestData()
.attributes(
new CreateAttachmentRequestDataAttributes()
.attachment(
new CreateAttachmentRequestDataAttributesAttachment()
.documentUrl(
"https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident")
.title("Example-Incident"))
.attachmentType(AttachmentDataAttributesAttachmentType.POSTMORTEM))
.type(IncidentAttachmentType.INCIDENT_ATTACHMENTS));
try {
Attachment result = apiInstance.createIncidentAttachment(INCIDENT_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IncidentsApi#createIncidentAttachment");
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 incident attachment returns "Created" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.incidents_api import IncidentsApi
from datadog_api_client.v2.model.attachment_data_attributes_attachment_type import (
AttachmentDataAttributesAttachmentType,
)
from datadog_api_client.v2.model.create_attachment_request import CreateAttachmentRequest
from datadog_api_client.v2.model.create_attachment_request_data import CreateAttachmentRequestData
from datadog_api_client.v2.model.create_attachment_request_data_attributes import CreateAttachmentRequestDataAttributes
from datadog_api_client.v2.model.create_attachment_request_data_attributes_attachment import (
CreateAttachmentRequestDataAttributesAttachment,
)
from datadog_api_client.v2.model.incident_attachment_type import IncidentAttachmentType
# there is a valid "incident" in the system
INCIDENT_DATA_ID = environ["INCIDENT_DATA_ID"]
body = CreateAttachmentRequest(
data=CreateAttachmentRequestData(
attributes=CreateAttachmentRequestDataAttributes(
attachment=CreateAttachmentRequestDataAttributesAttachment(
document_url="https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
title="Example-Incident",
),
attachment_type=AttachmentDataAttributesAttachmentType.POSTMORTEM,
),
type=IncidentAttachmentType.INCIDENT_ATTACHMENTS,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_incident_attachment"] = True
with ApiClient(configuration) as api_client:
api_instance = IncidentsApi(api_client)
response = api_instance.create_incident_attachment(incident_id=INCIDENT_DATA_ID, 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 incident attachment returns "Created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_incident_attachment".to_sym] = true
end
api_instance = DatadogAPIClient::V2::IncidentsAPI.new
# there is a valid "incident" in the system
INCIDENT_DATA_ID = ENV["INCIDENT_DATA_ID"]
body = DatadogAPIClient::V2::CreateAttachmentRequest.new({
data: DatadogAPIClient::V2::CreateAttachmentRequestData.new({
attributes: DatadogAPIClient::V2::CreateAttachmentRequestDataAttributes.new({
attachment: DatadogAPIClient::V2::CreateAttachmentRequestDataAttributesAttachment.new({
document_url: "https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
title: "Example-Incident",
}),
attachment_type: DatadogAPIClient::V2::AttachmentDataAttributesAttachmentType::POSTMORTEM,
}),
type: DatadogAPIClient::V2::IncidentAttachmentType::INCIDENT_ATTACHMENTS,
}),
})
p api_instance.create_incident_attachment(INCIDENT_DATA_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.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 incident attachment returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::CreateIncidentAttachmentOptionalParams;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::model::AttachmentDataAttributesAttachmentType;
use datadog_api_client::datadogV2::model::CreateAttachmentRequest;
use datadog_api_client::datadogV2::model::CreateAttachmentRequestData;
use datadog_api_client::datadogV2::model::CreateAttachmentRequestDataAttributes;
use datadog_api_client::datadogV2::model::CreateAttachmentRequestDataAttributesAttachment;
use datadog_api_client::datadogV2::model::IncidentAttachmentType;
#[tokio::main]
async fn main() {
// there is a valid "incident" in the system
let incident_data_id = std::env::var("INCIDENT_DATA_ID").unwrap();
let body = CreateAttachmentRequest::new().data(
CreateAttachmentRequestData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS).attributes(
CreateAttachmentRequestDataAttributes::new()
.attachment(
CreateAttachmentRequestDataAttributesAttachment::new()
.document_url(
"https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident"
.to_string(),
)
.title("Example-Incident".to_string()),
)
.attachment_type(AttachmentDataAttributesAttachmentType::POSTMORTEM),
),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.create_incident_attachment", true);
let api = IncidentsAPI::with_config(configuration);
let resp = api
.create_incident_attachment(
incident_data_id.clone(),
body,
CreateIncidentAttachmentOptionalParams::default(),
)
.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 incident attachment 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.createIncidentAttachment"] = true;
const apiInstance = new v2.IncidentsApi(configuration);
// there is a valid "incident" in the system
const INCIDENT_DATA_ID = process.env.INCIDENT_DATA_ID as string;
const params: v2.IncidentsApiCreateIncidentAttachmentRequest = {
body: {
data: {
attributes: {
attachment: {
documentUrl:
"https://app.datadoghq.com/notebook/ExampleIncident/Example-Incident",
title: "Example-Incident",
},
attachmentType: "postmortem",
},
type: "incident_attachments",
},
},
incidentId: INCIDENT_DATA_ID,
};
apiInstance
.createIncidentAttachment(params)
.then((data: v2.Attachment) => {
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"