2
2
3
3
from conductor .client .codegen .api_client import ApiClient
4
4
from conductor .client .configuration .configuration import Configuration
5
+ from conductor .client .adapters .rest_adapter import RESTClientObjectAdapter
5
6
6
7
from conductor .client .codegen .rest import AuthorizationException , ApiException
7
8
8
9
logger = logging .getLogger (Configuration .get_logging_formatted_name (__name__ ))
9
10
11
+
10
12
class ApiClientAdapter (ApiClient ):
13
+ def __init__ (
14
+ self , configuration = None , header_name = None , header_value = None , cookie = None
15
+ ):
16
+ """Initialize the API client adapter with httpx-based REST client."""
17
+ super ().__init__ (configuration , header_name , header_value , cookie )
18
+ self .rest_client = RESTClientObjectAdapter (
19
+ connection = configuration .http_connection if configuration else None
20
+ )
21
+
11
22
def __call_api (
12
- self , resource_path , method , path_params = None ,
13
- query_params = None , header_params = None , body = None , post_params = None ,
14
- files = None , response_type = None , auth_settings = None ,
15
- _return_http_data_only = None , collection_formats = None ,
16
- _preload_content = True , _request_timeout = None ):
23
+ self ,
24
+ resource_path ,
25
+ method ,
26
+ path_params = None ,
27
+ query_params = None ,
28
+ header_params = None ,
29
+ body = None ,
30
+ post_params = None ,
31
+ files = None ,
32
+ response_type = None ,
33
+ auth_settings = None ,
34
+ _return_http_data_only = None ,
35
+ collection_formats = None ,
36
+ _preload_content = True ,
37
+ _request_timeout = None ,
38
+ ):
17
39
try :
18
- logger .debug ("HTTP request method: %s; resource_path: %s; header_params: %s" , method , resource_path , header_params )
40
+ logger .debug (
41
+ "HTTP request method: %s; resource_path: %s; header_params: %s" ,
42
+ method ,
43
+ resource_path ,
44
+ header_params ,
45
+ )
19
46
return self .__call_api_no_retry (
20
- resource_path = resource_path , method = method , path_params = path_params ,
21
- query_params = query_params , header_params = header_params , body = body , post_params = post_params ,
22
- files = files , response_type = response_type , auth_settings = auth_settings ,
23
- _return_http_data_only = _return_http_data_only , collection_formats = collection_formats ,
24
- _preload_content = _preload_content , _request_timeout = _request_timeout
47
+ resource_path = resource_path ,
48
+ method = method ,
49
+ path_params = path_params ,
50
+ query_params = query_params ,
51
+ header_params = header_params ,
52
+ body = body ,
53
+ post_params = post_params ,
54
+ files = files ,
55
+ response_type = response_type ,
56
+ auth_settings = auth_settings ,
57
+ _return_http_data_only = _return_http_data_only ,
58
+ collection_formats = collection_formats ,
59
+ _preload_content = _preload_content ,
60
+ _request_timeout = _request_timeout ,
25
61
)
26
62
except AuthorizationException as ae :
27
63
if ae .token_expired or ae .invalid_token :
28
64
token_status = "expired" if ae .token_expired else "invalid"
29
- logger .warning ("HTTP response from: %s; token_status: %s; status code: 401 - obtaining new token" , resource_path , token_status )
65
+ logger .warning (
66
+ "HTTP response from: %s; token_status: %s; status code: 401 - obtaining new token" ,
67
+ resource_path ,
68
+ token_status ,
69
+ )
30
70
# if the token has expired or is invalid, lets refresh the token
31
71
self .__force_refresh_auth_token ()
32
72
# and now retry the same request
33
73
return self .__call_api_no_retry (
34
- resource_path = resource_path , method = method , path_params = path_params ,
35
- query_params = query_params , header_params = header_params , body = body , post_params = post_params ,
36
- files = files , response_type = response_type , auth_settings = auth_settings ,
37
- _return_http_data_only = _return_http_data_only , collection_formats = collection_formats ,
38
- _preload_content = _preload_content , _request_timeout = _request_timeout
74
+ resource_path = resource_path ,
75
+ method = method ,
76
+ path_params = path_params ,
77
+ query_params = query_params ,
78
+ header_params = header_params ,
79
+ body = body ,
80
+ post_params = post_params ,
81
+ files = files ,
82
+ response_type = response_type ,
83
+ auth_settings = auth_settings ,
84
+ _return_http_data_only = _return_http_data_only ,
85
+ collection_formats = collection_formats ,
86
+ _preload_content = _preload_content ,
87
+ _request_timeout = _request_timeout ,
39
88
)
40
89
raise ae
41
90
except ApiException as e :
42
- logger .error ("HTTP request failed url: %s status: %s; reason: %s" , resource_path , e .status , e .reason )
43
- raise e
91
+ logger .error (
92
+ "HTTP request failed url: %s status: %s; reason: %s" ,
93
+ resource_path ,
94
+ e .status ,
95
+ e .reason ,
96
+ )
97
+ raise e
0 commit comments