Create custom attribute config for work item type
https://api.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributeshttps://api.us3.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributeshttps://api.us5.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributeshttps://api.datadoghq.eu/api/v2/cases/types/{case_type_id}/custom_attributeshttps://api.ap1.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributeshttps://api.ap2.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributeshttps://api.uk1.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributeshttps://api.ddog-gov.com/api/v2/cases/types/{case_type_id}/custom_attributeshttps://api.us2.ddog-gov.com/api/v2/cases/types/{case_type_id}/custom_attributesOverview
Create a custom attribute configuration for a work item type.
Arguments
Path Parameters
case_type_id [required]The UUID of the work item type.
Request
Body Data (required)
Custom attribute config payload
data [required]Data object for creating a custom attribute configuration.
attributes [required]Attributes required to create a custom attribute configuration.
descriptionA description explaining the purpose and expected values for this custom attribute.
display_name [required]The human-readable label shown in the Work Management UI for this custom attribute.
is_multi [required]If true, this attribute accepts an array of values. If false, only a single value is allowed.
key [required]The programmatic key used to reference this custom attribute in search queries and API calls.
type [required]The data type of the custom attribute, which determines the allowed values and UI input control.
URL, TEXT, NUMBER, SELECTtype [required]JSON:API resource type for custom attribute configurations.
custom_attributecustom_attribute{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}Response
CREATED
Response containing a single custom attribute configuration.
dataA custom attribute configuration that defines an organization-specific metadata field on work items. Custom attributes are scoped to a work item type and can hold text, URLs, numbers, or predefined select options.
attributesAttributes of a custom attribute configuration, defining an organization-specific metadata field that can be added to work items of a given type.
case_type_id [required]The UUID of the work item type this custom attribute belongs to.
descriptionA description explaining the purpose and expected values for this custom attribute.
display_name [required]The human-readable label shown in the Work Management UI for this custom attribute.
is_multi [required]If true, this attribute accepts an array of values. If false, only a single value is allowed.
key [required]The programmatic key used to reference this custom attribute in search queries and API calls.
type [required]The data type of the custom attribute, which determines the allowed values and UI input control.
URL, TEXT, NUMBER, SELECTidCustom attribute configs identifier
typeJSON:API resource type for custom attribute configurations.
custom_attributecustom_attribute{
"data": {
"attributes": {
"case_type_id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"description": "AWS Region, must be a valid region supported by AWS",
"display_name": "AWS Region",
"is_multi": true,
"key": "aws_region",
"type": "NUMBER"
},
"id": "aeadc05e-98a8-11ec-ac2c-da7ad0900001",
"type": "custom_attribute"
}
}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"
]
}Code Example
# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# 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/cases/types/${case_type_id}/custom_attributes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"display_name": "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"is_multi": true,
"key": "region_d9fe56bc9274fbb6",
"type": "NUMBER"
},
"type": "custom_attribute"
}
}
EOF// Create custom attribute config for a case 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() {
// there is a valid "case_type" in the system
CaseTypeID := os.Getenv("CASE_TYPE_ID")
body := datadogV2.CustomAttributeConfigCreateRequest{
Data: datadogV2.CustomAttributeConfigCreate{
Attributes: datadogV2.CustomAttributeConfigAttributesCreate{
DisplayName: "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
IsMulti: true,
Key: "region_d9fe56bc9274fbb6",
Type: datadogV2.CUSTOMATTRIBUTETYPE_NUMBER,
},
Type: datadogV2.CUSTOMATTRIBUTECONFIGRESOURCETYPE_CUSTOM_ATTRIBUTE,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewCaseManagementAttributeApi(apiClient)
resp, r, err := api.CreateCustomAttributeConfig(ctx, CaseTypeID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementAttributeApi.CreateCustomAttributeConfig`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CaseManagementAttributeApi.CreateCustomAttributeConfig`:\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 custom attribute config for a case type returns "CREATED" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CaseManagementAttributeApi;
import com.datadog.api.client.v2.model.CustomAttributeConfigAttributesCreate;
import com.datadog.api.client.v2.model.CustomAttributeConfigCreate;
import com.datadog.api.client.v2.model.CustomAttributeConfigCreateRequest;
import com.datadog.api.client.v2.model.CustomAttributeConfigResourceType;
import com.datadog.api.client.v2.model.CustomAttributeConfigResponse;
import com.datadog.api.client.v2.model.CustomAttributeType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
CaseManagementAttributeApi apiInstance = new CaseManagementAttributeApi(defaultClient);
// there is a valid "case_type" in the system
String CASE_TYPE_ID = System.getenv("CASE_TYPE_ID");
CustomAttributeConfigCreateRequest body =
new CustomAttributeConfigCreateRequest()
.data(
new CustomAttributeConfigCreate()
.attributes(
new CustomAttributeConfigAttributesCreate()
.displayName("AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")
.isMulti(true)
.key("region_d9fe56bc9274fbb6")
.type(CustomAttributeType.NUMBER))
.type(CustomAttributeConfigResourceType.CUSTOM_ATTRIBUTE));
try {
CustomAttributeConfigResponse result =
apiInstance.createCustomAttributeConfig(CASE_TYPE_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling CaseManagementAttributeApi#createCustomAttributeConfig");
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 custom attribute config for a case type returns "CREATED" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.case_management_attribute_api import CaseManagementAttributeApi
from datadog_api_client.v2.model.custom_attribute_config_attributes_create import CustomAttributeConfigAttributesCreate
from datadog_api_client.v2.model.custom_attribute_config_create import CustomAttributeConfigCreate
from datadog_api_client.v2.model.custom_attribute_config_create_request import CustomAttributeConfigCreateRequest
from datadog_api_client.v2.model.custom_attribute_config_resource_type import CustomAttributeConfigResourceType
from datadog_api_client.v2.model.custom_attribute_type import CustomAttributeType
# there is a valid "case_type" in the system
CASE_TYPE_ID = environ["CASE_TYPE_ID"]
body = CustomAttributeConfigCreateRequest(
data=CustomAttributeConfigCreate(
attributes=CustomAttributeConfigAttributesCreate(
display_name="AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
is_multi=True,
key="region_d9fe56bc9274fbb6",
type=CustomAttributeType.NUMBER,
),
type=CustomAttributeConfigResourceType.CUSTOM_ATTRIBUTE,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = CaseManagementAttributeApi(api_client)
response = api_instance.create_custom_attribute_config(case_type_id=CASE_TYPE_ID, body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create custom attribute config for a case type returns "CREATED" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::CaseManagementAttributeAPI.new
# there is a valid "case_type" in the system
CASE_TYPE_ID = ENV["CASE_TYPE_ID"]
body = DatadogAPIClient::V2::CustomAttributeConfigCreateRequest.new({
data: DatadogAPIClient::V2::CustomAttributeConfigCreate.new({
attributes: DatadogAPIClient::V2::CustomAttributeConfigAttributesCreate.new({
display_name: "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
is_multi: true,
key: "region_d9fe56bc9274fbb6",
type: DatadogAPIClient::V2::CustomAttributeType::NUMBER,
}),
type: DatadogAPIClient::V2::CustomAttributeConfigResourceType::CUSTOM_ATTRIBUTE,
}),
})
p api_instance.create_custom_attribute_config(CASE_TYPE_ID, body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create custom attribute config for a case type returns "CREATED" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_case_management_attribute::CaseManagementAttributeAPI;
use datadog_api_client::datadogV2::model::CustomAttributeConfigAttributesCreate;
use datadog_api_client::datadogV2::model::CustomAttributeConfigCreate;
use datadog_api_client::datadogV2::model::CustomAttributeConfigCreateRequest;
use datadog_api_client::datadogV2::model::CustomAttributeConfigResourceType;
use datadog_api_client::datadogV2::model::CustomAttributeType;
#[tokio::main]
async fn main() {
// there is a valid "case_type" in the system
let case_type_id = std::env::var("CASE_TYPE_ID").unwrap();
let body = CustomAttributeConfigCreateRequest::new(CustomAttributeConfigCreate::new(
CustomAttributeConfigAttributesCreate::new(
"AWS Region ".to_string(),
true,
"region_d9fe56bc9274fbb6".to_string(),
CustomAttributeType::NUMBER,
),
CustomAttributeConfigResourceType::CUSTOM_ATTRIBUTE,
));
let configuration = datadog::Configuration::new();
let api = CaseManagementAttributeAPI::with_config(configuration);
let resp = api
.create_custom_attribute_config(case_type_id.clone(), 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="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create custom attribute config for a case 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,
},
},
});
const apiInstance = new v2.CaseManagementAttributeApi(configuration);
// there is a valid "case_type" in the system
const CASE_TYPE_ID = process.env.CASE_TYPE_ID as string;
const params: v2.CaseManagementAttributeApiCreateCustomAttributeConfigRequest =
{
body: {
data: {
attributes: {
displayName: "AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
isMulti: true,
key: "region_d9fe56bc9274fbb6",
type: "NUMBER",
},
type: "custom_attribute",
},
},
caseTypeId: CASE_TYPE_ID,
};
apiInstance
.createCustomAttributeConfig(params)
.then((data: v2.CustomAttributeConfigResponse) => {
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"