@@ -24,18 +24,18 @@ def partition(self, request: Optional[shared.PartitionParameters], retries: Opti
24
24
base_url = utils .template_url (* self .sdk_configuration .get_server_details ())
25
25
26
26
url = base_url + '/general/v0/general'
27
- headers = {}
27
+
28
+ if callable (self .sdk_configuration .security ):
29
+ headers , query_params = utils .get_security (self .sdk_configuration .security ())
30
+ else :
31
+ headers , query_params = utils .get_security (self .sdk_configuration .security )
32
+
28
33
req_content_type , data , form = utils .serialize_request_body (request , Optional [shared .PartitionParameters ], "request" , False , True , 'multipart' )
29
34
if req_content_type is not None and req_content_type not in ('multipart/form-data' , 'multipart/mixed' ):
30
35
headers ['content-type' ] = req_content_type
31
36
headers ['Accept' ] = 'application/json'
32
37
headers ['user-agent' ] = self .sdk_configuration .user_agent
33
-
34
- if callable (self .sdk_configuration .security ):
35
- client = utils .configure_security_client (self .sdk_configuration .client , self .sdk_configuration .security ())
36
- else :
37
- client = utils .configure_security_client (self .sdk_configuration .client , self .sdk_configuration .security )
38
-
38
+ client = self .sdk_configuration .client
39
39
40
40
global_retry_config = self .sdk_configuration .retry_config
41
41
retry_config = retries
@@ -45,11 +45,13 @@ def partition(self, request: Optional[shared.PartitionParameters], retries: Opti
45
45
else :
46
46
retry_config = utils .RetryConfig ('backoff' , utils .BackoffStrategy (500 , 60000 , 1.5 , 900000 ), True )
47
47
48
+ req = None
48
49
def do_request ():
50
+ nonlocal req
49
51
try :
50
52
req = self .sdk_configuration .get_hooks ().before_request (
51
53
hook_ctx ,
52
- requests_http .Request ('POST' , url , data = data , files = form , headers = headers ).prepare (),
54
+ requests_http .Request ('POST' , url , params = query_params , data = data , files = form , headers = headers ).prepare (),
53
55
)
54
56
http_res = client .send (req )
55
57
except Exception as e :
@@ -72,26 +74,28 @@ def do_request():
72
74
'5xx'
73
75
]))
74
76
75
- content_type = http_res .headers .get ('Content-Type' )
76
77
77
- res = operations .PartitionResponse (status_code = http_res .status_code , content_type = content_type , raw_response = http_res )
78
+ res = operations .PartitionResponse (status_code = http_res .status_code , content_type = http_res . headers . get ( 'Content-Type' ) , raw_response = http_res )
78
79
79
80
if http_res .status_code == 200 :
80
- if utils .match_content_type (content_type , 'application/json' ):
81
+ if utils .match_content_type (http_res . headers . get ( 'Content-Type' ) , 'application/json' ):
81
82
out = utils .unmarshal_json (http_res .text , Optional [List [Any ]])
82
83
res .elements = out
83
84
else :
85
+ content_type = http_res .headers .get ('Content-Type' )
84
86
raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
85
87
elif http_res .status_code == 422 :
86
- if utils .match_content_type (content_type , 'application/json' ):
88
+ if utils .match_content_type (http_res . headers . get ( 'Content-Type' ) , 'application/json' ):
87
89
out = utils .unmarshal_json (http_res .text , errors .HTTPValidationError )
88
- out .raw_response = http_res
89
90
raise out
90
91
else :
92
+ content_type = http_res .headers .get ('Content-Type' )
91
93
raise errors .SDKError (f'unknown content-type received: { content_type } ' , http_res .status_code , http_res .text , http_res )
92
94
elif http_res .status_code >= 400 and http_res .status_code < 500 or http_res .status_code >= 500 and http_res .status_code < 600 :
93
95
raise errors .SDKError ('API error occurred' , http_res .status_code , http_res .text , http_res )
96
+ else :
97
+ raise errors .SDKError ('unknown status code received' , http_res .status_code , http_res .text , http_res )
94
98
95
99
return res
96
100
97
-
101
+
0 commit comments