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 48EF91FF179 for ; Wed, 29 Oct 2025 15:48:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C5EEAE5C2; Wed, 29 Oct 2025 15:49:18 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Wed, 29 Oct 2025 15:48:51 +0100 Message-ID: <20251029144902.446852-3-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251029144902.446852-1-l.wagner@proxmox.com> References: <20251029144902.446852-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761749337729 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 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 02/13] pdm-api-types: views: add ViewFilterConfig type 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" This type will be used to define view filters. Signed-off-by: Lukas Wagner --- 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, + + /// 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, + + /// 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, + + /// List of included tags. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + #[updater(serde(skip_serializing_if = "Option::is_none"))] + pub include_tag: Vec, + + /// 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, + + /// 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, + + /// 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, + + /// 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, + + /// List of excluded tags. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + #[updater(serde(skip_serializing_if = "Option::is_none"))] + pub exclude_tag: Vec, + + /// 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, +} -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel