v2_logs_custom_destinations_UpdateLogsCustomDestination/
v2_logs-custom-destinations_UpdateLogsCustomDestination.rs

1// Update a custom destination returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_logs_custom_destinations::LogsCustomDestinationsAPI;
4use datadog_api_client::datadogV2::model::CustomDestinationAttributeTagsRestrictionListType;
5use datadog_api_client::datadogV2::model::CustomDestinationType;
6use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequest;
7use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequestAttributes;
8use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequestDefinition;
9
10#[tokio::main]
11async fn main() {
12    // there is a valid "custom_destination" in the system
13    let custom_destination_data_id = std::env::var("CUSTOM_DESTINATION_DATA_ID").unwrap();
14    let body = CustomDestinationUpdateRequest::new().data(
15        CustomDestinationUpdateRequestDefinition::new(
16            custom_destination_data_id.clone(),
17            CustomDestinationType::CUSTOM_DESTINATION,
18        )
19        .attributes(
20            CustomDestinationUpdateRequestAttributes::new()
21                .enabled(false)
22                .forward_tags(false)
23                .forward_tags_restriction_list_type(
24                    CustomDestinationAttributeTagsRestrictionListType::BLOCK_LIST,
25                )
26                .name("Nginx logs (Updated)".to_string())
27                .query("source:nginx".to_string()),
28        ),
29    );
30    let configuration = datadog::Configuration::new();
31    let api = LogsCustomDestinationsAPI::with_config(configuration);
32    let resp = api
33        .update_logs_custom_destination(custom_destination_data_id.clone(), body)
34        .await;
35    if let Ok(value) = resp {
36        println!("{:#?}", value);
37    } else {
38        println!("{:#?}", resp.unwrap_err());
39    }
40}