From: Christian Ebner <c.ebner@proxmox.com>
To: Christoph Heiss <c.heiss@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox-backup 1/2] manager: user: make 'user generate-token' accept --output-format
Date: Tue, 28 Jul 2026 16:26:35 +0200 [thread overview]
Message-ID: <ab20ff41-8408-4fe4-a287-0fe5340d79a0@proxmox.com> (raw)
In-Reply-To: <20260716103108.724902-2-c.heiss@proxmox.com>
NACK: This introduces a regression, as now all the previously optional
parameters cannot specified anymore since not declared in the api schema
for the command.
On 7/16/26 12:31 PM, Christoph Heiss wrote:
> Needs a small wrapper (like most other commands) to parse the option and
> print the result formatted appropriately.
>
> Before, when invoking 'proxmox-backup-manager user generate-token [..]',
> the output would be a mix of human-readable and machine-readable:
>
> Result: {
> "tokenid": "root@pam!my-token",
> "value": ".."
> }
>
> Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
> ---
> Ran across this while working on something else, definitely worth
> fixing.
>
> src/bin/proxmox_backup_manager/user.rs | 39 ++++++++++++++++++++++++--
> 1 file changed, 37 insertions(+), 2 deletions(-)
>
> diff --git a/src/bin/proxmox_backup_manager/user.rs b/src/bin/proxmox_backup_manager/user.rs
> index 87c1f4394..a429823de 100644
> --- a/src/bin/proxmox_backup_manager/user.rs
> +++ b/src/bin/proxmox_backup_manager/user.rs
> @@ -6,7 +6,7 @@ use std::collections::HashMap;
> use proxmox_router::{ApiHandler, RpcEnvironment, cli::*};
> use proxmox_schema::api;
>
> -use pbs_api_types::{ACL_PATH_SCHEMA, Authid, Userid};
> +use pbs_api_types::{ACL_PATH_SCHEMA, Authid, Tokenname, Userid};
>
> use proxmox_backup::api2;
>
> @@ -101,6 +101,41 @@ fn list_tokens(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, E
> Ok(Value::Null)
> }
>
> +#[api(
> + input: {
> + properties: {
> + "output-format": {
> + schema: OUTPUT_FORMAT,
> + optional: true,
> + },
> + userid: {
> + type: Userid,
> + },
> + "token-name": {
> + type: Tokenname,
> + },
need to re-declare all the api paramters for
api2::access::user::API_METHOD_GENERATE_TOKEN as well.
Also, I would prefer arg_params to be declared before optional ones here...
> + }
> + }
> +)]
> +/// Generate a new API token with given metadata
> +fn generate_token(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
> + let output_format = get_output_format(¶m);
> +
> + let info = &api2::access::user::API_METHOD_GENERATE_TOKEN;
> + let mut data = match info.handler {
> + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
> + _ => unreachable!(),
> + };
> +
> + let options = default_table_format_options()
> + .column(ColumnConfig::new("tokenid"))
> + .column(ColumnConfig::new("value"));
> +
> + format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
> +
> + Ok(Value::Null)
> +}
> +
> #[api(
> input: {
> properties: {
> @@ -219,7 +254,7 @@ pub fn user_commands() -> CommandLineInterface {
> )
> .insert(
> "generate-token",
> - CliCommand::new(&api2::access::user::API_METHOD_GENERATE_TOKEN)
> + CliCommand::new(&API_METHOD_GENERATE_TOKEN)
> .arg_param(&["userid", "token-name"])
> .completion_cb("userid", pbs_config::user::complete_userid),
> )
next prev parent reply other threads:[~2026-07-28 14:26 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 [this message]
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
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=ab20ff41-8408-4fe4-a287-0fe5340d79a0@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