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 ContainersCompat: HasConfig + Send + Sync {
8 fn image_commit<'a>(
14 &'a self,
15 params: Option<crate::v4::params::ImageCommit<'a>>,
16 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
17 Box::pin(request::execute_request_unit(
18 self.get_config(),
19 move |mut req_builder: Builder| {
20 req_builder = req_builder.method("POST");
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("/commit");
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(container) = params.container {
31 query_pairs.append_pair("container", container);
32 }
33 if let Some(repo) = params.repo {
34 query_pairs.append_pair("repo", repo);
35 }
36 if let Some(tag) = params.tag {
37 query_pairs.append_pair("tag", tag);
38 }
39 if let Some(comment) = params.comment {
40 query_pairs.append_pair("comment", comment);
41 }
42 if let Some(author) = params.author {
43 query_pairs.append_pair("author", author);
44 }
45 if let Some(pause) = params.pause {
46 query_pairs.append_pair("pause", &pause.to_string());
47 }
48 if let Some(changes) = params.changes {
49 query_pairs.append_pair("changes", changes);
50 }
51 if let Some(squash) = params.squash {
52 query_pairs.append_pair("squash", &squash.to_string());
53 }
54 }
55 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
56 req_builder = req_builder.uri(hyper_uri);
57 Ok(req_builder.body(String::new())?)
58 },
59 ))
60 }
61 fn container_delete<'a>(
65 &'a self,
66 name: &'a str,
67 params: Option<crate::v4::params::ContainerDelete>,
68 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
69 Box::pin(request::execute_request_unit(
70 self.get_config(),
71 move |mut req_builder: Builder| {
72 req_builder = req_builder.method("DELETE");
73 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
74 let mut request_path = request_url.path().to_owned();
75 if request_path.ends_with('/') {
76 request_path.pop();
77 }
78 request_path.push_str("/containers/{name}");
79 request_path = request_path.replace("{name}", name);
80 request_url.set_path(&request_path);
81 if let Some(params) = ¶ms {
82 let mut query_pairs = request_url.query_pairs_mut();
83 if let Some(force) = params.force {
84 query_pairs.append_pair("force", &force.to_string());
85 }
86 if let Some(v) = params.v {
87 query_pairs.append_pair("v", &v.to_string());
88 }
89 if let Some(link) = params.link {
90 query_pairs.append_pair("link", &link.to_string());
91 }
92 }
93 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
94 req_builder = req_builder.uri(hyper_uri);
95 Ok(req_builder.body(String::new())?)
96 },
97 ))
98 }
99 fn container_archive<'a>(
105 &'a self,
106 name: &'a str,
107 params: Option<crate::v4::params::ContainerArchive<'a>>,
108 ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'a>> {
109 Box::pin(request::execute_request_json(
110 self.get_config(),
111 move |mut req_builder: Builder| {
112 req_builder = req_builder.method("GET");
113 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
114 let mut request_path = request_url.path().to_owned();
115 if request_path.ends_with('/') {
116 request_path.pop();
117 }
118 request_path.push_str("/containers/{name}/archive");
119 request_path = request_path.replace("{name}", name);
120 request_url.set_path(&request_path);
121 if let Some(params) = ¶ms {
122 let mut query_pairs = request_url.query_pairs_mut();
123 query_pairs.append_pair("path", params.path);
124 }
125 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
126 req_builder = req_builder.uri(hyper_uri);
127 Ok(req_builder.body(String::new())?)
128 },
129 ))
130 }
131 fn put_container_archive<'a>(
137 &'a self,
138 name: &'a str,
139 params: Option<crate::v4::params::PutContainerArchive<'a>>,
140 request: String,
141 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
142 Box::pin(request::execute_request_unit(
143 self.get_config(),
144 move |mut req_builder: Builder| {
145 req_builder = req_builder.method("GET");
146 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
147 let mut request_path = request_url.path().to_owned();
148 if request_path.ends_with('/') {
149 request_path.pop();
150 }
151 request_path.push_str("/containers/{name}/archive");
152 request_path = request_path.replace("{name}", name);
153 request_url.set_path(&request_path);
154 if let Some(params) = ¶ms {
155 let mut query_pairs = request_url.query_pairs_mut();
156 query_pairs.append_pair("path", params.path);
157 if let Some(no_overwrite_dir_non_dir) = params.no_overwrite_dir_non_dir {
158 query_pairs.append_pair("noOverwriteDirNonDir", no_overwrite_dir_non_dir);
159 }
160 if let Some(copy_uidgid) = params.copy_uidgid {
161 query_pairs.append_pair("copyUIDGID", copy_uidgid);
162 }
163 }
164 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
165 req_builder = req_builder.uri(hyper_uri);
166 let body = serde_json::to_string(&request)?;
167 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
168 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
169 Ok(req_builder.body(body)?)
170 },
171 ))
172 }
173 fn container_attach<'a>(
183 &'a self,
184 name: &'a str,
185 params: Option<crate::v4::params::ContainerAttach<'a>>,
186 ) -> Pin<
187 Box<
188 dyn Future<Output = Result<hyper_util::rt::TokioIo<hyper::upgrade::Upgraded>, Error>>
189 + Send
190 + 'a,
191 >,
192 > {
193 Box::pin(request::execute_request_upgrade(
194 self.get_config(),
195 move |mut req_builder: Builder| {
196 req_builder = req_builder.method("POST");
197 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
198 let mut request_path = request_url.path().to_owned();
199 if request_path.ends_with('/') {
200 request_path.pop();
201 }
202 request_path.push_str("/containers/{name}/attach");
203 request_path = request_path.replace("{name}", name);
204 request_url.set_path(&request_path);
205 if let Some(params) = ¶ms {
206 let mut query_pairs = request_url.query_pairs_mut();
207 if let Some(detach_keys) = params.detach_keys {
208 query_pairs.append_pair("detachKeys", detach_keys);
209 }
210 if let Some(logs) = params.logs {
211 query_pairs.append_pair("logs", &logs.to_string());
212 }
213 if let Some(stream) = params.stream {
214 query_pairs.append_pair("stream", &stream.to_string());
215 }
216 if let Some(stdout) = params.stdout {
217 query_pairs.append_pair("stdout", &stdout.to_string());
218 }
219 if let Some(stderr) = params.stderr {
220 query_pairs.append_pair("stderr", &stderr.to_string());
221 }
222 if let Some(stdin) = params.stdin {
223 query_pairs.append_pair("stdin", &stdin.to_string());
224 }
225 }
226 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
227 req_builder = req_builder.uri(hyper_uri);
228 Ok(req_builder.body(String::new())?)
229 },
230 ))
231 }
232 fn container_export<'a>(
238 &'a self,
239 name: &'a str,
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("/containers/{name}/export");
251 request_path = request_path.replace("{name}", name);
252 request_url.set_path(&request_path);
253 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
254 req_builder = req_builder.uri(hyper_uri);
255 Ok(req_builder.body(String::new())?)
256 },
257 ))
258 }
259 fn container_inspect<'a>(
265 &'a self,
266 name: &'a str,
267 params: Option<crate::v4::params::ContainerInspect>,
268 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
269 Box::pin(request::execute_request_unit(
270 self.get_config(),
271 move |mut req_builder: Builder| {
272 req_builder = req_builder.method("GET");
273 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
274 let mut request_path = request_url.path().to_owned();
275 if request_path.ends_with('/') {
276 request_path.pop();
277 }
278 request_path.push_str("/containers/{name}/json");
279 request_path = request_path.replace("{name}", name);
280 request_url.set_path(&request_path);
281 if let Some(params) = ¶ms {
282 let mut query_pairs = request_url.query_pairs_mut();
283 if let Some(size) = params.size {
284 query_pairs.append_pair("size", &size.to_string());
285 }
286 }
287 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
288 req_builder = req_builder.uri(hyper_uri);
289 Ok(req_builder.body(String::new())?)
290 },
291 ))
292 }
293 fn container_kill<'a>(
299 &'a self,
300 name: &'a str,
301 params: Option<crate::v4::params::ContainerKill<'a>>,
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("/containers/{name}/kill");
313 request_path = request_path.replace("{name}", name);
314 request_url.set_path(&request_path);
315 if let Some(params) = ¶ms {
316 let mut query_pairs = request_url.query_pairs_mut();
317 if let Some(all) = params.all {
318 query_pairs.append_pair("all", &all.to_string());
319 }
320 if let Some(signal) = params.signal {
321 query_pairs.append_pair("signal", signal);
322 }
323 }
324 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
325 req_builder = req_builder.uri(hyper_uri);
326 Ok(req_builder.body(String::new())?)
327 },
328 ))
329 }
330 fn container_logs<'a>(
336 &'a self,
337 name: &'a str,
338 params: Option<crate::v4::params::ContainerLogs<'a>>,
339 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
340 Box::pin(request::execute_request_unit(
341 self.get_config(),
342 move |mut req_builder: Builder| {
343 req_builder = req_builder.method("GET");
344 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
345 let mut request_path = request_url.path().to_owned();
346 if request_path.ends_with('/') {
347 request_path.pop();
348 }
349 request_path.push_str("/containers/{name}/logs");
350 request_path = request_path.replace("{name}", name);
351 request_url.set_path(&request_path);
352 if let Some(params) = ¶ms {
353 let mut query_pairs = request_url.query_pairs_mut();
354 if let Some(follow) = params.follow {
355 query_pairs.append_pair("follow", &follow.to_string());
356 }
357 if let Some(stdout) = params.stdout {
358 query_pairs.append_pair("stdout", &stdout.to_string());
359 }
360 if let Some(stderr) = params.stderr {
361 query_pairs.append_pair("stderr", &stderr.to_string());
362 }
363 if let Some(since) = params.since {
364 query_pairs.append_pair("since", since);
365 }
366 if let Some(until) = params.until {
367 query_pairs.append_pair("until", until);
368 }
369 if let Some(timestamps) = params.timestamps {
370 query_pairs.append_pair("timestamps", ×tamps.to_string());
371 }
372 if let Some(tail) = params.tail {
373 query_pairs.append_pair("tail", tail);
374 }
375 }
376 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
377 req_builder = req_builder.uri(hyper_uri);
378 Ok(req_builder.body(String::new())?)
379 },
380 ))
381 }
382 fn container_pause<'a>(
388 &'a self,
389 name: &'a str,
390 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
391 Box::pin(request::execute_request_unit(
392 self.get_config(),
393 move |mut req_builder: Builder| {
394 req_builder = req_builder.method("POST");
395 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
396 let mut request_path = request_url.path().to_owned();
397 if request_path.ends_with('/') {
398 request_path.pop();
399 }
400 request_path.push_str("/containers/{name}/pause");
401 request_path = request_path.replace("{name}", name);
402 request_url.set_path(&request_path);
403 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
404 req_builder = req_builder.uri(hyper_uri);
405 Ok(req_builder.body(String::new())?)
406 },
407 ))
408 }
409 fn container_rename<'a>(
415 &'a self,
416 name: &'a str,
417 params: Option<crate::v4::params::ContainerRename<'a>>,
418 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
419 Box::pin(request::execute_request_unit(
420 self.get_config(),
421 move |mut req_builder: Builder| {
422 req_builder = req_builder.method("POST");
423 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
424 let mut request_path = request_url.path().to_owned();
425 if request_path.ends_with('/') {
426 request_path.pop();
427 }
428 request_path.push_str("/containers/{name}/rename");
429 request_path = request_path.replace("{name}", name);
430 request_url.set_path(&request_path);
431 if let Some(params) = ¶ms {
432 let mut query_pairs = request_url.query_pairs_mut();
433 query_pairs.append_pair("name", params.name);
434 }
435 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
436 req_builder = req_builder.uri(hyper_uri);
437 Ok(req_builder.body(String::new())?)
438 },
439 ))
440 }
441 fn container_resize<'a>(
447 &'a self,
448 name: &'a str,
449 params: Option<crate::v4::params::ContainerResize>,
450 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
451 Box::pin(request::execute_request_unit(
452 self.get_config(),
453 move |mut req_builder: Builder| {
454 req_builder = req_builder.method("POST");
455 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
456 let mut request_path = request_url.path().to_owned();
457 if request_path.ends_with('/') {
458 request_path.pop();
459 }
460 request_path.push_str("/containers/{name}/resize");
461 request_path = request_path.replace("{name}", name);
462 request_url.set_path(&request_path);
463 if let Some(params) = ¶ms {
464 let mut query_pairs = request_url.query_pairs_mut();
465 if let Some(h) = params.h {
466 query_pairs.append_pair("h", &h.to_string());
467 }
468 if let Some(w) = params.w {
469 query_pairs.append_pair("w", &w.to_string());
470 }
471 if let Some(running) = params.running {
472 query_pairs.append_pair("running", &running.to_string());
473 }
474 }
475 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
476 req_builder = req_builder.uri(hyper_uri);
477 Ok(req_builder.body(String::new())?)
478 },
479 ))
480 }
481 fn container_restart<'a>(
485 &'a self,
486 name: &'a str,
487 params: Option<crate::v4::params::ContainerRestart>,
488 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
489 Box::pin(request::execute_request_unit(
490 self.get_config(),
491 move |mut req_builder: Builder| {
492 req_builder = req_builder.method("POST");
493 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
494 let mut request_path = request_url.path().to_owned();
495 if request_path.ends_with('/') {
496 request_path.pop();
497 }
498 request_path.push_str("/containers/{name}/restart");
499 request_path = request_path.replace("{name}", name);
500 request_url.set_path(&request_path);
501 if let Some(params) = ¶ms {
502 let mut query_pairs = request_url.query_pairs_mut();
503 if let Some(t) = params.t {
504 query_pairs.append_pair("t", &t.to_string());
505 }
506 }
507 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
508 req_builder = req_builder.uri(hyper_uri);
509 Ok(req_builder.body(String::new())?)
510 },
511 ))
512 }
513 fn container_start<'a>(
517 &'a self,
518 name: &'a str,
519 params: Option<crate::v4::params::ContainerStart<'a>>,
520 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
521 Box::pin(request::execute_request_unit(
522 self.get_config(),
523 move |mut req_builder: Builder| {
524 req_builder = req_builder.method("POST");
525 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
526 let mut request_path = request_url.path().to_owned();
527 if request_path.ends_with('/') {
528 request_path.pop();
529 }
530 request_path.push_str("/containers/{name}/start");
531 request_path = request_path.replace("{name}", name);
532 request_url.set_path(&request_path);
533 if let Some(params) = ¶ms {
534 let mut query_pairs = request_url.query_pairs_mut();
535 if let Some(detach_keys) = params.detach_keys {
536 query_pairs.append_pair("detachKeys", detach_keys);
537 }
538 }
539 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
540 req_builder = req_builder.uri(hyper_uri);
541 Ok(req_builder.body(String::new())?)
542 },
543 ))
544 }
545 fn container_stats<'a>(
551 &'a self,
552 name: &'a str,
553 params: Option<crate::v4::params::ContainerStats>,
554 ) -> Pin<Box<dyn Future<Output = Result<serde_json::Value, Error>> + Send + 'a>> {
555 Box::pin(request::execute_request_json(
556 self.get_config(),
557 move |mut req_builder: Builder| {
558 req_builder = req_builder.method("GET");
559 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
560 let mut request_path = request_url.path().to_owned();
561 if request_path.ends_with('/') {
562 request_path.pop();
563 }
564 request_path.push_str("/containers/{name}/stats");
565 request_path = request_path.replace("{name}", name);
566 request_url.set_path(&request_path);
567 if let Some(params) = ¶ms {
568 let mut query_pairs = request_url.query_pairs_mut();
569 if let Some(stream) = params.stream {
570 query_pairs.append_pair("stream", &stream.to_string());
571 }
572 if let Some(one_shot) = params.one_shot {
573 query_pairs.append_pair("one-shot", &one_shot.to_string());
574 }
575 }
576 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
577 req_builder = req_builder.uri(hyper_uri);
578 Ok(req_builder.body(String::new())?)
579 },
580 ))
581 }
582 fn container_stop<'a>(
586 &'a self,
587 name: &'a str,
588 params: Option<crate::v4::params::ContainerStop>,
589 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
590 Box::pin(request::execute_request_unit(
591 self.get_config(),
592 move |mut req_builder: Builder| {
593 req_builder = req_builder.method("POST");
594 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
595 let mut request_path = request_url.path().to_owned();
596 if request_path.ends_with('/') {
597 request_path.pop();
598 }
599 request_path.push_str("/containers/{name}/stop");
600 request_path = request_path.replace("{name}", name);
601 request_url.set_path(&request_path);
602 if let Some(params) = ¶ms {
603 let mut query_pairs = request_url.query_pairs_mut();
604 if let Some(t) = params.t {
605 query_pairs.append_pair("t", &t.to_string());
606 }
607 }
608 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
609 req_builder = req_builder.uri(hyper_uri);
610 Ok(req_builder.body(String::new())?)
611 },
612 ))
613 }
614 fn container_top<'a>(
618 &'a self,
619 name: &'a str,
620 params: Option<crate::v4::params::ContainerTop<'a>>,
621 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
622 Box::pin(request::execute_request_unit(
623 self.get_config(),
624 move |mut req_builder: Builder| {
625 req_builder = req_builder.method("GET");
626 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
627 let mut request_path = request_url.path().to_owned();
628 if request_path.ends_with('/') {
629 request_path.pop();
630 }
631 request_path.push_str("/containers/{name}/top");
632 request_path = request_path.replace("{name}", name);
633 request_url.set_path(&request_path);
634 if let Some(params) = ¶ms {
635 let mut query_pairs = request_url.query_pairs_mut();
636 if let Some(ps_args) = params.ps_args {
637 query_pairs.append_pair("ps_args", ps_args);
638 }
639 }
640 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
641 req_builder = req_builder.uri(hyper_uri);
642 Ok(req_builder.body(String::new())?)
643 },
644 ))
645 }
646 fn container_unpause<'a>(
652 &'a self,
653 name: &'a str,
654 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
655 Box::pin(request::execute_request_unit(
656 self.get_config(),
657 move |mut req_builder: Builder| {
658 req_builder = req_builder.method("POST");
659 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
660 let mut request_path = request_url.path().to_owned();
661 if request_path.ends_with('/') {
662 request_path.pop();
663 }
664 request_path.push_str("/containers/{name}/unpause");
665 request_path = request_path.replace("{name}", name);
666 request_url.set_path(&request_path);
667 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
668 req_builder = req_builder.uri(hyper_uri);
669 Ok(req_builder.body(String::new())?)
670 },
671 ))
672 }
673 fn container_wait<'a>(
679 &'a self,
680 name: &'a str,
681 params: Option<crate::v4::params::ContainerWait<'a>>,
682 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
683 Box::pin(request::execute_request_unit(
684 self.get_config(),
685 move |mut req_builder: Builder| {
686 req_builder = req_builder.method("POST");
687 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
688 let mut request_path = request_url.path().to_owned();
689 if request_path.ends_with('/') {
690 request_path.pop();
691 }
692 request_path.push_str("/containers/{name}/wait");
693 request_path = request_path.replace("{name}", name);
694 request_url.set_path(&request_path);
695 if let Some(params) = ¶ms {
696 let mut query_pairs = request_url.query_pairs_mut();
697 if let Some(condition) = params.condition {
698 query_pairs.append_pair("condition", condition);
699 }
700 if let Some(interval) = params.interval {
701 query_pairs.append_pair("interval", interval);
702 }
703 }
704 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
705 req_builder = req_builder.uri(hyper_uri);
706 Ok(req_builder.body(String::new())?)
707 },
708 ))
709 }
710 fn container_create<'a>(
714 &'a self,
715 params: Option<crate::v4::params::ContainerCreate<'a>>,
716 body: (),
717 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
718 Box::pin(request::execute_request_unit(
719 self.get_config(),
720 move |mut req_builder: Builder| {
721 req_builder = req_builder.method("POST");
722 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
723 let mut request_path = request_url.path().to_owned();
724 if request_path.ends_with('/') {
725 request_path.pop();
726 }
727 request_path.push_str("/containers/create");
728 request_url.set_path(&request_path);
729 if let Some(params) = ¶ms {
730 let mut query_pairs = request_url.query_pairs_mut();
731 if let Some(name) = params.name {
732 query_pairs.append_pair("name", name);
733 }
734 }
735 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
736 req_builder = req_builder.uri(hyper_uri);
737 let body = serde_json::to_string(&body)?;
738 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
739 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
740 Ok(req_builder.body(body)?)
741 },
742 ))
743 }
744 fn container_list<'a>(
750 &'a self,
751 params: Option<crate::v4::params::ContainerList<'a>>,
752 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
753 Box::pin(request::execute_request_json(
754 self.get_config(),
755 move |mut req_builder: Builder| {
756 req_builder = req_builder.method("GET");
757 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
758 let mut request_path = request_url.path().to_owned();
759 if request_path.ends_with('/') {
760 request_path.pop();
761 }
762 request_path.push_str("/containers/json");
763 request_url.set_path(&request_path);
764 if let Some(params) = ¶ms {
765 let mut query_pairs = request_url.query_pairs_mut();
766 if let Some(all) = params.all {
767 query_pairs.append_pair("all", &all.to_string());
768 }
769 if let Some(external) = params.external {
770 query_pairs.append_pair("external", &external.to_string());
771 }
772 if let Some(limit) = params.limit {
773 query_pairs.append_pair("limit", &limit.to_string());
774 }
775 if let Some(size) = params.size {
776 query_pairs.append_pair("size", &size.to_string());
777 }
778 if let Some(filters) = params.filters {
779 query_pairs.append_pair("filters", filters);
780 }
781 }
782 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
783 req_builder = req_builder.uri(hyper_uri);
784 Ok(req_builder.body(String::new())?)
785 },
786 ))
787 }
788 fn container_prune<'a>(
794 &'a self,
795 params: Option<crate::v4::params::ContainerPrune<'a>>,
796 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
797 Box::pin(request::execute_request_json(
798 self.get_config(),
799 move |mut req_builder: Builder| {
800 req_builder = req_builder.method("POST");
801 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
802 let mut request_path = request_url.path().to_owned();
803 if request_path.ends_with('/') {
804 request_path.pop();
805 }
806 request_path.push_str("/containers/prune");
807 request_url.set_path(&request_path);
808 if let Some(params) = ¶ms {
809 let mut query_pairs = request_url.query_pairs_mut();
810 if let Some(filters) = params.filters {
811 query_pairs.append_pair("filters", filters);
812 }
813 }
814 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
815 req_builder = req_builder.uri(hyper_uri);
816 Ok(req_builder.body(String::new())?)
817 },
818 ))
819 }
820 fn container_archive_libpod<'a>(
826 &'a self,
827 name: &'a str,
828 params: Option<crate::v4::params::ContainerArchiveLibpod<'a>>,
829 ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'a>> {
830 Box::pin(request::execute_request_json(
831 self.get_config(),
832 move |mut req_builder: Builder| {
833 req_builder = req_builder.method("GET");
834 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
835 let mut request_path = request_url.path().to_owned();
836 if request_path.ends_with('/') {
837 request_path.pop();
838 }
839 request_path.push_str("/libpod/containers/{name}/archive");
840 request_path = request_path.replace("{name}", name);
841 request_url.set_path(&request_path);
842 if let Some(params) = ¶ms {
843 let mut query_pairs = request_url.query_pairs_mut();
844 query_pairs.append_pair("path", params.path);
845 if let Some(rename) = params.rename {
846 query_pairs.append_pair("rename", rename);
847 }
848 }
849 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
850 req_builder = req_builder.uri(hyper_uri);
851 Ok(req_builder.body(String::new())?)
852 },
853 ))
854 }
855}