pub struct ServiceLevelObjectivesAPI { /* private fields */ }
Expand description
Service Level Objectives (or SLOs) are a key part of the site reliability engineering toolkit. SLOs provide a framework for defining clear targets around application performance, which ultimately help teams provide a consistent customer experience, balance feature development with platform stability, and improve communication with internal and external users.
Implementations§
Source§impl ServiceLevelObjectivesAPI
impl ServiceLevelObjectivesAPI
pub fn new() -> Self
Sourcepub fn with_config(config: Configuration) -> Self
pub fn with_config(config: Configuration) -> Self
Examples found in repository?
More examples
6async fn main() {
7 // there is a valid "slo" in the system
8 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
9 let configuration = datadog::Configuration::new();
10 let api = ServiceLevelObjectivesAPI::with_config(configuration);
11 let resp = api.get_slo_corrections(slo_data_0_id.clone()).await;
12 if let Ok(value) = resp {
13 println!("{:#?}", value);
14 } else {
15 println!("{:#?}", resp.unwrap_err());
16 }
17}
9async fn main() {
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let response = api.list_slos_with_pagination(ListSLOsOptionalParams::default().limit(2));
13 pin_mut!(response);
14 while let Some(resp) = response.next().await {
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20 }
21}
7async fn main() {
8 // there is a valid "slo" in the system
9 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let resp = api
13 .get_slo(slo_data_0_id.clone(), GetSLOOptionalParams::default())
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
7async fn main() {
8 // there is a valid "slo" in the system
9 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let resp = api
13 .delete_slo(slo_data_0_id.clone(), DeleteSLOOptionalParams::default())
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
7async fn main() {
8 // there is a valid "slo" in the system
9 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let resp = api
13 .list_slos(ListSLOsOptionalParams::default().ids(slo_data_0_id.clone()))
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
- examples/v1_service-level-objectives_GetSLOHistory.rs
- examples/v1_service-level-objectives_SearchSLO.rs
- examples/v1_service-level-objectives_DeleteSLOTimeframeInBulk.rs
- examples/v1_service-level-objectives_UpdateSLO.rs
- examples/v1_service-level-objectives_CreateSLO.rs
- examples/v1_service-level-objectives_CreateSLO_3765703239.rs
pub fn with_client_and_config( config: Configuration, client: ClientWithMiddleware, ) -> Self
Sourcepub async fn check_can_delete_slo(
&self,
ids: String,
) -> Result<CheckCanDeleteSLOResponse, Error<CheckCanDeleteSLOError>>
pub async fn check_can_delete_slo( &self, ids: String, ) -> Result<CheckCanDeleteSLOResponse, Error<CheckCanDeleteSLOError>>
Check if an SLO can be safely deleted. For example, assure an SLO can be deleted without disrupting a dashboard.
Sourcepub async fn check_can_delete_slo_with_http_info(
&self,
ids: String,
) -> Result<ResponseContent<CheckCanDeleteSLOResponse>, Error<CheckCanDeleteSLOError>>
pub async fn check_can_delete_slo_with_http_info( &self, ids: String, ) -> Result<ResponseContent<CheckCanDeleteSLOResponse>, Error<CheckCanDeleteSLOError>>
Check if an SLO can be safely deleted. For example, assure an SLO can be deleted without disrupting a dashboard.
Sourcepub async fn create_slo(
&self,
body: ServiceLevelObjectiveRequest,
) -> Result<SLOListResponse, Error<CreateSLOError>>
pub async fn create_slo( &self, body: ServiceLevelObjectiveRequest, ) -> Result<SLOListResponse, Error<CreateSLOError>>
Create a service level objective object.
Examples found in repository?
11async fn main() {
12 let body = ServiceLevelObjectiveRequest::new(
13 "Example-Service-Level-Objective".to_string(),
14 vec![SLOThreshold::new(97.0, SLOTimeframe::SEVEN_DAYS)
15 .target_display("97.0".to_string())
16 .warning(98.0 as f64)
17 .warning_display("98.0".to_string())],
18 SLOType::METRIC,
19 )
20 .description(Some("string".to_string()))
21 .groups(vec!["env:test".to_string(), "role:mysql".to_string()])
22 .monitor_ids(vec![])
23 .query(ServiceLevelObjectiveQuery::new(
24 "sum:httpservice.hits{!code:3xx}.as_count()".to_string(),
25 "sum:httpservice.hits{code:2xx}.as_count()".to_string(),
26 ))
27 .tags(vec!["env:prod".to_string(), "app:core".to_string()])
28 .target_threshold(97.0 as f64)
29 .timeframe(SLOTimeframe::SEVEN_DAYS)
30 .warning_threshold(98.0 as f64);
31 let configuration = datadog::Configuration::new();
32 let api = ServiceLevelObjectivesAPI::with_config(configuration);
33 let resp = api.create_slo(body).await;
34 if let Ok(value) = resp {
35 println!("{:#?}", value);
36 } else {
37 println!("{:#?}", resp.unwrap_err());
38 }
39}
More examples
19async fn main() {
20 let body = ServiceLevelObjectiveRequest::new(
21 "Example-Service-Level-Objective".to_string(),
22 vec![SLOThreshold::new(97.0, SLOTimeframe::SEVEN_DAYS)
23 .target_display("97.0".to_string())
24 .warning(98.0 as f64)
25 .warning_display("98.0".to_string())],
26 SLOType::TIME_SLICE,
27 )
28 .description(Some("string".to_string()))
29 .sli_specification(SLOSliSpec::SLOTimeSliceSpec(Box::new(
30 SLOTimeSliceSpec::new(SLOTimeSliceCondition::new(
31 SLOTimeSliceComparator::GREATER,
32 SLOTimeSliceQuery::new(
33 vec![SLOFormula::new("query1".to_string())],
34 vec![
35 SLODataSourceQueryDefinition::FormulaAndFunctionMetricQueryDefinition(
36 Box::new(FormulaAndFunctionMetricQueryDefinition::new(
37 FormulaAndFunctionMetricDataSource::METRICS,
38 "query1".to_string(),
39 "trace.servlet.request{env:prod}".to_string(),
40 )),
41 ),
42 ],
43 ),
44 5.0,
45 )),
46 )))
47 .tags(vec!["env:prod".to_string()])
48 .target_threshold(97.0 as f64)
49 .timeframe(SLOTimeframe::SEVEN_DAYS)
50 .warning_threshold(98.0 as f64);
51 let configuration = datadog::Configuration::new();
52 let api = ServiceLevelObjectivesAPI::with_config(configuration);
53 let resp = api.create_slo(body).await;
54 if let Ok(value) = resp {
55 println!("{:#?}", value);
56 } else {
57 println!("{:#?}", resp.unwrap_err());
58 }
59}
Sourcepub async fn create_slo_with_http_info(
&self,
body: ServiceLevelObjectiveRequest,
) -> Result<ResponseContent<SLOListResponse>, Error<CreateSLOError>>
pub async fn create_slo_with_http_info( &self, body: ServiceLevelObjectiveRequest, ) -> Result<ResponseContent<SLOListResponse>, Error<CreateSLOError>>
Create a service level objective object.
Sourcepub async fn delete_slo(
&self,
slo_id: String,
params: DeleteSLOOptionalParams,
) -> Result<SLODeleteResponse, Error<DeleteSLOError>>
pub async fn delete_slo( &self, slo_id: String, params: DeleteSLOOptionalParams, ) -> Result<SLODeleteResponse, Error<DeleteSLOError>>
Permanently delete the specified service level objective object.
If an SLO is used in a dashboard, the DELETE /v1/slo/
endpoint returns
a 409 conflict error because the SLO is referenced in a dashboard.
Examples found in repository?
7async fn main() {
8 // there is a valid "slo" in the system
9 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let resp = api
13 .delete_slo(slo_data_0_id.clone(), DeleteSLOOptionalParams::default())
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
Sourcepub async fn delete_slo_with_http_info(
&self,
slo_id: String,
params: DeleteSLOOptionalParams,
) -> Result<ResponseContent<SLODeleteResponse>, Error<DeleteSLOError>>
pub async fn delete_slo_with_http_info( &self, slo_id: String, params: DeleteSLOOptionalParams, ) -> Result<ResponseContent<SLODeleteResponse>, Error<DeleteSLOError>>
Permanently delete the specified service level objective object.
If an SLO is used in a dashboard, the DELETE /v1/slo/
endpoint returns
a 409 conflict error because the SLO is referenced in a dashboard.
Sourcepub async fn delete_slo_timeframe_in_bulk(
&self,
body: BTreeMap<String, Vec<SLOTimeframe>>,
) -> Result<SLOBulkDeleteResponse, Error<DeleteSLOTimeframeInBulkError>>
pub async fn delete_slo_timeframe_in_bulk( &self, body: BTreeMap<String, Vec<SLOTimeframe>>, ) -> Result<SLOBulkDeleteResponse, Error<DeleteSLOTimeframeInBulkError>>
Delete (or partially delete) multiple service level objective objects.
This endpoint facilitates deletion of one or more thresholds for one or more service level objective objects. If all thresholds are deleted, the service level objective object is deleted as well.
Examples found in repository?
8async fn main() {
9 let body = BTreeMap::from([
10 (
11 "id1".to_string(),
12 vec![SLOTimeframe::SEVEN_DAYS, SLOTimeframe::THIRTY_DAYS],
13 ),
14 (
15 "id2".to_string(),
16 vec![SLOTimeframe::SEVEN_DAYS, SLOTimeframe::THIRTY_DAYS],
17 ),
18 ]);
19 let configuration = datadog::Configuration::new();
20 let api = ServiceLevelObjectivesAPI::with_config(configuration);
21 let resp = api.delete_slo_timeframe_in_bulk(body).await;
22 if let Ok(value) = resp {
23 println!("{:#?}", value);
24 } else {
25 println!("{:#?}", resp.unwrap_err());
26 }
27}
Sourcepub async fn delete_slo_timeframe_in_bulk_with_http_info(
&self,
body: BTreeMap<String, Vec<SLOTimeframe>>,
) -> Result<ResponseContent<SLOBulkDeleteResponse>, Error<DeleteSLOTimeframeInBulkError>>
pub async fn delete_slo_timeframe_in_bulk_with_http_info( &self, body: BTreeMap<String, Vec<SLOTimeframe>>, ) -> Result<ResponseContent<SLOBulkDeleteResponse>, Error<DeleteSLOTimeframeInBulkError>>
Delete (or partially delete) multiple service level objective objects.
This endpoint facilitates deletion of one or more thresholds for one or more service level objective objects. If all thresholds are deleted, the service level objective object is deleted as well.
Sourcepub async fn get_slo(
&self,
slo_id: String,
params: GetSLOOptionalParams,
) -> Result<SLOResponse, Error<GetSLOError>>
pub async fn get_slo( &self, slo_id: String, params: GetSLOOptionalParams, ) -> Result<SLOResponse, Error<GetSLOError>>
Get a service level objective object.
Examples found in repository?
7async fn main() {
8 // there is a valid "slo" in the system
9 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let resp = api
13 .get_slo(slo_data_0_id.clone(), GetSLOOptionalParams::default())
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
Sourcepub async fn get_slo_with_http_info(
&self,
slo_id: String,
params: GetSLOOptionalParams,
) -> Result<ResponseContent<SLOResponse>, Error<GetSLOError>>
pub async fn get_slo_with_http_info( &self, slo_id: String, params: GetSLOOptionalParams, ) -> Result<ResponseContent<SLOResponse>, Error<GetSLOError>>
Get a service level objective object.
Sourcepub async fn get_slo_corrections(
&self,
slo_id: String,
) -> Result<SLOCorrectionListResponse, Error<GetSLOCorrectionsError>>
pub async fn get_slo_corrections( &self, slo_id: String, ) -> Result<SLOCorrectionListResponse, Error<GetSLOCorrectionsError>>
Get corrections applied to an SLO
Examples found in repository?
6async fn main() {
7 // there is a valid "slo" in the system
8 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
9 let configuration = datadog::Configuration::new();
10 let api = ServiceLevelObjectivesAPI::with_config(configuration);
11 let resp = api.get_slo_corrections(slo_data_0_id.clone()).await;
12 if let Ok(value) = resp {
13 println!("{:#?}", value);
14 } else {
15 println!("{:#?}", resp.unwrap_err());
16 }
17}
Sourcepub async fn get_slo_corrections_with_http_info(
&self,
slo_id: String,
) -> Result<ResponseContent<SLOCorrectionListResponse>, Error<GetSLOCorrectionsError>>
pub async fn get_slo_corrections_with_http_info( &self, slo_id: String, ) -> Result<ResponseContent<SLOCorrectionListResponse>, Error<GetSLOCorrectionsError>>
Get corrections applied to an SLO
Sourcepub async fn get_slo_history(
&self,
slo_id: String,
from_ts: i64,
to_ts: i64,
params: GetSLOHistoryOptionalParams,
) -> Result<SLOHistoryResponse, Error<GetSLOHistoryError>>
pub async fn get_slo_history( &self, slo_id: String, from_ts: i64, to_ts: i64, params: GetSLOHistoryOptionalParams, ) -> Result<SLOHistoryResponse, Error<GetSLOHistoryError>>
Get a specific SLO’s history, regardless of its SLO type.
The detailed history data is structured according to the source data type. For example, metric data is included for event SLOs that use the metric source, and monitor SLO types include the monitor transition history.
Note: There are different response formats for event based and time based SLOs. Examples of both are shown.
Examples found in repository?
7async fn main() {
8 // there is a valid "slo" in the system
9 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let resp = api
13 .get_slo_history(
14 slo_data_0_id.clone(),
15 1636542671,
16 1636629071,
17 GetSLOHistoryOptionalParams::default(),
18 )
19 .await;
20 if let Ok(value) = resp {
21 println!("{:#?}", value);
22 } else {
23 println!("{:#?}", resp.unwrap_err());
24 }
25}
Sourcepub async fn get_slo_history_with_http_info(
&self,
slo_id: String,
from_ts: i64,
to_ts: i64,
params: GetSLOHistoryOptionalParams,
) -> Result<ResponseContent<SLOHistoryResponse>, Error<GetSLOHistoryError>>
pub async fn get_slo_history_with_http_info( &self, slo_id: String, from_ts: i64, to_ts: i64, params: GetSLOHistoryOptionalParams, ) -> Result<ResponseContent<SLOHistoryResponse>, Error<GetSLOHistoryError>>
Get a specific SLO’s history, regardless of its SLO type.
The detailed history data is structured according to the source data type. For example, metric data is included for event SLOs that use the metric source, and monitor SLO types include the monitor transition history.
Note: There are different response formats for event based and time based SLOs. Examples of both are shown.
Sourcepub async fn list_slos(
&self,
params: ListSLOsOptionalParams,
) -> Result<SLOListResponse, Error<ListSLOsError>>
pub async fn list_slos( &self, params: ListSLOsOptionalParams, ) -> Result<SLOListResponse, Error<ListSLOsError>>
Get a list of service level objective objects for your organization.
Examples found in repository?
7async fn main() {
8 // there is a valid "slo" in the system
9 let slo_data_0_id = std::env::var("SLO_DATA_0_ID").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let resp = api
13 .list_slos(ListSLOsOptionalParams::default().ids(slo_data_0_id.clone()))
14 .await;
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20}
Sourcepub fn list_slos_with_pagination(
&self,
params: ListSLOsOptionalParams,
) -> impl Stream<Item = Result<ServiceLevelObjective, Error<ListSLOsError>>> + '_
pub fn list_slos_with_pagination( &self, params: ListSLOsOptionalParams, ) -> impl Stream<Item = Result<ServiceLevelObjective, Error<ListSLOsError>>> + '_
Examples found in repository?
9async fn main() {
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let response = api.list_slos_with_pagination(ListSLOsOptionalParams::default().limit(2));
13 pin_mut!(response);
14 while let Some(resp) = response.next().await {
15 if let Ok(value) = resp {
16 println!("{:#?}", value);
17 } else {
18 println!("{:#?}", resp.unwrap_err());
19 }
20 }
21}
Sourcepub async fn list_slos_with_http_info(
&self,
params: ListSLOsOptionalParams,
) -> Result<ResponseContent<SLOListResponse>, Error<ListSLOsError>>
pub async fn list_slos_with_http_info( &self, params: ListSLOsOptionalParams, ) -> Result<ResponseContent<SLOListResponse>, Error<ListSLOsError>>
Get a list of service level objective objects for your organization.
Sourcepub async fn search_slo(
&self,
params: SearchSLOOptionalParams,
) -> Result<SearchSLOResponse, Error<SearchSLOError>>
pub async fn search_slo( &self, params: SearchSLOOptionalParams, ) -> Result<SearchSLOResponse, Error<SearchSLOError>>
Get a list of service level objective objects for your organization.
Examples found in repository?
7async fn main() {
8 // there is a valid "slo" in the system
9 let slo_data_0_name = std::env::var("SLO_DATA_0_NAME").unwrap();
10 let configuration = datadog::Configuration::new();
11 let api = ServiceLevelObjectivesAPI::with_config(configuration);
12 let resp = api
13 .search_slo(
14 SearchSLOOptionalParams::default()
15 .query(slo_data_0_name.clone())
16 .page_size(20)
17 .page_number(0),
18 )
19 .await;
20 if let Ok(value) = resp {
21 println!("{:#?}", value);
22 } else {
23 println!("{:#?}", resp.unwrap_err());
24 }
25}
Sourcepub async fn search_slo_with_http_info(
&self,
params: SearchSLOOptionalParams,
) -> Result<ResponseContent<SearchSLOResponse>, Error<SearchSLOError>>
pub async fn search_slo_with_http_info( &self, params: SearchSLOOptionalParams, ) -> Result<ResponseContent<SearchSLOResponse>, Error<SearchSLOError>>
Get a list of service level objective objects for your organization.
Sourcepub async fn update_slo(
&self,
slo_id: String,
body: ServiceLevelObjective,
) -> Result<SLOListResponse, Error<UpdateSLOError>>
pub async fn update_slo( &self, slo_id: String, body: ServiceLevelObjective, ) -> Result<SLOListResponse, Error<UpdateSLOError>>
Update the specified service level objective object.
Examples found in repository?
11async fn main() {
12 // there is a valid "slo" in the system
13 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}
Sourcepub async fn update_slo_with_http_info(
&self,
slo_id: String,
body: ServiceLevelObjective,
) -> Result<ResponseContent<SLOListResponse>, Error<UpdateSLOError>>
pub async fn update_slo_with_http_info( &self, slo_id: String, body: ServiceLevelObjective, ) -> Result<ResponseContent<SLOListResponse>, Error<UpdateSLOError>>
Update the specified service level objective object.
Trait Implementations§
Source§impl Clone for ServiceLevelObjectivesAPI
impl Clone for ServiceLevelObjectivesAPI
Source§fn clone(&self) -> ServiceLevelObjectivesAPI
fn clone(&self) -> ServiceLevelObjectivesAPI
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more