인시던트 가져오기
https://api.datadoghq.com/api/v2/incidents/importhttps://api.us3.datadoghq.com/api/v2/incidents/importhttps://api.us5.datadoghq.com/api/v2/incidents/importhttps://api.datadoghq.eu/api/v2/incidents/importhttps://api.ap1.datadoghq.com/api/v2/incidents/importhttps://api.ap2.datadoghq.com/api/v2/incidents/importhttps://api.uk1.datadoghq.com/api/v2/incidents/importhttps://api.ddog-gov.com/api/v2/incidents/importhttps://api.us2.ddog-gov.com/api/v2/incidents/import개요
외부 시스템에서 인시던트를 가져옵니다. 이 엔드포인트를 사용하면 탐지, 선언 및 해결을 위한 사용자 지정 타임스탬프와 같은 과거 데이터를 포함하여 인시던트를 생성할 수 있습니다. 가져온 인시던트는 통합 또는 알림 규칙을 실행하지 않습니다.
OAuth apps require the incident_write authorization scope to access this endpoint.
인수
쿼리 문자열
includeSpecifies which related object types to include in the response when importing an incident.
요청
Body Data (required)
인시던트 가져오기 페이로드입니다.
data [required]인시던트에 대한 가져오기 요청입니다. 외부 시스템에서 과거 인시던트를 가져오는 데 사용됩니다.
attributes [required]The incident's attributes for an import request.
declaredTimestamp when the incident was declared.
detectedTimestamp when the incident was detected.
fieldsA condensed view of the user-defined fields for which to create initial selections.
<any-key>Dynamic fields for which selections can be made, with field names as keys.
Object 1A field with a single value selected.
valueThe single value selected for this field.
Object 2A field with potentially multiple values selected.
valueThe multiple values selected for this field.
incident_type_uuidA unique identifier that represents the incident type. If not provided, the default incident type is used.
resolvedTimestamp when the incident was resolved. Can only be set when the state field is set to 'resolved'.
title [required]The title of the incident that summarizes what happened.
visibilityThe visibility of the incident.
organizationorganization, privaterelationshipsThe relationships for an incident import request.
commander_userRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersusersdeclared_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]Incident resource type.
incidentsincidents{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}응답
CREATED
Response with an incident.
data [required]Incident data from an import response.
attributesThe incident's attributes from an import response.
archivedTimestamp when the incident was archived.
case_idThe incident case ID.
createdTimestamp when the incident was created.
created_by_uuidUUID of the user who created the incident.
creation_idempotency_keyA unique key used to ensure idempotent incident creation.
customer_impact_endTimestamp when customers were no longer impacted by the incident.
customer_impact_scopeA summary of the impact customers experienced during the incident.
customer_impact_startTimestamp when customers began to be impacted by the incident.
declaredTimestamp when the incident was declared.
declared_by_uuidUUID of the user who declared the incident.
detectedTimestamp when the incident was detected.
fieldsA condensed view of the user-defined fields attached to incidents.
<any-key>Dynamic fields for which selections can be made, with field names as keys.
Object 1A field with a single value selected.
typeType of the single value field definitions.
dropdowndropdown, textboxvalueThe single value selected for this field.
Object 2A field with potentially multiple values selected.
typeType of the multiple value field definitions.
multiselectmultiselect, textarray, metrictag, autocompletevalueThe multiple values selected for this field.
incident_type_uuidA unique identifier that represents an incident type.
is_testA flag indicating whether the incident is a test incident.
last_modified_by_uuidUUID of the user who last modified the incident.
modifiedTimestamp when the incident was last modified.
non_datadog_creatorIncident's non Datadog creator.
image_48_pxNon Datadog creator 48px image.
nameNon Datadog creator name.
notification_handlesNotification handles that are notified of the incident during update.
display_nameThe name of the notified handle.
handleThe handle used for the notification. This includes an email address, Slack channel, or workflow.
public_idThe monotonically increasing integer ID for the incident.
resolvedTimestamp when the incident's state was last changed from active or stable to resolved or completed.
severityThe incident severity.
UNKNOWN, SEV-0, SEV-1, SEV-2, SEV-3, SEV-4, SEV-5stateThe state of the incident.
title [required]The title of the incident that summarizes what happened.
visibilityThe incident visibility status.
id [required]The incident's ID.
relationshipsThe incident's relationships from an import response.
attachmentsA relationship reference for attachments.
data [required]An array of incident attachments.
id [required]A unique identifier that represents the attachment.
type [required]The incident attachment resource type.
incident_attachmentsincident_attachmentscommander_userRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersuserscreated_by_userRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersusersdeclared_by_userRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersusersimpactsRelationship to impacts.
data [required]An array of incident impacts.
id [required]A unique identifier that represents the impact.
type [required]The incident impacts type.
incident_impactsincident_typeRelationship to an incident type.
data [required]Relationship to incident type object.
id [required]The incident type's ID.
type [required]Incident type resource type.
incident_typesincident_typesintegrationsA relationship reference for multiple integration metadata objects.
data [required]Integration metadata relationship array
id [required]A unique identifier that represents the integration metadata.
type [required]Integration metadata resource type.
incident_integrationsincident_integrationslast_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.
usersusersrespondersRelationship to incident responders.
data [required]An array of incident responders.
id [required]A unique identifier that represents the responder.
type [required]The incident responders type.
incident_respondersuser_defined_fieldsRelationship to incident user defined fields.
data [required]An array of user defined fields.
id [required]A unique identifier that represents the responder.
type [required]The incident user defined fields type.
user_defined_fieldtype [required]Incident resource type.
incidentsincidentsincludedIncluded related resources that the user requested.
<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<type=incident_types>Incident type response data.
attributesIncident type's attributes.
configurationThe incident-type-scoped behavior settings. All fields are optional on update. Any field omitted from a PATCH request keeps its current value. This object is read-only on the incident type resource itself and is only mutated through the update (PATCH) endpoint.
allow_incident_deletionWhether incidents of this type can be deleted.
falseallow_workflowsWhether automation workflows can be triggered for incidents of this type.
truecreate_messageAn optional message shown to users when they declare an incident of this type.
editable_timestampsWhether responders can edit incident timestamps for incidents of this type.
falseprivate_incidentsWhether responders can create private incidents of this type. This is an opt-in setting, distinct from private_incidents_by_default, which controls whether incidents are created private automatically.
falseprivate_incidents_by_defaultWhether incidents of this type are created as private by default.
falseslug_sourceWhen set to servicenow, incidents will display the ServiceNow record ID instead of the public ID. If no ServiceNow integration exists, the public ID will be displayed.
defaultdefault, servicenowtest_incidentsWhether incidents of this type are treated as test incidents.
truecreatedAtTimestamp when the incident type was created.
createdByA unique identifier that represents the user that created the incident type.
descriptionText that describes the incident type.
is_defaultIf true, this incident type will be used as the default incident type if a type is not specified during the creation of incident resources.
falselastModifiedByA unique identifier that represents the user that last modified the incident type.
modifiedAtTimestamp when the incident type was last modified.
name [required]The name of the incident type.
prefixThe string that will be prepended to the incident title across the Datadog app.
id [required]The incident type's ID.
relationshipsThe incident type's resource relationships.
created_by_userRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersusersgoogle_meet_configurationA reference to a Google Meet Configuration resource.
data [required]The Google Meet configuration relationship data object.
id [required]The unique identifier of the Google Meet configuration.
type [required]The type of the Google Meet configuration.
last_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.
usersusersmicrosoft_teams_configurationA reference to a Microsoft Teams Configuration resource.
data [required]The Microsoft Teams configuration relationship data object.
id [required]The unique identifier of the Microsoft Teams configuration.
type [required]The type of the Microsoft Teams configuration.
zoom_configurationA reference to a Zoom configuration resource.
data [required]The Zoom configuration relationship data object.
id [required]The unique identifier of the Zoom configuration.
type [required]The type of the Zoom configuration.
type [required]Incident type resource type.
incident_typesincident_types{
"data": {
"attributes": {
"archived": "2019-09-19T10:00:00.000Z",
"case_id": "integer",
"created": "2025-01-01T00:00:00Z",
"created_by_uuid": "string",
"creation_idempotency_key": "string",
"customer_impact_end": "2019-09-19T10:00:00.000Z",
"customer_impact_scope": "An example customer impact scope",
"customer_impact_start": "2019-09-19T10:00:00.000Z",
"declared": "2025-01-01T00:00:00Z",
"declared_by_uuid": "string",
"detected": "2025-01-01T00:00:00Z",
"fields": {
"<any-key>": "undefined"
},
"incident_type_uuid": "00000000-0000-0000-0000-000000000000",
"is_test": false,
"last_modified_by_uuid": "string",
"modified": "2019-09-19T10:00:00.000Z",
"non_datadog_creator": {
"image_48_px": "string",
"name": "string"
},
"notification_handles": [
{
"display_name": "Jane Doe",
"handle": "@test.user@test.com"
}
],
"public_id": 1,
"resolved": "2019-09-19T10:00:00.000Z",
"severity": "UNKNOWN",
"state": "string",
"title": "A test incident title",
"visibility": "string"
},
"id": "00000000-0000-0000-1234-000000000000",
"relationships": {
"attachments": {
"data": [
{
"id": "00000000-0000-abcd-1000-000000000000",
"type": "incident_attachments"
}
]
},
"commander_user": {
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "users"
}
},
"created_by_user": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
},
"declared_by_user": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
},
"impacts": {
"data": [
{
"id": "00000000-0000-0000-2345-000000000000",
"type": "incident_impacts"
}
]
},
"incident_type": {
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "incident_types"
}
},
"integrations": {
"data": [
{
"id": "00000000-abcd-0001-0000-000000000000",
"type": "incident_integrations"
}
]
},
"last_modified_by_user": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
},
"responders": {
"data": [
{
"id": "00000000-0000-0000-2345-000000000000",
"type": "incident_responders"
}
]
},
"user_defined_fields": {
"data": [
{
"id": "00000000-0000-0000-2345-000000000000",
"type": "user_defined_field"
}
]
}
},
"type": "incidents"
},
"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"
]
}Unauthorized
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"
]
}Not Found
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"
]
}코드 예시
# 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/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
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/incidents/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
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/incidents/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
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/incidents/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
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/incidents/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
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/incidents/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
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/incidents/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
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/incidents/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
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/incidents/import" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"type": "incidents",
"attributes": {
"title": "Example-Incident",
"visibility": "organization"
}
}
}
EOF// Import an incident 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() {
body := datadogV2.IncidentImportRequest{
Data: datadogV2.IncidentImportRequestData{
Type: datadogV2.INCIDENTTYPE_INCIDENTS,
Attributes: datadogV2.IncidentImportRequestAttributes{
Title: "Example-Incident",
Visibility: datadogV2.INCIDENTIMPORTVISIBILITY_ORGANIZATION.Ptr(),
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.ImportIncident", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewIncidentsApi(apiClient)
resp, r, err := api.ImportIncident(ctx, body, *datadogV2.NewImportIncidentOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.ImportIncident`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.ImportIncident`:\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"// Import an incident 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.IncidentImportRequest;
import com.datadog.api.client.v2.model.IncidentImportRequestAttributes;
import com.datadog.api.client.v2.model.IncidentImportRequestData;
import com.datadog.api.client.v2.model.IncidentImportResponse;
import com.datadog.api.client.v2.model.IncidentImportVisibility;
import com.datadog.api.client.v2.model.IncidentType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.importIncident", true);
IncidentsApi apiInstance = new IncidentsApi(defaultClient);
IncidentImportRequest body =
new IncidentImportRequest()
.data(
new IncidentImportRequestData()
.type(IncidentType.INCIDENTS)
.attributes(
new IncidentImportRequestAttributes()
.title("Example-Incident")
.visibility(IncidentImportVisibility.ORGANIZATION)));
try {
IncidentImportResponse result = apiInstance.importIncident(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IncidentsApi#importIncident");
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""""
Import an incident 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.incident_import_request import IncidentImportRequest
from datadog_api_client.v2.model.incident_import_request_attributes import IncidentImportRequestAttributes
from datadog_api_client.v2.model.incident_import_request_data import IncidentImportRequestData
from datadog_api_client.v2.model.incident_import_visibility import IncidentImportVisibility
from datadog_api_client.v2.model.incident_type import IncidentType
body = IncidentImportRequest(
data=IncidentImportRequestData(
type=IncidentType.INCIDENTS,
attributes=IncidentImportRequestAttributes(
title="Example-Incident",
visibility=IncidentImportVisibility.ORGANIZATION,
),
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["import_incident"] = True
with ApiClient(configuration) as api_client:
api_instance = IncidentsApi(api_client)
response = api_instance.import_incident(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"# Import an incident returns "CREATED" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.import_incident".to_sym] = true
end
api_instance = DatadogAPIClient::V2::IncidentsAPI.new
body = DatadogAPIClient::V2::IncidentImportRequest.new({
data: DatadogAPIClient::V2::IncidentImportRequestData.new({
type: DatadogAPIClient::V2::IncidentType::INCIDENTS,
attributes: DatadogAPIClient::V2::IncidentImportRequestAttributes.new({
title: "Example-Incident",
visibility: DatadogAPIClient::V2::IncidentImportVisibility::ORGANIZATION,
}),
}),
})
p api_instance.import_incident(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"// Import an incident returns "CREATED" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::ImportIncidentOptionalParams;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::model::IncidentImportRequest;
use datadog_api_client::datadogV2::model::IncidentImportRequestAttributes;
use datadog_api_client::datadogV2::model::IncidentImportRequestData;
use datadog_api_client::datadogV2::model::IncidentImportVisibility;
use datadog_api_client::datadogV2::model::IncidentType;
#[tokio::main]
async fn main() {
let body = IncidentImportRequest::new(IncidentImportRequestData::new(
IncidentImportRequestAttributes::new("Example-Incident".to_string())
.visibility(IncidentImportVisibility::ORGANIZATION),
IncidentType::INCIDENTS,
));
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.import_incident", true);
let api = IncidentsAPI::with_config(configuration);
let resp = api
.import_incident(body, ImportIncidentOptionalParams::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/**
* Import an incident 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.importIncident"] = true;
const apiInstance = new v2.IncidentsApi(configuration);
const params: v2.IncidentsApiImportIncidentRequest = {
body: {
data: {
type: "incidents",
attributes: {
title: "Example-Incident",
visibility: "organization",
},
},
},
};
apiInstance
.importIncident(params)
.then((data: v2.IncidentImportResponse) => {
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"