use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct PerHostnameTlsSettingsList<'a> {
client: &'a crate::Client,
zone_id: Result<types::TlsCertificatesAndHostnamesIdentifier, String>,
setting_id: Result<types::TlsCertificatesAndHostnamesSettingId, String>,
}
impl<'a> PerHostnameTlsSettingsList<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
setting_id: Err("setting_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 setting_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesSettingId>,
{
self.setting_id = value.try_into().map_err(|_| {
"conversion to `TlsCertificatesAndHostnamesSettingId` for setting_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,
setting_id,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let setting_id = setting_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/hostnames/settings/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&setting_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: "per_hostname_tls_settings_list",
};
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 PerHostnameTlsSettingsGet<'a> {
client: &'a crate::Client,
zone_id: Result<types::TlsCertificatesAndHostnamesIdentifier, String>,
setting_id: Result<types::TlsCertificatesAndHostnamesSettingId, String>,
hostname: Result<types::TlsCertificatesAndHostnamesComponentsSchemasHostname, String>,
}
impl<'a> PerHostnameTlsSettingsGet<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
setting_id: Err("setting_id was not initialized".to_string()),
hostname: Err("hostname 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 setting_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesSettingId>,
{
self.setting_id = value.try_into().map_err(|_| {
"conversion to `TlsCertificatesAndHostnamesSettingId` for setting_id failed"
.to_string()
});
self
}
pub fn hostname<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesComponentsSchemasHostname>,
{
self . hostname = value . try_into () . map_err (| _ | "conversion to `TlsCertificatesAndHostnamesComponentsSchemasHostname` for hostname 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,
setting_id,
hostname,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let setting_id = setting_id.map_err(Error::InvalidRequest)?;
let hostname = hostname.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/hostnames/settings/{}/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&setting_id.to_string()),
encode_path(&hostname.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: "per_hostname_tls_settings_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 PerHostnameTlsSettingsPut<'a> {
client: &'a crate::Client,
zone_id: Result<types::TlsCertificatesAndHostnamesIdentifier, String>,
setting_id: Result<types::TlsCertificatesAndHostnamesSettingId, String>,
hostname: Result<types::TlsCertificatesAndHostnamesComponentsSchemasHostname, String>,
body: Result<types::builder::PerHostnameTlsSettingsPutBody, String>,
}
impl<'a> PerHostnameTlsSettingsPut<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
setting_id: Err("setting_id was not initialized".to_string()),
hostname: Err("hostname was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
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 setting_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesSettingId>,
{
self.setting_id = value.try_into().map_err(|_| {
"conversion to `TlsCertificatesAndHostnamesSettingId` for setting_id failed"
.to_string()
});
self
}
pub fn hostname<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesComponentsSchemasHostname>,
{
self . hostname = value . try_into () . map_err (| _ | "conversion to `TlsCertificatesAndHostnamesComponentsSchemasHostname` for hostname failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::PerHostnameTlsSettingsPutBody>,
<V as std::convert::TryInto<types::PerHostnameTlsSettingsPutBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `PerHostnameTlsSettingsPutBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::PerHostnameTlsSettingsPutBody,
) -> types::builder::PerHostnameTlsSettingsPutBody,
{
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,
zone_id,
setting_id,
hostname,
body,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let setting_id = setting_id.map_err(Error::InvalidRequest)?;
let hostname = hostname.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::PerHostnameTlsSettingsPutBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/hostnames/settings/{}/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&setting_id.to_string()),
encode_path(&hostname.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
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "per_hostname_tls_settings_put",
};
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 PerHostnameTlsSettingsDelete<'a> {
client: &'a crate::Client,
zone_id: Result<types::TlsCertificatesAndHostnamesIdentifier, String>,
setting_id: Result<types::TlsCertificatesAndHostnamesSettingId, String>,
hostname: Result<types::TlsCertificatesAndHostnamesComponentsSchemasHostname, String>,
}
impl<'a> PerHostnameTlsSettingsDelete<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
zone_id: Err("zone_id was not initialized".to_string()),
setting_id: Err("setting_id was not initialized".to_string()),
hostname: Err("hostname 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 setting_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesSettingId>,
{
self.setting_id = value.try_into().map_err(|_| {
"conversion to `TlsCertificatesAndHostnamesSettingId` for setting_id failed"
.to_string()
});
self
}
pub fn hostname<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::TlsCertificatesAndHostnamesComponentsSchemasHostname>,
{
self . hostname = value . try_into () . map_err (| _ | "conversion to `TlsCertificatesAndHostnamesComponentsSchemasHostname` for hostname 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,
setting_id,
hostname,
} = self;
let zone_id = zone_id.map_err(Error::InvalidRequest)?;
let setting_id = setting_id.map_err(Error::InvalidRequest)?;
let hostname = hostname.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/zones/{}/hostnames/settings/{}/{}",
client.baseurl,
encode_path(&zone_id.to_string()),
encode_path(&setting_id.to_string()),
encode_path(&hostname.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: "per_hostname_tls_settings_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)),
}
}
}