podman_rest_client/v5/apis/
system_compat.rs

1use crate::api_common::config::HasConfig;
2use crate::api_common::request;
3use crate::api_common::Error;
4use http::request::Builder;
5use std::future::Future;
6use std::pin::Pin;
7pub trait SystemCompat: HasConfig + Send + Sync {
8    /// POST /auth
9    ///
10    /// Check auth configuration
11    fn system_auth<'a>(
12        &'a self,
13        auth_config: crate::v5::models::AuthConfig,
14    ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::AuthReport, Error>> + Send + 'a>>
15    {
16        Box::pin(request::execute_request_json(
17            self.get_config(),
18            move |mut req_builder: Builder| {
19                req_builder = req_builder.method("POST");
20                let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
21                let mut request_path = request_url.path().to_owned();
22                if request_path.ends_with('/') {
23                    request_path.pop();
24                }
25                request_path.push_str("/auth");
26                request_url.set_path(&request_path);
27                let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
28                req_builder = req_builder.uri(hyper_uri);
29                let body = serde_json::to_string(&auth_config)?;
30                req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
31                req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
32                Ok(req_builder.body(body)?)
33            },
34        ))
35    }
36    /// GET /events
37    ///
38    /// Get events
39    ///
40    /// Returns events filtered on query parameters
41    fn system_events<'a>(
42        &'a self,
43        params: Option<crate::v5::params::SystemEvents<'a>>,
44    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
45        Box::pin(request::execute_request_unit(
46            self.get_config(),
47            move |mut req_builder: Builder| {
48                req_builder = req_builder.method("GET");
49                let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
50                let mut request_path = request_url.path().to_owned();
51                if request_path.ends_with('/') {
52                    request_path.pop();
53                }
54                request_path.push_str("/events");
55                request_url.set_path(&request_path);
56                if let Some(params) = &params {
57                    let mut query_pairs = request_url.query_pairs_mut();
58                    if let Some(since) = params.since {
59                        query_pairs.append_pair("since", since);
60                    }
61                    if let Some(until) = params.until {
62                        query_pairs.append_pair("until", until);
63                    }
64                    if let Some(filters) = params.filters {
65                        query_pairs.append_pair("filters", filters);
66                    }
67                }
68                let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
69                req_builder = req_builder.uri(hyper_uri);
70                Ok(req_builder.body(String::new())?)
71            },
72        ))
73    }
74    /// GET /info
75    ///
76    /// Get info
77    ///
78    /// Returns information on the system and libpod configuration
79    fn system_info<'a>(&'a self) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
80        Box::pin(request::execute_request_unit(
81            self.get_config(),
82            move |mut req_builder: Builder| {
83                req_builder = req_builder.method("GET");
84                let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
85                let mut request_path = request_url.path().to_owned();
86                if request_path.ends_with('/') {
87                    request_path.pop();
88                }
89                request_path.push_str("/info");
90                request_url.set_path(&request_path);
91                let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
92                req_builder = req_builder.uri(hyper_uri);
93                Ok(req_builder.body(String::new())?)
94            },
95        ))
96    }
97    /// GET /libpod/_ping
98    ///
99    /// Ping service
100    ///
101    /// Return protocol information in response headers.
102    /// `HEAD /libpod/_ping` is also supported.
103    /// `/_ping` is available for compatibility with other engines.
104    /// The '_ping' endpoints are not versioned.
105    fn system_ping<'a>(
106        &'a self,
107    ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'a>> {
108        Box::pin(request::execute_request_text(
109            self.get_config(),
110            move |mut req_builder: Builder| {
111                req_builder = req_builder.method("GET");
112                let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
113                let mut request_path = request_url.path().to_owned();
114                if request_path.ends_with('/') {
115                    request_path.pop();
116                }
117                request_path.push_str("/libpod/_ping");
118                request_url.set_path(&request_path);
119                let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
120                req_builder = req_builder.uri(hyper_uri);
121                Ok(req_builder.body(String::new())?)
122            },
123        ))
124    }
125    /// GET /system/df
126    ///
127    /// Show disk usage
128    ///
129    /// Return information about disk usage for containers, images, and volumes
130    fn system_data_usage<'a>(
131        &'a self,
132    ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::SystemDfReport, Error>> + Send + 'a>>
133    {
134        Box::pin(request::execute_request_json(
135            self.get_config(),
136            move |mut req_builder: Builder| {
137                req_builder = req_builder.method("GET");
138                let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
139                let mut request_path = request_url.path().to_owned();
140                if request_path.ends_with('/') {
141                    request_path.pop();
142                }
143                request_path.push_str("/system/df");
144                request_url.set_path(&request_path);
145                let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
146                req_builder = req_builder.uri(hyper_uri);
147                Ok(req_builder.body(String::new())?)
148            },
149        ))
150    }
151    /// GET /version
152    ///
153    /// Component Version information
154    fn system_version<'a>(
155        &'a self,
156    ) -> Pin<
157        Box<
158            dyn Future<Output = Result<crate::v5::models::SystemComponentVersion, Error>>
159                + Send
160                + 'a,
161        >,
162    > {
163        Box::pin(request::execute_request_json(
164            self.get_config(),
165            move |mut req_builder: Builder| {
166                req_builder = req_builder.method("GET");
167                let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
168                let mut request_path = request_url.path().to_owned();
169                if request_path.ends_with('/') {
170                    request_path.pop();
171                }
172                request_path.push_str("/version");
173                request_url.set_path(&request_path);
174                let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
175                req_builder = req_builder.uri(hyper_uri);
176                Ok(req_builder.body(String::new())?)
177            },
178        ))
179    }
180}