use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct CertificatePacksGetCertificatePack<'a> {
client: &'a crate::Client,
zone_id: Result<types::TlsCertificatesAndHostnamesIdentifier, String>,
certificate_pack_id: Result<types::TlsCertificatesAndHostnamesIdentifier, String>,
}
impl<'a> CertificatePacksGetCertificatePack<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
certificate_pack_id: Err("certificate_pack_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `TlsCertificatesAndHostnamesIdentifier` for zone_id failed"
.to_string()
});
self
}
pub fn certificate_pack_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesIdentifier>,
{
self . certificate_pack_id = value . try_into () . map_err (| _ | "conversion to `TlsCertificatesAndHostnamesIdentifier` for certificate_pack_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,
certificate_pack_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let certificate_pack_id = certificate_pack_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/ssl/certificate_packs/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&certificate_pack_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: "certificate_packs_get_certificate_pack",
};
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 CertificatePacksGetCertificatePackQuotas<'a> {
client: &'a crate::Client,
zone_id: Result<types::TlsCertificatesAndHostnamesIdentifier, String>,
}
impl<'a> CertificatePacksGetCertificatePackQuotas<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
}
}
pub fn zone_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesIdentifier>,
{
self.zone_id = value.try_into().map_err(|_| {
"conversion to `TlsCertificatesAndHostnamesIdentifier` for zone_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 } = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/ssl/certificate_packs/quota",
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"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "certificate_packs_get_certificate_pack_quotas",
};
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)),
}
}
}