proxmox_api/generated/cluster/firewall/
ipset.rs1pub mod name;
2#[derive(Debug, Clone)]
3pub struct IpsetClient<T> {
4 client: T,
5 path: String,
6}
7impl<T> IpsetClient<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, "/ipset"),
15 }
16 }
17}
18impl<T> IpsetClient<T>
19where
20 T: crate::client::Client,
21{
22 #[doc = "List IPSets"]
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> IpsetClient<T>
32where
33 T: crate::client::Client,
34{
35 #[doc = "Create new IPSet"]
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(digest: DigestStr, name: NameStr) -> Self {
45 Self {
46 digest,
47 name,
48 comment: ::std::default::Default::default(),
49 additional_properties: ::std::default::Default::default(),
50 }
51 }
52}
53#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
54pub struct GetOutputItems {
55 #[serde(skip_serializing_if = "Option::is_none", default)]
56 pub comment: Option<String>,
57 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
58 #[doc = ""]
59 pub digest: DigestStr,
60 #[doc = "IP set name."]
61 #[doc = ""]
62 pub name: NameStr,
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(name: NameStr) -> Self {
72 Self {
73 name,
74 comment: ::std::default::Default::default(),
75 digest: ::std::default::Default::default(),
76 rename: ::std::default::Default::default(),
77 additional_properties: ::std::default::Default::default(),
78 }
79 }
80}
81#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
82pub struct PostParams {
83 #[serde(skip_serializing_if = "Option::is_none", default)]
84 pub comment: Option<String>,
85 #[serde(skip_serializing_if = "Option::is_none", default)]
86 #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
87 #[doc = ""]
88 pub digest: Option<DigestStr>,
89 #[doc = "IP set name."]
90 #[doc = ""]
91 pub name: NameStr,
92 #[serde(skip_serializing_if = "Option::is_none", default)]
93 #[doc = "Rename an existing IPSet. You can set 'rename' to the same value as 'name' to update the 'comment' of an existing IPSet."]
94 #[doc = ""]
95 pub rename: Option<RenameStr>,
96 #[serde(
97 flatten,
98 default,
99 skip_serializing_if = "::std::collections::HashMap::is_empty"
100 )]
101 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
102}
103#[derive(Debug, Clone, PartialEq, PartialOrd)]
104pub struct DigestStr {
105 value: String,
106}
107impl crate::types::bounded_string::BoundedString for DigestStr {
108 const MIN_LENGTH: Option<usize> = None::<usize>;
109 const MAX_LENGTH: Option<usize> = Some(64usize);
110 const DEFAULT: Option<&'static str> = None::<&'static str>;
111 const PATTERN: Option<&'static str> = None::<&'static str>;
112 const TYPE_DESCRIPTION: &'static str = "a string with length at most 64";
113 fn get_value(&self) -> &str {
114 &self.value
115 }
116 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
117 Self::validate(&value)?;
118 Ok(Self { value })
119 }
120}
121impl std::convert::TryFrom<String> for DigestStr {
122 type Error = crate::types::bounded_string::BoundedStringError;
123 fn try_from(value: String) -> Result<Self, Self::Error> {
124 crate::types::bounded_string::BoundedString::new(value)
125 }
126}
127impl ::serde::Serialize for DigestStr {
128 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
129 where
130 S: ::serde::Serializer,
131 {
132 crate::types::bounded_string::serialize_bounded_string(self, serializer)
133 }
134}
135impl<'de> ::serde::Deserialize<'de> for DigestStr {
136 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
137 where
138 D: ::serde::Deserializer<'de>,
139 {
140 crate::types::bounded_string::deserialize_bounded_string(deserializer)
141 }
142}
143#[derive(Debug, Clone, PartialEq, PartialOrd)]
144pub struct NameStr {
145 value: String,
146}
147impl crate::types::bounded_string::BoundedString for NameStr {
148 const MIN_LENGTH: Option<usize> = Some(2usize);
149 const MAX_LENGTH: Option<usize> = Some(64usize);
150 const DEFAULT: Option<&'static str> = None::<&'static str>;
151 const PATTERN: Option<&'static str> = Some("[A-Za-z][A-Za-z0-9\\-\\_]+");
152 const TYPE_DESCRIPTION: &'static str =
153 "a string with pattern r\"[A-Za-z][A-Za-z0-9\\-\\_]+\" and length between 2 and 64";
154 fn get_value(&self) -> &str {
155 &self.value
156 }
157 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
158 Self::validate(&value)?;
159 Ok(Self { value })
160 }
161}
162impl std::convert::TryFrom<String> for NameStr {
163 type Error = crate::types::bounded_string::BoundedStringError;
164 fn try_from(value: String) -> Result<Self, Self::Error> {
165 crate::types::bounded_string::BoundedString::new(value)
166 }
167}
168impl ::serde::Serialize for NameStr {
169 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
170 where
171 S: ::serde::Serializer,
172 {
173 crate::types::bounded_string::serialize_bounded_string(self, serializer)
174 }
175}
176impl<'de> ::serde::Deserialize<'de> for NameStr {
177 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
178 where
179 D: ::serde::Deserializer<'de>,
180 {
181 crate::types::bounded_string::deserialize_bounded_string(deserializer)
182 }
183}
184#[derive(Debug, Clone, PartialEq, PartialOrd)]
185pub struct RenameStr {
186 value: String,
187}
188impl crate::types::bounded_string::BoundedString for RenameStr {
189 const MIN_LENGTH: Option<usize> = Some(2usize);
190 const MAX_LENGTH: Option<usize> = Some(64usize);
191 const DEFAULT: Option<&'static str> = None::<&'static str>;
192 const PATTERN: Option<&'static str> = Some("[A-Za-z][A-Za-z0-9\\-\\_]+");
193 const TYPE_DESCRIPTION: &'static str =
194 "a string with pattern r\"[A-Za-z][A-Za-z0-9\\-\\_]+\" and length between 2 and 64";
195 fn get_value(&self) -> &str {
196 &self.value
197 }
198 fn new(value: String) -> Result<Self, crate::types::bounded_string::BoundedStringError> {
199 Self::validate(&value)?;
200 Ok(Self { value })
201 }
202}
203impl std::convert::TryFrom<String> for RenameStr {
204 type Error = crate::types::bounded_string::BoundedStringError;
205 fn try_from(value: String) -> Result<Self, Self::Error> {
206 crate::types::bounded_string::BoundedString::new(value)
207 }
208}
209impl ::serde::Serialize for RenameStr {
210 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
211 where
212 S: ::serde::Serializer,
213 {
214 crate::types::bounded_string::serialize_bounded_string(self, serializer)
215 }
216}
217impl<'de> ::serde::Deserialize<'de> for RenameStr {
218 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
219 where
220 D: ::serde::Deserializer<'de>,
221 {
222 crate::types::bounded_string::deserialize_bounded_string(deserializer)
223 }
224}
225impl<T> IpsetClient<T>
226where
227 T: crate::client::Client,
228{
229 pub fn name(&self, name: &str) -> name::NameClient<T> {
230 name::NameClient::<T>::new(self.client.clone(), &self.path, name)
231 }
232}