From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 3/7] pdm-api-types: api: factor out schema definitions for task log params
Date: Wed, 12 Nov 2025 10:41:59 +0100 [thread overview]
Message-ID: <20251112094203.112452-4-l.wagner@proxmox.com> (raw)
In-Reply-To: <20251112094203.112452-1-l.wagner@proxmox.com>
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 <l.wagner@proxmox.com>
---
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<Vec<TaskStateType>>,
}
+
+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
next prev parent reply other threads:[~2025-11-12 9:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 9:41 [pdm-devel] [PATCH datacenter-manager 0/7] PBS remotes: task API and task cache support Lukas Wagner
2025-11-12 9:41 ` [pdm-devel] [PATCH datacenter-manager 1/7] pdm-api-types: remote upid: add helpers for getting native UPID type Lukas Wagner
2025-11-12 9:41 ` [pdm-devel] [PATCH datacenter-manager 2/7] pbs-client: add bindings for task list, task status, task log Lukas Wagner
2025-11-12 20:23 ` Thomas Lamprecht
2025-11-12 9:41 ` Lukas Wagner [this message]
2025-11-12 9:42 ` [pdm-devel] [PATCH datacenter-manager 4/7] api: pbs tasks: add PBS task API Lukas Wagner
2025-11-12 9:42 ` [pdm-devel] [PATCH datacenter-manager 5/7] api: pve tasks: use shared helpers for RemoteUpid handling Lukas Wagner
2025-11-12 9:42 ` [pdm-devel] [PATCH datacenter-manager 6/7] remote tasks: fetch/track PBS tasks Lukas Wagner
2025-11-12 9:42 ` [pdm-devel] [PATCH datacenter-manager 7/7] remote updates: re-enable PBS update fetching Lukas Wagner
2025-11-12 20:26 ` Thomas Lamprecht
2025-11-12 20:27 ` [pdm-devel] applied-series: [PATCH datacenter-manager 0/7] PBS remotes: task API and task cache support 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=20251112094203.112452-4-l.wagner@proxmox.com \
--to=l.wagner@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.