use std::borrow::Borrow;
#[allow(unused_imports)]
use std::option::Option;
use std::pin::Pin;
use std::sync::Arc;
use futures::Future;
use hyper;
use hyper_util::client::legacy::connect::Connect;
use super::request as __internal_request;
use super::{configuration, Error};
use crate::models;
pub struct ExecApiClient<C: Connect>
where
C: Clone + std::marker::Send + Sync + 'static,
{
configuration: Arc<configuration::Configuration<C>>,
}
impl<C: Connect> ExecApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
pub fn new(configuration: Arc<configuration::Configuration<C>>) -> ExecApiClient<C> {
ExecApiClient { configuration }
}
}
pub trait ExecApi: Send + Sync {
fn container_exec_libpod(
&self,
name: &str,
control: Option<models::ContainerExecRequest>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
fn exec_inspect_libpod(
&self,
id: &str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
fn exec_resize_libpod(
&self,
id: &str,
h: Option<i32>,
w: Option<i32>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
fn exec_start_libpod(
&self,
id: &str,
control: Option<models::ExecStartLibpodRequest>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>;
}
impl<C: Connect> ExecApi for ExecApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
#[allow(unused_mut)]
fn container_exec_libpod(
&self,
name: &str,
control: Option<models::ContainerExecRequest>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/libpod/containers/{name}/exec".to_string(),
);
req = req.with_path_param("name".to_string(), name.to_string());
req = req.with_body_param(control);
req = req.returns_nothing();
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn exec_inspect_libpod(
&self,
id: &str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
let mut req = __internal_request::Request::new(
hyper::Method::GET,
"/libpod/exec/{id}/json".to_string(),
);
req = req.with_path_param("id".to_string(), id.to_string());
req = req.returns_nothing();
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn exec_resize_libpod(
&self,
id: &str,
h: Option<i32>,
w: Option<i32>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/libpod/exec/{id}/resize".to_string(),
);
if let Some(ref s) = h {
let query_value = s.to_string();
req = req.with_query_param("h".to_string(), query_value);
}
if let Some(ref s) = w {
let query_value = s.to_string();
req = req.with_query_param("w".to_string(), query_value);
}
req = req.with_path_param("id".to_string(), id.to_string());
req = req.returns_nothing();
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn exec_start_libpod(
&self,
id: &str,
control: Option<models::ExecStartLibpodRequest>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/libpod/exec/{id}/start".to_string(),
);
req = req.with_path_param("id".to_string(), id.to_string());
req = req.with_body_param(control);
req = req.returns_nothing();
req.execute(self.configuration.borrow())
}
}