public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: Proxmox Datacenter Manager development discussion
	<pdm-devel@lists.proxmox.com>,
	Lukas Wagner <l.wagner@proxmox.com>
Subject: Re: [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] server: add api for getting available updates/changelogs for remote nodes
Date: Wed, 3 Sep 2025 11:19:15 +0200	[thread overview]
Message-ID: <9d849f90-766f-4978-a37a-5a30a0931dbd@proxmox.com> (raw)
In-Reply-To: <3b096098-d5c9-4108-8a92-717af8cf3978@proxmox.com>

On 9/3/25 11:02 AM, Stefan Hanreich wrote:
> On 9/2/25 5:14 PM, Lukas Wagner wrote:
>> This adds new APIs for update management:
>>
>>     GET /pve/remotes/{remote}/nodes/{node}/apt/changelog
>>       -> get package changelog
>>     GET /pve/remotes/{remote}/nodes/{node}/apt/update
>>       -> get list of updatable packages
>>     POST /pve/remotes/{remote}/nodes/{node}/apt/update
>>       -> refresh APT database
>>
>> At this time these just pass the call through to PVE with no caching
>> involved on the PDM side. This should be fine for this API, but once
>> we have an API for 'give me a view of ALL available remote updates',
>> we need to introduce a cache that is periodically refreshed.
>>
>> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
>> ---
>>  server/src/api/pve/apt.rs    | 119 +++++++++++++++++++++++++++++++++++
>>  server/src/api/pve/mod.rs    |   3 +-
>>  server/src/api/pve/node.rs   |   1 +
>>  server/src/lib.rs            |   1 +
>>  server/src/remote_updates.rs |  96 ++++++++++++++++++++++++++++
>>  5 files changed, 219 insertions(+), 1 deletion(-)
>>  create mode 100644 server/src/api/pve/apt.rs
>>  create mode 100644 server/src/remote_updates.rs
>>
>> diff --git a/server/src/api/pve/apt.rs b/server/src/api/pve/apt.rs
>> new file mode 100644
>> index 00000000..f5027fb8
>> --- /dev/null
>> +++ b/server/src/api/pve/apt.rs
>> @@ -0,0 +1,119 @@
>> +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> {
> 
> potentially fine to take a ref here for both params as well?
> 
>> +    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> {
> 
> here too then
> 
>> +    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,
> 
> here too then

sorry, was too liberal when scanning the functions, those three cannot
take a ref ofc

[snip]


_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  reply	other threads:[~2025-09-03  9:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 15:14 [pdm-devel] [PATCH manager/proxmox{-api-types, -yew-comp, -datacenter-manager} 00/10] PVE node update view Lukas Wagner
2025-09-02 15:14 ` [pdm-devel] [PATCH manager 1/1] api: apt: add JSON schema for 'list_updates' endpoint Lukas Wagner
2025-09-03  8:25   ` [pdm-devel] applied: " Thomas Lamprecht
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-api-types 1/3] Schema2Rust: fix handling of non-optional params Lukas Wagner
2025-09-03  8:57   ` [pdm-devel] applied: " Wolfgang Bumiller
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-api-types 2/3] generate: add bindings for various APT functions Lukas Wagner
2025-09-03  8:58   ` [pdm-devel] applied: " Wolfgang Bumiller
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-api-types 3/3] refresh bindings Lukas Wagner
2025-09-03  8:59   ` Wolfgang Bumiller
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-yew-comp 1/2] apt view: allow to set task_base_url Lukas Wagner
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-yew-comp 2/2] apt view: reload if base urls have changed Lukas Wagner
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-datacenter-manager 1/4] server: add api for getting available updates/changelogs for remote nodes Lukas Wagner
2025-09-03  8:42   ` Lukas Wagner
2025-09-03  9:02   ` Stefan Hanreich
2025-09-03  9:19     ` Stefan Hanreich [this message]
2025-09-03  9:23     ` Lukas Wagner
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-datacenter-manager 2/4] ui: pve: promote node.rs to dir-style module Lukas Wagner
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-datacenter-manager 3/4] ui: pve: move node overview to a new overview tab Lukas Wagner
2025-09-03  9:10   ` Stefan Hanreich
2025-09-03  9:48     ` Lukas Wagner
2025-09-03  9:52       ` Stefan Hanreich
2025-09-03  9:55         ` Lukas Wagner
2025-09-02 15:14 ` [pdm-devel] [PATCH proxmox-datacenter-manager 4/4] ui: pve: node: add update tab Lukas Wagner
2025-09-03 10:20 ` [pdm-devel] [PATCH manager/proxmox{-api-types, -yew-comp, -datacenter-manager} 00/10] PVE node update view Stefan Hanreich
2025-09-03 11:43 ` [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=9d849f90-766f-4978-a37a-5a30a0931dbd@proxmox.com \
    --to=s.hanreich@proxmox.com \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal