pve/cluster/firewall/ipset/
name.rs

1pub mod cidr;
2
3#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
4pub struct DeleteParameters {
5    #[doc = "Delete all members of the IPSet, if there are any."]
6    #[serde(
7        skip_serializing_if = "Option::is_none",
8        default,
9        deserialize_with = "crate::common::deserialize_option_bool_lax",
10        serialize_with = "crate::common::serialize_option_bool_as_u64"
11    )]
12    pub force: Option<bool>,
13}
14
15#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
16pub struct GetResponseItem {
17    pub cidr: String,
18    #[serde(skip_serializing_if = "Option::is_none", default)]
19    pub comment: Option<String>,
20    #[doc = "Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications."]
21    pub digest: String,
22    #[serde(
23        skip_serializing_if = "Option::is_none",
24        default,
25        deserialize_with = "crate::common::deserialize_option_bool_lax",
26        serialize_with = "crate::common::serialize_option_bool_as_u64"
27    )]
28    pub nomatch: Option<bool>,
29}
30
31#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
32pub struct PostParameters {
33    #[doc = "Network/IP specification in CIDR format."]
34    pub cidr: String,
35    #[serde(skip_serializing_if = "Option::is_none", default)]
36    pub comment: Option<String>,
37    #[serde(
38        skip_serializing_if = "Option::is_none",
39        default,
40        deserialize_with = "crate::common::deserialize_option_bool_lax",
41        serialize_with = "crate::common::serialize_option_bool_as_u64"
42    )]
43    pub nomatch: Option<bool>,
44}
45
46#[derive(Debug, Clone)]
47pub struct NameClient<T> {
48    client: T,
49    path: String,
50}
51
52impl<T> NameClient<T>
53where
54    T: Clone,
55{
56    pub fn new(client: T, parent_path: &str, name: &str) -> Self {
57        Self {
58            client,
59            path: format!("{}/{}", parent_path, name),
60        }
61    }
62
63    pub fn cidr(&self, cidr: &str) -> cidr::CidrClient<T> {
64        cidr::CidrClient::<T>::new(self.client.clone(), &self.path, cidr)
65    }
66}
67impl<T> NameClient<T>
68where
69    T: crate::client::HttpClient,
70{
71    #[doc = "Delete IPSet"]
72    pub fn delete(&self, parameters: DeleteParameters) -> Result<(), T::Error> {
73        self.client.delete(&self.path, &parameters)
74    }
75
76    #[doc = "List IPSet content"]
77    pub fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
78        self.client.get(&self.path, &())
79    }
80
81    #[doc = "Add IP or Network to IPSet."]
82    pub fn post(&self, parameters: PostParameters) -> Result<(), T::Error> {
83        self.client.post(&self.path, &parameters)
84    }
85}
86#[derive(Debug, Clone)]
87pub struct AsyncNameClient<T> {
88    client: T,
89    path: String,
90}
91
92impl<T> AsyncNameClient<T>
93where
94    T: Clone,
95{
96    pub fn new(client: T, parent_path: &str, name: &str) -> Self {
97        Self {
98            client,
99            path: format!("{}/{}", parent_path, name),
100        }
101    }
102
103    pub fn cidr(&self, cidr: &str) -> cidr::AsyncCidrClient<T> {
104        cidr::AsyncCidrClient::<T>::new(self.client.clone(), &self.path, cidr)
105    }
106}
107impl<T> AsyncNameClient<T>
108where
109    T: crate::client::AsyncHttpClient,
110{
111    #[doc = "Delete IPSet"]
112    pub async fn delete(&self, parameters: DeleteParameters) -> Result<(), T::Error> {
113        self.client.delete(&self.path, &parameters).await
114    }
115
116    #[doc = "List IPSet content"]
117    pub async fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
118        self.client.get(&self.path, &()).await
119    }
120
121    #[doc = "Add IP or Network to IPSet."]
122    pub async fn post(&self, parameters: PostParameters) -> Result<(), T::Error> {
123        self.client.post(&self.path, &parameters).await
124    }
125}