-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathv2_widgets_UpdateWidget.rs
More file actions
36 lines (35 loc) · 1.33 KB
/
v2_widgets_UpdateWidget.rs
File metadata and controls
36 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Update a widget returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_widgets::WidgetsAPI;
use datadog_api_client::datadogV2::model::CreateOrUpdateWidgetRequest;
use datadog_api_client::datadogV2::model::CreateOrUpdateWidgetRequestAttributes;
use datadog_api_client::datadogV2::model::CreateOrUpdateWidgetRequestData;
use datadog_api_client::datadogV2::model::WidgetDefinition;
use datadog_api_client::datadogV2::model::WidgetExperienceType;
use datadog_api_client::datadogV2::model::WidgetType;
use uuid::Uuid;
#[tokio::main]
async fn main() {
let body = CreateOrUpdateWidgetRequest::new(CreateOrUpdateWidgetRequestData::new(
CreateOrUpdateWidgetRequestAttributes::new(WidgetDefinition::new(
"My Widget".to_string(),
WidgetType::BAR_CHART,
))
.tags(Some(vec![])),
"widgets".to_string(),
));
let configuration = datadog::Configuration::new();
let api = WidgetsAPI::with_config(configuration);
let resp = api
.update_widget(
WidgetExperienceType::CCM_REPORTS,
Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"),
body,
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}