Update custom attribute config

PUT https://api.ap1.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}https://api.ap2.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}https://api.datadoghq.eu/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}https://api.ddog-gov.com/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}https://api.us2.ddog-gov.com/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}https://api.uk1.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}https://api.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}https://api.us3.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}https://api.us5.datadoghq.com/api/v2/cases/types/{case_type_id}/custom_attributes/{custom_attribute_id}

개요

케이스 유형에 대한 기존 사용자 지정 속성 구성의 표시 이름, 설명, 유형 또는 옵션을 업데이트합니다.

OAuth apps require the cases_shared_settings_write authorization scope to access this endpoint.

인수

경로 파라미터

이름

유형

설명

case_type_id [required]

string

The UUID of the work item type.

custom_attribute_id [required]

string

Work item custom attribute’s UUID.

요청

Body Data (required)

사용자 지정 속성 구성 페이로드입니다.

Expand All

항목

유형

설명

data [required]

object

Data object for updating a custom attribute configuration.

attributes

object

Attributes that can be updated on a custom attribute configuration. All fields are optional; only provided fields are changed.

description

string

A description explaining the purpose and expected values for this custom attribute.

display_name

string

The human-readable label shown in the Work Management UI for this custom attribute.

map_from

string

An external field identifier to auto-populate this attribute from (used for integrations with external systems).

type

enum

The data type of the custom attribute, which determines the allowed values and UI input control. Allowed enum values: URL,TEXT,NUMBER,SELECT

type_data

object

Type-specific configuration for the custom attribute. For SELECT-type attributes, this contains the list of allowed options.

options

[object]

Options for SELECT type custom attributes.

value [required]

string

Option value.

type [required]

enum

JSON:API resource type for custom attribute configurations. Allowed enum values: custom_attribute

default: custom_attribute

{
  "data": {
    "attributes": {
      "description": "Updated description.",
      "display_name": "AWS Region",
      "map_from": "string",
      "type": "NUMBER",
      "type_data": {
        "options": [
          {
            "value": "us-east-1"
          }
        ]
      }
    },
    "type": "custom_attribute"
  }
}

응답

OK

Response containing a single custom attribute configuration.

Expand All

항목

유형

설명

data

object

A 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.

attributes

object

Attributes 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]

string

The UUID of the work item type this custom attribute belongs to.

description

string

A description explaining the purpose and expected values for this custom attribute.

display_name [required]

string

The human-readable label shown in the Work Management UI for this custom attribute.

is_multi [required]

boolean

If true, this attribute accepts an array of values. If false, only a single value is allowed.

key [required]

string

The programmatic key used to reference this custom attribute in search queries and API calls.

type [required]

enum

The data type of the custom attribute, which determines the allowed values and UI input control. Allowed enum values: URL,TEXT,NUMBER,SELECT

id

string

Custom attribute configs identifier

type

enum

JSON:API resource type for custom attribute configurations. Allowed enum values: custom_attribute

default: custom_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.

Expand All

항목

유형

설명

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Unauthorized

API error response.

Expand All

항목

유형

설명

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

항목

유형

설명

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not Found

API error response.

Expand All

항목

유형

설명

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Too many requests

API error response.

Expand All

항목

유형

설명

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

코드 예시

                  ## default
# 

# Path parameters
export case_type_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
export custom_attribute_id="f98a5a5b-e0ff-45d4-b2f5-afe6e74de505"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

