[pdm-devel] [PATCH proxmox 2/3] proxmox-client: adapt to new compat mode introduced for proxmox-login
Christian Ebner
c.ebner at proxmox.com
Mon Sep 29 17:48:16 CEST 2025
The API for setting the compatibility changed to allow for easier
extension. Adapt the client to the new interface and expose the same
changes to the client.
Also, re-export the `CompatMode` so users do not need to directly
depend on the implementation in proxmox-login.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
proxmox-client/src/client.rs | 12 ++++++------
proxmox-client/src/lib.rs | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs
index da2c5c59..894d9216 100644
--- a/proxmox-client/src/client.rs
+++ b/proxmox-client/src/client.rs
@@ -17,7 +17,7 @@ use serde::Serialize;
use proxmox_http::Body;
use proxmox_login::ticket::Validity;
-use proxmox_login::{Login, SecondFactorChallenge, TicketResult};
+use proxmox_login::{CompatMode, Login, SecondFactorChallenge, TicketResult};
use crate::auth::AuthenticationKind;
use crate::error::ParseFingerprintError;
@@ -68,7 +68,7 @@ pub struct Client {
api_url: Uri,
auth: Mutex<Option<Arc<AuthenticationKind>>>,
client: Arc<proxmox_http::client::Client>,
- pve_compat: bool,
+ compat_mode: CompatMode,
cookie_name: Option<String>,
}
@@ -91,7 +91,7 @@ impl Client {
api_url,
auth: Mutex::new(None),
client,
- pve_compat: false,
+ compat_mode: CompatMode::default(),
cookie_name: None,
}
}
@@ -181,8 +181,8 @@ impl Client {
/// Enable Proxmox VE login API compatibility. This is required to support TFA authentication
/// on Proxmox VE APIs which require the `new-format` option.
- pub fn set_pve_compatibility(&mut self, compatibility: bool) {
- self.pve_compat = compatibility;
+ pub fn set_compatibility(&mut self, compat_mode: CompatMode) {
+ self.compat_mode = compat_mode;
}
pub fn set_cookie_name(&mut self, cookie_name: &str) {
@@ -418,7 +418,7 @@ impl Client {
/// If the authentication is complete, `None` is returned and the authentication state updated.
/// If a 2nd factor is required, `Some` is returned.
pub async fn login(&self, login: Login) -> Result<Option<SecondFactorChallenge>, Error> {
- let login = login.pve_compatibility(self.pve_compat);
+ let login = login.set_compatibility(self.compat_mode);
let (ticket, api_response) = self.do_login_request(login.request()).await?;
diff --git a/proxmox-client/src/lib.rs b/proxmox-client/src/lib.rs
index f1df1e1d..3bac1333 100644
--- a/proxmox-client/src/lib.rs
+++ b/proxmox-client/src/lib.rs
@@ -12,7 +12,7 @@ mod error;
pub use error::Error;
pub use proxmox_login::tfa::TfaChallenge;
-pub use proxmox_login::{Authentication, Ticket};
+pub use proxmox_login::{CompatMode, Authentication, Ticket};
mod api_path_builder;
pub use api_path_builder::ApiPathBuilder;
--
2.47.3
More information about the pdm-devel
mailing list