use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct TunnelRouteGetTunnelRoute<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
route_id: Result<types::TunnelRouteId, String>,
}
impl<'a> TunnelRouteGetTunnelRoute<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
route_id: Err("route_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelRouteId>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `TunnelRouteId` for route_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,
route_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/routes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&route_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: "tunnel_route_get_tunnel_route",
};
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 TunnelRouteDeleteATunnelRoute<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
route_id: Result<types::TunnelRouteId, String>,
}
impl<'a> TunnelRouteDeleteATunnelRoute<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
route_id: Err("route_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelRouteId>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `TunnelRouteId` for route_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,
route_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/routes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&route_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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "tunnel_route_delete_a_tunnel_route",
};
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 TunnelRouteUpdateATunnelRoute<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
route_id: Result<types::TunnelRouteId, String>,
body: Result<types::builder::TunnelRouteUpdateATunnelRouteBody, String>,
}
impl<'a> TunnelRouteUpdateATunnelRoute<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
route_id: Err("route_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn route_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelRouteId>,
{
self.route_id = value
.try_into()
.map_err(|_| "conversion to `TunnelRouteId` for route_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelRouteUpdateATunnelRouteBody>,
<V as std::convert::TryInto<types::TunnelRouteUpdateATunnelRouteBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `TunnelRouteUpdateATunnelRouteBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::TunnelRouteUpdateATunnelRouteBody,
) -> types::builder::TunnelRouteUpdateATunnelRouteBody,
{
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,
account_id,
route_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let route_id = route_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::TunnelRouteUpdateATunnelRouteBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/routes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&route_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: "tunnel_route_update_a_tunnel_route",
};
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 TunnelRouteGetTunnelRouteByIp<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
ip: Result<types::TunnelIp, String>,
default_virtual_network_fallback: Result<bool, String>,
virtual_network_id: Result<types::TunnelVirtualNetworkId, String>,
}
impl<'a> TunnelRouteGetTunnelRouteByIp<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ip: Err("ip was not initialized".to_string()),
default_virtual_network_fallback: Err(
"default_virtual_network_fallback was not initialized".to_string(),
),
virtual_network_id: Err("virtual_network_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn ip<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelIp>,
{
self.ip = value
.try_into()
.map_err(|_| "conversion to `TunnelIp` for ip failed".to_string());
self
}
pub fn default_virtual_network_fallback<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.default_virtual_network_fallback = value.try_into().map_err(|_| {
"conversion to `bool` for default_virtual_network_fallback failed".to_string()
});
self
}
pub fn virtual_network_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkId>,
{
self.virtual_network_id = value.try_into().map_err(|_| {
"conversion to `TunnelVirtualNetworkId` for virtual_network_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,
ip,
default_virtual_network_fallback,
virtual_network_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ip = ip.map_err(Error::InvalidRequest)?;
let default_virtual_network_fallback =
default_virtual_network_fallback.map_err(Error::InvalidRequest)?;
let virtual_network_id = virtual_network_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/routes/ip/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ip.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(
"default_virtual_network_fallback",
&default_virtual_network_fallback,
))
.query(&progenitor_client::QueryParam::new(
"virtual_network_id",
&virtual_network_id,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "tunnel_route_get_tunnel_route_by_ip",
};
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 TunnelRouteCreateATunnelRouteWithCidr<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
ip_network_encoded: Result<types::TunnelIpNetworkEncoded, String>,
body: Result<types::builder::TunnelRouteCreateATunnelRouteWithCidrBody, String>,
}
impl<'a> TunnelRouteCreateATunnelRouteWithCidr<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ip_network_encoded: Err("ip_network_encoded was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn ip_network_encoded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelIpNetworkEncoded>,
{
self.ip_network_encoded = value.try_into().map_err(|_| {
"conversion to `TunnelIpNetworkEncoded` for ip_network_encoded failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelRouteCreateATunnelRouteWithCidrBody>,
<V as std::convert::TryInto<types::TunnelRouteCreateATunnelRouteWithCidrBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `TunnelRouteCreateATunnelRouteWithCidrBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::TunnelRouteCreateATunnelRouteWithCidrBody,
)
-> types::builder::TunnelRouteCreateATunnelRouteWithCidrBody,
{
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,
account_id,
ip_network_encoded,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ip_network_encoded = ip_network_encoded.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::TunnelRouteCreateATunnelRouteWithCidrBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/routes/network/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ip_network_encoded.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: "tunnel_route_create_a_tunnel_route_with_cidr",
};
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 TunnelRouteDeleteATunnelRouteWithCidr<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
ip_network_encoded: Result<types::TunnelIpNetworkEncoded, String>,
tun_type: Result<types::TunnelTunnelType, String>,
tunnel_id: Result<types::TunnelTunnelId, String>,
virtual_network_id: Result<types::TunnelVirtualNetworkId, String>,
}
impl<'a> TunnelRouteDeleteATunnelRouteWithCidr<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ip_network_encoded: Err("ip_network_encoded was not initialized".to_string()),
tun_type: Err("tun_type was not initialized".to_string()),
tunnel_id: Err("tunnel_id was not initialized".to_string()),
virtual_network_id: Err("virtual_network_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn ip_network_encoded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelIpNetworkEncoded>,
{
self.ip_network_encoded = value.try_into().map_err(|_| {
"conversion to `TunnelIpNetworkEncoded` for ip_network_encoded failed".to_string()
});
self
}
pub fn tun_type<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelType>,
{
self.tun_type = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelType` for tun_type failed".to_string());
self
}
pub fn tunnel_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelTunnelId>,
{
self.tunnel_id = value
.try_into()
.map_err(|_| "conversion to `TunnelTunnelId` for tunnel_id failed".to_string());
self
}
pub fn virtual_network_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkId>,
{
self.virtual_network_id = value.try_into().map_err(|_| {
"conversion to `TunnelVirtualNetworkId` for virtual_network_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,
ip_network_encoded,
tun_type,
tunnel_id,
virtual_network_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ip_network_encoded = ip_network_encoded.map_err(Error::InvalidRequest)?;
let tun_type = tun_type.map_err(Error::InvalidRequest)?;
let tunnel_id = tunnel_id.map_err(Error::InvalidRequest)?;
let virtual_network_id = virtual_network_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/routes/network/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ip_network_encoded.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"),
)
.query(&progenitor_client::QueryParam::new("tun_type", &tun_type))
.query(&progenitor_client::QueryParam::new("tunnel_id", &tunnel_id))
.query(&progenitor_client::QueryParam::new(
"virtual_network_id",
&virtual_network_id,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "tunnel_route_delete_a_tunnel_route_with_cidr",
};
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 TunnelRouteUpdateATunnelRouteWithCidr<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
ip_network_encoded: Result<types::TunnelIpNetworkEncoded, String>,
}
impl<'a> TunnelRouteUpdateATunnelRouteWithCidr<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
ip_network_encoded: Err("ip_network_encoded was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn ip_network_encoded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelIpNetworkEncoded>,
{
self.ip_network_encoded = value.try_into().map_err(|_| {
"conversion to `TunnelIpNetworkEncoded` for ip_network_encoded 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,
ip_network_encoded,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let ip_network_encoded = ip_network_encoded.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/routes/network/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&ip_network_encoded.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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "tunnel_route_update_a_tunnel_route_with_cidr",
};
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 TunnelVirtualNetworkListVirtualNetworks<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
id: Result<types::TunnelVirtualNetworkId, String>,
is_default: Result<bool, String>,
is_default_network: Result<bool, String>,
is_deleted: Result<bool, String>,
name: Result<types::TunnelVirtualNetworkName, String>,
}
impl<'a> TunnelVirtualNetworkListVirtualNetworks<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
id: Err("id was not initialized".to_string()),
is_default: Err("is_default was not initialized".to_string()),
is_default_network: Err("is_default_network was not initialized".to_string()),
is_deleted: Err("is_deleted was not initialized".to_string()),
name: Err("name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkId>,
{
self.id = value
.try_into()
.map_err(|_| "conversion to `TunnelVirtualNetworkId` for id failed".to_string());
self
}
pub fn is_default<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_default = value
.try_into()
.map_err(|_| "conversion to `bool` for is_default failed".to_string());
self
}
pub fn is_default_network<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_default_network = value
.try_into()
.map_err(|_| "conversion to `bool` for is_default_network failed".to_string());
self
}
pub fn is_deleted<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.is_deleted = value
.try_into()
.map_err(|_| "conversion to `bool` for is_deleted failed".to_string());
self
}
pub fn name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkName>,
{
self.name = value.try_into().map_err(|_| {
"conversion to `TunnelVirtualNetworkName` for name 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,
id,
is_default,
is_default_network,
is_deleted,
name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let id = id.map_err(Error::InvalidRequest)?;
let is_default = is_default.map_err(Error::InvalidRequest)?;
let is_default_network = is_default_network.map_err(Error::InvalidRequest)?;
let is_deleted = is_deleted.map_err(Error::InvalidRequest)?;
let name = name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/virtual_networks",
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("id", &id))
.query(&progenitor_client::QueryParam::new(
"is_default",
&is_default,
))
.query(&progenitor_client::QueryParam::new(
"is_default_network",
&is_default_network,
))
.query(&progenitor_client::QueryParam::new(
"is_deleted",
&is_deleted,
))
.query(&progenitor_client::QueryParam::new("name", &name))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "tunnel_virtual_network_list_virtual_networks",
};
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 TunnelVirtualNetworkCreateAVirtualNetwork<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
body: Result<types::builder::TunnelVirtualNetworkCreateAVirtualNetworkBody, String>,
}
impl<'a> TunnelVirtualNetworkCreateAVirtualNetwork<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
} pub fn body < V > (mut self , value : V) -> Self where V : std :: convert :: TryInto < types :: TunnelVirtualNetworkCreateAVirtualNetworkBody > , < V as std :: convert :: TryInto < types :: TunnelVirtualNetworkCreateAVirtualNetworkBody >> :: Error : std :: fmt :: Display ,{
self . body = value . try_into () . map (From :: from) . map_err (| s | format ! ("conversion to `TunnelVirtualNetworkCreateAVirtualNetworkBody` for body failed: {}" , s)) ;
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::TunnelVirtualNetworkCreateAVirtualNetworkBody,
)
-> types::builder::TunnelVirtualNetworkCreateAVirtualNetworkBody,
{
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,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::TunnelVirtualNetworkCreateAVirtualNetworkBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/virtual_networks",
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
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "tunnel_virtual_network_create_a_virtual_network",
};
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 TunnelVirtualNetworkGet<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
virtual_network_id: Result<types::TunnelVirtualNetworkId, String>,
body: Result<types::builder::TunnelVirtualNetworkGetBody, String>,
}
impl<'a> TunnelVirtualNetworkGet<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
virtual_network_id: Err("virtual_network_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn virtual_network_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkId>,
{
self.virtual_network_id = value.try_into().map_err(|_| {
"conversion to `TunnelVirtualNetworkId` for virtual_network_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkGetBody>,
<V as std::convert::TryInto<types::TunnelVirtualNetworkGetBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `TunnelVirtualNetworkGetBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::TunnelVirtualNetworkGetBody,
) -> types::builder::TunnelVirtualNetworkGetBody,
{
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,
account_id,
virtual_network_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let virtual_network_id = virtual_network_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::TunnelVirtualNetworkGetBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/virtual_networks/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&virtual_network_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"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "tunnel_virtual_network_get",
};
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 TunnelVirtualNetworkDelete<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
virtual_network_id: Result<types::TunnelVirtualNetworkId, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> TunnelVirtualNetworkDelete<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
virtual_network_id: Err("virtual_network_id was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn virtual_network_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkId>,
{
self.virtual_network_id = value.try_into().map_err(|_| {
"conversion to `TunnelVirtualNetworkId` for virtual_network_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,
account_id,
virtual_network_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let virtual_network_id = virtual_network_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/virtual_networks/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&virtual_network_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: "tunnel_virtual_network_delete",
};
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 TunnelVirtualNetworkUpdate<'a> {
client: &'a crate::Client,
account_id: Result<types::TunnelAccountId, String>,
virtual_network_id: Result<types::TunnelVirtualNetworkId, String>,
body: Result<types::builder::TunnelVirtualNetworkUpdateBody, String>,
}
impl<'a> TunnelVirtualNetworkUpdate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
virtual_network_id: Err("virtual_network_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelAccountId>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `TunnelAccountId` for account_id failed".to_string());
self
}
pub fn virtual_network_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkId>,
{
self.virtual_network_id = value.try_into().map_err(|_| {
"conversion to `TunnelVirtualNetworkId` for virtual_network_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TunnelVirtualNetworkUpdateBody>,
<V as std::convert::TryInto<types::TunnelVirtualNetworkUpdateBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `TunnelVirtualNetworkUpdateBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::TunnelVirtualNetworkUpdateBody,
) -> types::builder::TunnelVirtualNetworkUpdateBody,
{
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,
account_id,
virtual_network_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let virtual_network_id = virtual_network_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::TunnelVirtualNetworkUpdateBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/teamnet/virtual_networks/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&virtual_network_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: "tunnel_virtual_network_update",
};
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)),
}
}
}