use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct CloudflareIpsCloudflareIpDetails<'a> {
client: &'a crate::Client,
networks: Result<::std::string::String, String>,
}
impl<'a> CloudflareIpsCloudflareIpDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
networks: Err("networks was not initialized".to_string()),
}
}
pub fn networks<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.networks = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for networks failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, networks } = self;
let networks = networks.map_err(Error::InvalidRequest)?;
let url = format!("{}/ips", client.baseurl,);
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("networks", &networks))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "cloudflare_ips_cloudflare_ip_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)),
}
}
}