Skip to main content

unifly_api/session/
firewallgroup.rs

1// Legacy firewall group operations.
2//
3// Manages port groups, address groups, and IPv6 address groups via the
4// classic `rest/firewallgroup` collection behind the Session API.
5
6use serde_json::Value;
7use tracing::debug;
8
9use super::SessionClient;
10use crate::error::Error;
11
12impl SessionClient {
13    /// List all firewall groups for the current site.
14    pub async fn list_firewall_groups(&self) -> Result<Vec<Value>, Error> {
15        let url = self.site_url("rest/firewallgroup");
16        debug!("listing firewall groups");
17        self.get(url).await
18    }
19
20    /// Create a firewall group for the current site.
21    pub async fn create_firewall_group(&self, body: &Value) -> Result<Vec<Value>, Error> {
22        let url = self.site_url("rest/firewallgroup");
23        debug!("creating firewall group");
24        self.post(url, body).await
25    }
26
27    /// Update a firewall group for the current site.
28    pub async fn update_firewall_group(
29        &self,
30        record_id: &str,
31        body: &Value,
32    ) -> Result<Vec<Value>, Error> {
33        let url = self.site_url(&format!("rest/firewallgroup/{record_id}"));
34        debug!(record_id, "updating firewall group");
35        self.put(url, body).await
36    }
37
38    /// Delete a firewall group for the current site.
39    pub async fn delete_firewall_group(&self, record_id: &str) -> Result<Vec<Value>, Error> {
40        let url = self.site_url(&format!("rest/firewallgroup/{record_id}"));
41        debug!(record_id, "deleting firewall group");
42        self.delete(url).await
43    }
44}