use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct IpAddressManagementPrefixesListPrefixes<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
}
impl<'a> IpAddressManagementPrefixesListPrefixes<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_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 } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes",
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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ip_address_management_prefixes_list_prefixes",
};
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 IpAddressManagementPrefixesAddPrefix<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
body: Result<types::builder::IpAddressManagementPrefixesAddPrefixBody, String>,
}
impl<'a> IpAddressManagementPrefixesAddPrefix<'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::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::IpAddressManagementPrefixesAddPrefixBody>,
<V as std::convert::TryInto<types::IpAddressManagementPrefixesAddPrefixBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `IpAddressManagementPrefixesAddPrefixBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::IpAddressManagementPrefixesAddPrefixBody,
)
-> types::builder::IpAddressManagementPrefixesAddPrefixBody,
{
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::IpAddressManagementPrefixesAddPrefixBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes",
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: "ip_address_management_prefixes_add_prefix",
};
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() {
201u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct IpAddressManagementPrefixesPrefixDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
prefix_id: Result<types::AddressingPrefixIdentifier, String>,
}
impl<'a> IpAddressManagementPrefixesPrefixDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
prefix_id: Err("prefix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingPrefixIdentifier>,
{
self.prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingPrefixIdentifier` for prefix_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,
prefix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let prefix_id = prefix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&prefix_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: "ip_address_management_prefixes_prefix_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 IpAddressManagementPrefixesDeletePrefix<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
prefix_id: Result<types::AddressingPrefixIdentifier, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> IpAddressManagementPrefixesDeletePrefix<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
prefix_id: Err("prefix_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::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingPrefixIdentifier>,
{
self.prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingPrefixIdentifier` for prefix_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,
prefix_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let prefix_id = prefix_id.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&prefix_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: "ip_address_management_prefixes_delete_prefix",
};
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 IpAddressManagementPrefixesListBgpPrefixes<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
prefix_id: Result<types::AddressingPrefixIdentifier, String>,
}
impl<'a> IpAddressManagementPrefixesListBgpPrefixes<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
prefix_id: Err("prefix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingPrefixIdentifier>,
{
self.prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingPrefixIdentifier` for prefix_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,
prefix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let prefix_id = prefix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes/{}/bgp/prefixes",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&prefix_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: "ip_address_management_prefixes_list_bgp_prefixes",
};
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 IpAddressManagementPrefixesCreateBgpPrefix<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
prefix_id: Result<types::AddressingPrefixIdentifier, String>,
body: Result<types::builder::AddressingBgpPrefixCreate, String>,
}
impl<'a> IpAddressManagementPrefixesCreateBgpPrefix<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
prefix_id: Err("prefix_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::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingPrefixIdentifier>,
{
self.prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingPrefixIdentifier` for prefix_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingBgpPrefixCreate>,
<V as std::convert::TryInto<types::AddressingBgpPrefixCreate>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AddressingBgpPrefixCreate` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AddressingBgpPrefixCreate,
) -> types::builder::AddressingBgpPrefixCreate,
{
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,
prefix_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let prefix_id = prefix_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AddressingBgpPrefixCreate::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes/{}/bgp/prefixes",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&prefix_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: "ip_address_management_prefixes_create_bgp_prefix",
};
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 IpAddressManagementPrefixesFetchBgpPrefix<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
prefix_id: Result<types::AddressingPrefixIdentifier, String>,
bgp_prefix_id: Result<types::AddressingBgpPrefixIdentifier, String>,
}
impl<'a> IpAddressManagementPrefixesFetchBgpPrefix<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
prefix_id: Err("prefix_id was not initialized".to_string()),
bgp_prefix_id: Err("bgp_prefix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingPrefixIdentifier>,
{
self.prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingPrefixIdentifier` for prefix_id failed".to_string()
});
self
}
pub fn bgp_prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingBgpPrefixIdentifier>,
{
self.bgp_prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingBgpPrefixIdentifier` for bgp_prefix_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,
prefix_id,
bgp_prefix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let prefix_id = prefix_id.map_err(Error::InvalidRequest)?;
let bgp_prefix_id = bgp_prefix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes/{}/bgp/prefixes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&prefix_id.to_string()),
encode_path(&bgp_prefix_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: "ip_address_management_prefixes_fetch_bgp_prefix",
};
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 IpAddressManagementPrefixesDeleteBgpPrefix<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
prefix_id: Result<types::AddressingPrefixIdentifier, String>,
bgp_prefix_id: Result<types::AddressingBgpPrefixIdentifier, String>,
}
impl<'a> IpAddressManagementPrefixesDeleteBgpPrefix<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
prefix_id: Err("prefix_id was not initialized".to_string()),
bgp_prefix_id: Err("bgp_prefix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingPrefixIdentifier>,
{
self.prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingPrefixIdentifier` for prefix_id failed".to_string()
});
self
}
pub fn bgp_prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingBgpPrefixIdentifier>,
{
self.bgp_prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingBgpPrefixIdentifier` for bgp_prefix_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,
prefix_id,
bgp_prefix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let prefix_id = prefix_id.map_err(Error::InvalidRequest)?;
let bgp_prefix_id = bgp_prefix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes/{}/bgp/prefixes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&prefix_id.to_string()),
encode_path(&bgp_prefix_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: "ip_address_management_prefixes_delete_bgp_prefix",
};
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 IpAddressManagementPrefixesUpdateBgpPrefix<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
prefix_id: Result<types::AddressingPrefixIdentifier, String>,
bgp_prefix_id: Result<types::AddressingBgpPrefixIdentifier, String>,
body: Result<types::builder::AddressingBgpPrefixUpdateAdvertisement, String>,
}
impl<'a> IpAddressManagementPrefixesUpdateBgpPrefix<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
prefix_id: Err("prefix_id was not initialized".to_string()),
bgp_prefix_id: Err("bgp_prefix_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::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingPrefixIdentifier>,
{
self.prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingPrefixIdentifier` for prefix_id failed".to_string()
});
self
}
pub fn bgp_prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingBgpPrefixIdentifier>,
{
self.bgp_prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingBgpPrefixIdentifier` for bgp_prefix_id failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingBgpPrefixUpdateAdvertisement>,
<V as std::convert::TryInto<types::AddressingBgpPrefixUpdateAdvertisement>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `AddressingBgpPrefixUpdateAdvertisement` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::AddressingBgpPrefixUpdateAdvertisement,
)
-> types::builder::AddressingBgpPrefixUpdateAdvertisement,
{
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,
prefix_id,
bgp_prefix_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let prefix_id = prefix_id.map_err(Error::InvalidRequest)?;
let bgp_prefix_id = bgp_prefix_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::AddressingBgpPrefixUpdateAdvertisement::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes/{}/bgp/prefixes/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&prefix_id.to_string()),
encode_path(&bgp_prefix_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: "ip_address_management_prefixes_update_bgp_prefix",
};
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 IpAddressManagementPrefixesValidatePrefix<'a> {
client: &'a crate::Client,
account_id: Result<types::AddressingAccountIdentifier, String>,
prefix_id: Result<types::AddressingPrefixIdentifier, String>,
}
impl<'a> IpAddressManagementPrefixesValidatePrefix<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
prefix_id: Err("prefix_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingAccountIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `AddressingAccountIdentifier` for account_id failed".to_string()
});
self
}
pub fn prefix_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::AddressingPrefixIdentifier>,
{
self.prefix_id = value.try_into().map_err(|_| {
"conversion to `AddressingPrefixIdentifier` for prefix_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,
prefix_id,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let prefix_id = prefix_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/addressing/prefixes/{}/validate",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&prefix_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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ip_address_management_prefixes_validate_prefix",
};
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() {
202u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct IpAccessRulesForAZoneListIpAccessRules<'a> {
client: &'a crate::Client,
zone_id: Result<types::FirewallIdentifier, String>,
configuration_target:
Result<types::IpAccessRulesForAZoneListIpAccessRulesConfigurationTarget, String>,
configuration_value: Result<::std::string::String, String>,
direction: Result<types::IpAccessRulesForAZoneListIpAccessRulesDirection, String>,
pattern: Result<types::IpAccessRulesForAZoneListIpAccessRulesMatch, String>,
mode: Result<types::FirewallSchemasMode, String>,
notes: Result<::std::string::String, String>,
order: Result<types::IpAccessRulesForAZoneListIpAccessRulesOrder, String>,
page: Result<f64, String>,
per_page: Result<f64, String>,
}
impl<'a> IpAccessRulesForAZoneListIpAccessRules<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
configuration_target: Err("configuration_target was not initialized".to_string()),
configuration_value: Err("configuration_value was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
pattern: Err("pattern was not initialized".to_string()),
mode: Err("mode was not initialized".to_string()),
notes: Err("notes was not initialized".to_string()),
order: Err("order was not initialized".to_string()),
page: Err("page was not initialized".to_string()),
per_page: Err("per_page was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallIdentifier>,
{
self.zone_id = value
.try_into()
.map_err(|_| "conversion to `FirewallIdentifier` for zone_id failed".to_string());
self
}
pub fn configuration_target<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<
types::IpAccessRulesForAZoneListIpAccessRulesConfigurationTarget,
>,
{
self . configuration_target = value . try_into () . map_err (| _ | "conversion to `IpAccessRulesForAZoneListIpAccessRulesConfigurationTarget` for configuration_target failed" . to_string ()) ;
self
}
pub fn configuration_value<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.configuration_value = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for configuration_value failed"
.to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::IpAccessRulesForAZoneListIpAccessRulesDirection>,
{
self . direction = value . try_into () . map_err (| _ | "conversion to `IpAccessRulesForAZoneListIpAccessRulesDirection` for direction failed" . to_string ()) ;
self
}
pub fn pattern<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::IpAccessRulesForAZoneListIpAccessRulesMatch>,
{
self.pattern = value.try_into().map_err(|_| {
"conversion to `IpAccessRulesForAZoneListIpAccessRulesMatch` for pattern failed"
.to_string()
});
self
}
pub fn mode<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::FirewallSchemasMode>,
{
self.mode = value
.try_into()
.map_err(|_| "conversion to `FirewallSchemasMode` for mode failed".to_string());
self
}
pub fn notes<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.notes = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for notes failed".to_string()
});
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::IpAccessRulesForAZoneListIpAccessRulesOrder>,
{
self.order = value.try_into().map_err(|_| {
"conversion to `IpAccessRulesForAZoneListIpAccessRulesOrder` for order failed"
.to_string()
});
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `f64` for page failed".to_string());
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `f64` for per_page 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,
configuration_target,
configuration_value,
direction,
pattern,
mode,
notes,
order,
page,
per_page,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let configuration_target = configuration_target.map_err(Error::InvalidRequest)?;
let configuration_value = configuration_value.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let pattern = pattern.map_err(Error::InvalidRequest)?;
let mode = mode.map_err(Error::InvalidRequest)?;
let notes = notes.map_err(Error::InvalidRequest)?;
let order = order.map_err(Error::InvalidRequest)?;
let page = page.map_err(Error::InvalidRequest)?;
let per_page = per_page.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/firewall/access_rules/rules",
client.baseurl,
encode_path(&zone_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(
"configuration.target",
&configuration_target,
))
.query(&progenitor_client::QueryParam::new(
"configuration.value",
&configuration_value,
))
.query(&progenitor_client::QueryParam::new("direction", &direction))
.query(&progenitor_client::QueryParam::new("match", &pattern))
.query(&progenitor_client::QueryParam::new("mode", &mode))
.query(&progenitor_client::QueryParam::new("notes", ¬es))
.query(&progenitor_client::QueryParam::new("order", &order))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "ip_access_rules_for_a_zone_list_ip_access_rules",
};
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)),
}
}
}