#[derive(Debug, Clone)]
pub struct OptionsClient<T> {
client: T,
path: String,
}
impl<T> OptionsClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str) -> Self {
Self {
client,
path: format!("{}{}", parent_path, "/options"),
}
}
}
impl<T> OptionsClient<T>
where
T: crate::client::Client,
{
#[doc = "Get vnet firewall options."]
#[doc = ""]
#[doc = "Needs SDN.Audit or SDN.Allocate permissions on '/sdn/zones/\\<zone\\>/\\<vnet\\>'"]
pub async fn get(&self) -> Result<GetOutput, T::Error> {
let path = self.path.to_string();
self.client.get(&path, &()).await
}
}
impl<T> OptionsClient<T>
where
T: crate::client::Client,
{
#[doc = "Set Firewall options."]
#[doc = ""]
#[doc = "Needs SDN.Allocate permissions on '/sdn/zones/\\<zone\\>/\\<vnet\\>'"]
pub async fn put(&self, params: PutParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.put(&path, ¶ms).await
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
pub struct GetOutput {
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Enable/disable firewall rules."]
#[doc = ""]
pub enable: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Log level for forwarded traffic."]
#[doc = ""]
pub log_level_forward: Option<LogLevelForward>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Forward policy."]
#[doc = ""]
pub policy_forward: Option<PolicyForward>,
#[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 PutParams {
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "A list of settings you want to delete."]
#[doc = ""]
pub delete: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
#[doc = ""]
pub digest: Option<DigestStr>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Enable/disable firewall rules."]
#[doc = ""]
pub enable: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Log level for forwarded traffic."]
#[doc = ""]
pub log_level_forward: Option<LogLevelForward>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Forward policy."]
#[doc = ""]
pub policy_forward: Option<PolicyForward>,
#[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 = "Log level for forwarded traffic."]
#[doc = ""]
pub enum LogLevelForward {
#[serde(rename = "alert")]
Alert,
#[serde(rename = "crit")]
Crit,
#[serde(rename = "debug")]
Debug,
#[serde(rename = "emerg")]
Emerg,
#[serde(rename = "err")]
Err,
#[serde(rename = "info")]
Info,
#[serde(rename = "nolog")]
Nolog,
#[serde(rename = "notice")]
Notice,
#[serde(rename = "warning")]
Warning,
}
impl TryFrom<&str> for LogLevelForward {
type Error = String;
fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
match value {
"alert" => Ok(Self::Alert),
"crit" => Ok(Self::Crit),
"debug" => Ok(Self::Debug),
"emerg" => Ok(Self::Emerg),
"err" => Ok(Self::Err),
"info" => Ok(Self::Info),
"nolog" => Ok(Self::Nolog),
"notice" => Ok(Self::Notice),
"warning" => Ok(Self::Warning),
v => Err(format!("Unknown variant {v}")),
}
}
}
#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
#[doc = "Forward policy."]
#[doc = ""]
pub enum PolicyForward {
ACCEPT,
DROP,
}
impl TryFrom<&str> for PolicyForward {
type Error = String;
fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
match value {
"ACCEPT" => Ok(Self::ACCEPT),
"DROP" => Ok(Self::DROP),
v => Err(format!("Unknown variant {v}")),
}
}
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct DigestStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for DigestStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(64usize);
const DEFAULT: Option<&'static str> = None::<&'static str>;
const PATTERN: Option<&'static str> = None::<&'static str>;
const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
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 DigestStr {
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 DigestStr {
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 DigestStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}