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 NetworksCompatApiClient<C: Connect>
where
C: Clone + std::marker::Send + Sync + 'static,
{
configuration: Rc<configuration::Configuration<C>>,
}
impl<C: Connect> NetworksCompatApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> NetworksCompatApiClient<C> {
NetworksCompatApiClient { configuration }
}
}
pub trait NetworksCompatApi {
fn network_connect(
&self,
name: &str,
create: Option<models::NetworkConnect>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
fn network_create(
&self,
create: Option<models::NetworkCreateRequest>,
) -> Pin<Box<dyn Future<Output = Result<models::NetworkCreate201Response, Error>>>>;
fn network_delete(&self, name: &str) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
fn network_disconnect(
&self,
name: &str,
create: Option<models::NetworkDisconnect>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>>;
fn network_inspect(
&self,
name: &str,
verbose: Option<bool>,
scope: Option<&str>,
) -> Pin<Box<dyn Future<Output = Result<models::NetworkResource, Error>>>>;
fn network_list(
&self,
filters: Option<&str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<models::NetworkResource>, Error>>>>;
fn network_prune(
&self,
filters: Option<&str>,
) -> Pin<Box<dyn Future<Output = Result<models::NetworkPrune200Response, Error>>>>;
}
impl<C: Connect> NetworksCompatApi for NetworksCompatApiClient<C>
where
C: Clone + std::marker::Send + Sync,
{
#[allow(unused_mut)]
fn network_connect(
&self,
name: &str,
create: Option<models::NetworkConnect>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/networks/{name}/connect".to_string(),
);
req = req.with_path_param("name".to_string(), name.to_string());
req = req.with_body_param(create);
req = req.returns_nothing();
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn network_create(
&self,
create: Option<models::NetworkCreateRequest>,
) -> Pin<Box<dyn Future<Output = Result<models::NetworkCreate201Response, Error>>>> {
let mut req =
__internal_request::Request::new(hyper::Method::POST, "/networks/create".to_string());
req = req.with_body_param(create);
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn network_delete(&self, name: &str) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req =
__internal_request::Request::new(hyper::Method::DELETE, "/networks/{name}".to_string());
req = req.with_path_param("name".to_string(), name.to_string());
req = req.returns_nothing();
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn network_disconnect(
&self,
name: &str,
create: Option<models::NetworkDisconnect>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
let mut req = __internal_request::Request::new(
hyper::Method::POST,
"/networks/{name}/disconnect".to_string(),
);
req = req.with_path_param("name".to_string(), name.to_string());
req = req.with_body_param(create);
req = req.returns_nothing();
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn network_inspect(
&self,
name: &str,
verbose: Option<bool>,
scope: Option<&str>,
) -> Pin<Box<dyn Future<Output = Result<models::NetworkResource, Error>>>> {
let mut req =
__internal_request::Request::new(hyper::Method::GET, "/networks/{name}".to_string());
if let Some(ref s) = verbose {
let query_value = s.to_string();
req = req.with_query_param("verbose".to_string(), query_value);
}
if let Some(ref s) = scope {
let query_value = s.to_string();
req = req.with_query_param("scope".to_string(), query_value);
}
req = req.with_path_param("name".to_string(), name.to_string());
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn network_list(
&self,
filters: Option<&str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<models::NetworkResource>, Error>>>> {
let mut req = __internal_request::Request::new(hyper::Method::GET, "/networks".to_string());
if let Some(ref s) = filters {
let query_value = s.to_string();
req = req.with_query_param("filters".to_string(), query_value);
}
req.execute(self.configuration.borrow())
}
#[allow(unused_mut)]
fn network_prune(
&self,
filters: Option<&str>,
) -> Pin<Box<dyn Future<Output = Result<models::NetworkPrune200Response, Error>>>> {
let mut req =
__internal_request::Request::new(hyper::Method::POST, "/networks/prune".to_string());
if let Some(ref s) = filters {
let query_value = s.to_string();
req = req.with_query_param("filters".to_string(), query_value);
}
req.execute(self.configuration.borrow())
}
}