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 406B21FF179 for ; Wed, 12 Nov 2025 10:42:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 83B851C58B; Wed, 12 Nov 2025 10:42:48 +0100 (CET) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Wed, 12 Nov 2025 10:41:59 +0100 Message-ID: <20251112094203.112452-4-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112094203.112452-1-l.wagner@proxmox.com> References: <20251112094203.112452-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762940506060 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 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 3/7] pdm-api-types: api: factor out schema definitions for task log params 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" The PBS tasks API will also need them, so it makes sense to move them to a shared crate now. Signed-off-by: Lukas Wagner --- lib/pdm-api-types/src/lib.rs | 21 +++++++++++++++++++++ server/src/api/nodes/tasks.rs | 30 +++++------------------------- server/src/api/pve/tasks.rs | 35 ++++++++--------------------------- 3 files changed, 34 insertions(+), 52 deletions(-) diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs index ad52372e..5ac99aa1 100644 --- a/lib/pdm-api-types/src/lib.rs +++ b/lib/pdm-api-types/src/lib.rs @@ -494,3 +494,24 @@ pub struct TaskFilters { #[serde(skip_serializing_if = "Option::is_none")] pub statusfilter: Option>, } + +pub const TASKLOG_START_PARAM_SCHEMA: Schema = + proxmox_schema::IntegerSchema::new("Start at this line when reading the tasklog") + .minimum(0) + .default(0) + .schema(); + +pub const TASKLOG_LIMIT_PARAM_SCHEMA: Schema = proxmox_schema::IntegerSchema::new( + "The amount of lines to read from the tasklog. \ + Setting this parameter to 0 will return all lines until the end of the file.", +) +.minimum(0) +.default(50) +.schema(); + +pub const TASKLOG_DOWNLOAD_PARAM_SCHEMA: Schema = proxmox_schema::BooleanSchema::new( + "Whether the tasklog file should be downloaded. \ + This parameter can't be used in conjunction with other parameters", +) +.default(false) +.schema(); diff --git a/server/src/api/nodes/tasks.rs b/server/src/api/nodes/tasks.rs index 2ab1284f..9725f022 100644 --- a/server/src/api/nodes/tasks.rs +++ b/server/src/api/nodes/tasks.rs @@ -13,7 +13,8 @@ use proxmox_sortable_macro::sortable; use pdm_api_types::{ Authid, TaskFilters, TaskListItem, TaskStateType, Tokenname, Userid, NODE_SCHEMA, - PRIV_SYS_AUDIT, PRIV_SYS_MODIFY, UPID, UPID_SCHEMA, + PRIV_SYS_AUDIT, PRIV_SYS_MODIFY, TASKLOG_DOWNLOAD_PARAM_SCHEMA, TASKLOG_LIMIT_PARAM_SCHEMA, + TASKLOG_START_PARAM_SCHEMA, UPID, UPID_SCHEMA, }; pub const ROUTER: Router = Router::new() @@ -305,27 +306,6 @@ async fn get_task_status(upid: UPID, rpcenv: &mut dyn RpcEnvironment) -> Result< Ok(result) } -const START_PARAM_SCHEMA: Schema = - proxmox_schema::IntegerSchema::new("Start at this line when reading the tasklog") - .minimum(0) - .default(0) - .schema(); - -const LIMIT_PARAM_SCHEMA: Schema = proxmox_schema::IntegerSchema::new( - "The amount of lines to read from the tasklog. \ - Setting this parameter to 0 will return all lines until the end of the file.", -) -.minimum(0) -.default(50) -.schema(); - -const DOWNLOAD_PARAM_SCHEMA: Schema = proxmox_schema::BooleanSchema::new( - "Whether the tasklog file should be downloaded. \ - This parameter can't be used in conjunction with other parameters", -) -.default(false) -.schema(); - const TEST_STATUS_PARAM_SCHEMA: Schema = proxmox_schema::BooleanSchema::new( "Test task status, and set result attribute \"active\" accordingly.", ) @@ -339,9 +319,9 @@ pub const API_METHOD_READ_TASK_LOG: proxmox_router::ApiMethod = proxmox_router:: &sorted!([ ("node", false, &NODE_SCHEMA), ("upid", false, &UPID_SCHEMA), - ("start", true, &START_PARAM_SCHEMA), - ("limit", true, &LIMIT_PARAM_SCHEMA), - ("download", true, &DOWNLOAD_PARAM_SCHEMA), + ("start", true, &TASKLOG_START_PARAM_SCHEMA), + ("limit", true, &TASKLOG_LIMIT_PARAM_SCHEMA), + ("download", true, &TASKLOG_DOWNLOAD_PARAM_SCHEMA), ("test-status", true, &TEST_STATUS_PARAM_SCHEMA) ]), ), diff --git a/server/src/api/pve/tasks.rs b/server/src/api/pve/tasks.rs index 9f04a448..e66712ac 100644 --- a/server/src/api/pve/tasks.rs +++ b/server/src/api/pve/tasks.rs @@ -3,11 +3,14 @@ use anyhow::{bail, format_err, Error}; use proxmox_router::{list_subdirs_api_method, Permission, Router, RpcEnvironment, SubdirMap}; -use proxmox_schema::{api, Schema}; +use proxmox_schema::api; use proxmox_sortable_macro::sortable; use pdm_api_types::remotes::REMOTE_ID_SCHEMA; -use pdm_api_types::{RemoteUpid, NODE_SCHEMA, PRIV_RESOURCE_AUDIT, PRIV_RESOURCE_MANAGE}; +use pdm_api_types::{ + RemoteUpid, NODE_SCHEMA, PRIV_RESOURCE_AUDIT, PRIV_RESOURCE_MANAGE, + TASKLOG_DOWNLOAD_PARAM_SCHEMA, TASKLOG_LIMIT_PARAM_SCHEMA, TASKLOG_START_PARAM_SCHEMA, +}; use pve_api_types::PveUpid; use super::{connect, connect_to_remote, get_remote}; @@ -149,28 +152,6 @@ pub async fn get_task_status( } } -// FIXME: Deduplicate these into pdm_api_types: -const START_PARAM_SCHEMA: Schema = - proxmox_schema::IntegerSchema::new("Start at this line when reading the tasklog") - .minimum(0) - .default(0) - .schema(); - -const LIMIT_PARAM_SCHEMA: Schema = proxmox_schema::IntegerSchema::new( - "The amount of lines to read from the tasklog. \ - Setting this parameter to 0 will return all lines until the end of the file.", -) -.minimum(0) -.default(50) -.schema(); - -const DOWNLOAD_PARAM_SCHEMA: Schema = proxmox_schema::BooleanSchema::new( - "Whether the tasklog file should be downloaded. \ - This parameter can't be used in conjunction with other parameters", -) -.default(false) -.schema(); - // FIXME: make *actually* streaming with router support! #[api( input: { @@ -178,15 +159,15 @@ const DOWNLOAD_PARAM_SCHEMA: Schema = proxmox_schema::BooleanSchema::new( remote: { schema: REMOTE_ID_SCHEMA }, upid: { type: RemoteUpid }, start: { - schema: START_PARAM_SCHEMA, + schema: TASKLOG_START_PARAM_SCHEMA, optional: true, }, limit: { - schema: LIMIT_PARAM_SCHEMA, + schema: TASKLOG_LIMIT_PARAM_SCHEMA, optional: true, }, download: { - schema: DOWNLOAD_PARAM_SCHEMA, + schema: TASKLOG_DOWNLOAD_PARAM_SCHEMA, optional: true, } }, -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel