v1_service_level_objectives_UpdateSLO/
v1_service-level-objectives_UpdateSLO.rs1use datadog_api_client::datadog;
3use datadog_api_client::datadogV1::api_service_level_objectives::ServiceLevelObjectivesAPI;
4use datadog_api_client::datadogV1::model::SLOThreshold;
5use datadog_api_client::datadogV1::model::SLOTimeframe;
6use datadog_api_client::datadogV1::model::SLOType;
7use datadog_api_client::datadogV1::model::ServiceLevelObjective;
8use datadog_api_client::datadogV1::model::ServiceLevelObjectiveQuery;
9
10#[tokio::main]
11async fn main() {
12 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
14 let slo_data_0_name = std::env::var("SLO_DATA_0_NAME").unwrap();
15 let body = ServiceLevelObjective::new(
16 slo_data_0_name.clone(),
17 vec![SLOThreshold::new(97.0, SLOTimeframe::SEVEN_DAYS).warning(98.0 as f64)],
18 SLOType::METRIC,
19 )
20 .query(ServiceLevelObjectiveQuery::new(
21 "sum:httpservice.hits{!code:3xx}.as_count()".to_string(),
22 "sum:httpservice.hits{code:2xx}.as_count()".to_string(),
23 ))
24 .target_threshold(97.0 as f64)
25 .timeframe(SLOTimeframe::SEVEN_DAYS)
26 .warning_threshold(98.0 as f64);
27 let configuration = datadog::Configuration::new();
28 let api = ServiceLevelObjectivesAPI::with_config(configuration);
29 let resp = api.update_slo(slo_data_0_id.clone(), body).await;
30 if let Ok(value) = resp {
31 println!("{:#?}", value);
32 } else {
33 println!("{:#?}", resp.unwrap_err());
34 }
35}