From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id C27D11FF1A6 for ; Fri, 5 Dec 2025 16:25:33 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EACF951DE; Fri, 5 Dec 2025 16:26:01 +0100 (CET) From: Hannes Laimer To: pdm-devel@lists.proxmox.com Date: Fri, 5 Dec 2025 16:25:41 +0100 Message-ID: <20251205152543.91431-7-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251205152543.91431-1-h.laimer@proxmox.com> References: <20251205152543.91431-1-h.laimer@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764948310530 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.097 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 2/2] api: firewall: add pve firewall security group GET endpoints X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" Signed-off-by: Hannes Laimer --- server/src/api/pve/firewall.rs | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/server/src/api/pve/firewall.rs b/server/src/api/pve/firewall.rs index e60961c..7957264 100644 --- a/server/src/api/pve/firewall.rs +++ b/server/src/api/pve/firewall.rs @@ -47,6 +47,7 @@ const PVE_FW_SUBDIRS: SubdirMap = &sorted!([("status", &PVE_STATUS_ROUTER),]); // cluster #[sortable] const CLUSTER_FW_SUBDIRS: SubdirMap = &sorted!([ + ("groups", &FIREWALL_SECURITY_GROUPS_ROUTER), ("options", &CLUSTER_OPTIONS_ROUTER), ("rules", &CLUSTER_RULES_ROUTER), ("status", &CLUSTER_STATUS_ROUTER), @@ -72,6 +73,13 @@ const QEMU_FW_SUBDIRS: SubdirMap = &sorted!([ ("rules", &QEMU_RULES_ROUTER), ]); +// /groups +const FIREWALL_SECURITY_GROUPS_ROUTER: Router = Router::new() + .get(&API_METHOD_FIREWALL_SECURITY_GROUPS) + .match_all("group", &FIREWALL_SECURITY_GROUP_ROUTER); +const FIREWALL_SECURITY_GROUP_ROUTER: Router = + Router::new().get(&API_METHOD_FIREWALL_SECURITY_GROUP); + // /options const CLUSTER_OPTIONS_ROUTER: Router = Router::new() .get(&API_METHOD_CLUSTER_FIREWALL_OPTIONS) @@ -331,6 +339,63 @@ pub async fn pve_firewall_status( Ok(result) } +#[api( + input: { + properties: { + remote: { schema: REMOTE_ID_SCHEMA }, + }, + }, + returns: { + type: Array, + description: "List of firewall security groups.", + items: { type: pve_api_types::FirewallSecurityGroup }, + }, + access: { + permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), + }, +)] +/// Get firewall security groups. +pub async fn firewall_security_groups( + remote: String, + _rpcenv: &mut dyn RpcEnvironment, +) -> Result, Error> { + let (remotes, _) = pdm_config::remotes::config()?; + let pve = connect_to_remote(&remotes, &remote)?; + + Ok(pve.list_firewall_security_groups().await?) +} + +#[api( + input: { + properties: { + remote: { schema: REMOTE_ID_SCHEMA }, + group: { + type: String, + description: "The security groups name", + }, + }, + }, + returns: { + type: Array, + description: "List firewall security group rules.", + items: { type: pve_api_types::FirewallRule }, + }, + access: { + permission: &Permission::Privilege(&["resource", "{remote}"], PRIV_RESOURCE_AUDIT, false), + }, +)] +/// Get firewall security group rules. +pub async fn firewall_security_group( + remote: String, + group: String, + _rpcenv: &mut dyn RpcEnvironment, +) -> Result, Error> { + let (remotes, _) = pdm_config::remotes::config()?; + let pve = connect_to_remote(&remotes, &remote)?; + + Ok(pve.list_firewall_security_group_rules(&group).await?) +} + #[api( input: { properties: { -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel