podman_rest_client/v5/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::v5::params::NetworkDeleteLibpod>,
17 ) -> Pin<
18 Box<
19 dyn Future<Output = Result<Vec<crate::v5::models::NetworkRmReport>, Error>> + Send + 'a,
20 >,
21 > {
22 Box::pin(request::execute_request_json(
23 self.get_config(),
24 move |mut req_builder: Builder| {
25 req_builder = req_builder.method("DELETE");
26 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
27 let mut request_path = request_url.path().to_owned();
28 if request_path.ends_with('/') {
29 request_path.pop();
30 }
31 request_path.push_str("/libpod/networks/{name}");
32 request_path = request_path.replace("{name}", name);
33 request_url.set_path(&request_path);
34 if let Some(params) = ¶ms {
35 let mut query_pairs = request_url.query_pairs_mut();
36 if let Some(force) = params.force {
37 query_pairs.append_pair("force", &force.to_string());
38 }
39 }
40 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
41 req_builder = req_builder.uri(hyper_uri);
42 Ok(req_builder.body(String::new())?)
43 },
44 ))
45 }
46 fn network_connect_libpod<'a>(
52 &'a self,
53 name: &'a str,
54 create: crate::v5::models::NetworkConnectOptions,
55 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
56 Box::pin(request::execute_request_unit(
57 self.get_config(),
58 move |mut req_builder: Builder| {
59 req_builder = req_builder.method("POST");
60 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
61 let mut request_path = request_url.path().to_owned();
62 if request_path.ends_with('/') {
63 request_path.pop();
64 }
65 request_path.push_str("/libpod/networks/{name}/connect");
66 request_path = request_path.replace("{name}", name);
67 request_url.set_path(&request_path);
68 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
69 req_builder = req_builder.uri(hyper_uri);
70 let body = serde_json::to_string(&create)?;
71 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
72 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
73 Ok(req_builder.body(body)?)
74 },
75 ))
76 }
77 fn network_disconnect_libpod<'a>(
83 &'a self,
84 name: &'a str,
85 create: crate::v5::models::NetworkDisconnect,
86 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
87 Box::pin(request::execute_request_unit(
88 self.get_config(),
89 move |mut req_builder: Builder| {
90 req_builder = req_builder.method("POST");
91 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
92 let mut request_path = request_url.path().to_owned();
93 if request_path.ends_with('/') {
94 request_path.pop();
95 }
96 request_path.push_str("/libpod/networks/{name}/disconnect");
97 request_path = request_path.replace("{name}", name);
98 request_url.set_path(&request_path);
99 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
100 req_builder = req_builder.uri(hyper_uri);
101 let body = serde_json::to_string(&create)?;
102 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
103 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
104 Ok(req_builder.body(body)?)
105 },
106 ))
107 }
108 fn network_exists_libpod<'a>(
114 &'a self,
115 name: &'a str,
116 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
117 Box::pin(request::execute_request_unit(
118 self.get_config(),
119 move |mut req_builder: Builder| {
120 req_builder = req_builder.method("GET");
121 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
122 let mut request_path = request_url.path().to_owned();
123 if request_path.ends_with('/') {
124 request_path.pop();
125 }
126 request_path.push_str("/libpod/networks/{name}/exists");
127 request_path = request_path.replace("{name}", name);
128 request_url.set_path(&request_path);
129 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
130 req_builder = req_builder.uri(hyper_uri);
131 Ok(req_builder.body(String::new())?)
132 },
133 ))
134 }
135 fn network_inspect_libpod<'a>(
141 &'a self,
142 name: &'a str,
143 ) -> Pin<
144 Box<
145 dyn Future<Output = Result<crate::v5::models::NetworkInspectReport, Error>> + Send + 'a,
146 >,
147 > {
148 Box::pin(request::execute_request_json(
149 self.get_config(),
150 move |mut req_builder: Builder| {
151 req_builder = req_builder.method("GET");
152 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
153 let mut request_path = request_url.path().to_owned();
154 if request_path.ends_with('/') {
155 request_path.pop();
156 }
157 request_path.push_str("/libpod/networks/{name}/json");
158 request_path = request_path.replace("{name}", name);
159 request_url.set_path(&request_path);
160 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
161 req_builder = req_builder.uri(hyper_uri);
162 Ok(req_builder.body(String::new())?)
163 },
164 ))
165 }
166 fn network_update_libpod<'a>(
170 &'a self,
171 name: &'a str,
172 update: crate::v5::models::NetworkUpdateOptions,
173 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>> {
174 Box::pin(request::execute_request_unit(
175 self.get_config(),
176 move |mut req_builder: Builder| {
177 req_builder = req_builder.method("POST");
178 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
179 let mut request_path = request_url.path().to_owned();
180 if request_path.ends_with('/') {
181 request_path.pop();
182 }
183 request_path.push_str("/libpod/networks/{name}/update");
184 request_path = request_path.replace("{name}", name);
185 request_url.set_path(&request_path);
186 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
187 req_builder = req_builder.uri(hyper_uri);
188 let body = serde_json::to_string(&update)?;
189 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
190 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
191 Ok(req_builder.body(body)?)
192 },
193 ))
194 }
195 fn network_create_libpod<'a>(
201 &'a self,
202 create: crate::v5::models::NetworkCreateLibpod,
203 ) -> Pin<Box<dyn Future<Output = Result<crate::v5::models::Network, Error>> + Send + 'a>> {
204 Box::pin(request::execute_request_json(
205 self.get_config(),
206 move |mut req_builder: Builder| {
207 req_builder = req_builder.method("POST");
208 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
209 let mut request_path = request_url.path().to_owned();
210 if request_path.ends_with('/') {
211 request_path.pop();
212 }
213 request_path.push_str("/libpod/networks/create");
214 request_url.set_path(&request_path);
215 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
216 req_builder = req_builder.uri(hyper_uri);
217 let body = serde_json::to_string(&create)?;
218 req_builder = req_builder.header(hyper::header::CONTENT_TYPE, "application/json");
219 req_builder = req_builder.header(hyper::header::CONTENT_LENGTH, body.len());
220 Ok(req_builder.body(body)?)
221 },
222 ))
223 }
224 fn network_list_libpod<'a>(
231 &'a self,
232 params: Option<crate::v5::params::NetworkListLibpod<'a>>,
233 ) -> Pin<Box<dyn Future<Output = Result<Vec<crate::v5::models::Network>, Error>> + Send + 'a>>
234 {
235 Box::pin(request::execute_request_json(
236 self.get_config(),
237 move |mut req_builder: Builder| {
238 req_builder = req_builder.method("GET");
239 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
240 let mut request_path = request_url.path().to_owned();
241 if request_path.ends_with('/') {
242 request_path.pop();
243 }
244 request_path.push_str("/libpod/networks/json");
245 request_url.set_path(&request_path);
246 if let Some(params) = ¶ms {
247 let mut query_pairs = request_url.query_pairs_mut();
248 if let Some(filters) = params.filters {
249 query_pairs.append_pair("filters", filters);
250 }
251 }
252 let hyper_uri: hyper::Uri = request_url.as_str().parse()?;
253 req_builder = req_builder.uri(hyper_uri);
254 Ok(req_builder.body(String::new())?)
255 },
256 ))
257 }
258 fn network_prune_libpod<'a>(
264 &'a self,
265 params: Option<crate::v5::params::NetworkPruneLibpod<'a>>,
266 ) -> Pin<
267 Box<
268 dyn Future<Output = Result<Vec<crate::v5::models::NetworkPruneReport>, Error>>
269 + Send
270 + 'a,
271 >,
272 > {
273 Box::pin(request::execute_request_json(
274 self.get_config(),
275 move |mut req_builder: Builder| {
276 req_builder = req_builder.method("POST");
277 let mut request_url = url::Url::parse(self.get_config().get_base_path())?;
278 let mut request_path = request_url.path().to_owned();
279 if request_path.ends_with('/') {
280 request_path.pop();
281 }
282 request_path.push_str("/libpod/networks/prune");
283 request_url.set_path(&request_path);
284 if let Some(params) = ¶ms {
285 let mut query_pairs = request_url.query_pairs_mut();
286 if let Some(filters) = params.filters {
287 query_pairs.append_pair("filters", filters);
288 }
289 }
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}