use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct DnsViewsForAnAccountListInternalDnsViews<'a> {
client: &'a crate::Client,
account_id: Result<types::DnsSettingsIdentifier, String>,
direction: Result<types::DnsSettingsDirection, String>,
pattern: Result<types::DnsSettingsMatch, String>,
name: Result<::std::string::String, String>,
name_contains: Result<::std::string::String, String>,
name_endswith: Result<::std::string::String, String>,
name_exact: Result<::std::string::String, String>,
name_startswith: Result<::std::string::String, String>,
order: Result<types::DnsSettingsOrder, String>,
page: Result<types::DnsSettingsPage, String>,
per_page: Result<types::DnsSettingsPerPage, String>,
zone_id: Result<::std::string::String, String>,
zone_name: Result<::std::string::String, String>,
}
impl<'a> DnsViewsForAnAccountListInternalDnsViews<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
direction: Err("direction was not initialized".to_string()),
pattern: Err("pattern was not initialized".to_string()),
name: Err("name was not initialized".to_string()),
name_contains: Err("name_contains was not initialized".to_string()),
name_endswith: Err("name_endswith was not initialized".to_string()),
name_exact: Err("name_exact was not initialized".to_string()),
name_startswith: Err("name_startswith 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()),
zone_id: Err("zone_id was not initialized".to_string()),
zone_name: Err("zone_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::DnsSettingsIdentifier>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `DnsSettingsIdentifier` for account_id failed".to_string()
});
self
}
pub fn direction<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::DnsSettingsDirection>,
{
self.direction = value.try_into().map_err(|_| {
"conversion to `DnsSettingsDirection` for direction failed".to_string()
});
self
}
pub fn pattern<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::DnsSettingsMatch>,
{
self.pattern = value
.try_into()
.map_err(|_| "conversion to `DnsSettingsMatch` for pattern failed".to_string());
self
}
pub fn name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.name = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for name failed".to_string()
});
self
}
pub fn name_contains<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.name_contains = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for name_contains failed".to_string()
});
self
}
pub fn name_endswith<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.name_endswith = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for name_endswith failed".to_string()
});
self
}
pub fn name_exact<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.name_exact = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for name_exact failed".to_string()
});
self
}
pub fn name_startswith<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.name_startswith = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for name_startswith failed".to_string()
});
self
}
pub fn order<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::DnsSettingsOrder>,
{
self.order = value
.try_into()
.map_err(|_| "conversion to `DnsSettingsOrder` for order failed".to_string());
self
}
pub fn page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::DnsSettingsPage>,
{
self.page = value
.try_into()
.map_err(|_| "conversion to `DnsSettingsPage` for page failed".to_string());
self
}
pub fn per_page<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::DnsSettingsPerPage>,
{
self.per_page = value
.try_into()
.map_err(|_| "conversion to `DnsSettingsPerPage` for per_page failed".to_string());
self
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for zone_id failed".to_string()
});
self
}
pub fn zone_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.zone_name = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for zone_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,
direction,
pattern,
name,
name_contains,
name_endswith,
name_exact,
name_startswith,
order,
page,
per_page,
zone_id,
zone_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let direction = direction.map_err(Error::InvalidRequest)?;
let pattern = pattern.map_err(Error::InvalidRequest)?;
let name = name.map_err(Error::InvalidRequest)?;
let name_contains = name_contains.map_err(Error::InvalidRequest)?;
let name_endswith = name_endswith.map_err(Error::InvalidRequest)?;
let name_exact = name_exact.map_err(Error::InvalidRequest)?;
let name_startswith = name_startswith.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 zone_id = zone_id.map_err(Error::InvalidRequest)?;
let zone_name = zone_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/dns_settings/views",
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("direction", &direction))
.query(&progenitor_client::QueryParam::new("match", &pattern))
.query(&progenitor_client::QueryParam::new("name", &name))
.query(&progenitor_client::QueryParam::new(
"name.contains",
&name_contains,
))
.query(&progenitor_client::QueryParam::new(
"name.endswith",
&name_endswith,
))
.query(&progenitor_client::QueryParam::new(
"name.exact",
&name_exact,
))
.query(&progenitor_client::QueryParam::new(
"name.startswith",
&name_startswith,
))
.query(&progenitor_client::QueryParam::new("order", &order))
.query(&progenitor_client::QueryParam::new("page", &page))
.query(&progenitor_client::QueryParam::new("per_page", &per_page))
.query(&progenitor_client::QueryParam::new("zone_id", &zone_id))
.query(&progenitor_client::QueryParam::new("zone_name", &zone_name))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "dns_views_for_an_account_list_internal_dns_views",
};
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)),
}
}
}