From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id CD04D1FF138 for ; Wed, 18 Feb 2026 17:42:51 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5CDEF671; Wed, 18 Feb 2026 17:43:51 +0100 (CET) From: Shan Shaji To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager v4 1/6] server: pbs-client: add method to delete token from remote Date: Wed, 18 Feb 2026 17:41:29 +0100 Message-ID: <20260218164135.413762-2-s.shaji@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260218164135.413762-1-s.shaji@proxmox.com> References: <20260218164135.413762-1-s.shaji@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1771433019825 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.110 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 3PRMWNNZPT5YJFMXGKHMI667MRO5EHEC X-Message-ID-Hash: 3PRMWNNZPT5YJFMXGKHMI667MRO5EHEC X-MailFrom: s.shaji@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Inorder to allow deleting the generated token of PBS from PDM, add method inside the `PbsClient` to delete the token. Signed-off-by: Shan Shaji --- changes since v3: - use percent_encoding to encode the userid. - change the function name from delete_admin_token to delete_token. - nit: change "API-Token" to "API token". - pass &TokennameRef from callsite. server/src/pbs_client.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/server/src/pbs_client.rs b/server/src/pbs_client.rs index f4f1f82..6158da7 100644 --- a/server/src/pbs_client.rs +++ b/server/src/pbs_client.rs @@ -13,7 +13,7 @@ use proxmox_router::stream::JsonRecords; use proxmox_schema::api; use proxmox_section_config::typed::SectionConfigData; -use pbs_api_types::{Authid, Tokenname, Userid}; +use pbs_api_types::{Authid, Tokenname, TokennameRef, Userid}; use pdm_api_types::remotes::{Remote, RemoteType}; @@ -260,6 +260,20 @@ impl PbsClient { Ok(token) } + /// Delete API token from the PBS remote. + pub async fn delete_token(&self, userid: &Userid, tokenid: &TokennameRef) -> Result<(), Error> { + let path = format!( + "/api2/extjs/access/users/{}/token/{}", + percent_encoding::percent_encode( + userid.as_str().as_bytes(), + percent_encoding::NON_ALPHANUMERIC + ), + tokenid.as_str() + ); + self.0.delete(&path).await?.nodata()?; + Ok(()) + } + /// Return the status the Proxmox Backup Server instance pub async fn node_status(&self) -> Result { let path = "/api2/extjs/nodes/localhost/status"; -- 2.47.3