public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Christoph Heiss <c.heiss@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-backup 2/2] manager: user: add 'user update-token' command
Date: Tue, 28 Jul 2026 16:35:30 +0200	[thread overview]
Message-ID: <805079f5-5189-4990-a9bb-926e9a7c7eda@proxmox.com> (raw)
In-Reply-To: <20260716103108.724902-3-c.heiss@proxmox.com>

On 7/16/26 12:31 PM, Christoph Heiss wrote:
> .. enabling users to easily update API tokens from the command line.
> 
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
>   src/bin/proxmox_backup_manager/user.rs | 62 +++++++++++++++++++++++++-
>   1 file changed, 61 insertions(+), 1 deletion(-)
> 
> diff --git a/src/bin/proxmox_backup_manager/user.rs b/src/bin/proxmox_backup_manager/user.rs
> index a429823de..93cb2d43f 100644
> --- a/src/bin/proxmox_backup_manager/user.rs
> +++ b/src/bin/proxmox_backup_manager/user.rs
> @@ -6,7 +6,10 @@ use std::collections::HashMap;
>   use proxmox_router::{ApiHandler, RpcEnvironment, cli::*};
>   use proxmox_schema::api;
>   
> -use pbs_api_types::{ACL_PATH_SCHEMA, Authid, Tokenname, Userid};
> +use pbs_api_types::{
> +    ACL_PATH_SCHEMA, Authid, ENABLE_USER_SCHEMA, EXPIRE_USER_SCHEMA, REGENERATE_TOKEN_SCHEMA,
> +    SINGLE_LINE_COMMENT_SCHEMA, Tokenname, Userid,
> +};
>   
>   use proxmox_backup::api2;
>   
> @@ -136,6 +139,56 @@ fn generate_token(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
>       Ok(Value::Null)
>   }
>   
> +#[api(
> +    input: {
> +        properties: {
> +            "output-format": {
> +                schema: OUTPUT_FORMAT,
> +                optional: true,
> +            },

nit: let's keep arg params declared first here...

> +            userid: {
> +                type: Userid,
> +            },
> +            "token-name": {
> +                type: Tokenname,
> +            },
> +            comment: {
> +                optional: true,

nit: this is bike-shedding, but could we keep the schema before the 
optional to be consistent with

> +                schema: SINGLE_LINE_COMMENT_SCHEMA,
> +            },
> +            enable: {
> +                schema: ENABLE_USER_SCHEMA,
> +                optional: true,
> +            },
> +            expire: {
> +                schema: EXPIRE_USER_SCHEMA,
> +                optional: true,
> +            },
> +            regenerate: {
> +                schema: REGENERATE_TOKEN_SCHEMA,
> +                optional: true,
> +            },

comment: This is missing the `delete` property, which should be exposed 
in the command as well.

> +        }
> +    }
> +)]
> +/// Update an existing API token
> +fn update_token(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
> +    let output_format = get_output_format(&param);
> +
> +    let info = &api2::access::user::API_METHOD_UPDATE_TOKEN;
> +    let mut data = match info.handler {
> +        ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
> +        _ => unreachable!(),
> +    };
> +
> +    let options = default_table_format_options().column(ColumnConfig::new("secret"));
> +    if !data.is_null() {
> +        format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
> +    }
> +
> +    Ok(Value::Null)
> +}
> +
>   #[api(
>       input: {
>           properties: {
> @@ -258,6 +311,13 @@ pub fn user_commands() -> CommandLineInterface {
>                   .arg_param(&["userid", "token-name"])
>                   .completion_cb("userid", pbs_config::user::complete_userid),
>           )
> +        .insert(
> +            "update-token",
> +            CliCommand::new(&API_METHOD_UPDATE_TOKEN)
> +                .arg_param(&["userid", "token-name"])
> +                .completion_cb("userid", pbs_config::user::complete_userid)
> +                .completion_cb("token-name", pbs_config::user::complete_token_name),
> +        )
>           .insert(
>               "delete-token",
>               CliCommand::new(&api2::access::user::API_METHOD_DELETE_TOKEN)





      reply	other threads:[~2026-07-28 14:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 10:29 [PATCH proxmox-backup 0/2] manager: user: improve 'generate-token', implement 'update-token' Christoph Heiss
2026-07-16 10:29 ` [PATCH proxmox-backup 1/2] manager: user: make 'user generate-token' accept --output-format Christoph Heiss
2026-07-28 14:26   ` Christian Ebner
2026-07-16 10:29 ` [PATCH proxmox-backup 2/2] manager: user: add 'user update-token' command Christoph Heiss
2026-07-28 14:35   ` Christian Ebner [this message]

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=805079f5-5189-4990-a9bb-926e9a7c7eda@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=c.heiss@proxmox.com \
    --cc=pbs-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