Add a DeletableFirewallRuleProperty enum listing the optional
FirewallRule properties that can be explicitly deleted via the
update_rule API. Use kebab-case serialization to match the existing
API conventions.

Add the 'delete' parameter to the update_rule mock API handler
to verify that the new type integrates correctly with the #[api]
macro.

Signed-off-by: Dietmar Maurer <[email protected]>
---
 proxmox-firewall-api-types/src/lib.rs  |  4 ++-
 proxmox-firewall-api-types/src/rule.rs | 43 +++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/proxmox-firewall-api-types/src/lib.rs 
b/proxmox-firewall-api-types/src/lib.rs
index 25e260c3..0eebd727 100644
--- a/proxmox-firewall-api-types/src/lib.rs
+++ b/proxmox-firewall-api-types/src/lib.rs
@@ -39,4 +39,6 @@ pub use port::{
 };
 
 mod rule;
-pub use rule::{FirewallRule, FirewallRuleType};
+pub use rule::{
+    DeletableFirewallRuleProperty, FirewallRule, FirewallRuleListEntry, 
FirewallRuleType,
+};
diff --git a/proxmox-firewall-api-types/src/rule.rs 
b/proxmox-firewall-api-types/src/rule.rs
index d067c209..f22de9e9 100644
--- a/proxmox-firewall-api-types/src/rule.rs
+++ b/proxmox-firewall-api-types/src/rule.rs
@@ -160,6 +160,37 @@ pub struct FirewallRuleListEntry {
     pub rule: FirewallRule,
 }
 
+#[api()]
+#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
+/// Deletable property name
+pub enum DeletableFirewallRuleProperty {
+    /// Delete the comment property.
+    Comment,
+    /// Delete the destination address property.
+    Dest,
+    /// Delete the destination port property.
+    DestPort,
+    /// Delete the enable property.
+    Enable,
+    /// Delete the group property.
+    Group,
+    /// Delete the ICMP type property.
+    IcmpType,
+    /// Delete the interface property.
+    Iface,
+    /// Delete the log property.
+    Log,
+    /// Delete the macro property.
+    Macro,
+    /// Delete the protocol property.
+    Proto,
+    /// Delete the source address property.
+    Source,
+    /// Delete the source port property.
+    Sport,
+}
+
 #[api]
 /// Rule type.
 #[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)]
@@ -232,6 +263,7 @@ mod test {
 }
 
 #[cfg(test)]
+#[allow(unused)]
 mod test_fake_server_client_api {
     use super::*;
     use anyhow::Error;
@@ -273,9 +305,17 @@ mod test_fake_server_client_api {
                 pos: {
                     schema: FIREWALL_RULE_POS_SCHEMA,
                 },
-                digest: {
+                delete: {
+                    description: "List of properties to delete.",
+                    type: Array,
                     optional: true,
+                    items: {
+                        type: DeletableFirewallRuleProperty,
+                    }
                 },
+                digest: {
+                    optional: true,
+                },  
             },
         },
     )]
@@ -283,6 +323,7 @@ mod test_fake_server_client_api {
     pub fn update_rule(
         pos: u64,
         rule: FirewallRuleUpdater,
+        delete: Option<Vec<DeletableFirewallRuleProperty>>,
         digest: Option<ConfigDigest>,
     ) -> Result<(), Error> {
         unimplemented!();
-- 
2.47.3



Reply via email to