@@ -159,12 +159,16 @@ pub struct VerifierClient {
159159#[ derive( Debug ) ]
160160pub struct VerifierClientBuilder < ' a > {
161161 config : Option < & ' a Config > ,
162+ override_api_version : Option < String > ,
162163}
163164
164165impl < ' a > VerifierClientBuilder < ' a > {
165166 /// Create a new builder instance
166167 pub fn new ( ) -> Self {
167- Self { config : None }
168+ Self {
169+ config : None ,
170+ override_api_version : None ,
171+ }
168172 }
169173
170174 /// Set the configuration for the client
@@ -173,19 +177,40 @@ impl<'a> VerifierClientBuilder<'a> {
173177 self
174178 }
175179
180+ /// Override the API version after detection
181+ ///
182+ /// This allows you to override the detected API version for specific
183+ /// operations while still benefiting from detection for component
184+ /// discovery. Useful for push-model where verifier needs v3.0 but
185+ /// other components may use different versions.
186+ pub fn override_api_version ( mut self , version : & str ) -> Self {
187+ self . override_api_version = Some ( version. to_string ( ) ) ;
188+ self
189+ }
190+
176191 /// Build the VerifierClient with automatic API version detection
177192 ///
178193 /// This is the recommended way to create a client for production use,
179194 /// as it will automatically detect the optimal API version supported
180195 /// by the verifier service.
196+ ///
197+ /// If `override_api_version()` was called, the detected version will
198+ /// be overridden after detection completes.
181199 pub async fn build ( self ) -> Result < VerifierClient , KeylimectlError > {
182200 let config = self . config . ok_or_else ( || {
183201 KeylimectlError :: validation (
184202 "Configuration is required for VerifierClient" ,
185203 )
186204 } ) ?;
187205
188- VerifierClient :: new ( config) . await
206+ let mut client = VerifierClient :: new ( config) . await ?;
207+
208+ // Override API version if specified
209+ if let Some ( version) = self . override_api_version {
210+ client. api_version = version;
211+ }
212+
213+ Ok ( client)
189214 }
190215}
191216
@@ -1965,6 +1990,32 @@ mod tests {
19651990 assert_eq ! ( client. api_version, "3.0" ) ;
19661991 }
19671992
1993+ #[ tokio:: test]
1994+ async fn test_builder_override_api_version ( ) {
1995+ let config = create_test_config ( ) ;
1996+ let client = VerifierClient :: builder ( )
1997+ . config ( & config)
1998+ . override_api_version ( "3.0" )
1999+ . build ( )
2000+ . await ;
2001+
2002+ assert ! ( client. is_ok( ) ) ;
2003+ let client = client. unwrap ( ) ;
2004+ // Should use the overridden version
2005+ assert_eq ! ( client. api_version, "3.0" ) ;
2006+ }
2007+
2008+ #[ tokio:: test]
2009+ async fn test_builder_without_override ( ) {
2010+ let config = create_test_config ( ) ;
2011+ let client =
2012+ VerifierClient :: builder ( ) . config ( & config) . build ( ) . await ;
2013+
2014+ // This will fail to connect but we can check the structure
2015+ // In a real scenario, it would detect the version
2016+ assert ! ( client. is_ok( ) || client. is_err( ) ) ;
2017+ }
2018+
19682019 #[ test]
19692020 fn test_base_url_construction_with_different_versions ( ) {
19702021 let config = create_test_config ( ) ;
0 commit comments