#[derive(Debug, Clone)]
pub struct SubnetClient<T> {
client: T,
path: String,
}
impl<T> SubnetClient<T>
where
T: crate::client::Client,
{
pub fn new(client: T, parent_path: &str, subnet: &str) -> Self {
Self {
client,
path: format!("{}/{}", parent_path, subnet),
}
}
}
impl<T> SubnetClient<T>
where
T: crate::client::Client,
{
#[doc = "Delete sdn subnet object configuration."]
#[doc = ""]
#[doc = "Require 'SDN.Allocate' permission on '/sdn/zones/\\<zone\\>/\\<vnet\\>'"]
pub async fn delete(&self, params: DeleteParams) -> Result<(), T::Error> {
let path = self.path.to_string();
self.client.delete(&path, ¶ms).await
}
}
impl<T> SubnetClient<T>
where
T: crate::client::Client,
{
#[doc = "Read sdn subnet configuration."]
#[doc = ""]
#[doc = "Require 'SDN.Audit' or 'SDN.Allocate' permissions on '/sdn/zones/\\<zone\\>/\\<vnet\\>'"]
pub async fn get(&self, params: GetParams) -> Result<GetOutput, T::Error> {
let path = self.path.to_string();
self.client.get(&path, ¶ms).await
}
}
impl<T> SubnetClient<T>
where
T: crate::client::Client,
{
#[doc = "Update sdn subnet object configuration."]
#[doc = ""]
#[doc = "Require 'SDN.Allocate' permission 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 DeleteParams {
#[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(
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 GetOutput {
#[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(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Display pending config."]
#[doc = ""]
pub pending: Option<bool>,
#[serde(
serialize_with = "crate::types::serialize_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Display running config."]
#[doc = ""]
pub running: Option<bool>,
#[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<DeleteStr>,
#[serde(rename = "dhcp-dns-server")]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "IP address for the DNS server"]
#[doc = ""]
pub dhcp_dns_server: Option<::std::net::IpAddr>,
#[serde(rename = "dhcp-range")]
#[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
#[doc = "A list of DHCP ranges for this subnet"]
#[doc = ""]
pub dhcp_range: Vec<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(skip_serializing_if = "Option::is_none", default)]
#[doc = "dns domain zone prefix ex: 'adm' -\\\\> \\\\<hostname\\\\>.adm.mydomain.com"]
#[doc = ""]
pub dnszoneprefix: Option<String>,
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "Subnet Gateway: Will be assign on vnet for layer3 zones"]
#[doc = ""]
pub gateway: Option<::std::net::IpAddr>,
#[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_bool_optional",
deserialize_with = "crate::types::deserialize_bool_optional"
)]
#[serde(skip_serializing_if = "Option::is_none", default)]
#[doc = "enable masquerade for this subnet if pve-firewall"]
#[doc = ""]
pub snat: Option<bool>,
#[serde(
flatten,
default,
skip_serializing_if = "::std::collections::HashMap::is_empty"
)]
pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct DeleteStr {
value: String,
}
impl crate::types::bounded_string::BoundedString for DeleteStr {
const MIN_LENGTH: Option<usize> = None::<usize>;
const MAX_LENGTH: Option<usize> = Some(4096usize);
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 4096";
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 DeleteStr {
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 DeleteStr {
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 DeleteStr {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
crate::types::bounded_string::deserialize_bounded_string(deserializer)
}
}
#[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)
}
}