pub mod dns;
#[derive(Debug, Clone)]
pub struct DnsClient<T> {
client: T,
path: String,
}
impl<T> DnsClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str) -> Self {
Self {
client,
path: format!("{}{}", parent_path, "/dns"),
}
}
}
impl<T> DnsClient<T>
where
T: crate::client::Client,
{
#[doc = "SDN dns index."]
#[doc = ""]
#[doc = "Only list entries where you have 'SDN.Audit' or 'SDN.Allocate' permissions on '/sdn/dns/\\<dns\\>'"]
pub async fn get(&self, params: GetParams) -> Result<Vec<GetOutputItems>, T::Error> {
let path = self.path.to_string();
let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, ¶ms).await?;
Ok(optional_vec.unwrap_or_default())
}
}
impl<T> DnsClient<T>
where
T: crate::client::Client,
{
#[doc = "Create a new sdn dns object."]
#[doc = ""]
#[doc = "Permission check: perm(\"/sdn/dns\", [\"SDN.Allocate\"])"]
pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.post(&path, ¶ms).await
}
}
impl GetOutputItems {
pub fn new(dns: String, ty: String) -> Self {
Self {
dns,
ty,
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct GetOutputItems {
pub dns: String,
#[serde(rename = "type")]
pub ty: String,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct GetParams {
#[serde(rename = "type")]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Only list sdn dns of specific type"]
#[doc = ""]
pub ty: Option<Type>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
impl PostParams {
pub fn new(dns: String, key: String, ty: Type, url: String) -> Self {
Self {
dns,
key,
ty,
url,
fingerprint: ::std::default::Default::default(),
lock_token: ::std::default::Default::default(),
reversemaskv6: ::std::default::Default::default(),
reversev6mask: ::std::default::Default::default(),
ttl: ::std::default::Default::default(),
additional_properties: ::std::default::Default::default(),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
pub struct PostParams {
#[doc = "The SDN dns object identifier."]
#[doc = ""]
pub dns: String,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Certificate SHA 256 fingerprint."]
#[doc = ""]
pub fingerprint: Option<FingerprintStr>,
pub key: String,
#[serde(rename = "lock-token")]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "the token for unlocking the global SDN configuration"]
#[doc = ""]
pub lock_token: Option<String>,
#[serde(
serialize_with = "crate::types::serialize_int_optional",
deserialize_with = "crate::types::deserialize_int_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
pub reversemaskv6: Option<i64>,
#[serde(
serialize_with = "crate::types::serialize_int_optional",
deserialize_with = "crate::types::deserialize_int_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
pub reversev6mask: Option<i64>,
#[serde(
serialize_with = "crate::types::serialize_int_optional",
deserialize_with = "crate::types::deserialize_int_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ttl: Option<i64>,
#[serde(rename = "type")]
#[doc = "Plugin type."]
#[doc = ""]
pub ty: Type,
pub url: String,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
#[doc = "Only list sdn dns of specific type"]
#[doc = ""]
pub enum Type {
#[serde(rename = "powerdns")]
Powerdns,
}
impl TryFrom<&str> for Type {
type Error = String;
fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
match value {
"powerdns" => Ok(Self::Powerdns),
v => Err(format!("Unknown variant {v}")),
}
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct FingerprintStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for FingerprintStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = None::<usize>;
const DEFAULT: Option<&'static str> = None::<&'static str>;
const PATTERN: Option<&'static str> = Some("([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}");
const TYPE_DESCRIPTION: &'static str =
"a string with pattern r\"([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}\" and no length constraints";
fn get_value(&self) -> &str {
&self.value
}
fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
Self::validate(&value)?;
Ok(Self { value })
}
}
impl std::convert::TryFrom<String> for FingerprintStr {
type Error = crate::types::bounded_string::BoundedStringError;
fn try_from(value: String) -> Result<Self, Self::Error> {
crate::types::bounded_string::BoundedString::new(value)
}
}
impl ::serde::Serialize for FingerprintStr {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ::serde::Serializer,
{
crate::types::bounded_string::serialize_bounded_string(self, serializer)
}
}
impl<'de> ::serde::Deserialize<'de> for FingerprintStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
impl<T> DnsClient<T>
where
T: crate::client::Client,
{
pub fn dns(&self, dns: &str) -> dns::DnsClient<T> {
dns::DnsClient::<T>::new(self.client.clone(), &self.path, dns)
}
}