podman_autogen_api/apis/
exec_api.rs1use std::borrow::Borrow;
12#[allow(unused_imports)]
13use std::option::Option;
14use std::pin::Pin;
15use std::sync::Arc;
16
17use futures::Future;
18use hyper;
19use hyper_util::client::legacy::connect::Connect;
20
21use super::request as __internal_request;
22use super::{configuration, Error};
23use crate::models;
24
25pub struct ExecApiClient<C: Connect>
26where
27 C: Clone + std::marker::Send + Sync + 'static,
28{
29 configuration: Arc<configuration::Configuration<C>>,
30}
31
32impl<C: Connect> ExecApiClient<C>
33where
34 C: Clone + std::marker::Send + Sync,
35{
36 pub fn new(configuration: Arc<configuration::Configuration<C>>) -> ExecApiClient<C> {
37 ExecApiClient { configuration }
38 }
39}
40
41pub trait ExecApi: Send + Sync {
42 fn container_exec_libpod(
43 &self,
44 name: &str,
45 control: Option<models::ContainerExecRequest>,
46 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
47 fn exec_inspect_libpod(
48 &self,
49 id: &str,
50 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
51 fn exec_resize_libpod(
52 &self,
53 id: &str,
54 h: Option<i32>,
55 w: Option<i32>,
56 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
57 fn exec_start_libpod(
58 &self,
59 id: &str,
60 control: Option<models::ExecStartLibpodRequest>,
61 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
62}
63
64impl<C: Connect> ExecApi for ExecApiClient<C>
65where
66 C: Clone + std::marker::Send + Sync,
67{
68 #[allow(unused_mut)]
69 fn container_exec_libpod(
70 &self,
71 name: &str,
72 control: Option<models::ContainerExecRequest>,
73 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
74 let mut req = __internal_request::Request::new(
75 hyper::Method::POST,
76 "/libpod/containers/{name}/exec".to_string(),
77 );
78 req = req.with_path_param("name".to_string(), name.to_string());
79 req = req.with_body_param(control);
80 req = req.returns_nothing();
81
82 req.execute(self.configuration.borrow())
83 }
84
85 #[allow(unused_mut)]
86 fn exec_inspect_libpod(
87 &self,
88 id: &str,
89 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
90 let mut req = __internal_request::Request::new(
91 hyper::Method::GET,
92 "/libpod/exec/{id}/json".to_string(),
93 );
94 req = req.with_path_param("id".to_string(), id.to_string());
95 req = req.returns_nothing();
96
97 req.execute(self.configuration.borrow())
98 }
99
100 #[allow(unused_mut)]
101 fn exec_resize_libpod(
102 &self,
103 id: &str,
104 h: Option<i32>,
105 w: Option<i32>,
106 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
107 let mut req = __internal_request::Request::new(
108 hyper::Method::POST,
109 "/libpod/exec/{id}/resize".to_string(),
110 );
111 if let Some(ref s) = h {
112 let query_value = s.to_string();
113 req = req.with_query_param("h".to_string(), query_value);
114 }
115 if let Some(ref s) = w {
116 let query_value = s.to_string();
117 req = req.with_query_param("w".to_string(), query_value);
118 }
119 req = req.with_path_param("id".to_string(), id.to_string());
120 req = req.returns_nothing();
121
122 req.execute(self.configuration.borrow())
123 }
124
125 #[allow(unused_mut)]
126 fn exec_start_libpod(
127 &self,
128 id: &str,
129 control: Option<models::ExecStartLibpodRequest>,
130 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
131 let mut req = __internal_request::Request::new(
132 hyper::Method::POST,
133 "/libpod/exec/{id}/start".to_string(),
134 );
135 req = req.with_path_param("id".to_string(), id.to_string());
136 req = req.with_body_param(control);
137 req = req.returns_nothing();
138
139 req.execute(self.configuration.borrow())
140 }
141}