podman_rest_client/v4/apis/
networks.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 Networks: HasConfig + Send + Sync {
8 fn network_delete_libpod<'a>(
14 &'a self,
15 name: &'a str,
16 params: Option<crate::v4::params::NetworkDeleteLibpod>,
17 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
18 Box::pin(request::execute_request_json(
19 self.get_config(),
20 move |mut req_builder: Builder| {
21 req_builder = req_builder.method("DELETE");
22 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
23 let mut request_path = request_url.path().to_owned();
24 if request_path.ends_with('/') {
25 request_path.pop();
26 }
27 request_path.push_str("/libpod/networks/{name}");
28 request_path = request_path.replace("{name}", name);
29 request_url.set_path(&request_path);
30 if let Some(params) = ¶ms {
31 let mut query_pairs = request_url.query_pairs_mut();
32 if let Some(force) = params.force {
33 query_pairs.append_pair("force", &force.to_string());
34 }
35 }
36 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
37 req_builder = req_builder.uri(hyper_uri);
38 Ok(req_builder.body(String::new())?)
39 },
40 ))
41 }
42 fn network_connect_libpod<'a>(
48 &'a self,
49 name: &'a str,
50 create: (),
51 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
52 Box::pin(request::execute_request_unit(
53 self.get_config(),
54 move |mut req_builder: Builder| {
55 req_builder = req_builder.method("POST");
56 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
57 let mut request_path = request_url.path().to_owned();
58 if request_path.ends_with('/') {
59 request_path.pop();
60 }
61 request_path.push_str("/libpod/networks/{name}/connect");
62 request_path = request_path.replace("{name}", name);
63 request_url.set_path(&request_path);
64 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
65 req_builder = req_builder.uri(hyper_uri);
66 let body = serde_json::to_string(&create)?;
67 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
68 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
69 Ok(req_builder.body(body)?)
70 },
71 ))
72 }
73 fn network_disconnect_libpod<'a>(
79 &'a self,
80 name: &'a str,
81 create: (),
82 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
83 Box::pin(request::execute_request_unit(
84 self.get_config(),
85 move |mut req_builder: Builder| {
86 req_builder = req_builder.method("POST");
87 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
88 let mut request_path = request_url.path().to_owned();
89 if request_path.ends_with('/') {
90 request_path.pop();
91 }
92 request_path.push_str("/libpod/networks/{name}/disconnect");
93 request_path = request_path.replace("{name}", name);
94 request_url.set_path(&request_path);
95 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
96 req_builder = req_builder.uri(hyper_uri);
97 let body = serde_json::to_string(&create)?;
98 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
99 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
100 Ok(req_builder.body(body)?)
101 },
102 ))
103 }
104 fn network_exists_libpod<'a>(
110 &'a self,
111 name: &'a str,
112 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
113 Box::pin(request::execute_request_unit(
114 self.get_config(),
115 move |mut req_builder: Builder| {
116 req_builder = req_builder.method("GET");
117 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
118 let mut request_path = request_url.path().to_owned();
119 if request_path.ends_with('/') {
120 request_path.pop();
121 }
122 request_path.push_str("/libpod/networks/{name}/exists");
123 request_path = request_path.replace("{name}", name);
124 request_url.set_path(&request_path);
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 network_inspect_libpod<'a>(
137 &'a self,
138 name: &'a str,
139 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
140 Box::pin(request::execute_request_unit(
141 self.get_config(),
142 move |mut req_builder: Builder| {
143 req_builder = req_builder.method("GET");
144 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
145 let mut request_path = request_url.path().to_owned();
146 if request_path.ends_with('/') {
147 request_path.pop();
148 }
149 request_path.push_str("/libpod/networks/{name}/json");
150 request_path = request_path.replace("{name}", name);
151 request_url.set_path(&request_path);
152 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
153 req_builder = req_builder.uri(hyper_uri);
154 Ok(req_builder.body(String::new())?)
155 },
156 ))
157 }
158 fn network_update_libpod<'a>(
162 &'a self,
163 name: &'a str,
164 update: (),
165 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
166 Box::pin(request::execute_request_unit(
167 self.get_config(),
168 move |mut req_builder: Builder| {
169 req_builder = req_builder.method("POST");
170 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
171 let mut request_path = request_url.path().to_owned();
172 if request_path.ends_with('/') {
173 request_path.pop();
174 }
175 request_path.push_str("/libpod/networks/{name}/update");
176 request_path = request_path.replace("{name}", name);
177 request_url.set_path(&request_path);
178 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
179 req_builder = req_builder.uri(hyper_uri);
180 let body = serde_json::to_string(&update)?;
181 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
182 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
183 Ok(req_builder.body(body)?)
184 },
185 ))
186 }
187 fn network_create_libpod<'a>(
193 &'a self,
194 create: (),
195 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
196 Box::pin(request::execute_request_unit(
197 self.get_config(),
198 move |mut req_builder: Builder| {
199 req_builder = req_builder.method("POST");
200 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
201 let mut request_path = request_url.path().to_owned();
202 if request_path.ends_with('/') {
203 request_path.pop();
204 }
205 request_path.push_str("/libpod/networks/create");
206 request_url.set_path(&request_path);
207 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
208 req_builder = req_builder.uri(hyper_uri);
209 let body = serde_json::to_string(&create)?;
210 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
211 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
212 Ok(req_builder.body(body)?)
213 },
214 ))
215 }
216 fn network_list_libpod<'a>(
223 &'a self,
224 params: Option<crate::v4::params::NetworkListLibpod<'a>>,
225 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
226 Box::pin(request::execute_request_json(
227 self.get_config(),
228 move |mut req_builder: Builder| {
229 req_builder = req_builder.method("GET");
230 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
231 let mut request_path = request_url.path().to_owned();
232 if request_path.ends_with('/') {
233 request_path.pop();
234 }
235 request_path.push_str("/libpod/networks/json");
236 request_url.set_path(&request_path);
237 if let Some(params) = ¶ms {
238 let mut query_pairs = request_url.query_pairs_mut();
239 if let Some(filters) = params.filters {
240 query_pairs.append_pair("filters", filters);
241 }
242 }
243 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
244 req_builder = req_builder.uri(hyper_uri);
245 Ok(req_builder.body(String::new())?)
246 },
247 ))
248 }
249 fn network_prune_libpod<'a>(
255 &'a self,
256 params: Option<crate::v4::params::NetworkPruneLibpod<'a>>,
257 ) -> Pin<Box<dyn Future<Output = Result<Vec<()>, Error>> + Send + 'a>> {
258 Box::pin(request::execute_request_json(
259 self.get_config(),
260 move |mut req_builder: Builder| {
261 req_builder = req_builder.method("POST");
262 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
263 let mut request_path = request_url.path().to_owned();
264 if request_path.ends_with('/') {
265 request_path.pop();
266 }
267 request_path.push_str("/libpod/networks/prune");
268 request_url.set_path(&request_path);
269 if let Some(params) = ¶ms {
270 let mut query_pairs = request_url.query_pairs_mut();
271 if let Some(filters) = params.filters {
272 query_pairs.append_pair("filters", filters);
273 }
274 }
275 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
276 req_builder = req_builder.uri(hyper_uri);
277 Ok(req_builder.body(String::new())?)
278 },
279 ))
280 }
281}