From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox-datacenter-manager v2 2/3] resources: api: add network type match category
Date: Thu, 13 Nov 2025 17:20:52 +0100 [thread overview]
Message-ID: <20251113162112.795835-5-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20251113162112.795835-1-s.hanreich@proxmox.com>
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 <s.hanreich@proxmox.com>
---
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 98239b0..299fa0a 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<Self, Self::Err> {
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
next prev parent reply other threads:[~2025-11-13 16:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-13 16:20 [pdm-devel] [PATCH proxmox{, -datacenter-manager} v2 0/5] Add support for network resource type Stefan Hanreich
2025-11-13 16:20 ` [pdm-devel] [PATCH proxmox v2 1/2] pve-api-types: update /cluster/resources endpoint Stefan Hanreich
2025-11-13 16:20 ` [pdm-devel] [PATCH proxmox v2 2/2] pve-api-types: regenerate Stefan Hanreich
2025-11-13 16:20 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 1/3] resources: views: support new pve network resource type Stefan Hanreich
2025-11-13 21:45 ` [pdm-devel] applied: " Thomas Lamprecht
2025-11-13 16:20 ` Stefan Hanreich [this message]
2025-11-13 21:45 ` [pdm-devel] applied: [PATCH proxmox-datacenter-manager v2 2/3] resources: api: add network type match category Thomas Lamprecht
2025-11-13 16:20 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 3/3] ui: use new network resource type Stefan Hanreich
2025-11-13 21:45 ` [pdm-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251113162112.795835-5-s.hanreich@proxmox.com \
--to=s.hanreich@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.