Skip to main content

proxmox_api/generated/cluster/firewall/
groups.rs

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