v1_logs_indexes_CreateLogsIndex/
v1_logs-indexes_CreateLogsIndex.rs

1// Create an index returns "OK" response
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV1::api_logs_indexes::LogsIndexesAPI;
4use datadog_api_client::datadogV1::model::LogsDailyLimitReset;
5use datadog_api_client::datadogV1::model::LogsExclusion;
6use datadog_api_client::datadogV1::model::LogsExclusionFilter;
7use datadog_api_client::datadogV1::model::LogsFilter;
8use datadog_api_client::datadogV1::model::LogsIndex;
9
10#[tokio::main]
11async fn main() {
12    let body = LogsIndex::new(
13        LogsFilter::new().query("source:python".to_string()),
14        "main".to_string(),
15    )
16    .daily_limit(300000000)
17    .daily_limit_reset(
18        LogsDailyLimitReset::new()
19            .reset_time("14:00".to_string())
20            .reset_utc_offset("+02:00".to_string()),
21    )
22    .daily_limit_warning_threshold_percentage(70.0 as f64)
23    .exclusion_filters(vec![LogsExclusion::new("payment".to_string())
24        .filter(LogsExclusionFilter::new(1.0).query("*".to_string()))])
25    .num_flex_logs_retention_days(360)
26    .num_retention_days(15);
27    let configuration = datadog::Configuration::new();
28    let api = LogsIndexesAPI::with_config(configuration);
29    let resp = api.create_logs_index(body).await;
30    if let Ok(value) = resp {
31        println!("{:#?}", value);
32    } else {
33        println!("{:#?}", resp.unwrap_err());
34    }
35}