Modificar una incidencia existente
https://api.datadoghq.com/api/v2/incidents/{incident_id}https://api.us3.datadoghq.com/api/v2/incidents/{incident_id}https://api.us5.datadoghq.com/api/v2/incidents/{incident_id}https://api.datadoghq.eu/api/v2/incidents/{incident_id}https://api.ap1.datadoghq.com/api/v2/incidents/{incident_id}https://api.ap2.datadoghq.com/api/v2/incidents/{incident_id}https://api.uk1.datadoghq.com/api/v2/incidents/{incident_id}https://api.ddog-gov.com/api/v2/incidents/{incident_id}https://api.us2.ddog-gov.com/api/v2/incidents/{incident_id}Descripción general
Modifica una incidencia. Indica únicamente los atributos que deben modificarse, ya que esta solicitud supone una modificación parcial.
OAuth apps require the incident_write authorization scope to access this endpoint.
Argumentos
Parámetros de ruta
incident_id [required]The UUID of the incident.
Cadenas de consulta
includeSpecifies which types of related objects should be included in the response.
Solicitud
Body Data (required)
Carga útil de la incidencia.
data [required]Solicitud de modificación de una incidencia.
attributesThe incident's attributes for an update request.
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 being impacted by the incident.
customer_impactedA flag indicating whether the incident caused customer impact.
detectedTimestamp when the incident was detected.
fieldsA condensed view of the user-defined fields for which to update selections.
<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.
notification_handlesNotification handles that will be 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.
titleThe title of the incident, which summarizes what happened.
id [required]The incident's ID.
relationshipsThe incident's relationships for an update 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.
usersusersintegrationsA 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_integrationspostmortemA relationship reference for postmortems.
data [required]The postmortem relationship data.
id [required]A unique identifier that represents the postmortem.
type [required]Incident postmortem resource type.
incident_postmortemsincident_postmortemstype [required]Incident resource type.
incidentsincidentsAdd commander to an incident returns "OK" response
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}Remove commander from an incident returns "OK" response
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}Update an existing incident returns "OK" response
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}Respuesta
OK
Response with an incident.
data [required]Incident data from a response.
attributesThe incident's attributes from a response.
archivedTimestamp of when the incident was archived.
case_idThe incident case id.
createdTimestamp when the incident was created.
customer_impact_durationLength of the incident's customer impact in seconds.
Equals the difference between customer_impact_start and customer_impact_end.
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 being impacted by the incident.
customer_impactedA flag indicating whether the incident caused customer impact.
declaredTimestamp when the incident was declared.
declared_byIncident's non Datadog creator.
image_48_pxNon Datadog creator 48px image.
nameNon Datadog creator name.
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.
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 will be 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 incident.
time_to_detectThe amount of time in seconds to detect the incident.
Equals the difference between customer_impact_start and detected.
time_to_internal_responseThe amount of time in seconds to call incident after detection. Equals the difference of detected and created.
time_to_repairThe amount of time in seconds to resolve customer impact after detecting the issue. Equals the difference between customer_impact_end and detected.
time_to_resolveThe amount of time in seconds to resolve the incident after it was created. Equals the difference between created and resolved.
title [required]The title of the incident, which summarizes what happened.
visibilityThe incident visibility status.
id [required]The incident's ID.
relationshipsThe incident's relationships from a 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_impactsintegrationsA 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_attachments>Attachment 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_attachments{
"data": {
"attributes": {
"archived": "2019-09-19T10:00:00.000Z",
"case_id": "integer",
"created": "2019-09-19T10:00:00.000Z",
"customer_impact_duration": "integer",
"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",
"customer_impacted": false,
"declared": "2019-09-19T10:00:00.000Z",
"declared_by": {
"image_48_px": "string",
"name": "string"
},
"declared_by_uuid": "string",
"detected": "2019-09-19T10:00:00.000Z",
"fields": {
"<any-key>": "undefined"
},
"incident_type_uuid": "00000000-0000-0000-0000-000000000000",
"is_test": false,
"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",
"time_to_detect": "integer",
"time_to_internal_response": "integer",
"time_to_repair": "integer",
"time_to_resolve": "integer",
"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"
}
]
},
"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"
]
}Ejemplo de código
Add commander to an incident returns "OK" response
# 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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": {
"id": "string",
"type": "users"
}
}
}
}
}
EOFRemove commander from an incident returns "OK" response
# 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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"relationships": {
"commander_user": {
"data": null
}
}
}
}
EOFUpdate an existing incident returns "OK" response
# 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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"id": "00000000-0000-0000-1234-000000000000",
"type": "incidents",
"attributes": {
"fields": {
"state": {
"type": "dropdown",
"value": "resolved"
}
},
"title": "A test incident title-updated"
}
}
}
EOFAdd commander to an incident returns "OK" response
// Add commander to an incident returns "OK" 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")
// there is a valid "user" in the system
UserDataID := os.Getenv("USER_DATA_ID")
body := datadogV2.IncidentUpdateRequest{
Data: datadogV2.IncidentUpdateData{
Id: IncidentDataID,
Type: datadogV2.INCIDENTTYPE_INCIDENTS,
Relationships: &datadogV2.IncidentUpdateRelationships{
CommanderUser: *datadogV2.NewNullableNullableRelationshipToUser(&datadogV2.NullableRelationshipToUser{
Data: *datadogV2.NewNullableNullableRelationshipToUserData(&datadogV2.NullableRelationshipToUserData{
Id: UserDataID,
Type: datadogV2.USERSTYPE_USERS,
}),
}),
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.UpdateIncident", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewIncidentsApi(apiClient)
resp, r, err := api.UpdateIncident(ctx, IncidentDataID, body, *datadogV2.NewUpdateIncidentOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.UpdateIncident`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateIncident`:\n%s\n", responseContent)
}
Remove commander from an incident returns "OK" response
// Remove commander from an incident returns "OK" 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.IncidentUpdateRequest{
Data: datadogV2.IncidentUpdateData{
Id: IncidentDataID,
Type: datadogV2.INCIDENTTYPE_INCIDENTS,
Relationships: &datadogV2.IncidentUpdateRelationships{
CommanderUser: *datadogV2.NewNullableNullableRelationshipToUser(&datadogV2.NullableRelationshipToUser{
Data: *datadogV2.NewNullableNullableRelationshipToUserData(nil),
}),
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.UpdateIncident", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewIncidentsApi(apiClient)
resp, r, err := api.UpdateIncident(ctx, IncidentDataID, body, *datadogV2.NewUpdateIncidentOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.UpdateIncident`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateIncident`:\n%s\n", responseContent)
}
Update an existing incident returns "OK" response
// Update an existing incident returns "OK" 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.IncidentUpdateRequest{
Data: datadogV2.IncidentUpdateData{
Id: IncidentDataID,
Type: datadogV2.INCIDENTTYPE_INCIDENTS,
Attributes: &datadogV2.IncidentUpdateAttributes{
Fields: map[string]datadogV2.IncidentFieldAttributes{
"state": datadogV2.IncidentFieldAttributes{
IncidentFieldAttributesSingleValue: &datadogV2.IncidentFieldAttributesSingleValue{
Type: datadogV2.INCIDENTFIELDATTRIBUTESSINGLEVALUETYPE_DROPDOWN.Ptr(),
Value: *datadog.NewNullableString(datadog.PtrString("resolved")),
}},
},
Title: datadog.PtrString("A test incident title-updated"),
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.UpdateIncident", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewIncidentsApi(apiClient)
resp, r, err := api.UpdateIncident(ctx, IncidentDataID, body, *datadogV2.NewUpdateIncidentOptionalParameters())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.UpdateIncident`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateIncident`:\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"Add commander to an incident returns "OK" response
// Add commander to an incident returns "OK" 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.IncidentResponse;
import com.datadog.api.client.v2.model.IncidentType;
import com.datadog.api.client.v2.model.IncidentUpdateData;
import com.datadog.api.client.v2.model.IncidentUpdateRelationships;
import com.datadog.api.client.v2.model.IncidentUpdateRequest;
import com.datadog.api.client.v2.model.NullableRelationshipToUser;
import com.datadog.api.client.v2.model.NullableRelationshipToUserData;
import com.datadog.api.client.v2.model.UsersType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.updateIncident", true);
IncidentsApi apiInstance = new IncidentsApi(defaultClient);
// there is a valid "incident" in the system
String INCIDENT_DATA_ID = System.getenv("INCIDENT_DATA_ID");
// there is a valid "user" in the system
String USER_DATA_ID = System.getenv("USER_DATA_ID");
IncidentUpdateRequest body =
new IncidentUpdateRequest()
.data(
new IncidentUpdateData()
.id(INCIDENT_DATA_ID)
.type(IncidentType.INCIDENTS)
.relationships(
new IncidentUpdateRelationships()
.commanderUser(
new NullableRelationshipToUser()
.data(
new NullableRelationshipToUserData()
.id(USER_DATA_ID)
.type(UsersType.USERS)))));
try {
IncidentResponse result = apiInstance.updateIncident(INCIDENT_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IncidentsApi#updateIncident");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Remove commander from an incident returns "OK" response
// Remove commander from an incident returns "OK" 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.IncidentResponse;
import com.datadog.api.client.v2.model.IncidentType;
import com.datadog.api.client.v2.model.IncidentUpdateData;
import com.datadog.api.client.v2.model.IncidentUpdateRelationships;
import com.datadog.api.client.v2.model.IncidentUpdateRequest;
import com.datadog.api.client.v2.model.NullableRelationshipToUser;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.updateIncident", true);
IncidentsApi apiInstance = new IncidentsApi(defaultClient);
// there is a valid "incident" in the system
String INCIDENT_DATA_ID = System.getenv("INCIDENT_DATA_ID");
IncidentUpdateRequest body =
new IncidentUpdateRequest()
.data(
new IncidentUpdateData()
.id(INCIDENT_DATA_ID)
.type(IncidentType.INCIDENTS)
.relationships(
new IncidentUpdateRelationships()
.commanderUser(new NullableRelationshipToUser().data(null))));
try {
IncidentResponse result = apiInstance.updateIncident(INCIDENT_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IncidentsApi#updateIncident");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Update an existing incident returns "OK" response
// Update an existing incident returns "OK" 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.IncidentFieldAttributes;
import com.datadog.api.client.v2.model.IncidentFieldAttributesSingleValue;
import com.datadog.api.client.v2.model.IncidentFieldAttributesSingleValueType;
import com.datadog.api.client.v2.model.IncidentResponse;
import com.datadog.api.client.v2.model.IncidentType;
import com.datadog.api.client.v2.model.IncidentUpdateAttributes;
import com.datadog.api.client.v2.model.IncidentUpdateData;
import com.datadog.api.client.v2.model.IncidentUpdateRequest;
import java.util.Map;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.updateIncident", true);
IncidentsApi apiInstance = new IncidentsApi(defaultClient);
// there is a valid "incident" in the system
String INCIDENT_DATA_ATTRIBUTES_TITLE = System.getenv("INCIDENT_DATA_ATTRIBUTES_TITLE");
String INCIDENT_DATA_ID = System.getenv("INCIDENT_DATA_ID");
IncidentUpdateRequest body =
new IncidentUpdateRequest()
.data(
new IncidentUpdateData()
.id(INCIDENT_DATA_ID)
.type(IncidentType.INCIDENTS)
.attributes(
new IncidentUpdateAttributes()
.fields(
Map.ofEntries(
Map.entry(
"state",
new IncidentFieldAttributes(
new IncidentFieldAttributesSingleValue()
.type(
IncidentFieldAttributesSingleValueType.DROPDOWN)
.value("resolved")))))
.title("A test incident title-updated")));
try {
IncidentResponse result = apiInstance.updateIncident(INCIDENT_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IncidentsApi#updateIncident");
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"Add commander to an incident returns "OK" response
"""
Add commander to an incident returns "OK" 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_type import IncidentType
from datadog_api_client.v2.model.incident_update_data import IncidentUpdateData
from datadog_api_client.v2.model.incident_update_relationships import IncidentUpdateRelationships
from datadog_api_client.v2.model.incident_update_request import IncidentUpdateRequest
from datadog_api_client.v2.model.nullable_relationship_to_user import NullableRelationshipToUser
from datadog_api_client.v2.model.nullable_relationship_to_user_data import NullableRelationshipToUserData
from datadog_api_client.v2.model.users_type import UsersType
# there is a valid "incident" in the system
INCIDENT_DATA_ID = environ["INCIDENT_DATA_ID"]
# there is a valid "user" in the system
USER_DATA_ID = environ["USER_DATA_ID"]
body = IncidentUpdateRequest(
data=IncidentUpdateData(
id=INCIDENT_DATA_ID,
type=IncidentType.INCIDENTS,
relationships=IncidentUpdateRelationships(
commander_user=NullableRelationshipToUser(
data=NullableRelationshipToUserData(
id=USER_DATA_ID,
type=UsersType.USERS,
),
),
),
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["update_incident"] = True
with ApiClient(configuration) as api_client:
api_instance = IncidentsApi(api_client)
response = api_instance.update_incident(incident_id=INCIDENT_DATA_ID, body=body)
print(response)
Remove commander from an incident returns "OK" response
"""
Remove commander from an incident returns "OK" 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_type import IncidentType
from datadog_api_client.v2.model.incident_update_data import IncidentUpdateData
from datadog_api_client.v2.model.incident_update_relationships import IncidentUpdateRelationships
from datadog_api_client.v2.model.incident_update_request import IncidentUpdateRequest
from datadog_api_client.v2.model.nullable_relationship_to_user import NullableRelationshipToUser
# there is a valid "incident" in the system
INCIDENT_DATA_ID = environ["INCIDENT_DATA_ID"]
body = IncidentUpdateRequest(
data=IncidentUpdateData(
id=INCIDENT_DATA_ID,
type=IncidentType.INCIDENTS,
relationships=IncidentUpdateRelationships(
commander_user=NullableRelationshipToUser(
data=None,
),
),
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["update_incident"] = True
with ApiClient(configuration) as api_client:
api_instance = IncidentsApi(api_client)
response = api_instance.update_incident(incident_id=INCIDENT_DATA_ID, body=body)
print(response)
Update an existing incident returns "OK" response
"""
Update an existing incident returns "OK" 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_field_attributes_single_value import IncidentFieldAttributesSingleValue
from datadog_api_client.v2.model.incident_field_attributes_single_value_type import (
IncidentFieldAttributesSingleValueType,
)
from datadog_api_client.v2.model.incident_type import IncidentType
from datadog_api_client.v2.model.incident_update_attributes import IncidentUpdateAttributes
from datadog_api_client.v2.model.incident_update_data import IncidentUpdateData
from datadog_api_client.v2.model.incident_update_request import IncidentUpdateRequest
# there is a valid "incident" in the system
INCIDENT_DATA_ATTRIBUTES_TITLE = environ["INCIDENT_DATA_ATTRIBUTES_TITLE"]
INCIDENT_DATA_ID = environ["INCIDENT_DATA_ID"]
body = IncidentUpdateRequest(
data=IncidentUpdateData(
id=INCIDENT_DATA_ID,
type=IncidentType.INCIDENTS,
attributes=IncidentUpdateAttributes(
fields=dict(
state=IncidentFieldAttributesSingleValue(
type=IncidentFieldAttributesSingleValueType.DROPDOWN,
value="resolved",
),
),
title="A test incident title-updated",
),
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["update_incident"] = True
with ApiClient(configuration) as api_client:
api_instance = IncidentsApi(api_client)
response = api_instance.update_incident(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"Add commander to an incident returns "OK" response
# Add commander to an incident returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.update_incident".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"]
# there is a valid "user" in the system
USER_DATA_ID = ENV["USER_DATA_ID"]
body = DatadogAPIClient::V2::IncidentUpdateRequest.new({
data: DatadogAPIClient::V2::IncidentUpdateData.new({
id: INCIDENT_DATA_ID,
type: DatadogAPIClient::V2::IncidentType::INCIDENTS,
relationships: DatadogAPIClient::V2::IncidentUpdateRelationships.new({
commander_user: DatadogAPIClient::V2::NullableRelationshipToUser.new({
data: DatadogAPIClient::V2::NullableRelationshipToUserData.new({
id: USER_DATA_ID,
type: DatadogAPIClient::V2::UsersType::USERS,
}),
}),
}),
}),
})
p api_instance.update_incident(INCIDENT_DATA_ID, body)
Remove commander from an incident returns "OK" response
# Remove commander from an incident returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.update_incident".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::IncidentUpdateRequest.new({
data: DatadogAPIClient::V2::IncidentUpdateData.new({
id: INCIDENT_DATA_ID,
type: DatadogAPIClient::V2::IncidentType::INCIDENTS,
relationships: DatadogAPIClient::V2::IncidentUpdateRelationships.new({
commander_user: DatadogAPIClient::V2::NullableRelationshipToUser.new({
data: nil,
}),
}),
}),
})
p api_instance.update_incident(INCIDENT_DATA_ID, body)
Update an existing incident returns "OK" response
# Update an existing incident returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.update_incident".to_sym] = true
end
api_instance = DatadogAPIClient::V2::IncidentsAPI.new
# there is a valid "incident" in the system
INCIDENT_DATA_ATTRIBUTES_TITLE = ENV["INCIDENT_DATA_ATTRIBUTES_TITLE"]
INCIDENT_DATA_ID = ENV["INCIDENT_DATA_ID"]
body = DatadogAPIClient::V2::IncidentUpdateRequest.new({
data: DatadogAPIClient::V2::IncidentUpdateData.new({
id: INCIDENT_DATA_ID,
type: DatadogAPIClient::V2::IncidentType::INCIDENTS,
attributes: DatadogAPIClient::V2::IncidentUpdateAttributes.new({
fields: {
state: DatadogAPIClient::V2::IncidentFieldAttributesSingleValue.new({
type: DatadogAPIClient::V2::IncidentFieldAttributesSingleValueType::DROPDOWN,
value: "resolved",
}),
},
title: "A test incident title-updated",
}),
}),
})
p api_instance.update_incident(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"Add commander to an incident returns "OK" response
// Add commander to an incident returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::api_incidents::UpdateIncidentOptionalParams;
use datadog_api_client::datadogV2::model::IncidentType;
use datadog_api_client::datadogV2::model::IncidentUpdateData;
use datadog_api_client::datadogV2::model::IncidentUpdateRelationships;
use datadog_api_client::datadogV2::model::IncidentUpdateRequest;
use datadog_api_client::datadogV2::model::NullableRelationshipToUser;
use datadog_api_client::datadogV2::model::NullableRelationshipToUserData;
use datadog_api_client::datadogV2::model::UsersType;
#[tokio::main]
async fn main() {
// there is a valid "incident" in the system
let incident_data_id = std::env::var("INCIDENT_DATA_ID").unwrap();
// there is a valid "user" in the system
let user_data_id = std::env::var("USER_DATA_ID").unwrap();
let body = IncidentUpdateRequest::new(
IncidentUpdateData::new(incident_data_id.clone(), IncidentType::INCIDENTS).relationships(
IncidentUpdateRelationships::new().commander_user(Some(
NullableRelationshipToUser::new(Some(NullableRelationshipToUserData::new(
user_data_id.clone(),
UsersType::USERS,
))),
)),
),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.update_incident", true);
let api = IncidentsAPI::with_config(configuration);
let resp = api
.update_incident(
incident_data_id.clone(),
body,
UpdateIncidentOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Remove commander from an incident returns "OK" response
// Remove commander from an incident returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::api_incidents::UpdateIncidentOptionalParams;
use datadog_api_client::datadogV2::model::IncidentType;
use datadog_api_client::datadogV2::model::IncidentUpdateData;
use datadog_api_client::datadogV2::model::IncidentUpdateRelationships;
use datadog_api_client::datadogV2::model::IncidentUpdateRequest;
use datadog_api_client::datadogV2::model::NullableRelationshipToUser;
#[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 = IncidentUpdateRequest::new(
IncidentUpdateData::new(incident_data_id.clone(), IncidentType::INCIDENTS).relationships(
IncidentUpdateRelationships::new()
.commander_user(Some(NullableRelationshipToUser::new(None))),
),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.update_incident", true);
let api = IncidentsAPI::with_config(configuration);
let resp = api
.update_incident(
incident_data_id.clone(),
body,
UpdateIncidentOptionalParams::default(),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Update an existing incident returns "OK" response
// Update an existing incident returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::api_incidents::UpdateIncidentOptionalParams;
use datadog_api_client::datadogV2::model::IncidentFieldAttributes;
use datadog_api_client::datadogV2::model::IncidentFieldAttributesSingleValue;
use datadog_api_client::datadogV2::model::IncidentFieldAttributesSingleValueType;
use datadog_api_client::datadogV2::model::IncidentType;
use datadog_api_client::datadogV2::model::IncidentUpdateAttributes;
use datadog_api_client::datadogV2::model::IncidentUpdateData;
use datadog_api_client::datadogV2::model::IncidentUpdateRequest;
use std::collections::BTreeMap;
#[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 = IncidentUpdateRequest::new(
IncidentUpdateData::new(incident_data_id.clone(), IncidentType::INCIDENTS).attributes(
IncidentUpdateAttributes::new()
.fields(BTreeMap::from([(
"state".to_string(),
IncidentFieldAttributes::IncidentFieldAttributesSingleValue(Box::new(
IncidentFieldAttributesSingleValue::new()
.type_(IncidentFieldAttributesSingleValueType::DROPDOWN)
.value(Some("resolved".to_string())),
)),
)]))
.title("A test incident title-updated".to_string()),
),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.update_incident", true);
let api = IncidentsAPI::with_config(configuration);
let resp = api
.update_incident(
incident_data_id.clone(),
body,
UpdateIncidentOptionalParams::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 runAdd commander to an incident returns "OK" response
/**
* Add commander to an incident returns "OK" 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.updateIncident"] = 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;
// there is a valid "user" in the system
const USER_DATA_ID = process.env.USER_DATA_ID as string;
const params: v2.IncidentsApiUpdateIncidentRequest = {
body: {
data: {
id: INCIDENT_DATA_ID,
type: "incidents",
relationships: {
commanderUser: {
data: {
id: USER_DATA_ID,
type: "users",
},
},
},
},
},
incidentId: INCIDENT_DATA_ID,
};
apiInstance
.updateIncident(params)
.then((data: v2.IncidentResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Remove commander from an incident returns "OK" response
/**
* Remove commander from an incident returns "OK" 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.updateIncident"] = 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.IncidentsApiUpdateIncidentRequest = {
body: {
data: {
id: INCIDENT_DATA_ID,
type: "incidents",
relationships: {
commanderUser: {
data: null,
},
},
},
},
incidentId: INCIDENT_DATA_ID,
};
apiInstance
.updateIncident(params)
.then((data: v2.IncidentResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Update an existing incident returns "OK" response
/**
* Update an existing incident returns "OK" 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.updateIncident"] = 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.IncidentsApiUpdateIncidentRequest = {
body: {
data: {
id: INCIDENT_DATA_ID,
type: "incidents",
attributes: {
fields: {
state: {
type: "dropdown",
value: "resolved",
},
},
title: "A test incident title-updated",
},
},
},
incidentId: INCIDENT_DATA_ID,
};
apiInstance
.updateIncident(params)
.then((data: v2.IncidentResponse) => {
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"