v1_dashboards_CreateDashboard_2338918735/
v1_dashboards_CreateDashboard_2338918735.rs

1// Create a new dashboard with list_stream widget
2use datadog_api_client::datadog;
3use datadog_api_client::datadogV1::api_dashboards::DashboardsAPI;
4use datadog_api_client::datadogV1::model::Dashboard;
5use datadog_api_client::datadogV1::model::DashboardLayoutType;
6use datadog_api_client::datadogV1::model::ListStreamColumn;
7use datadog_api_client::datadogV1::model::ListStreamColumnWidth;
8use datadog_api_client::datadogV1::model::ListStreamQuery;
9use datadog_api_client::datadogV1::model::ListStreamResponseFormat;
10use datadog_api_client::datadogV1::model::ListStreamSource;
11use datadog_api_client::datadogV1::model::ListStreamWidgetDefinition;
12use datadog_api_client::datadogV1::model::ListStreamWidgetDefinitionType;
13use datadog_api_client::datadogV1::model::ListStreamWidgetRequest;
14use datadog_api_client::datadogV1::model::Widget;
15use datadog_api_client::datadogV1::model::WidgetDefinition;
16
17#[tokio::main]
18async fn main() {
19    let body = Dashboard::new(
20        DashboardLayoutType::ORDERED,
21        "Example-Dashboard with list_stream widget".to_string(),
22        vec![Widget::new(WidgetDefinition::ListStreamWidgetDefinition(
23            Box::new(ListStreamWidgetDefinition::new(
24                vec![ListStreamWidgetRequest::new(
25                    vec![ListStreamColumn::new(
26                        "timestamp".to_string(),
27                        ListStreamColumnWidth::AUTO,
28                    )],
29                    ListStreamQuery::new(ListStreamSource::APM_ISSUE_STREAM, "".to_string()),
30                    ListStreamResponseFormat::EVENT_LIST,
31                )],
32                ListStreamWidgetDefinitionType::LIST_STREAM,
33            )),
34        ))],
35    );
36    let configuration = datadog::Configuration::new();
37    let api = DashboardsAPI::with_config(configuration);
38    let resp = api.create_dashboard(body).await;
39    if let Ok(value) = resp {
40        println!("{:#?}", value);
41    } else {
42        println!("{:#?}", resp.unwrap_err());
43    }
44}