@@ -31,22 +31,22 @@ def url_to_str(cls, v: typing.Any) -> str:
31
31
32
32
@pydantic .field_validator ("token" )
33
33
def check_token (cls , v : typing .Any ) -> str :
34
- if not (expiry := get_expiry (v )):
34
+ value = v .get_secret_value ()
35
+ if not (expiry := get_expiry (value )):
35
36
raise AssertionError ("Failed to parse Simvue token - invalid token form" )
36
37
if time .time () - expiry > 0 :
37
38
raise AssertionError ("Simvue token has expired" )
38
- return v
39
+ return value
39
40
40
41
@pydantic .model_validator (mode = "after" )
41
- def check_valid_server (cls , values : dict ) -> bool :
42
- url = values ["url" ]
43
- token = values ["token" ]
42
+ @classmethod
43
+ def check_valid_server (cls , values : "ServerSpecifications" ) -> bool :
44
44
headers : dict [str , str ] = {
45
- "Authorization" : f"Bearer { token } " ,
45
+ "Authorization" : f"Bearer { values . token } " ,
46
46
"User-Agent" : f"Simvue Python client { __version__ } " ,
47
47
}
48
48
try :
49
- response = get (f"{ url } /api/version" , headers )
49
+ response = get (f"{ values . url } /api/version" , headers )
50
50
51
51
if response .status_code != http .HTTPStatus .OK or not response .json ().get (
52
52
"version"
@@ -59,6 +59,8 @@ def check_valid_server(cls, values: dict) -> bool:
59
59
except Exception as err :
60
60
raise AssertionError (f"Exception retrieving server version: { str (err )} " )
61
61
62
+ return values
63
+
62
64
63
65
class DefaultRunSpecifications (pydantic .BaseModel ):
64
66
description : typing .Optional [str ] = None
0 commit comments