1use 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 NetworksApiClient<C: Connect>
26where
27 C: Clone + std::marker::Send + Sync + 'static,
28{
29 configuration: Arc<configuration::Configuration<C>>,
30}
31
32impl<C: Connect> NetworksApiClient<C>
33where
34 C: Clone + std::marker::Send + Sync,
35{
36 pub fn new(configuration: Arc<configuration::Configuration<C>>) -> NetworksApiClient<C> {
37 NetworksApiClient { configuration }
38 }
39}
40
41pub trait NetworksApi: Send + Sync {
42 fn network_connect_libpod(
43 &self,
44 name: &str,
45 create: Option<models::NetworkConnectOptions>,
46 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
47 fn network_create_libpod(
48 &self,
49 create: Option<models::NetworkCreateLibpod>,
50 ) -> Pin<Box<dyn Future<Output = Result<models::Network, Error>> + Send>>;
51 fn network_delete_libpod(
52 &self,
53 name: &str,
54 force: Option<bool>,
55 ) -> Pin<Box<dyn Future<Output = Result<Vec<models::NetworkRmReport>, Error>> + Send>>;
56 fn network_disconnect_libpod(
57 &self,
58 name: &str,
59 create: Option<models::NetworkDisconnect>,
60 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
61 fn network_exists_libpod(
62 &self,
63 name: &str,
64 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
65 fn network_inspect_libpod(
66 &self,
67 name: &str,
68 ) -> Pin<Box<dyn Future<Output = Result<models::NetworkInspectReport, Error>> + Send>>;
69 fn network_list_libpod(
70 &self,
71 filters: Option<&str>,
72 ) -> Pin<Box<dyn Future<Output = Result<Vec<models::Network>, Error>> + Send>>;
73 fn network_prune_libpod(
74 &self,
75 filters: Option<&str>,
76 ) -> Pin<Box<dyn Future<Output = Result<Vec<models::NetworkPruneReport>, Error>> + Send>>;
77 fn network_update_libpod(
78 &self,
79 name: &str,
80 update: Option<models::NetworkUpdateOptions>,
81 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
82}
83
84impl<C: Connect> NetworksApi for NetworksApiClient<C>
85where
86 C: Clone + std::marker::Send + Sync,
87{
88 #[allow(unused_mut)]
89 fn network_connect_libpod(
90 &self,
91 name: &str,
92 create: Option<models::NetworkConnectOptions>,
93 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
94 let mut req = __internal_request::Request::new(
95 hyper::Method::POST,
96 "/libpod/networks/{name}/connect".to_string(),
97 );
98 req = req.with_path_param("name".to_string(), name.to_string());
99 req = req.with_body_param(create);
100 req = req.returns_nothing();
101
102 req.execute(self.configuration.borrow())
103 }
104
105 #[allow(unused_mut)]
106 fn network_create_libpod(
107 &self,
108 create: Option<models::NetworkCreateLibpod>,
109 ) -> Pin<Box<dyn Future<Output = Result<models::Network, Error>> + Send>> {
110 let mut req = __internal_request::Request::new(
111 hyper::Method::POST,
112 "/libpod/networks/create".to_string(),
113 );
114 req = req.with_body_param(create);
115
116 req.execute(self.configuration.borrow())
117 }
118
119 #[allow(unused_mut)]
120 fn network_delete_libpod(
121 &self,
122 name: &str,
123 force: Option<bool>,
124 ) -> Pin<Box<dyn Future<Output = Result<Vec<models::NetworkRmReport>, Error>> + Send>> {
125 let mut req = __internal_request::Request::new(
126 hyper::Method::DELETE,
127 "/libpod/networks/{name}".to_string(),
128 );
129 if let Some(ref s) = force {
130 let query_value = s.to_string();
131 req = req.with_query_param("force".to_string(), query_value);
132 }
133 req = req.with_path_param("name".to_string(), name.to_string());
134
135 req.execute(self.configuration.borrow())
136 }
137
138 #[allow(unused_mut)]
139 fn network_disconnect_libpod(
140 &self,
141 name: &str,
142 create: Option<models::NetworkDisconnect>,
143 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
144 let mut req = __internal_request::Request::new(
145 hyper::Method::POST,
146 "/libpod/networks/{name}/disconnect".to_string(),
147 );
148 req = req.with_path_param("name".to_string(), name.to_string());
149 req = req.with_body_param(create);
150 req = req.returns_nothing();
151
152 req.execute(self.configuration.borrow())
153 }
154
155 #[allow(unused_mut)]
156 fn network_exists_libpod(
157 &self,
158 name: &str,
159 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
160 let mut req = __internal_request::Request::new(
161 hyper::Method::GET,
162 "/libpod/networks/{name}/exists".to_string(),
163 );
164 req = req.with_path_param("name".to_string(), name.to_string());
165 req = req.returns_nothing();
166
167 req.execute(self.configuration.borrow())
168 }
169
170 #[allow(unused_mut)]
171 fn network_inspect_libpod(
172 &self,
173 name: &str,
174 ) -> Pin<Box<dyn Future<Output = Result<models::NetworkInspectReport, Error>> + Send>> {
175 let mut req = __internal_request::Request::new(
176 hyper::Method::GET,
177 "/libpod/networks/{name}/json".to_string(),
178 );
179 req = req.with_path_param("name".to_string(), name.to_string());
180
181 req.execute(self.configuration.borrow())
182 }
183
184 #[allow(unused_mut)]
185 fn network_list_libpod(
186 &self,
187 filters: Option<&str>,
188 ) -> Pin<Box<dyn Future<Output = Result<Vec<models::Network>, Error>> + Send>> {
189 let mut req = __internal_request::Request::new(
190 hyper::Method::GET,
191 "/libpod/networks/json".to_string(),
192 );
193 if let Some(ref s) = filters {
194 let query_value = s.to_string();
195 req = req.with_query_param("filters".to_string(), query_value);
196 }
197
198 req.execute(self.configuration.borrow())
199 }
200
201 #[allow(unused_mut)]
202 fn network_prune_libpod(
203 &self,
204 filters: Option<&str>,
205 ) -> Pin<Box<dyn Future<Output = Result<Vec<models::NetworkPruneReport>, Error>> + Send>> {
206 let mut req = __internal_request::Request::new(
207 hyper::Method::POST,
208 "/libpod/networks/prune".to_string(),
209 );
210 if let Some(ref s) = filters {
211 let query_value = s.to_string();
212 req = req.with_query_param("filters".to_string(), query_value);
213 }
214
215 req.execute(self.configuration.borrow())
216 }
217
218 #[allow(unused_mut)]
219 fn network_update_libpod(
220 &self,
221 name: &str,
222 update: Option<models::NetworkUpdateOptions>,
223 ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
224 let mut req = __internal_request::Request::new(
225 hyper::Method::POST,
226 "/libpod/networks/{name}/update".to_string(),
227 );
228 req = req.with_path_param("name".to_string(), name.to_string());
229 req = req.with_body_param(update);
230 req = req.returns_nothing();
231
232 req.execute(self.configuration.borrow())
233 }
234}