proxmox_api/generated/cluster/firewall/
aliases.rs1pub mod name;
2#[derive(Debug, Clone)]
3pub struct AliasesClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> AliasesClient<T>
8where
9 T: crate::client::Client,
10{
11 pub fn new(client: T, parent_path: &str) -> Self {
12 Self {
13 client,
14 path: format!("{}{}", parent_path, "/aliases"),
15 }
16 }
17}
18impl<T> AliasesClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "List aliases"]
23 #[doc = ""]
24 #[doc = "Permission check: perm(\"/\", [\"Sys.Audit\"])"]
25 pub async fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
26 let path = self.path.to_string();
27 let optional_vec: Option<Vec<GetOutputItems>> = self.client.get(&path, &()).await?;
28 Ok(optional_vec.unwrap_or_default())
29 }
30}
31impl<T> AliasesClient<T>
32where
33 T: crate::client::Client,
34{
35 #[doc = "Create IP or Network Alias."]
36 #[doc = ""]
37 #[doc = "Permission check: perm(\"/\", [\"Sys.Modify\"])"]
38 pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
39 let path = self.path.to_string();
40 self.client.post(&path, ¶ms).await
41 }
42}
43impl GetOutputItems {
44 pub fn new(cidr: String, digest: DigestStr, name: String) -> Self {
45 Self {
46 cidr,
47 digest,
48 name,
49 comment: ::std::default::Default::default(),
50 additional_properties: ::std::default::Default::default(),
51 }
52 }
53}
54#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
55pub struct GetOutputItems {
56 pub cidr: String,
57 #[serde(skip_serializing_if = "Option::is_none", default)]
58 pub comment: Option<String>,
59 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
60 #[doc = ""]
61 pub digest: DigestStr,
62 pub name: String,
63 #[serde(
64 flatten,
65 default,
66 skip_serializing_if = "::std::collections::HashMap::is_empty"
67 )]
68 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
69}
70impl PostParams {
71 pub fn new(cidr: String, name: NameStr) -> Self {
72 Self {
73 cidr,
74 name,
75 comment: ::std::default::Default::default(),
76 additional_properties: ::std::default::Default::default(),
77 }
78 }
79}
80#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
81pub struct PostParams {
82 #[doc = "Network/IP specification in CIDR format."]
83 #[doc = ""]
84 pub cidr: String,
85 #[serde(skip_serializing_if = "Option::is_none", default)]
86 pub comment: Option<String>,
87 #[doc = "Alias name."]
88 #[doc = ""]
89 pub name: NameStr,
90 #[serde(
91 flatten,
92 default,
93 skip_serializing_if = "::std::collections::HashMap::is_empty"
94 )]
95 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
96}
97#[derive(Debug, Clone, PartialEq, PartialOrd)]
98pub struct DigestStr {
99 value: String,
100}
101impl crate::types::bounded_string::BoundedString for DigestStr {
102 const MIN_LENGTH: Option<usize> = None::<usize>;
103 const MAX_LENGTH: Option<usize> = Some(64usize);
104 const DEFAULT: Option<&'static str> = None::<&'static str>;
105 const PATTERN: Option<&'static str> = None::<&'static str>;
106 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
107 fn get_value(&self) -> &str {
108 &self.value
109 }
110 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
111 Self::validate(&value)?;
112 Ok(Self { value })
113 }
114}
115impl std::convert::TryFrom<String> for DigestStr {
116 type Error = crate::types::bounded_string::BoundedStringError;
117 fn try_from(value: String) -> Result<Self, Self::Error> {
118 crate::types::bounded_string::BoundedString::new(value)
119 }
120}
121impl ::serde::Serialize for DigestStr {
122 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
123 where
124 S: ::serde::Serializer,
125 {
126 crate::types::bounded_string::serialize_bounded_string(self, serializer)
127 }
128}
129impl<'de> ::serde::Deserialize<'de> for DigestStr {
130 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
131 where
132 D: ::serde::Deserializer<'de>,
133 {
134 crate::types::bounded_string::deserialize_bounded_string(deserializer)
135 }
136}
137#[derive(Debug, Clone, PartialEq, PartialOrd)]
138pub struct NameStr {
139 value: String,
140}
141impl crate::types::bounded_string::BoundedString for NameStr {
142 const MIN_LENGTH: Option<usize> = Some(2usize);
143 const MAX_LENGTH: Option<usize> = Some(64usize);
144 const DEFAULT: Option<&'static str> = None::<&'static str>;
145 const PATTERN: Option<&'static str> = Some("[A-Za-z][A-Za-z0-9\\-\\_]+");
146 const TYPE_DESCRIPTION: &'static str =
147 "a string with pattern r\"[A-Za-z][A-Za-z0-9\\-\\_]+\" and length between 2 and 64";
148 fn get_value(&self) -> &str {
149 &self.value
150 }
151 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
152 Self::validate(&value)?;
153 Ok(Self { value })
154 }
155}
156impl std::convert::TryFrom<String> for NameStr {
157 type Error = crate::types::bounded_string::BoundedStringError;
158 fn try_from(value: String) -> Result<Self, Self::Error> {
159 crate::types::bounded_string::BoundedString::new(value)
160 }
161}
162impl ::serde::Serialize for NameStr {
163 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
164 where
165 S: ::serde::Serializer,
166 {
167 crate::types::bounded_string::serialize_bounded_string(self, serializer)
168 }
169}
170impl<'de> ::serde::Deserialize<'de> for NameStr {
171 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
172 where
173 D: ::serde::Deserializer<'de>,
174 {
175 crate::types::bounded_string::deserialize_bounded_string(deserializer)
176 }
177}
178impl<T> AliasesClient<T>
179where
180 T: crate::client::Client,
181{
182 pub fn name(&self, name: &str) -> name::NameClient<T> {
183 name::NameClient::<T>::new(self.client.clone(), &self.path, name)
184 }
185}