v2_ci_visibility_tests_AggregateCIAppTestEvents/
v2_ci-visibility-tests_AggregateCIAppTestEvents.rs1use datadog_api_client::datadog;
3use datadog_api_client::datadogV2::api_ci_visibility_tests::CIVisibilityTestsAPI;
4use datadog_api_client::datadogV2::model::CIAppAggregateSort;
5use datadog_api_client::datadogV2::model::CIAppAggregationFunction;
6use datadog_api_client::datadogV2::model::CIAppCompute;
7use datadog_api_client::datadogV2::model::CIAppComputeType;
8use datadog_api_client::datadogV2::model::CIAppGroupByTotal;
9use datadog_api_client::datadogV2::model::CIAppQueryOptions;
10use datadog_api_client::datadogV2::model::CIAppSortOrder;
11use datadog_api_client::datadogV2::model::CIAppTestsAggregateRequest;
12use datadog_api_client::datadogV2::model::CIAppTestsGroupBy;
13use datadog_api_client::datadogV2::model::CIAppTestsQueryFilter;
14
15#[tokio::main]
16async fn main() {
17 let body = CIAppTestsAggregateRequest::new()
18 .compute(vec![CIAppCompute::new(CIAppAggregationFunction::COUNT)
19 .metric("@test.is_flaky".to_string())
20 .type_(CIAppComputeType::TOTAL)])
21 .filter(
22 CIAppTestsQueryFilter::new()
23 .from("now-15m".to_string())
24 .query("@language:(python OR go)".to_string())
25 .to("now".to_string()),
26 )
27 .group_by(vec![CIAppTestsGroupBy::new("@git.branch".to_string())
28 .limit(10)
29 .sort(CIAppAggregateSort::new().order(CIAppSortOrder::ASCENDING))
30 .total(CIAppGroupByTotal::CIAppGroupByTotalBoolean(false))])
31 .options(CIAppQueryOptions::new().timezone("GMT".to_string()));
32 let configuration = datadog::Configuration::new();
33 let api = CIVisibilityTestsAPI::with_config(configuration);
34 let resp = api.aggregate_ci_app_test_events(body).await;
35 if let Ok(value) = resp {
36 println!("{:#?}", value);
37 } else {
38 println!("{:#?}", resp.unwrap_err());
39 }
40}