Skip to main content

proxmox_api/generated/cluster/firewall/ipset/
name.rs

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