podman_rest_client/v5/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::v5::params::PodDeleteLibpod>,
15 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodRmReport, Error>> + Send + 'a>>
16 {
17 Box::pin(request::execute_request_json(
18 self.get_config(),
19 move |mut req_builder: Builder| {
20 req_builder = req_builder.method("DELETE");
21 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
22 let mut request_path = request_url.path().to_owned();
23 if request_path.ends_with('/') {
24 request_path.pop();
25 }
26 request_path.push_str("/libpod/pods/{name}");
27 request_path = request_path.replace("{name}", name);
28 request_url.set_path(&request_path);
29 if let Some(params) = ¶ms {
30 let mut query_pairs = request_url.query_pairs_mut();
31 if let Some(force) = params.force {
32 query_pairs.append_pair("force", &force.to_string());
33 }
34 }
35 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
36 req_builder = req_builder.uri(hyper_uri);
37 Ok(req_builder.body(String::new())?)
38 },
39 ))
40 }
41 fn pod_exists_libpod<'a>(
47 &'a self,
48 name: &'a str,
49 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
50 Box::pin(request::execute_request_unit(
51 self.get_config(),
52 move |mut req_builder: Builder| {
53 req_builder = req_builder.method("GET");
54 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
55 let mut request_path = request_url.path().to_owned();
56 if request_path.ends_with('/') {
57 request_path.pop();
58 }
59 request_path.push_str("/libpod/pods/{name}/exists");
60 request_path = request_path.replace("{name}", name);
61 request_url.set_path(&request_path);
62 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
63 req_builder = req_builder.uri(hyper_uri);
64 Ok(req_builder.body(String::new())?)
65 },
66 ))
67 }
68 fn pod_inspect_libpod<'a>(
72 &'a self,
73 name: &'a str,
74 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::InspectPodData, Error>> + Send + 'a>>
75 {
76 Box::pin(request::execute_request_json(
77 self.get_config(),
78 move |mut req_builder: Builder| {
79 req_builder = req_builder.method("GET");
80 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
81 let mut request_path = request_url.path().to_owned();
82 if request_path.ends_with('/') {
83 request_path.pop();
84 }
85 request_path.push_str("/libpod/pods/{name}/json");
86 request_path = request_path.replace("{name}", name);
87 request_url.set_path(&request_path);
88 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
89 req_builder = req_builder.uri(hyper_uri);
90 Ok(req_builder.body(String::new())?)
91 },
92 ))
93 }
94 fn pod_kill_libpod<'a>(
98 &'a self,
99 name: &'a str,
100 params: Option<crate::v5::params::PodKillLibpod<'a>>,
101 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodKillReport, Error>> + Send + 'a>>
102 {
103 Box::pin(request::execute_request_json(
104 self.get_config(),
105 move |mut req_builder: Builder| {
106 req_builder = req_builder.method("POST");
107 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
108 let mut request_path = request_url.path().to_owned();
109 if request_path.ends_with('/') {
110 request_path.pop();
111 }
112 request_path.push_str("/libpod/pods/{name}/kill");
113 request_path = request_path.replace("{name}", name);
114 request_url.set_path(&request_path);
115 if let Some(params) = ¶ms {
116 let mut query_pairs = request_url.query_pairs_mut();
117 if let Some(signal) = params.signal {
118 query_pairs.append_pair("signal", signal);
119 }
120 }
121 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
122 req_builder = req_builder.uri(hyper_uri);
123 Ok(req_builder.body(String::new())?)
124 },
125 ))
126 }
127 fn pod_pause_libpod<'a>(
131 &'a self,
132 name: &'a str,
133 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodPauseReport, Error>> + Send + 'a>>
134 {
135 Box::pin(request::execute_request_json(
136 self.get_config(),
137 move |mut req_builder: Builder| {
138 req_builder = req_builder.method("POST");
139 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
140 let mut request_path = request_url.path().to_owned();
141 if request_path.ends_with('/') {
142 request_path.pop();
143 }
144 request_path.push_str("/libpod/pods/{name}/pause");
145 request_path = request_path.replace("{name}", name);
146 request_url.set_path(&request_path);
147 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
148 req_builder = req_builder.uri(hyper_uri);
149 Ok(req_builder.body(String::new())?)
150 },
151 ))
152 }
153 fn pod_restart_libpod<'a>(
157 &'a self,
158 name: &'a str,
159 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodRestartReport, Error>> + Send + 'a>>
160 {
161 Box::pin(request::execute_request_json(
162 self.get_config(),
163 move |mut req_builder: Builder| {
164 req_builder = req_builder.method("POST");
165 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
166 let mut request_path = request_url.path().to_owned();
167 if request_path.ends_with('/') {
168 request_path.pop();
169 }
170 request_path.push_str("/libpod/pods/{name}/restart");
171 request_path = request_path.replace("{name}", name);
172 request_url.set_path(&request_path);
173 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
174 req_builder = req_builder.uri(hyper_uri);
175 Ok(req_builder.body(String::new())?)
176 },
177 ))
178 }
179 fn pod_start_libpod<'a>(
183 &'a self,
184 name: &'a str,
185 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodStartReport, Error>> + Send + 'a>>
186 {
187 Box::pin(request::execute_request_json(
188 self.get_config(),
189 move |mut req_builder: Builder| {
190 req_builder = req_builder.method("POST");
191 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
192 let mut request_path = request_url.path().to_owned();
193 if request_path.ends_with('/') {
194 request_path.pop();
195 }
196 request_path.push_str("/libpod/pods/{name}/start");
197 request_path = request_path.replace("{name}", name);
198 request_url.set_path(&request_path);
199 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
200 req_builder = req_builder.uri(hyper_uri);
201 Ok(req_builder.body(String::new())?)
202 },
203 ))
204 }
205 fn pod_stop_libpod<'a>(
209 &'a self,
210 name: &'a str,
211 params: Option<crate::v5::params::PodStopLibpod>,
212 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodStopReport, Error>> + Send + 'a>>
213 {
214 Box::pin(request::execute_request_json(
215 self.get_config(),
216 move |mut req_builder: Builder| {
217 req_builder = req_builder.method("POST");
218 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
219 let mut request_path = request_url.path().to_owned();
220 if request_path.ends_with('/') {
221 request_path.pop();
222 }
223 request_path.push_str("/libpod/pods/{name}/stop");
224 request_path = request_path.replace("{name}", name);
225 request_url.set_path(&request_path);
226 if let Some(params) = ¶ms {
227 let mut query_pairs = request_url.query_pairs_mut();
228 if let Some(t) = params.t {
229 query_pairs.append_pair("t", &t.to_string());
230 }
231 }
232 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
233 req_builder = req_builder.uri(hyper_uri);
234 Ok(req_builder.body(String::new())?)
235 },
236 ))
237 }
238 fn pod_top_libpod<'a>(
244 &'a self,
245 name: &'a str,
246 params: Option<crate::v5::params::PodTopLibpod<'a>>,
247 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodTopOkBody, Error>> + Send + 'a>>
248 {
249 Box::pin(request::execute_request_json(
250 self.get_config(),
251 move |mut req_builder: Builder| {
252 req_builder = req_builder.method("GET");
253 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
254 let mut request_path = request_url.path().to_owned();
255 if request_path.ends_with('/') {
256 request_path.pop();
257 }
258 request_path.push_str("/libpod/pods/{name}/top");
259 request_path = request_path.replace("{name}", name);
260 request_url.set_path(&request_path);
261 if let Some(params) = ¶ms {
262 let mut query_pairs = request_url.query_pairs_mut();
263 if let Some(stream) = params.stream {
264 query_pairs.append_pair("stream", &stream.to_string());
265 }
266 if let Some(delay) = params.delay {
267 query_pairs.append_pair("delay", &delay.to_string());
268 }
269 if let Some(ps_args) = params.ps_args {
270 query_pairs.append_pair("ps_args", ps_args);
271 }
272 }
273 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
274 req_builder = req_builder.uri(hyper_uri);
275 Ok(req_builder.body(String::new())?)
276 },
277 ))
278 }
279 fn pod_unpause_libpod<'a>(
283 &'a self,
284 name: &'a str,
285 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodUnpauseReport, Error>> + Send + 'a>>
286 {
287 Box::pin(request::execute_request_json(
288 self.get_config(),
289 move |mut req_builder: Builder| {
290 req_builder = req_builder.method("POST");
291 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
292 let mut request_path = request_url.path().to_owned();
293 if request_path.ends_with('/') {
294 request_path.pop();
295 }
296 request_path.push_str("/libpod/pods/{name}/unpause");
297 request_path = request_path.replace("{name}", name);
298 request_url.set_path(&request_path);
299 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
300 req_builder = req_builder.uri(hyper_uri);
301 Ok(req_builder.body(String::new())?)
302 },
303 ))
304 }
305 fn pod_create_libpod<'a>(
309 &'a self,
310 create: crate::v5::models::PodSpecGenerator,
311 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::IdResponse, Error>> + Send + 'a>>
312 {
313 Box::pin(request::execute_request_json(
314 self.get_config(),
315 move |mut req_builder: Builder| {
316 req_builder = req_builder.method("POST");
317 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
318 let mut request_path = request_url.path().to_owned();
319 if request_path.ends_with('/') {
320 request_path.pop();
321 }
322 request_path.push_str("/libpod/pods/create");
323 request_url.set_path(&request_path);
324 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
325 req_builder = req_builder.uri(hyper_uri);
326 let body = serde_json::to_string(&create)?;
327 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
328 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
329 Ok(req_builder.body(body)?)
330 },
331 ))
332 }
333 fn pod_list_libpod<'a>(
337 &'a self,
338 params: Option<crate::v5::params::PodListLibpod<'a>>,
339 ) -> Pin<
340 Box<dyn Future<Output = Result<Vec<crate::v5::models::ListPodsReport>, Error>> + Send + 'a>,
341 > {
342 Box::pin(request::execute_request_json(
343 self.get_config(),
344 move |mut req_builder: Builder| {
345 req_builder = req_builder.method("GET");
346 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
347 let mut request_path = request_url.path().to_owned();
348 if request_path.ends_with('/') {
349 request_path.pop();
350 }
351 request_path.push_str("/libpod/pods/json");
352 request_url.set_path(&request_path);
353 if let Some(params) = ¶ms {
354 let mut query_pairs = request_url.query_pairs_mut();
355 if let Some(filters) = params.filters {
356 query_pairs.append_pair("filters", filters);
357 }
358 }
359 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
360 req_builder = req_builder.uri(hyper_uri);
361 Ok(req_builder.body(String::new())?)
362 },
363 ))
364 }
365 fn pod_prune_libpod<'a>(
369 &'a self,
370 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::PodPruneReport, Error>> + Send + 'a>>
371 {
372 Box::pin(request::execute_request_json(
373 self.get_config(),
374 move |mut req_builder: Builder| {
375 req_builder = req_builder.method("POST");
376 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
377 let mut request_path = request_url.path().to_owned();
378 if request_path.ends_with('/') {
379 request_path.pop();
380 }
381 request_path.push_str("/libpod/pods/prune");
382 request_url.set_path(&request_path);
383 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
384 req_builder = req_builder.uri(hyper_uri);
385 Ok(req_builder.body(String::new())?)
386 },
387 ))
388 }
389 fn pod_stats_all_libpod<'a>(
395 &'a self,
396 params: Option<crate::v5::params::PodStatsAllLibpod<'a>>,
397 ) -> Pin<
398 Box<dyn Future<Output = Result<Vec<crate::v5::models::PodStatsReport>, Error>> + Send + 'a>,
399 > {
400 Box::pin(request::execute_request_json(
401 self.get_config(),
402 move |mut req_builder: Builder| {
403 req_builder = req_builder.method("GET");
404 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
405 let mut request_path = request_url.path().to_owned();
406 if request_path.ends_with('/') {
407 request_path.pop();
408 }
409 request_path.push_str("/libpod/pods/stats");
410 request_url.set_path(&request_path);
411 if let Some(params) = ¶ms {
412 let mut query_pairs = request_url.query_pairs_mut();
413 if let Some(all) = params.all {
414 query_pairs.append_pair("all", &all.to_string());
415 }
416 if let Some(names_or_i_ds) = ¶ms.names_or_i_ds {
417 for value in names_or_i_ds {
418 query_pairs.append_pair("namesOrIDs", &value.to_string());
419 }
420 }
421 }
422 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
423 req_builder = req_builder.uri(hyper_uri);
424 Ok(req_builder.body(String::new())?)
425 },
426 ))
427 }
428}