v2_usage_metering_GetMonthlyCostAttribution/
v2_usage-metering_GetMonthlyCostAttribution.rs

1// Get Monthly Cost Attribution returns "OK" response
2use chrono::{DateTime, Utc};
3use datadog_api_client::datadog;
4use datadog_api_client::datadogV2::api_usage_metering::GetMonthlyCostAttributionOptionalParams;
5use datadog_api_client::datadogV2::api_usage_metering::UsageMeteringAPI;
6
7#[tokio::main]
8async fn main() {
9    let configuration = datadog::Configuration::new();
10    let api = UsageMeteringAPI::with_config(configuration);
11    let resp = api
12        .get_monthly_cost_attribution(
13            DateTime::parse_from_rfc3339("2021-11-06T11:11:11+00:00")
14                .expect("Failed to parse datetime")
15                .with_timezone(&Utc),
16            "infra_host_total_cost".to_string(),
17            GetMonthlyCostAttributionOptionalParams::default().end_month(
18                DateTime::parse_from_rfc3339("2021-11-08T11:11:11+00:00")
19                    .expect("Failed to parse datetime")
20                    .with_timezone(&Utc),
21            ),
22        )
23        .await;
24    if let Ok(value) = resp {
25        println!("{:#?}", value);
26    } else {
27        println!("{:#?}", resp.unwrap_err());
28    }
29}