From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH proxmox-datacenter-manager 10/12] api: add APT endpoints for PBS remotes
Date: Wed, 15 Oct 2025 14:47:09 +0200 [thread overview]
Message-ID: <20251015124711.312943-11-l.wagner@proxmox.com> (raw)
In-Reply-To: <20251015124711.312943-1-l.wagner@proxmox.com>
Since the endpoints are exactly identical as the PVE ones, we move the
implementation to a shared module and use the same for both.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
server/src/api/pbs/mod.rs | 4 ++
server/src/api/pbs/node.rs | 9 +++
server/src/api/pve/apt.rs | 119 -------------------------------
server/src/api/pve/mod.rs | 1 -
server/src/api/pve/node.rs | 2 +-
server/src/api/remote_updates.rs | 118 +++++++++++++++++++++++++++++-
6 files changed, 130 insertions(+), 123 deletions(-)
create mode 100644 server/src/api/pbs/node.rs
delete mode 100644 server/src/api/pve/apt.rs
diff --git a/server/src/api/pbs/mod.rs b/server/src/api/pbs/mod.rs
index b3bb126c..43bd1a28 100644
--- a/server/src/api/pbs/mod.rs
+++ b/server/src/api/pbs/mod.rs
@@ -20,6 +20,7 @@ use crate::{
use crate::remote_tasks;
+mod node;
mod rrddata;
pub const ROUTER: Router = Router::new()
@@ -41,8 +42,11 @@ pub const MAIN_ROUTER: Router = Router::new()
.get(&list_subdirs_api_method!(REMOTE_SUBDIRS))
.subdirs(REMOTE_SUBDIRS);
+const NODES_ROUTER: Router = Router::new().match_all("node", &node::ROUTER);
+
#[sortable]
const REMOTE_SUBDIRS: SubdirMap = &sorted!([
+ ("nodes", &NODES_ROUTER),
("status", &Router::new().get(&API_METHOD_GET_STATUS)),
("rrddata", &rrddata::PBS_NODE_RRD_ROUTER),
("datastore", &DATASTORE_ROUTER)
diff --git a/server/src/api/pbs/node.rs b/server/src/api/pbs/node.rs
new file mode 100644
index 00000000..286e1a11
--- /dev/null
+++ b/server/src/api/pbs/node.rs
@@ -0,0 +1,9 @@
+use proxmox_router::{list_subdirs_api_method, Router, SubdirMap};
+use proxmox_sortable_macro::sortable;
+
+pub const ROUTER: Router = Router::new()
+ .get(&list_subdirs_api_method!(SUBDIRS))
+ .subdirs(SUBDIRS);
+
+#[sortable]
+const SUBDIRS: SubdirMap = &sorted!([("apt", &crate::api::remote_updates::APT_ROUTER),]);
diff --git a/server/src/api/pve/apt.rs b/server/src/api/pve/apt.rs
deleted file mode 100644
index f5027fb8..00000000
--- a/server/src/api/pve/apt.rs
+++ /dev/null
@@ -1,119 +0,0 @@
-use anyhow::Error;
-
-use proxmox_apt_api_types::{APTGetChangelogOptions, APTUpdateInfo};
-use proxmox_router::{list_subdirs_api_method, Permission, Router, SubdirMap};
-use proxmox_schema::api;
-use proxmox_schema::api_types::NODE_SCHEMA;
-
-use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, RemoteUpid, PRIV_RESOURCE_MODIFY};
-
-use crate::{api::remotes::get_remote, remote_updates};
-
-#[api(
- input: {
- properties: {
- remote: {
- schema: REMOTE_ID_SCHEMA,
- },
- node: {
- schema: NODE_SCHEMA,
- },
- },
- },
- returns: {
- description: "A list of packages with available updates.",
- type: Array,
- items: {
- type: APTUpdateInfo
- },
- },
- access: {
- permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false),
- },
-)]
-/// List available APT updates for a remote PVE node.
-async fn apt_update_available(remote: String, node: String) -> Result<Vec<APTUpdateInfo>, Error> {
- let (config, _digest) = pdm_config::remotes::config()?;
- let remote = get_remote(&config, &remote)?;
-
- let updates = remote_updates::list_available_updates(remote.clone(), &node).await?;
-
- Ok(updates)
-}
-
-#[api(
- input: {
- properties: {
- remote: {
- schema: REMOTE_ID_SCHEMA,
- },
- node: {
- schema: NODE_SCHEMA,
- },
- },
- },
- access: {
- permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false),
- },
-)]
-/// Update the APT database of a remote PVE node.
-pub async fn apt_update_database(remote: String, node: String) -> Result<RemoteUpid, Error> {
- let (config, _digest) = pdm_config::remotes::config()?;
- let remote = get_remote(&config, &remote)?;
-
- let upid = remote_updates::update_apt_database(remote, &node).await?;
-
- Ok(upid)
-}
-
-#[api(
- input: {
- properties: {
- remote: {
- schema: REMOTE_ID_SCHEMA,
- },
- node: {
- schema: NODE_SCHEMA,
- },
- options: {
- type: APTGetChangelogOptions,
- flatten: true,
- },
- },
- },
- returns: {
- description: "The Package changelog.",
- type: String,
- },
- access: {
- permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false),
- },
-)]
-/// Retrieve the changelog of the specified package for a remote PVE node.
-async fn apt_get_changelog(
- remote: String,
- node: String,
- options: APTGetChangelogOptions,
-) -> Result<String, Error> {
- let (config, _digest) = pdm_config::remotes::config()?;
- let remote = get_remote(&config, &remote)?;
-
- remote_updates::get_changelog(remote.clone(), &node, options.name).await
-}
-
-const SUBDIRS: SubdirMap = &[
- (
- "changelog",
- &Router::new().get(&API_METHOD_APT_GET_CHANGELOG),
- ),
- (
- "update",
- &Router::new()
- .get(&API_METHOD_APT_UPDATE_AVAILABLE)
- .post(&API_METHOD_APT_UPDATE_DATABASE),
- ),
-];
-
-pub const ROUTER: Router = Router::new()
- .get(&list_subdirs_api_method!(SUBDIRS))
- .subdirs(SUBDIRS);
diff --git a/server/src/api/pve/mod.rs b/server/src/api/pve/mod.rs
index a94ab8d0..fd4ea542 100644
--- a/server/src/api/pve/mod.rs
+++ b/server/src/api/pve/mod.rs
@@ -33,7 +33,6 @@ use crate::connection::PveClient;
use crate::connection::{self, probe_tls_connection};
use crate::remote_tasks;
-mod apt;
mod lxc;
mod node;
mod qemu;
diff --git a/server/src/api/pve/node.rs b/server/src/api/pve/node.rs
index 1924e252..301c0b19 100644
--- a/server/src/api/pve/node.rs
+++ b/server/src/api/pve/node.rs
@@ -15,7 +15,7 @@ pub const ROUTER: Router = Router::new()
#[sortable]
const SUBDIRS: SubdirMap = &sorted!([
- ("apt", &super::apt::ROUTER),
+ ("apt", &crate::api::remote_updates::APT_ROUTER),
("rrddata", &super::rrddata::NODE_RRD_ROUTER),
("network", &Router::new().get(&API_METHOD_GET_NETWORK)),
("storage", &STORAGE_ROUTER),
diff --git a/server/src/api/remote_updates.rs b/server/src/api/remote_updates.rs
index 724b705a..5907259f 100644
--- a/server/src/api/remote_updates.rs
+++ b/server/src/api/remote_updates.rs
@@ -2,10 +2,13 @@
use anyhow::Error;
-use pdm_api_types::remote_updates::UpdateSummary;
use pdm_api_types::remotes::Remote;
-use pdm_api_types::{PRIV_RESOURCE_MODIFY, UPID};
+use pdm_api_types::{
+ remote_updates::UpdateSummary, remotes::REMOTE_ID_SCHEMA, RemoteUpid, NODE_SCHEMA,
+ PRIV_RESOURCE_MODIFY, UPID,
+};
use proxmox_access_control::CachedUserInfo;
+use proxmox_apt_api_types::{APTGetChangelogOptions, APTUpdateInfo};
use proxmox_rest_server::WorkerTask;
use proxmox_router::{
http_bail, list_subdirs_api_method, Permission, Router, RpcEnvironment, SubdirMap,
@@ -15,6 +18,8 @@ use proxmox_sortable_macro::sortable;
use crate::remote_updates;
+use super::remotes::get_remote;
+
pub const ROUTER: Router = Router::new()
.get(&list_subdirs_api_method!(SUBDIRS))
.subdirs(SUBDIRS);
@@ -106,3 +111,112 @@ pub fn refresh_remote_update_summaries(rpcenv: &mut dyn RpcEnvironment) -> Resul
upid_str.parse()
}
+
+#[api(
+ input: {
+ properties: {
+ remote: {
+ schema: REMOTE_ID_SCHEMA,
+ },
+ node: {
+ schema: NODE_SCHEMA,
+ },
+ },
+ },
+ returns: {
+ description: "A list of packages with available updates.",
+ type: Array,
+ items: {
+ type: APTUpdateInfo
+ },
+ },
+ access: {
+ permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false),
+ },
+)]
+/// List available APT updates for a remote PVE node.
+async fn apt_update_available(remote: String, node: String) -> Result<Vec<APTUpdateInfo>, Error> {
+ let (config, _digest) = pdm_config::remotes::config()?;
+ let remote = get_remote(&config, &remote)?;
+
+ let updates = remote_updates::list_available_updates(remote.clone(), &node).await?;
+
+ Ok(updates)
+}
+
+#[api(
+ input: {
+ properties: {
+ remote: {
+ schema: REMOTE_ID_SCHEMA,
+ },
+ node: {
+ schema: NODE_SCHEMA,
+ },
+ },
+ },
+ access: {
+ permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false),
+ },
+)]
+/// Update the APT database of a remote PVE node.
+pub async fn apt_update_database(remote: String, node: String) -> Result<RemoteUpid, Error> {
+ let (config, _digest) = pdm_config::remotes::config()?;
+ let remote = get_remote(&config, &remote)?;
+
+ let upid = remote_updates::update_apt_database(remote, &node).await?;
+
+ Ok(upid)
+}
+
+#[api(
+ input: {
+ properties: {
+ remote: {
+ schema: REMOTE_ID_SCHEMA,
+ },
+ node: {
+ schema: NODE_SCHEMA,
+ },
+ options: {
+ type: APTGetChangelogOptions,
+ flatten: true,
+ },
+ },
+ },
+ returns: {
+ description: "The Package changelog.",
+ type: String,
+ },
+ access: {
+ permission: &Permission::Privilege(&["resource", "{remote}", "node", "{node}", "system"], PRIV_RESOURCE_MODIFY, false),
+ },
+)]
+/// Retrieve the changelog of the specified package for a remote PVE node.
+async fn apt_get_changelog(
+ remote: String,
+ node: String,
+ options: APTGetChangelogOptions,
+) -> Result<String, Error> {
+ let (config, _digest) = pdm_config::remotes::config()?;
+ let remote = get_remote(&config, &remote)?;
+
+ remote_updates::get_changelog(remote.clone(), &node, options.name).await
+}
+
+const APT_SUBDIRS: SubdirMap = &[
+ (
+ "changelog",
+ &Router::new().get(&API_METHOD_APT_GET_CHANGELOG),
+ ),
+ (
+ "update",
+ &Router::new()
+ .get(&API_METHOD_APT_UPDATE_AVAILABLE)
+ .post(&API_METHOD_APT_UPDATE_DATABASE),
+ ),
+];
+
+pub const APT_ROUTER: Router = Router::new()
+ .get(&list_subdirs_api_method!(APT_SUBDIRS))
+ .subdirs(APT_SUBDIRS);
--
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-10-15 12:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 12:46 [pdm-devel] [PATCH proxmox-datacenter-manager 00/12] add global remote update view Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 01/12] metric collection task: tests: add missing parameter for cluster_metric_export Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 02/12] pdm-api-types: add types for remote upgrade summary Lukas Wagner
2025-10-17 10:15 ` Shannon Sterz
2025-10-17 11:12 ` Lukas Wagner
2025-10-17 11:52 ` Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 03/12] remote updates: add cache for remote update availability Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 04/12] api: add API for retrieving/refreshing the remote update summary Lukas Wagner
2025-10-17 7:44 ` Lukas Wagner
2025-10-17 10:15 ` Shannon Sterz
2025-10-17 11:00 ` Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 05/12] unprivileged api daemon: tasks: add remote update refresh task Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 06/12] pdm-client: add API methods for remote update summaries Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 07/12] pbs-client: add bindings for APT-related API calls Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 08/12] task cache: use separate functions for tracking PVE and PBS tasks Lukas Wagner
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 09/12] remote updates: add support for PBS remotes Lukas Wagner
2025-10-15 12:47 ` Lukas Wagner [this message]
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 11/12] ui: add remote update view Lukas Wagner
2025-10-17 10:15 ` Shannon Sterz
2025-10-15 12:47 ` [pdm-devel] [PATCH proxmox-datacenter-manager 12/12] ui: show new remote update view in the 'Remotes' section Lukas Wagner
2025-10-17 10:15 ` [pdm-devel] [PATCH proxmox-datacenter-manager 00/12] add global remote update view Shannon Sterz
2025-10-17 12:14 ` [pdm-devel] superseded: " Lukas Wagner
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=20251015124711.312943-11-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.