podman_rest_client/v4/apis/
pods.rs1use 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 Pods: HasConfig + Send + Sync {
8 fn pod_delete_libpod<'a>(
12 &'a self,
13 name: &'a str,
14 params: Option<crate::v4::params::PodDeleteLibpod>,
15 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
16 Box::pin(request::execute_request_unit(
17 self.get_config(),
18 move |mut req_builder: Builder| {
19 req_builder = req_builder.method("DELETE");
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("/libpod/pods/{name}");
26 request_path = request_path.replace("{name}", name);
27 request_url.set_path(&request_path);
28 if let Some(params) = ¶ms {
29 let mut query_pairs = request_url.query_pairs_mut();
30 if let Some(force) = params.force {
31 query_pairs.append_pair("force", &force.to_string());
32 }
33 }
34 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
35 req_builder = req_builder.uri(hyper_uri);
36 Ok(req_builder.body(String::new())?)
37 },
38 ))
39 }
40 fn pod_exists_libpod<'a>(
46 &'a self,
47 name: &'a str,
48 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
49 Box::pin(request::execute_request_unit(
50 self.get_config(),
51 move |mut req_builder: Builder| {
52 req_builder = req_builder.method("GET");
53 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
54 let mut request_path = request_url.path().to_owned();
55 if request_path.ends_with('/') {
56 request_path.pop();
57 }
58 request_path.push_str("/libpod/pods/{name}/exists");
59 request_path = request_path.replace("{name}", name);
60 request_url.set_path(&request_path);
61 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
62 req_builder = req_builder.uri(hyper_uri);
63 Ok(req_builder.body(String::new())?)
64 },
65 ))
66 }
67 fn pod_inspect_libpod<'a>(
71 &'a self,
72 name: &'a str,
73 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
74 Box::pin(request::execute_request_unit(
75 self.get_config(),
76 move |mut req_builder: Builder| {
77 req_builder = req_builder.method("GET");
78 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
79 let mut request_path = request_url.path().to_owned();
80 if request_path.ends_with('/') {
81 request_path.pop();
82 }
83 request_path.push_str("/libpod/pods/{name}/json");
84 request_path = request_path.replace("{name}", name);
85 request_url.set_path(&request_path);
86 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
87 req_builder = req_builder.uri(hyper_uri);
88 Ok(req_builder.body(String::new())?)
89 },
90 ))
91 }
92 fn pod_kill_libpod<'a>(
96 &'a self,
97 name: &'a str,
98 params: Option<crate::v4::params::PodKillLibpod<'a>>,
99 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
100 Box::pin(request::execute_request_unit(
101 self.get_config(),
102 move |mut req_builder: Builder| {
103 req_builder = req_builder.method("POST");
104 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
105 let mut request_path = request_url.path().to_owned();
106 if request_path.ends_with('/') {
107 request_path.pop();
108 }
109 request_path.push_str("/libpod/pods/{name}/kill");
110 request_path = request_path.replace("{name}", name);
111 request_url.set_path(&request_path);
112 if let Some(params) = ¶ms {
113 let mut query_pairs = request_url.query_pairs_mut();
114 if let Some(signal) = params.signal {
115 query_pairs.append_pair("signal", signal);
116 }
117 }
118 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
119 req_builder = req_builder.uri(hyper_uri);
120 Ok(req_builder.body(String::new())?)
121 },
122 ))
123 }
124 fn pod_pause_libpod<'a>(
128 &'a self,
129 name: &'a str,
130 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
131 Box::pin(request::execute_request_unit(
132 self.get_config(),
133 move |mut req_builder: Builder| {
134 req_builder = req_builder.method("POST");
135 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
136 let mut request_path = request_url.path().to_owned();
137 if request_path.ends_with('/') {
138 request_path.pop();
139 }
140 request_path.push_str("/libpod/pods/{name}/pause");
141 request_path = request_path.replace("{name}", name);
142 request_url.set_path(&request_path);
143 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
144 req_builder = req_builder.uri(hyper_uri);
145 Ok(req_builder.body(String::new())?)
146 },
147 ))
148 }
149 fn pod_restart_libpod<'a>(
153 &'a self,
154 name: &'a str,
155 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
156 Box::pin(request::execute_request_unit(
157 self.get_config(),
158 move |mut req_builder: Builder| {
159 req_builder = req_builder.method("POST");
160 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
161 let mut request_path = request_url.path().to_owned();
162 if request_path.ends_with('/') {
163 request_path.pop();
164 }
165 request_path.push_str("/libpod/pods/{name}/restart");
166 request_path = request_path.replace("{name}", name);
167 request_url.set_path(&request_path);
168 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
169 req_builder = req_builder.uri(hyper_uri);
170 Ok(req_builder.body(String::new())?)
171 },
172 ))
173 }
174 fn pod_start_libpod<'a>(
178 &'a self,
179 name: &'a str,
180 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
181 Box::pin(request::execute_request_unit(
182 self.get_config(),
183 move |mut req_builder: Builder| {
184 req_builder = req_builder.method("POST");
185 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
186 let mut request_path = request_url.path().to_owned();
187 if request_path.ends_with('/') {
188 request_path.pop();
189 }
190 request_path.push_str("/libpod/pods/{name}/start");
191 request_path = request_path.replace("{name}", name);
192 request_url.set_path(&request_path);
193 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
194 req_builder = req_builder.uri(hyper_uri);
195 Ok(req_builder.body(String::new())?)
196 },
197 ))
198 }
199 fn pod_stop_libpod<'a>(
203 &'a self,
204 name: &'a str,
205 params: Option<crate::v4::params::PodStopLibpod>,
206 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
207 Box::pin(request::execute_request_unit(
208 self.get_config(),
209 move |mut req_builder: Builder| {
210 req_builder = req_builder.method("POST");
211 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
212 let mut request_path = request_url.path().to_owned();
213 if request_path.ends_with('/') {
214 request_path.pop();
215 }
216 request_path.push_str("/libpod/pods/{name}/stop");
217 request_path = request_path.replace("{name}", name);
218 request_url.set_path(&request_path);
219 if let Some(params) = ¶ms {
220 let mut query_pairs = request_url.query_pairs_mut();
221 if let Some(t) = params.t {
222 query_pairs.append_pair("t", &t.to_string());
223 }
224 }
225 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
226 req_builder = req_builder.uri(hyper_uri);
227 Ok(req_builder.body(String::new())?)
228 },
229 ))
230 }
231 fn pod_top_libpod<'a>(
237 &'a self,
238 name: &'a str,
239 params: Option<crate::v4::params::PodTopLibpod<'a>>,
240 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
241 Box::pin(request::execute_request_unit(
242 self.get_config(),
243 move |mut req_builder: Builder| {
244 req_builder = req_builder.method("GET");
245 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
246 let mut request_path = request_url.path().to_owned();
247 if request_path.ends_with('/') {
248 request_path.pop();
249 }
250 request_path.push_str("/libpod/pods/{name}/top");
251 request_path = request_path.replace("{name}", name);
252 request_url.set_path(&request_path);
253 if let Some(params) = ¶ms {
254 let mut query_pairs = request_url.query_pairs_mut();
255 if let Some(stream) = params.stream {
256 query_pairs.append_pair("stream", &stream.to_string());
257 }
258 if let Some(delay) = params.delay {
259 query_pairs.append_pair("delay", &delay.to_string());
260 }
261 if let Some(ps_args) = params.ps_args {
262 query_pairs.append_pair("ps_args", ps_args);
263 }
264 }
265 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
266 req_builder = req_builder.uri(hyper_uri);
267 Ok(req_builder.body(String::new())?)
268 },
269 ))
270 }
271 fn pod_unpause_libpod<'a>(
275 &'a self,
276 name: &'a str,
277 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
278 Box::pin(request::execute_request_unit(
279 self.get_config(),
280 move |mut req_builder: Builder| {
281 req_builder = req_builder.method("POST");
282 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
283 let mut request_path = request_url.path().to_owned();
284 if request_path.ends_with('/') {
285 request_path.pop();
286 }
287 request_path.push_str("/libpod/pods/{name}/unpause");
288 request_path = request_path.replace("{name}", name);
289 request_url.set_path(&request_path);
290 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
291 req_builder = req_builder.uri(hyper_uri);
292 Ok(req_builder.body(String::new())?)
293 },
294 ))
295 }
296 fn pod_create_libpod<'a>(
300 &'a self,
301 create: serde_json::Value,
302 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
303 Box::pin(request::execute_request_unit(
304 self.get_config(),
305 move |mut req_builder: Builder| {
306 req_builder = req_builder.method("POST");
307 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
308 let mut request_path = request_url.path().to_owned();
309 if request_path.ends_with('/') {
310 request_path.pop();
311 }
312 request_path.push_str("/libpod/pods/create");
313 request_url.set_path(&request_path);
314 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
315 req_builder = req_builder.uri(hyper_uri);
316 let body = serde_json::to_string(&create)?;
317 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
318 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
319 Ok(req_builder.body(body)?)
320 },
321 ))
322 }
323 fn pod_list_libpod<'a>(
327 &'a self,
328 params: Option<crate::v4::params::PodListLibpod<'a>>,
329 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
330 Box::pin(request::execute_request_json(
331 self.get_config(),
332 move |mut req_builder: Builder| {
333 req_builder = req_builder.method("GET");
334 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
335 let mut request_path = request_url.path().to_owned();
336 if request_path.ends_with('/') {
337 request_path.pop();
338 }
339 request_path.push_str("/libpod/pods/json");
340 request_url.set_path(&request_path);
341 if let Some(params) = ¶ms {
342 let mut query_pairs = request_url.query_pairs_mut();
343 if let Some(filters) = params.filters {
344 query_pairs.append_pair("filters", filters);
345 }
346 }
347 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
348 req_builder = req_builder.uri(hyper_uri);
349 Ok(req_builder.body(String::new())?)
350 },
351 ))
352 }
353 fn pod_prune_libpod<'a>(
357 &'a self,
358 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
359 Box::pin(request::execute_request_unit(
360 self.get_config(),
361 move |mut req_builder: Builder| {
362 req_builder = req_builder.method("POST");
363 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
364 let mut request_path = request_url.path().to_owned();
365 if request_path.ends_with('/') {
366 request_path.pop();
367 }
368 request_path.push_str("/libpod/pods/prune");
369 request_url.set_path(&request_path);
370 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
371 req_builder = req_builder.uri(hyper_uri);
372 Ok(req_builder.body(String::new())?)
373 },
374 ))
375 }
376 fn pod_stats_all_libpod<'a>(
382 &'a self,
383 params: Option<crate::v4::params::PodStatsAllLibpod<'a>>,
384 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
385 Box::pin(request::execute_request_json(
386 self.get_config(),
387 move |mut req_builder: Builder| {
388 req_builder = req_builder.method("GET");
389 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
390 let mut request_path = request_url.path().to_owned();
391 if request_path.ends_with('/') {
392 request_path.pop();
393 }
394 request_path.push_str("/libpod/pods/stats");
395 request_url.set_path(&request_path);
396 if let Some(params) = ¶ms {
397 let mut query_pairs = request_url.query_pairs_mut();
398 if let Some(all) = params.all {
399 query_pairs.append_pair("all", &all.to_string());
400 }
401 if let Some(names_or_i_ds) = ¶ms.names_or_i_ds {
402 for value in names_or_i_ds {
403 query_pairs.append_pair("namesOrIDs", &value.to_string());
404 }
405 }
406 }
407 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
408 req_builder = req_builder.uri(hyper_uri);
409 Ok(req_builder.body(String::new())?)
410 },
411 ))
412 }
413}