v2_case_management_UpdateCaseCustomAttribute/
v2_case-management_UpdateCaseCustomAttribute.rs

1// Update case custom attribute returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_case_management::CaseManagementAPI;
4use datadog_api_client::datadogV2::model::CaseResourceType;
5use datadog_api_client::datadogV2::model::CaseUpdateCustomAttribute;
6use datadog_api_client::datadogV2::model::CaseUpdateCustomAttributeRequest;
7use datadog_api_client::datadogV2::model::CustomAttributeType;
8use datadog_api_client::datadogV2::model::CustomAttributeValue;
9use datadog_api_client::datadogV2::model::CustomAttributeValuesUnion;
10
11#[tokio::main]
12async fn main() {
13    // there is a valid "case" with a custom "case_type" in the system
14    let case_with_type_id = std::env::var("CASE_WITH_TYPE_ID").unwrap();
15
16    // there is a valid "custom_attribute" in the system
17    let custom_attribute_attributes_key = std::env::var("CUSTOM_ATTRIBUTE_ATTRIBUTES_KEY").unwrap();
18    let body = CaseUpdateCustomAttributeRequest::new(CaseUpdateCustomAttribute::new(
19        CustomAttributeValue::new(
20            true,
21            CustomAttributeType::TEXT,
22            CustomAttributeValuesUnion::CustomAttributeMultiStringValue(vec![
23                "Abba".to_string(),
24                "The Cure".to_string(),
25            ]),
26        ),
27        CaseResourceType::CASE,
28    ));
29    let configuration = datadog::Configuration::new();
30    let api = CaseManagementAPI::with_config(configuration);
31    let resp = api
32        .update_case_custom_attribute(
33            case_with_type_id.clone(),
34            custom_attribute_attributes_key.clone(),
35            body,
36        )
37        .await;
38    if let Ok(value) = resp {
39        println!("{:#?}", value);
40    } else {
41        println!("{:#?}", resp.unwrap_err());
42    }
43}