proxmox_api/generated/cluster/firewall/groups/
group.rs

1pub mod pos;
2pub struct GroupClient<T> {
3    client: T,
4    path: String,
5}
6impl<T> GroupClient<T>
7where
8    T: crate::client::Client,
9{
10    pub fn new(client: T, parent_path: &str, group: &str) -> Self {
11        Self {
12            client,
13            path: format!("{}/{}", parent_path, group),
14        }
15    }
16}
17impl<T> GroupClient<T>
18where
19    T: crate::client::Client,
20{
21    #[doc = "Delete security group."]
22    pub fn delete(&self) -> Result<(), T::Error> {
23        let path = self.path.to_string();
24        self.client.delete(&path, &())
25    }
26}
27impl<T> GroupClient<T>
28where
29    T: crate::client::Client,
30{
31    #[doc = "List rules."]
32    pub fn get(&self) -> Result<Vec<GetOutputItems>, T::Error> {
33        let path = self.path.to_string();
34        self.client.get(&path, &())
35    }
36}
37impl<T> GroupClient<T>
38where
39    T: crate::client::Client,
40{
41    #[doc = "Create new rule."]
42    pub fn post(&self, params: PostParams) -> Result<(), T::Error> {
43        let path = self.path.to_string();
44        self.client.post(&path, &params)
45    }
46}
47impl GetOutputItems {
48    pub fn new(pos: u64) -> Self {
49        Self {
50            pos,
51            additional_properties: Default::default(),
52        }
53    }
54}
55#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
56pub struct GetOutputItems {
57    #[serde(
58        serialize_with = "crate::types::serialize_int",
59        deserialize_with = "crate::types::deserialize_int"
60    )]
61    pub pos: u64,
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(action: String, ty: Type) -> Self {
71        Self {
72            action,
73            ty,
74            comment: Default::default(),
75            dest: Default::default(),
76            digest: Default::default(),
77            dport: Default::default(),
78            enable: Default::default(),
79            icmp_type: Default::default(),
80            iface: Default::default(),
81            log: Default::default(),
82            macro_def: Default::default(),
83            pos: Default::default(),
84            proto: Default::default(),
85            source: Default::default(),
86            sport: Default::default(),
87            additional_properties: Default::default(),
88        }
89    }
90}
91#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
92pub struct PostParams {
93    #[doc = "Rule action ('ACCEPT', 'DROP', 'REJECT') or security group name."]
94    pub action: String,
95    #[serde(skip_serializing_if = "Option::is_none", default)]
96    #[doc = "Descriptive comment."]
97    pub comment: Option<String>,
98    #[serde(skip_serializing_if = "Option::is_none", default)]
99    #[doc = "Restrict packet destination address. This can refer to a single IP address, an IP set ('+ipsetname') or an IP alias definition. You can also specify an address range like '20.34.101.207-201.3.9.99', or a list of IP addresses and networks (entries are separated by comma). Please do not mix IPv4 and IPv6 addresses inside such lists."]
100    pub dest: Option<String>,
101    #[serde(skip_serializing_if = "Option::is_none", default)]
102    #[doc = "Prevent changes if current configuration file has a different digest. This can be used to prevent concurrent modifications."]
103    pub digest: Option<String>,
104    #[serde(skip_serializing_if = "Option::is_none", default)]
105    #[doc = "Restrict TCP/UDP destination port. You can use service names or simple numbers (0-65535), as defined in '/etc/services'. Port ranges can be specified with '\\d+:\\d+', for example '80:85', and you can use comma separated list to match several ports or ranges."]
106    pub dport: Option<String>,
107    #[serde(
108        serialize_with = "crate::types::serialize_int_optional",
109        deserialize_with = "crate::types::deserialize_int_optional"
110    )]
111    #[serde(skip_serializing_if = "Option::is_none", default)]
112    #[doc = "Flag to enable/disable a rule."]
113    pub enable: Option<u64>,
114    #[serde(rename = "icmp-type")]
115    #[serde(skip_serializing_if = "Option::is_none", default)]
116    #[doc = "Specify icmp-type. Only valid if proto equals 'icmp' or 'icmpv6'/'ipv6-icmp'."]
117    pub icmp_type: Option<String>,
118    #[serde(skip_serializing_if = "Option::is_none", default)]
119    #[doc = "Network interface name. You have to use network configuration key names for VMs and containers ('net\\d+'). Host related rules can use arbitrary strings."]
120    pub iface: Option<String>,
121    #[serde(skip_serializing_if = "Option::is_none", default)]
122    #[doc = "Log level for firewall rule."]
123    pub log: Option<Log>,
124    #[serde(rename = "macro")]
125    #[serde(skip_serializing_if = "Option::is_none", default)]
126    #[doc = "Use predefined standard macro."]
127    pub macro_def: Option<String>,
128    #[serde(
129        serialize_with = "crate::types::serialize_int_optional",
130        deserialize_with = "crate::types::deserialize_int_optional"
131    )]
132    #[serde(skip_serializing_if = "Option::is_none", default)]
133    #[doc = "Update rule at position \\<pos\\>."]
134    pub pos: Option<u64>,
135    #[serde(skip_serializing_if = "Option::is_none", default)]
136    #[doc = "IP protocol. You can use protocol names ('tcp'/'udp') or simple numbers, as defined in '/etc/protocols'."]
137    pub proto: Option<String>,
138    #[serde(skip_serializing_if = "Option::is_none", default)]
139    #[doc = "Restrict packet source address. This can refer to a single IP address, an IP set ('+ipsetname') or an IP alias definition. You can also specify an address range like '20.34.101.207-201.3.9.99', or a list of IP addresses and networks (entries are separated by comma). Please do not mix IPv4 and IPv6 addresses inside such lists."]
140    pub source: Option<String>,
141    #[serde(skip_serializing_if = "Option::is_none", default)]
142    #[doc = "Restrict TCP/UDP source port. You can use service names or simple numbers (0-65535), as defined in '/etc/services'. Port ranges can be specified with '\\d+:\\d+', for example '80:85', and you can use comma separated list to match several ports or ranges."]
143    pub sport: Option<String>,
144    #[serde(rename = "type")]
145    #[doc = "Rule type."]
146    pub ty: Type,
147    #[serde(
148        flatten,
149        default,
150        skip_serializing_if = "::std::collections::HashMap::is_empty"
151    )]
152    pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
153}
154#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
155pub enum Log {
156    #[serde(rename = "alert")]
157    Alert,
158    #[serde(rename = "crit")]
159    Crit,
160    #[serde(rename = "debug")]
161    Debug,
162    #[serde(rename = "emerg")]
163    Emerg,
164    #[serde(rename = "err")]
165    Err,
166    #[serde(rename = "info")]
167    Info,
168    #[serde(rename = "nolog")]
169    Nolog,
170    #[serde(rename = "notice")]
171    Notice,
172    #[serde(rename = "warning")]
173    Warning,
174}
175#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
176pub enum Type {
177    #[serde(rename = "group")]
178    Group,
179    #[serde(rename = "in")]
180    In,
181    #[serde(rename = "out")]
182    Out,
183}
184impl<T> GroupClient<T>
185where
186    T: crate::client::Client,
187{
188    pub fn pos(&self, pos: &str) -> pos::PosClient<T> {
189        pos::PosClient::<T>::new(self.client.clone(), &self.path, pos)
190    }
191}