# Curl command
curl -X PUT "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/cases/types/${case_type_id}/custom_attributes/${custom_attribute_id}" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${DD_BEARER_TOKEN}" \ -d @- << EOF { "data": { "attributes": { "description": "Updated description.", "display_name": "AWS Region" }, "type": "custom_attribute" } } EOF
"""
Update custom attribute config returns "OK" 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_resource_type import CustomAttributeConfigResourceType
from datadog_api_client.v2.model.custom_attribute_config_update import CustomAttributeConfigUpdate
from datadog_api_client.v2.model.custom_attribute_config_update_attributes import CustomAttributeConfigUpdateAttributes
from datadog_api_client.v2.model.custom_attribute_config_update_request import CustomAttributeConfigUpdateRequest
from datadog_api_client.v2.model.custom_attribute_select_option import CustomAttributeSelectOption
from datadog_api_client.v2.model.custom_attribute_type import CustomAttributeType
from datadog_api_client.v2.model.custom_attribute_type_data import CustomAttributeTypeData

body = CustomAttributeConfigUpdateRequest(
    data=CustomAttributeConfigUpdate(
        attributes=CustomAttributeConfigUpdateAttributes(
            description="Updated description.",
            display_name="AWS Region",
            type=CustomAttributeType.NUMBER,
            type_data=CustomAttributeTypeData(
                options=[
                    CustomAttributeSelectOption(
                        value="us-east-1",
                    ),
                ],
            ),
        ),
        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.update_custom_attribute_config(
        case_type_id="case_type_id", custom_attribute_id="custom_attribute_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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
# Update custom attribute config returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::CaseManagementAttributeAPI.new

body = DatadogAPIClient::V2::CustomAttributeConfigUpdateRequest.new({
  data: DatadogAPIClient::V2::CustomAttributeConfigUpdate.new({
    attributes: DatadogAPIClient::V2::CustomAttributeConfigUpdateAttributes.new({
      description: "Updated description.",
      display_name: "AWS Region",
      type: DatadogAPIClient::V2::CustomAttributeType::NUMBER,
      type_data: DatadogAPIClient::V2::CustomAttributeTypeData.new({
        options: [
          DatadogAPIClient::V2::CustomAttributeSelectOption.new({
            value: "us-east-1",
          }),
        ],
      }),
    }),
    type: DatadogAPIClient::V2::CustomAttributeConfigResourceType::CUSTOM_ATTRIBUTE,
  }),
})
p api_instance.update_custom_attribute_config("case_type_id", "custom_attribute_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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
// Update custom attribute config 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() {
	body := datadogV2.CustomAttributeConfigUpdateRequest{
		Data: datadogV2.CustomAttributeConfigUpdate{
			Attributes: &datadogV2.CustomAttributeConfigUpdateAttributes{
				Description: datadog.PtrString("Updated description."),
				DisplayName: datadog.PtrString("AWS Region"),
				Type:        datadogV2.CUSTOMATTRIBUTETYPE_NUMBER.Ptr(),
				TypeData: &datadogV2.CustomAttributeTypeData{
					Options: []datadogV2.CustomAttributeSelectOption{
						{
							Value: "us-east-1",
						},
					},
				},
			},
			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.UpdateCustomAttributeConfig(ctx, "case_type_id", "custom_attribute_id", body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementAttributeApi.UpdateCustomAttributeConfig`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `CaseManagementAttributeApi.UpdateCustomAttributeConfig`:\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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
// Update custom attribute config returns "OK" 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.CustomAttributeConfigResourceType;
import com.datadog.api.client.v2.model.CustomAttributeConfigResponse;
import com.datadog.api.client.v2.model.CustomAttributeConfigUpdate;
import com.datadog.api.client.v2.model.CustomAttributeConfigUpdateAttributes;
import com.datadog.api.client.v2.model.CustomAttributeConfigUpdateRequest;
import com.datadog.api.client.v2.model.CustomAttributeSelectOption;
import com.datadog.api.client.v2.model.CustomAttributeType;
import com.datadog.api.client.v2.model.CustomAttributeTypeData;
import java.util.Collections;

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);

    CustomAttributeConfigUpdateRequest body =
        new CustomAttributeConfigUpdateRequest()
            .data(
                new CustomAttributeConfigUpdate()
                    .attributes(
                        new CustomAttributeConfigUpdateAttributes()
                            .description("Updated description.")
                            .displayName("AWS Region")
                            .type(CustomAttributeType.NUMBER)
                            .typeData(
                                new CustomAttributeTypeData()
                                    .options(
                                        Collections.singletonList(
                                            new CustomAttributeSelectOption().value("us-east-1")))))
                    .type(CustomAttributeConfigResourceType.CUSTOM_ATTRIBUTE));

    try {
      CustomAttributeConfigResponse result =
          apiInstance.updateCustomAttributeConfig(
              "f98a5a5b-e0ff-45d4-b2f5-afe6e74de505", "f98a5a5b-e0ff-45d4-b2f5-afe6e74de505", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling CaseManagementAttributeApi#updateCustomAttributeConfig");
      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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
// Update custom attribute config returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_case_management_attribute::CaseManagementAttributeAPI;
use datadog_api_client::datadogV2::model::CustomAttributeConfigResourceType;
use datadog_api_client::datadogV2::model::CustomAttributeConfigUpdate;
use datadog_api_client::datadogV2::model::CustomAttributeConfigUpdateAttributes;
use datadog_api_client::datadogV2::model::CustomAttributeConfigUpdateRequest;
use datadog_api_client::datadogV2::model::CustomAttributeSelectOption;
use datadog_api_client::datadogV2::model::CustomAttributeType;
use datadog_api_client::datadogV2::model::CustomAttributeTypeData;

#[tokio::main]
async fn main() {
    let body = CustomAttributeConfigUpdateRequest::new(
        CustomAttributeConfigUpdate::new(CustomAttributeConfigResourceType::CUSTOM_ATTRIBUTE)
            .attributes(
                CustomAttributeConfigUpdateAttributes::new()
                    .description("Updated description.".to_string())
                    .display_name("AWS Region".to_string())
                    .type_(CustomAttributeType::NUMBER)
                    .type_data(CustomAttributeTypeData::new().options(vec![
                        CustomAttributeSelectOption::new("us-east-1".to_string()),
                    ])),
            ),
    );
    let configuration = datadog::Configuration::new();
    let api = CaseManagementAttributeAPI::with_config(configuration);
    let resp = api
        .update_custom_attribute_config(
            "case_type_id".to_string(),
            "custom_attribute_id".to_string(),
            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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Update custom attribute config 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,
    },
  },
});
const apiInstance = new v2.CaseManagementAttributeApi(configuration);

const params: v2.CaseManagementAttributeApiUpdateCustomAttributeConfigRequest =
  {
    body: {
      data: {
        attributes: {
          description: "Updated description.",
          displayName: "AWS Region",
          type: "NUMBER",
          typeData: {
            options: [
              {
                value: "us-east-1",
              },
            ],
          },
        },
        type: "custom_attribute",
      },
    },
    caseTypeId: "case_type_id",
    customAttributeId: "custom_attribute_id",
  };

apiInstance
  .updateCustomAttributeConfig(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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"