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 C64221FF191 for ; Tue, 21 Oct 2025 13:11:38 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 460511BB4B; Tue, 21 Oct 2025 13:11:54 +0200 (CEST) From: Christian Ebner To: pdm-devel@lists.proxmox.com Date: Tue, 21 Oct 2025 13:11:28 +0200 Message-ID: <20251021111129.294349-19-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251021111129.294349-1-c.ebner@proxmox.com> References: <20251021111129.294349-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761045097108 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.042 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 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 datacenter-manager v3 18/19] server: resources: add property matching for resources 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" Extends the search categories by the Property variant, which allows to match against a list of properties defined on a resource. Resources provide the list of properties as comma separates strings. Signed-off-by: Christian Ebner --- Changes since version 2: - not present in previous version server/src/api/resources.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs index 3b629d1..57563b3 100644 --- a/server/src/api/resources.rs +++ b/server/src/api/resources.rs @@ -59,6 +59,7 @@ enum MatchCategory { Template, Remote, RemoteType, + Property, } impl std::str::FromStr for MatchCategory { @@ -73,6 +74,7 @@ impl std::str::FromStr for MatchCategory { "template" => MatchCategory::Template, "remote" => MatchCategory::Remote, "remote-type" => MatchCategory::RemoteType, + "property" => MatchCategory::Property, _ => bail!("invalid category"), }; Ok(category) @@ -99,6 +101,10 @@ impl MatchCategory { (Ok(a), Ok(b)) => a == b, _ => false, }, + MatchCategory::Property => value + .to_lowercase() + .split(",") + .any(|property| property == search_term.to_lowercase()), } } } @@ -115,6 +121,7 @@ fn resource_matches_search_term( MatchCategory::Name => category.matches(resource.name(), &term.value), MatchCategory::Id => category.matches(&resource.id(), &term.value), MatchCategory::Status => category.matches(resource.status(), &term.value), + MatchCategory::Property => category.matches(&resource.properties(), &term.value), MatchCategory::Template => match resource { Resource::PveQemu(PveQemuResource { template, .. }) | Resource::PveLxc(PveLxcResource { template, .. }) => { @@ -151,6 +158,7 @@ fn remote_matches_search_term( Some(false) => category.matches("offline", &term.value), None => true, }, + MatchCategory::Property => false, MatchCategory::Template => false, MatchCategory::RemoteType => category.matches(&remote.ty.to_string(), &term.value), }, -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel