podman_autogen_api/apis/
exec_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 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}