From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id D4DBF1FF16B for ; Fri, 7 Nov 2025 15:39:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D9B29150A1; Fri, 7 Nov 2025 15:40:23 +0100 (CET) From: Stefan Hanreich To: pdm-devel@lists.proxmox.com Date: Fri, 7 Nov 2025 15:40:10 +0100 Message-ID: <20251107144018.700695-6-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251107144018.700695-1-s.hanreich@proxmox.com> References: <20251107144018.700695-1-s.hanreich@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.173 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 2/3] resources: api: add network type match category 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" All network resources are now contained inside the top-level PveNetwork variant of the Resource enum. In order to provide filtering based on the sub-types of the network entities, introduce a new network-type filter to the search, which can be used for matching specific types of network resources. Signed-off-by: Stefan Hanreich --- server/src/api/resources.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs index 0204f95..8b9d3b1 100644 --- a/server/src/api/resources.rs +++ b/server/src/api/resources.rs @@ -54,6 +54,7 @@ const SUBDIRS: SubdirMap = &sorted!([ enum MatchCategory { Type, + NetworkType, Name, Id, Status, @@ -69,6 +70,7 @@ impl std::str::FromStr for MatchCategory { fn from_str(s: &str) -> Result { let category = match s { "type" => MatchCategory::Type, + "network-type" => MatchCategory::NetworkType, "name" => MatchCategory::Name, "id" => MatchCategory::Id, "status" => MatchCategory::Status, @@ -85,7 +87,7 @@ impl std::str::FromStr for MatchCategory { impl MatchCategory { fn matches(&self, value: &str, search_term: &str) -> bool { match self { - MatchCategory::Type | MatchCategory::Status => value + MatchCategory::Type | MatchCategory::Status | MatchCategory::NetworkType => value .to_lowercase() .starts_with(&search_term.to_lowercase()), MatchCategory::Name | MatchCategory::Id | MatchCategory::Remote => { @@ -132,6 +134,12 @@ fn resource_matches_search_term( }, MatchCategory::Remote => category.matches(remote_name, &term.value), MatchCategory::RemoteType => return None, + MatchCategory::NetworkType => match resource { + Resource::PveNetwork(network_resource) => { + category.matches(&network_resource.network_type().as_str(), &term.value) + } + _ => false, + }, }, Some(Err(_)) => false, None => { @@ -162,6 +170,7 @@ fn remote_matches_search_term( MatchCategory::Property => false, MatchCategory::Template => false, MatchCategory::RemoteType => category.matches(&remote.ty.to_string(), &term.value), + MatchCategory::NetworkType => false, }, Some(Err(_)) => false, None => { -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel