use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct LoadBalancerRegionsListRegions<'a> {
client: &'a crate::Client,
account_id: Result<types::LoadBalancingComponentsSchemasIdentifier, String>,
country_code_a2: Result<::std::string::String, String>,
subdivision_code: Result<types::LoadBalancingSubdivisionCodeA2, String>,
subdivision_code_a2: Result<types::LoadBalancingSubdivisionCodeA2, String>,
}
impl<'a> LoadBalancerRegionsListRegions<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
country_code_a2: Err("country_code_a2 was not initialized".to_string()),
subdivision_code: Err("subdivision_code was not initialized".to_string()),
subdivision_code_a2: Err("subdivision_code_a2 was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingComponentsSchemasIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingComponentsSchemasIdentifier` for account_id failed"
.to_string()
});
self
}
pub fn country_code_a2<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.country_code_a2 = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for country_code_a2 failed".to_string()
});
self
}
pub fn subdivision_code<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingSubdivisionCodeA2>,
{
self.subdivision_code = value.try_into().map_err(|_| {
"conversion to `LoadBalancingSubdivisionCodeA2` for subdivision_code failed"
.to_string()
});
self
}
pub fn subdivision_code_a2<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingSubdivisionCodeA2>,
{
self.subdivision_code_a2 = value.try_into().map_err(|_| {
"conversion to `LoadBalancingSubdivisionCodeA2` for subdivision_code_a2 failed"
.to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
country_code_a2,
subdivision_code,
subdivision_code_a2,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let country_code_a2 = country_code_a2.map_err(Error::InvalidRequest)?;
let subdivision_code = subdivision_code.map_err(Error::InvalidRequest)?;
let subdivision_code_a2 = subdivision_code_a2.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/load_balancers/regions",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new(
"country_code_a2",
&country_code_a2,
))
.query(&progenitor_client::QueryParam::new(
"subdivision_code",
&subdivision_code,
))
.query(&progenitor_client::QueryParam::new(
"subdivision_code_a2",
&subdivision_code_a2,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_regions_list_regions",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerRegionsGetRegion<'a> {
client: &'a crate::Client,
account_id: Result<types::LoadBalancingComponentsSchemasIdentifier, String>,
region_id: Result<types::LoadBalancingRegionCode, String>,
}
impl<'a> LoadBalancerRegionsGetRegion<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
region_id: Err("region_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingComponentsSchemasIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingComponentsSchemasIdentifier` for account_id failed"
.to_string()
});
self
}
pub fn region_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingRegionCode>,
{
self.region_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingRegionCode` for region_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
region_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let region_id = region_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/load_balancers/regions/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(®ion_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_regions_get_region",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerMonitorsMonitorDetails<'a> {
client: &'a crate::Client,
monitor_id: Result<types::LoadBalancingIdentifier, String>,
}
impl<'a> LoadBalancerMonitorsMonitorDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
monitor_id: Err("monitor_id was not initialized".to_string()),
}
}
pub fn monitor_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingIdentifier>,
{
self.monitor_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingIdentifier` for monitor_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, monitor_id } = self;
let monitor_id = monitor_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/monitors/{}",
client.baseurl,
encode_path(&monitor_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_monitors_monitor_details",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerMonitorsUpdateMonitor<'a> {
client: &'a crate::Client,
monitor_id: Result<types::LoadBalancingIdentifier, String>,
body: Result<types::builder::LoadBalancingMonitorEditable, String>,
}
impl<'a> LoadBalancerMonitorsUpdateMonitor<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
monitor_id: Err("monitor_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn monitor_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingIdentifier>,
{
self.monitor_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingIdentifier` for monitor_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingMonitorEditable>,
<V as std::convert::TryInto<types::LoadBalancingMonitorEditable>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `LoadBalancingMonitorEditable` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::LoadBalancingMonitorEditable,
) -> types::builder::LoadBalancingMonitorEditable,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
monitor_id,
body,
} = self;
let monitor_id = monitor_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::LoadBalancingMonitorEditable::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/monitors/{}",
client.baseurl,
encode_path(&monitor_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_monitors_update_monitor",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerMonitorsDeleteMonitor<'a> {
client: &'a crate::Client,
monitor_id: Result<types::LoadBalancingIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> LoadBalancerMonitorsDeleteMonitor<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
monitor_id: Err("monitor_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn monitor_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingIdentifier>,
{
self.monitor_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingIdentifier` for monitor_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` for body failed" . to_string ()) ;
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
monitor_id,
body,
} = self;
let monitor_id = monitor_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/monitors/{}",
client.baseurl,
encode_path(&monitor_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_monitors_delete_monitor",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerMonitorsPatchMonitor<'a> {
client: &'a crate::Client,
monitor_id: Result<types::LoadBalancingIdentifier, String>,
body: Result<types::builder::LoadBalancingMonitorEditable, String>,
}
impl<'a> LoadBalancerMonitorsPatchMonitor<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
monitor_id: Err("monitor_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn monitor_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingIdentifier>,
{
self.monitor_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingIdentifier` for monitor_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingMonitorEditable>,
<V as std::convert::TryInto<types::LoadBalancingMonitorEditable>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `LoadBalancingMonitorEditable` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::LoadBalancingMonitorEditable,
) -> types::builder::LoadBalancingMonitorEditable,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
monitor_id,
body,
} = self;
let monitor_id = monitor_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::LoadBalancingMonitorEditable::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/monitors/{}",
client.baseurl,
encode_path(&monitor_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_monitors_patch_monitor",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerMonitorsPreviewMonitor<'a> {
client: &'a crate::Client,
monitor_id: Result<types::LoadBalancingIdentifier, String>,
body: Result<types::builder::LoadBalancingMonitorEditable, String>,
}
impl<'a> LoadBalancerMonitorsPreviewMonitor<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
monitor_id: Err("monitor_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn monitor_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingIdentifier>,
{
self.monitor_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingIdentifier` for monitor_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingMonitorEditable>,
<V as std::convert::TryInto<types::LoadBalancingMonitorEditable>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `LoadBalancingMonitorEditable` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::LoadBalancingMonitorEditable,
) -> types::builder::LoadBalancingMonitorEditable,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
monitor_id,
body,
} = self;
let monitor_id = monitor_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::LoadBalancingMonitorEditable::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/monitors/{}/preview",
client.baseurl,
encode_path(&monitor_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_monitors_preview_monitor",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerMonitorsListMonitorReferences<'a> {
client: &'a crate::Client,
monitor_id: Result<types::LoadBalancingIdentifier, String>,
}
impl<'a> LoadBalancerMonitorsListMonitorReferences<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
monitor_id: Err("monitor_id was not initialized".to_string()),
}
}
pub fn monitor_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingIdentifier>,
{
self.monitor_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingIdentifier` for monitor_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, monitor_id } = self;
let monitor_id = monitor_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/monitors/{}/references",
client.baseurl,
encode_path(&monitor_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_monitors_list_monitor_references",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerPoolsPoolHealthDetails<'a> {
client: &'a crate::Client,
pool_id: Result<types::LoadBalancingSchemasIdentifier, String>,
}
impl<'a> LoadBalancerPoolsPoolHealthDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
pool_id: Err("pool_id was not initialized".to_string()),
}
}
pub fn pool_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingSchemasIdentifier>,
{
self.pool_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingSchemasIdentifier` for pool_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, pool_id } = self;
let pool_id = pool_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/pools/{}/health",
client.baseurl,
encode_path(&pool_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_pools_pool_health_details",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerPoolsPreviewPool<'a> {
client: &'a crate::Client,
pool_id: Result<types::LoadBalancingSchemasIdentifier, String>,
body: Result<types::builder::LoadBalancingMonitorEditable, String>,
}
impl<'a> LoadBalancerPoolsPreviewPool<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
pool_id: Err("pool_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn pool_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingSchemasIdentifier>,
{
self.pool_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingSchemasIdentifier` for pool_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingMonitorEditable>,
<V as std::convert::TryInto<types::LoadBalancingMonitorEditable>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `LoadBalancingMonitorEditable` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::LoadBalancingMonitorEditable,
) -> types::builder::LoadBalancingMonitorEditable,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
pool_id,
body,
} = self;
let pool_id = pool_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::LoadBalancingMonitorEditable::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/pools/{}/preview",
client.baseurl,
encode_path(&pool_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_pools_preview_pool",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancerPoolsListPoolReferences<'a> {
client: &'a crate::Client,
pool_id: Result<types::LoadBalancingSchemasIdentifier, String>,
}
impl<'a> LoadBalancerPoolsListPoolReferences<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
pool_id: Err("pool_id was not initialized".to_string()),
}
}
pub fn pool_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingSchemasIdentifier>,
{
self.pool_id = value.try_into().map_err(|_| {
"conversion to `LoadBalancingSchemasIdentifier` for pool_id failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, pool_id } = self;
let pool_id = pool_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/user/load_balancers/pools/{}/references",
client.baseurl,
encode_path(&pool_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancer_pools_list_pool_references",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancersLoadBalancerDetails<'a> {
client: &'a crate::Client,
zone_id: Result<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier, String>,
load_balancer_id:
Result<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier, String>,
}
impl<'a> LoadBalancersLoadBalancerDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
load_balancer_id: Err("load_balancer_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier>,
{
self . zone_id = value . try_into () . map_err (| _ | "conversion to `LoadBalancingLoadBalancerComponentsSchemasIdentifier` for zone_id failed" . to_string ()) ;
self
}
pub fn load_balancer_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier>,
{
self . load_balancer_id = value . try_into () . map_err (| _ | "conversion to `LoadBalancingLoadBalancerComponentsSchemasIdentifier` for load_balancer_id failed" . to_string ()) ;
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
load_balancer_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let load_balancer_id = load_balancer_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/load_balancers/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&load_balancer_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancers_load_balancer_details",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancersUpdateLoadBalancer<'a> {
client: &'a crate::Client,
zone_id: Result<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier, String>,
load_balancer_id:
Result<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier, String>,
body: Result<types::builder::LoadBalancersUpdateLoadBalancerBody, String>,
}
impl<'a> LoadBalancersUpdateLoadBalancer<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
load_balancer_id: Err("load_balancer_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier>,
{
self . zone_id = value . try_into () . map_err (| _ | "conversion to `LoadBalancingLoadBalancerComponentsSchemasIdentifier` for zone_id failed" . to_string ()) ;
self
}
pub fn load_balancer_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier>,
{
self . load_balancer_id = value . try_into () . map_err (| _ | "conversion to `LoadBalancingLoadBalancerComponentsSchemasIdentifier` for load_balancer_id failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancersUpdateLoadBalancerBody>,
<V as std::convert::TryInto<types::LoadBalancersUpdateLoadBalancerBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `LoadBalancersUpdateLoadBalancerBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::LoadBalancersUpdateLoadBalancerBody,
) -> types::builder::LoadBalancersUpdateLoadBalancerBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
load_balancer_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let load_balancer_id = load_balancer_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::LoadBalancersUpdateLoadBalancerBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/load_balancers/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&load_balancer_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancers_update_load_balancer",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancersDeleteLoadBalancer<'a> {
client: &'a crate::Client,
zone_id: Result<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier, String>,
load_balancer_id:
Result<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> LoadBalancersDeleteLoadBalancer<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
load_balancer_id: Err("load_balancer_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier>,
{
self . zone_id = value . try_into () . map_err (| _ | "conversion to `LoadBalancingLoadBalancerComponentsSchemasIdentifier` for zone_id failed" . to_string ()) ;
self
}
pub fn load_balancer_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier>,
{
self . load_balancer_id = value . try_into () . map_err (| _ | "conversion to `LoadBalancingLoadBalancerComponentsSchemasIdentifier` for load_balancer_id failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` for body failed" . to_string ()) ;
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
load_balancer_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let load_balancer_id = load_balancer_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/load_balancers/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&load_balancer_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancers_delete_load_balancer",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct LoadBalancersPatchLoadBalancer<'a> {
client: &'a crate::Client,
zone_id: Result<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier, String>,
load_balancer_id:
Result<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier, String>,
body: Result<types::builder::LoadBalancersPatchLoadBalancerBody, String>,
}
impl<'a> LoadBalancersPatchLoadBalancer<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
load_balancer_id: Err("load_balancer_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier>,
{
self . zone_id = value . try_into () . map_err (| _ | "conversion to `LoadBalancingLoadBalancerComponentsSchemasIdentifier` for zone_id failed" . to_string ()) ;
self
}
pub fn load_balancer_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancingLoadBalancerComponentsSchemasIdentifier>,
{
self . load_balancer_id = value . try_into () . map_err (| _ | "conversion to `LoadBalancingLoadBalancerComponentsSchemasIdentifier` for load_balancer_id failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::LoadBalancersPatchLoadBalancerBody>,
<V as std::convert::TryInto<types::LoadBalancersPatchLoadBalancerBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `LoadBalancersPatchLoadBalancerBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::LoadBalancersPatchLoadBalancerBody,
) -> types::builder::LoadBalancersPatchLoadBalancerBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
zone_id,
load_balancer_id,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let load_balancer_id = load_balancer_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::LoadBalancersPatchLoadBalancerBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/load_balancers/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&load_balancer_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "load_balancers_patch_load_balancer",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}