podman_client/system/
check.rs1use http_body_util::Empty;
2use hyper::body::Bytes;
3use url::form_urlencoded;
4
5use crate::{
6 client::Client,
7 models::{
8 connection::SendRequestOptions,
9 lib::Error,
10 podman::system::check::{SystemCheck, SystemCheckOptions},
11 },
12 utils::bool_to_str::bool_to_str,
13};
14
15impl Client {
16 pub async fn system_check(
17 &self,
18 options: Option<SystemCheckOptions<'_>>,
19 ) -> Result<SystemCheck, Error> {
20 let mut query = form_urlencoded::Serializer::new(String::new());
21 if let Some(options) = options {
22 if let Some(quick) = options.quick {
23 query.append_pair("quick", bool_to_str(quick));
24 }
25 if let Some(repair) = options.repair {
26 query.append_pair("repair", bool_to_str(repair));
27 }
28 if let Some(repair_lossy) = options.repair_lossy {
29 query.append_pair("repair_lossy", bool_to_str(repair_lossy));
30 }
31 if let Some(unreferenced_layer_max_age) = options.unreferenced_layer_max_age {
32 query.append_pair("unreferenced_layer_max_age", unreferenced_layer_max_age);
33 }
34 }
35
36 let query_string = query.finish();
37
38 let mut path = "/libpod/system/check".to_owned();
39 if !query_string.is_empty() {
40 path += &["?", &query_string].concat();
41 }
42
43 let (_, data) = self
44 .send_request::<_, (), _>(SendRequestOptions {
45 method: "POST",
46 path: &path,
47 header: None,
48 body: Empty::<Bytes>::new(),
49 })
50 .await?;
51
52 Ok(data)
53 }
54}