|
| 1 | +// Create custom attribute config for a case type returns "CREATED" response |
| 2 | + |
| 3 | +import com.datadog.api.client.ApiClient; |
| 4 | +import com.datadog.api.client.ApiException; |
| 5 | +import com.datadog.api.client.v2.api.CaseManagementAttributeApi; |
| 6 | +import com.datadog.api.client.v2.model.CustomAttributeConfigAttributesCreate; |
| 7 | +import com.datadog.api.client.v2.model.CustomAttributeConfigCreate; |
| 8 | +import com.datadog.api.client.v2.model.CustomAttributeConfigCreateRequest; |
| 9 | +import com.datadog.api.client.v2.model.CustomAttributeConfigResourceType; |
| 10 | +import com.datadog.api.client.v2.model.CustomAttributeConfigResponse; |
| 11 | +import com.datadog.api.client.v2.model.CustomAttributeType; |
| 12 | + |
| 13 | +public class Example { |
| 14 | + public static void main(String[] args) { |
| 15 | + ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
| 16 | + CaseManagementAttributeApi apiInstance = new CaseManagementAttributeApi(defaultClient); |
| 17 | + |
| 18 | + // there is a valid "case_type" in the system |
| 19 | + String CASE_TYPE_ID = System.getenv("CASE_TYPE_ID"); |
| 20 | + |
| 21 | + CustomAttributeConfigCreateRequest body = |
| 22 | + new CustomAttributeConfigCreateRequest() |
| 23 | + .data( |
| 24 | + new CustomAttributeConfigCreate() |
| 25 | + .attributes( |
| 26 | + new CustomAttributeConfigAttributesCreate() |
| 27 | + .displayName("AWS Region 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d") |
| 28 | + .isMulti(true) |
| 29 | + .key("region_d9fe56bc9274fbb6") |
| 30 | + .type(CustomAttributeType.NUMBER)) |
| 31 | + .type(CustomAttributeConfigResourceType.CUSTOM_ATTRIBUTE)); |
| 32 | + |
| 33 | + try { |
| 34 | + CustomAttributeConfigResponse result = |
| 35 | + apiInstance.createCustomAttributeConfig(CASE_TYPE_ID, body); |
| 36 | + System.out.println(result); |
| 37 | + } catch (ApiException e) { |
| 38 | + System.err.println( |
| 39 | + "Exception when calling CaseManagementAttributeApi#createCustomAttributeConfig"); |
| 40 | + System.err.println("Status code: " + e.getCode()); |
| 41 | + System.err.println("Reason: " + e.getResponseBody()); |
| 42 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 43 | + e.printStackTrace(); |
| 44 | + } |
| 45 | + } |
| 46 | +} |
0 commit comments