From: Christoph Heiss <c.heiss@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup 2/2] manager: user: add 'user update-token' command
Date: Thu, 16 Jul 2026 12:29:57 +0200 [thread overview]
Message-ID: <20260716103108.724902-3-c.heiss@proxmox.com> (raw)
In-Reply-To: <20260716103108.724902-1-c.heiss@proxmox.com>
.. 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,
+ },
+ userid: {
+ type: Userid,
+ },
+ "token-name": {
+ type: Tokenname,
+ },
+ comment: {
+ optional: true,
+ 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,
+ },
+ }
+ }
+)]
+/// Update an existing API token
+fn update_token(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
+ let output_format = get_output_format(¶m);
+
+ 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)
--
2.54.0
prev parent reply other threads:[~2026-07-16 10:31 UTC|newest]
Thread overview: 3+ 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-16 10:29 ` Christoph Heiss [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=20260716103108.724902-3-c.heiss@proxmox.com \
--to=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