use std::borrow::Borrow;
#[allow(unused_imports)]
use std::option::Option;
use std::pin::Pin;
use std::rc::Rc;
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 ExecCompatApiClient<C: Connect>
where
C: Clone + std::marker::Send + Sync + 'static,
{
configuration: Rc<configuration::Configuration<C>>,
}
impl<C: Connect> ExecCompatApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> ExecCompatApiClient<C> {
ExecCompatApiClient { configuration }
}
}
pub trait ExecCompatApi {
fn container_exec(
&self,
name: &str,
control: Option<models::ContainerExecRequest>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
fn exec_inspect(
&self,
id: &str,
) -> Pin<Box<dyn Future<Output = Result<models::InspectExecSession, Error>>>>;
fn exec_resize(
&self,
id: &str,
h: Option<i32>,
w: Option<i32>,
running: Option<bool>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
fn exec_start(
&self,
id: &str,
control: Option<models::ExecStartRequest>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
}
impl<C: Connect> ExecCompatApi for ExecCompatApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
#[allow(unused_mut)]
fn container_exec(
&self,
name: &str,
control: Option<models::ContainerExecRequest>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/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(
&self,
id: &str,
) -> Pin<Box<dyn Future<Output = Result<models::InspectExecSession, Error>>>> {
let mut req =
__internal_request::Request::new(hyper::Method::GET, "/exec/{id}/json".to_string());
req = req.with_path_param("id".to_string(), id.to_string());
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn exec_resize(
&self,
id: &str,
h: Option<i32>,
w: Option<i32>,
running: Option<bool>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req =
__internal_request::Request::new(hyper::Method::POST, "/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);
}
if let Some(ref s) = running {
let query_value = s.to_string();
req = req.with_query_param("running".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(
&self,
id: &str,
control: Option<models::ExecStartRequest>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req =
__internal_request::Request::new(hyper::Method::POST, "/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())
}
}