Créer un type incident
https://api.datadoghq.com/api/v2/incidents/config/typeshttps://api.us3.datadoghq.com/api/v2/incidents/config/typeshttps://api.us5.datadoghq.com/api/v2/incidents/config/typeshttps://api.datadoghq.eu/api/v2/incidents/config/typeshttps://api.ap1.datadoghq.com/api/v2/incidents/config/typeshttps://api.ap2.datadoghq.com/api/v2/incidents/config/typeshttps://api.uk1.datadoghq.com/api/v2/incidents/config/typeshttps://api.ddog-gov.com/api/v2/incidents/config/typeshttps://api.us2.ddog-gov.com/api/v2/incidents/config/typesPrésentation
Créez un type d'incident.
OAuth apps require the incident_settings_write authorization scope to access this endpoint.
Requête
Body Data (required)
Charge utile du type d'incident.
data [required]Requête de création d'un type d'incident.
attributes [required]Incident 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.
truedescriptionText 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.
falsename [required]The name of the incident type.
type [required]Incident type resource type.
incident_typesincident_types{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}Réponse
CREATED
Incident type response data.
data [required]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": {
"configuration": {
"allow_incident_deletion": false,
"allow_workflows": true,
"create_message": "Create an incident here",
"editable_timestamps": false,
"private_incidents": false,
"private_incidents_by_default": false,
"slug_source": "default",
"test_incidents": true
},
"createdAt": "2019-09-19T10:00:00.000Z",
"createdBy": "00000000-0000-0000-0000-000000000000",
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"lastModifiedBy": "00000000-0000-0000-0000-000000000000",
"modifiedAt": "2019-09-19T10:00:00.000Z",
"name": "Security Incident",
"prefix": "IR"
},
"id": "00000000-0000-0000-0000-000000000000",
"relationships": {
"created_by_user": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
},
"google_meet_configuration": {
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "google_meet_configurations"
}
},
"last_modified_by_user": {
"data": {
"id": "00000000-0000-0000-2345-000000000000",
"type": "users"
}
},
"microsoft_teams_configuration": {
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "microsoft_teams_configurations"
}
},
"zoom_configuration": {
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "zoom_configurations"
}
}
},
"type": "incident_types"
}
}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"
]
}Exemple de code
# 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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
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/config/types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"description": "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
"is_default": false,
"name": "Security Incident"
},
"type": "incident_types"
}
}
EOF// Create an incident type 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.IncidentTypeCreateRequest{
Data: datadogV2.IncidentTypeCreateData{
Attributes: datadogV2.IncidentTypeAttributes{
Description: datadog.PtrString("Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data."),
IsDefault: datadog.PtrBool(false),
Name: "Security Incident",
},
Type: datadogV2.INCIDENTTYPETYPE_INCIDENT_TYPES,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateIncidentType", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewIncidentsApi(apiClient)
resp, r, err := api.CreateIncidentType(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.CreateIncidentType`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.CreateIncidentType`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create an incident type 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.IncidentTypeAttributes;
import com.datadog.api.client.v2.model.IncidentTypeCreateData;
import com.datadog.api.client.v2.model.IncidentTypeCreateRequest;
import com.datadog.api.client.v2.model.IncidentTypeResponse;
import com.datadog.api.client.v2.model.IncidentTypeType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createIncidentType", true);
IncidentsApi apiInstance = new IncidentsApi(defaultClient);
IncidentTypeCreateRequest body =
new IncidentTypeCreateRequest()
.data(
new IncidentTypeCreateData()
.attributes(
new IncidentTypeAttributes()
.description(
"Any incidents that harm (or have the potential to) the"
+ " confidentiality, integrity, or availability of our data.")
.isDefault(false)
.name("Security Incident"))
.type(IncidentTypeType.INCIDENT_TYPES));
try {
IncidentTypeResponse result = apiInstance.createIncidentType(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling IncidentsApi#createIncidentType");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create an incident type 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_type_attributes import IncidentTypeAttributes
from datadog_api_client.v2.model.incident_type_create_data import IncidentTypeCreateData
from datadog_api_client.v2.model.incident_type_create_request import IncidentTypeCreateRequest
from datadog_api_client.v2.model.incident_type_type import IncidentTypeType
body = IncidentTypeCreateRequest(
data=IncidentTypeCreateData(
attributes=IncidentTypeAttributes(
description="Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
is_default=False,
name="Security Incident",
),
type=IncidentTypeType.INCIDENT_TYPES,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_incident_type"] = True
with ApiClient(configuration) as api_client:
api_instance = IncidentsApi(api_client)
response = api_instance.create_incident_type(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create an incident type returns "CREATED" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_incident_type".to_sym] = true
end
api_instance = DatadogAPIClient::V2::IncidentsAPI.new
body = DatadogAPIClient::V2::IncidentTypeCreateRequest.new({
data: DatadogAPIClient::V2::IncidentTypeCreateData.new({
attributes: DatadogAPIClient::V2::IncidentTypeAttributes.new({
description: "Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
is_default: false,
name: "Security Incident",
}),
type: DatadogAPIClient::V2::IncidentTypeType::INCIDENT_TYPES,
}),
})
p api_instance.create_incident_type(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create an incident type returns "CREATED" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::model::IncidentTypeAttributes;
use datadog_api_client::datadogV2::model::IncidentTypeCreateData;
use datadog_api_client::datadogV2::model::IncidentTypeCreateRequest;
use datadog_api_client::datadogV2::model::IncidentTypeType;
#[tokio::main]
async fn main() {
let body =
IncidentTypeCreateRequest::new(
IncidentTypeCreateData::new(
IncidentTypeAttributes::new("Security Incident".to_string())
.description(
"Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.".to_string(),
)
.is_default(false),
IncidentTypeType::INCIDENT_TYPES,
),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.create_incident_type", true);
let api = IncidentsAPI::with_config(configuration);
let resp = api.create_incident_type(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Create an incident type 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.createIncidentType"] = true;
const apiInstance = new v2.IncidentsApi(configuration);
const params: v2.IncidentsApiCreateIncidentTypeRequest = {
body: {
data: {
attributes: {
description:
"Any incidents that harm (or have the potential to) the confidentiality, integrity, or availability of our data.",
isDefault: false,
name: "Security Incident",
},
type: "incident_types",
},
},
};
apiInstance
.createIncidentType(params)
.then((data: v2.IncidentTypeResponse) => {
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"