use std::borrow::Borrow;
use std::rc::Rc;
use futures;
use futures::Future;
use hyper;
use super::{configuration, put, query, Error};
pub struct WormApiClient<C: hyper::client::connect::Connect> {
configuration: Rc<configuration::Configuration<C>>,
}
impl<C: hyper::client::connect::Connect> WormApiClient<C> {
pub fn new(configuration: Rc<configuration::Configuration<C>>) -> WormApiClient<C> {
WormApiClient {
configuration: configuration,
}
}
}
pub trait WormApi {
fn create_worm_domain(
&self,
worm_domain: crate::models::WormDomainCreateParams,
) -> Box<dyn Future<Item = crate::models::WormDomainExtended, Error = Error>>;
fn get_worm_domain(
&self,
worm_domain_id: &str,
) -> Box<dyn Future<Item = crate::models::WormDomains, Error = Error>>;
fn get_worm_settings(
&self,
) -> Box<dyn Future<Item = crate::models::WormSettings, Error = Error>>;
fn list_worm_domains(
&self,
sort: &str,
limit: i32,
dir: &str,
resume: &str,
) -> Box<dyn Future<Item = crate::models::WormDomainsExtended, Error = Error>>;
fn update_worm_domain(
&self,
worm_domain: crate::models::WormDomain,
worm_domain_id: &str,
) -> Box<dyn Future<Item = (), Error = Error>>;
fn update_worm_settings(
&self,
worm_settings: crate::models::WormSettingsExtended,
) -> Box<dyn Future<Item = (), Error = Error>>;
}
impl<C: hyper::client::connect::Connect + 'static> WormApi for WormApiClient<C> {
fn create_worm_domain(
&self,
worm_domain: crate::models::WormDomainCreateParams,
) -> Box<dyn Future<Item = crate::models::WormDomainExtended, Error = Error>> {
let uri_str = format!("{}/platform/1/worm/domains", self.configuration.base_path);
query(
self.configuration.borrow(),
&uri_str,
&worm_domain,
hyper::Method::POST,
)
}
fn get_worm_domain(
&self,
worm_domain_id: &str,
) -> Box<dyn Future<Item = crate::models::WormDomains, Error = Error>> {
let uri_str = format!(
"{}/platform/1/worm/domains/{WormDomainId}",
self.configuration.base_path,
WormDomainId = worm_domain_id
);
query(
self.configuration.borrow(),
&uri_str,
&"",
hyper::Method::GET,
)
}
fn get_worm_settings(
&self,
) -> Box<dyn Future<Item = crate::models::WormSettings, Error = Error>> {
let uri_str = format!("{}/platform/1/worm/settings", self.configuration.base_path);
query(
self.configuration.borrow(),
&uri_str,
&"",
hyper::Method::GET,
)
}
fn list_worm_domains(
&self,
sort: &str,
limit: i32,
dir: &str,
resume: &str,
) -> Box<dyn Future<Item = crate::models::WormDomainsExtended, Error = Error>> {
let q = ::url::form_urlencoded::Serializer::new(String::new())
.append_pair("sort", &sort.to_string())
.append_pair("limit", &limit.to_string())
.append_pair("dir", &dir.to_string())
.append_pair("resume", &resume.to_string())
.finish();
let uri_str = format!(
"{}/platform/1/worm/domains?{}",
self.configuration.base_path, q
);
query(
self.configuration.borrow(),
&uri_str,
&"",
hyper::Method::GET,
)
}
fn update_worm_domain(
&self,
worm_domain: crate::models::WormDomain,
worm_domain_id: &str,
) -> Box<dyn Future<Item = (), Error = Error>> {
let uri_str = format!(
"{}/platform/1/worm/domains/{WormDomainId}",
self.configuration.base_path,
WormDomainId = worm_domain_id
);
put(self.configuration.borrow(), &uri_str, &worm_domain)
}
fn update_worm_settings(
&self,
worm_settings: crate::models::WormSettingsExtended,
) -> Box<dyn Future<Item = (), Error = Error>> {
let uri_str = format!("{}/platform/1/worm/settings", self.configuration.base_path);
put(self.configuration.borrow(), &uri_str, &worm_settings)
}
}