v1_dashboards_CreateDashboard_3117424216/
v1_dashboards_CreateDashboard_3117424216.rs

1// Create a new dashboard with logs_stream list_stream widget and storage parameter
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::LOGS_STREAM, "".to_string())
30                        .storage("hot".to_string()),
31                    ListStreamResponseFormat::EVENT_LIST,
32                )],
33                ListStreamWidgetDefinitionType::LIST_STREAM,
34            )),
35        ))],
36    );
37    let configuration = datadog::Configuration::new();
38    let api = DashboardsAPI::with_config(configuration);
39    let resp = api.create_dashboard(body).await;
40    if let Ok(value) = resp {
41        println!("{:#?}", value);
42    } else {
43        println!("{:#?}", resp.unwrap_err());
44    }
45}