@@ -159,16 +159,12 @@ pub struct VerifierClient {
159159#[ derive( Debug ) ]
160160pub struct VerifierClientBuilder < ' a > {
161161 config : Option < & ' a Config > ,
162- override_api_version : Option < String > ,
163162}
164163
165164impl < ' a > VerifierClientBuilder < ' a > {
166165 /// Create a new builder instance
167166 pub fn new ( ) -> Self {
168- Self {
169- config : None ,
170- override_api_version : None ,
171- }
167+ Self { config : None }
172168 }
173169
174170 /// Set the configuration for the client
@@ -177,40 +173,19 @@ impl<'a> VerifierClientBuilder<'a> {
177173 self
178174 }
179175
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-
191176 /// Build the VerifierClient with automatic API version detection
192177 ///
193178 /// This is the recommended way to create a client for production use,
194179 /// as it will automatically detect the optimal API version supported
195180 /// by the verifier service.
196- ///
197- /// If `override_api_version()` was called, the detected version will
198- /// be overridden after detection completes.
199181 pub async fn build ( self ) -> Result < VerifierClient , KeylimectlError > {
200182 let config = self . config . ok_or_else ( || {
201183 KeylimectlError :: validation (
202184 "Configuration is required for VerifierClient" ,
203185 )
204186 } ) ?;
205187
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)
188+ VerifierClient :: new ( config) . await
214189 }
215190}
216191
@@ -580,16 +555,11 @@ impl VerifierClient {
580555 ) -> Result < Value , KeylimectlError > {
581556 debug ! ( "Adding agent {agent_uuid} to verifier" ) ;
582557
583- // API v3.0+ uses POST /v3.0/agents/ (without agent ID)
584- // API v2.x uses POST /v2.x/agents/{agent_id}
585- let url = if self . api_version . parse :: < f32 > ( ) . unwrap_or ( 2.1 ) >= 3.0 {
586- format ! ( "{}/v{}/agents/" , self . base. base_url, self . api_version)
587- } else {
588- format ! (
589- "{}/v{}/agents/{}" ,
590- self . base. base_url, self . api_version, agent_uuid
591- )
592- } ;
558+ // POST to /agents/:agent_uuid for all API versions
559+ let url = format ! (
560+ "{}/v{}/agents/{}" ,
561+ self . base. base_url, self . api_version, agent_uuid
562+ ) ;
593563
594564 debug ! (
595565 "POST {url} with data: {}" ,
@@ -1991,22 +1961,7 @@ mod tests {
19911961 }
19921962
19931963 #[ 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 ( ) {
1964+ async fn test_builder ( ) {
20101965 let config = create_test_config ( ) ;
20111966 let client =
20121967 VerifierClient :: builder ( ) . config ( & config) . build ( ) . await ;
0 commit comments