podman_autogen_api/apis/
networks_compat_api.rs

1/*
2 * supports a RESTful API for the Libpod library
3 *
4 * This documentation describes the Podman v2.x+ RESTful API. It consists of a Docker-compatible API and a Libpod API providing support for Podman’s unique features such as pods.  To start the service and keep it running for 5,000 seconds (-t 0 runs forever):  podman system service -t 5000 &  You can then use cURL on the socket using requests documented below.  NOTE: if you install the package podman-docker, it will create a symbolic link for /run/docker.sock to /run/podman/podman.sock  NOTE: Some fields in the API response JSON are encoded as omitempty, which means that if said field has a zero value, they will not be encoded in the API response. This is a feature to help reduce the size of the JSON responses returned via the API.  NOTE: Due to the limitations of [go-swagger](https://github.com/go-swagger/go-swagger), some field values that have a complex type show up as null in the docs as well as in the API responses. This is because the zero value for the field type is null. The field description in the docs will state what type the field is expected to be for such cases.  See podman-system-service(1) for more information.  Quick Examples:  'podman info'  curl --unix-socket /run/podman/podman.sock http://d/v5.0.0/libpod/info  'podman pull quay.io/containers/podman'  curl -XPOST --unix-socket /run/podman/podman.sock -v 'http://d/v5.0.0/images/create?fromImage=quay.io%2Fcontainers%2Fpodman'  'podman list images'  curl --unix-socket /run/podman/podman.sock -v 'http://d/v5.0.0/libpod/images/json' | jq
5 *
6 * The version of the OpenAPI document: 5.0.0
7 * Contact: podman@lists.podman.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11use 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 NetworksCompatApiClient<C: Connect>
26where
27    C: Clone + std::marker::Send + Sync + 'static,
28{
29    configuration: Arc<configuration::Configuration<C>>,
30}
31
32impl<C: Connect> NetworksCompatApiClient<C>
33where
34    C: Clone + std::marker::Send + Sync,
35{
36    pub fn new(configuration: Arc<configuration::Configuration<C>>) -> NetworksCompatApiClient<C> {
37        NetworksCompatApiClient { configuration }
38    }
39}
40
41pub trait NetworksCompatApi: Send + Sync {
42    fn network_connect(
43        &self,
44        name: &str,
45        create: Option<models::NetworkConnect>,
46    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
47    fn network_create(
48        &self,
49        create: Option<models::NetworkCreateRequest>,
50    ) -> Pin<Box<dyn Future<Output = Result<models::NetworkCreate201Response, Error>> + Send>>;
51    fn network_delete(&self, name: &str)
52        -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
53    fn network_disconnect(
54        &self,
55        name: &str,
56        create: Option<models::NetworkDisconnect>,
57    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
58    fn network_inspect(
59        &self,
60        name: &str,
61        verbose: Option<bool>,
62        scope: Option<&str>,
63    ) -> Pin<Box<dyn Future<Output = Result<models::NetworkResource, Error>> + Send>>;
64    fn network_list(
65        &self,
66        filters: Option<&str>,
67    ) -> Pin<Box<dyn Future<Output = Result<Vec<models::NetworkResource>, Error>> + Send>>;
68    fn network_prune(
69        &self,
70        filters: Option<&str>,
71    ) -> Pin<Box<dyn Future<Output = Result<models::NetworkPrune200Response, Error>> + Send>>;
72}
73
74impl<C: Connect> NetworksCompatApi for NetworksCompatApiClient<C>
75where
76    C: Clone + std::marker::Send + Sync,
77{
78    #[allow(unused_mut)]
79    fn network_connect(
80        &self,
81        name: &str,
82        create: Option<models::NetworkConnect>,
83    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
84        let mut req = __internal_request::Request::new(
85            hyper::Method::POST,
86            "/networks/{name}/connect".to_string(),
87        );
88        req = req.with_path_param("name".to_string(), name.to_string());
89        req = req.with_body_param(create);
90        req = req.returns_nothing();
91
92        req.execute(self.configuration.borrow())
93    }
94
95    #[allow(unused_mut)]
96    fn network_create(
97        &self,
98        create: Option<models::NetworkCreateRequest>,
99    ) -> Pin<Box<dyn Future<Output = Result<models::NetworkCreate201Response, Error>> + Send>> {
100        let mut req =
101            __internal_request::Request::new(hyper::Method::POST, "/networks/create".to_string());
102        req = req.with_body_param(create);
103
104        req.execute(self.configuration.borrow())
105    }
106
107    #[allow(unused_mut)]
108    fn network_delete(
109        &self,
110        name: &str,
111    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
112        let mut req =
113            __internal_request::Request::new(hyper::Method::DELETE, "/networks/{name}".to_string());
114        req = req.with_path_param("name".to_string(), name.to_string());
115        req = req.returns_nothing();
116
117        req.execute(self.configuration.borrow())
118    }
119
120    #[allow(unused_mut)]
121    fn network_disconnect(
122        &self,
123        name: &str,
124        create: Option<models::NetworkDisconnect>,
125    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
126        let mut req = __internal_request::Request::new(
127            hyper::Method::POST,
128            "/networks/{name}/disconnect".to_string(),
129        );
130        req = req.with_path_param("name".to_string(), name.to_string());
131        req = req.with_body_param(create);
132        req = req.returns_nothing();
133
134        req.execute(self.configuration.borrow())
135    }
136
137    #[allow(unused_mut)]
138    fn network_inspect(
139        &self,
140        name: &str,
141        verbose: Option<bool>,
142        scope: Option<&str>,
143    ) -> Pin<Box<dyn Future<Output = Result<models::NetworkResource, Error>> + Send>> {
144        let mut req =
145            __internal_request::Request::new(hyper::Method::GET, "/networks/{name}".to_string());
146        if let Some(ref s) = verbose {
147            let query_value = s.to_string();
148            req = req.with_query_param("verbose".to_string(), query_value);
149        }
150        if let Some(ref s) = scope {
151            let query_value = s.to_string();
152            req = req.with_query_param("scope".to_string(), query_value);
153        }
154        req = req.with_path_param("name".to_string(), name.to_string());
155
156        req.execute(self.configuration.borrow())
157    }
158
159    #[allow(unused_mut)]
160    fn network_list(
161        &self,
162        filters: Option<&str>,
163    ) -> Pin<Box<dyn Future<Output = Result<Vec<models::NetworkResource>, Error>> + Send>> {
164        let mut req = __internal_request::Request::new(hyper::Method::GET, "/networks".to_string());
165        if let Some(ref s) = filters {
166            let query_value = s.to_string();
167            req = req.with_query_param("filters".to_string(), query_value);
168        }
169
170        req.execute(self.configuration.borrow())
171    }
172
173    #[allow(unused_mut)]
174    fn network_prune(
175        &self,
176        filters: Option<&str>,
177    ) -> Pin<Box<dyn Future<Output = Result<models::NetworkPrune200Response, Error>> + Send>> {
178        let mut req =
179            __internal_request::Request::new(hyper::Method::POST, "/networks/prune".to_string());
180        if let Some(ref s) = filters {
181            let query_value = s.to_string();
182            req = req.with_query_param("filters".to_string(), query_value);
183        }
184
185        req.execute(self.configuration.borrow())
186    }
187}