pve/cluster/firewall/
ipset.rs1pub mod name;
2
3#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
4pub struct GetResponseItem {
5 #[serde(skip_serializing_if = "Option::is_none", default)]
6 pub comment: Option<String>,
7 #[doc = "Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications."]
8 pub digest: String,
9 #[doc = "IP set name."]
10 pub name: String,
11}
12
13#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
14pub struct PostParameters {
15 #[serde(skip_serializing_if = "Option::is_none", default)]
16 pub comment: Option<String>,
17 #[doc = "Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications."]
18 #[serde(skip_serializing_if = "Option::is_none", default)]
19 pub digest: Option<String>,
20 #[doc = "IP set name."]
21 pub name: String,
22 #[doc = "Rename an existing IPSet. You can set 'rename' to the same value as 'name' to update the 'comment' of an existing IPSet."]
23 #[serde(skip_serializing_if = "Option::is_none", default)]
24 pub rename: Option<String>,
25}
26
27#[derive(Debug, Clone)]
28pub struct IpsetClient<T> {
29 client: T,
30 path: String,
31}
32
33impl<T> IpsetClient<T>
34where
35 T: Clone,
36{
37 pub fn new(client: T, parent_path: &str) -> Self {
38 Self {
39 client,
40 path: format!("{}/{}", parent_path, "ipset"),
41 }
42 }
43
44 pub fn name(&self, name: &str) -> name::NameClient<T> {
45 name::NameClient::<T>::new(self.client.clone(), &self.path, name)
46 }
47}
48impl<T> IpsetClient<T>
49where
50 T: crate::client::HttpClient,
51{
52 #[doc = "List IPSets"]
53 pub fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
54 self.client.get(&self.path, &())
55 }
56
57 #[doc = "Create new IPSet"]
58 pub fn post(&self, parameters: PostParameters) -> Result<(), T::Error> {
59 self.client.post(&self.path, ¶meters)
60 }
61}
62#[derive(Debug, Clone)]
63pub struct AsyncIpsetClient<T> {
64 client: T,
65 path: String,
66}
67
68impl<T> AsyncIpsetClient<T>
69where
70 T: Clone,
71{
72 pub fn new(client: T, parent_path: &str) -> Self {
73 Self {
74 client,
75 path: format!("{}/{}", parent_path, "ipset"),
76 }
77 }
78
79 pub fn name(&self, name: &str) -> name::AsyncNameClient<T> {
80 name::AsyncNameClient::<T>::new(self.client.clone(), &self.path, name)
81 }
82}
83impl<T> AsyncIpsetClient<T>
84where
85 T: crate::client::AsyncHttpClient,
86{
87 #[doc = "List IPSets"]
88 pub async fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
89 self.client.get(&self.path, &()).await
90 }
91
92 #[doc = "Create new IPSet"]
93 pub async fn post(&self, parameters: PostParameters) -> Result<(), T::Error> {
94 self.client.post(&self.path, ¶meters).await
95 }
96}