[pdm-devel] [PATCH datacenter-manager 02/13] pdm-api-types: views: add ViewFilterConfig type

Lukas Wagner l.wagner at proxmox.com
Wed Oct 29 15:48:51 CET 2025


This type will be used to define view filters.

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
 lib/pdm-api-types/src/lib.rs   |   2 +
 lib/pdm-api-types/src/views.rs | 147 +++++++++++++++++++++++++++++++++
 2 files changed, 149 insertions(+)
 create mode 100644 lib/pdm-api-types/src/views.rs

diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs
index 2fb61ef7..a7ba6d89 100644
--- a/lib/pdm-api-types/src/lib.rs
+++ b/lib/pdm-api-types/src/lib.rs
@@ -106,6 +106,8 @@ pub mod subscription;
 
 pub mod sdn;
 
+pub mod views;
+
 const_regex! {
     // just a rough check - dummy acceptor is used before persisting
     pub OPENSSL_CIPHERS_REGEX = r"^[0-9A-Za-z_:, +!\-@=.]+$";
diff --git a/lib/pdm-api-types/src/views.rs b/lib/pdm-api-types/src/views.rs
new file mode 100644
index 00000000..8a00f4de
--- /dev/null
+++ b/lib/pdm-api-types/src/views.rs
@@ -0,0 +1,147 @@
+use serde::{Deserialize, Serialize};
+
+use proxmox_schema::{api, Updater};
+
+use crate::{remotes::REMOTE_ID_SCHEMA, resource::ResourceType};
+
+#[api(
+    properties: {
+        "include-resource-id": {
+            type: Array,
+            items: {
+                // TODO: Define some schema for this somewhere.
+                type: String,
+                description: "Global resource ID, e.g. 'remote/{remote}/node/{nodename}'",
+            },
+            optional: true,
+        },
+        "exclude-resource-id": {
+            type: Array,
+            items: {
+                // TODO: Define some schema for this somewhere.
+                type: String,
+                description: "Global resource ID, e.g. 'remote/{remote}/node/{nodename}'",
+            },
+            optional: true,
+        },
+        "include-remote": {
+            type: Array,
+            items: {
+                schema: REMOTE_ID_SCHEMA,
+            },
+            optional: true,
+        },
+        "exclude-remote": {
+            type: Array,
+            items: {
+                schema: REMOTE_ID_SCHEMA,
+            },
+            optional: true,
+        },
+        "include-resource-type": {
+            type: Array,
+            items: {
+                type: ResourceType,
+            },
+            optional: true,
+        },
+        "exclude-resource-type": {
+            type: Array,
+            items: {
+                type: ResourceType,
+            },
+            optional: true,
+        },
+        "include-tag": {
+            type: Array,
+            items: {
+                type: String,
+                description: "A tag of remote guest."
+            },
+            optional: true,
+        },
+        "exclude-tag": {
+            type: Array,
+            items: {
+                type: String,
+                description: "A tag of remote guest."
+            },
+            optional: true,
+        },
+        "include-resource-pool": {
+            type: Array,
+            items: {
+                // TODO: Define some schema for this somewhere.
+                type: String,
+                description: "Pool name."
+            },
+            optional: true,
+        },
+        "exclude-resource-pool": {
+            type: Array,
+            items: {
+                // TODO: Define some schema for this somewhere.
+                type: String,
+                description: "Pool name."
+            },
+            optional: true,
+        }
+    }
+)]
+#[derive(Clone, Default, Deserialize, Serialize, Updater)]
+#[serde(rename_all = "kebab-case")]
+/// View definition
+pub struct ViewFilterConfig {
+    /// View filter name
+    pub id: String,
+
+    /// List of resource IDs to include.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub include_resource_id: Vec<String>,
+
+    /// List of remotes to include.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub include_remote: Vec<String>,
+
+    /// List of included resource types.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub include_resource_type: Vec<ResourceType>,
+
+    /// List of included tags.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub include_tag: Vec<String>,
+
+    /// List of included resource pools.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub include_resource_pool: Vec<String>,
+
+    /// List of resource IDs to exclude.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub exclude_resource_id: Vec<String>,
+
+    /// List of remotes to exclude.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub exclude_remote: Vec<String>,
+
+    /// List of excluded resource types.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub exclude_resource_type: Vec<ResourceType>,
+
+    /// List of excluded tags.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub exclude_tag: Vec<String>,
+
+    /// List of excluded resource pools.
+    #[serde(default, skip_serializing_if = "Vec::is_empty")]
+    #[updater(serde(skip_serializing_if = "Option::is_none"))]
+    pub exclude_resource_pool: Vec<String>,
+}
-- 
2.47.3





More information about the pdm-devel mailing list