Skip to content

Commit 97c36c3

Browse files
committed
Updated client.py to conform to new openapi generated api_client.py
I removed the default Content-Type: */* as kubernetes does not seem to like that. Example: curl -k -x socks5://localhost:9090/ \ --header "Accept: application/json" \ --header "Content-Type: */*" \ https://xxxx:6443/version { "kind": "Status", "apiVersion": "v1", "metadata": {}, "status": "Failure", "message": "406: Not Acceptable\n\nAvailable representations: ", "reason": "NotAcceptable", "details": {}, "code": 406 } Unsure how that worked before, but simply not setting a content type worked.
1 parent 9638aab commit 97c36c3

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

Diff for: kubernetes/base/dynamic/client.py

+11-16
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ def inner(self, *args, **kwargs):
5656
except ApiException as e:
5757
raise api_exception(e)
5858
if serialize_response:
59+
data = resp.read()
5960
try:
6061
if six.PY2:
61-
return serializer(self, json.loads(resp.data))
62-
return serializer(self, json.loads(resp.data.decode('utf8')))
62+
return serializer(self, json.loads(data))
63+
return serializer(self, json.loads(data.decode('utf8')))
6364
except ValueError:
6465
if six.PY2:
65-
return resp.data
66-
return resp.data.decode('utf8')
66+
return data
67+
return data.decode('utf8')
6768
return resp
6869

6970
return inner
@@ -264,31 +265,25 @@ def request(self, method, path, body=None, **params):
264265
# HTTP header `Content-Type`
265266
if params.get('content_type'):
266267
header_params['Content-Type'] = params['content_type']
267-
else:
268-
header_params['Content-Type'] = self.client.select_header_content_type(['*/*'])
269268

270269
# Authentication setting
271270
auth_settings = ['BearerToken']
272-
273-
api_response = self.client.call_api(
274-
path,
271+
call_params = self.client.param_serialize(
275272
method.upper(),
273+
path,
276274
path_params,
277275
query_params,
278276
header_params,
279277
body=body,
280278
post_params=form_params,
281-
async_req=params.get('async_req'),
282279
files=local_var_files,
283280
auth_settings=auth_settings,
284-
_preload_content=False,
285-
_return_http_data_only=params.get('_return_http_data_only', True),
281+
)
282+
api_response = self.client.call_api(*call_params,
286283
_request_timeout=params.get('_request_timeout')
287284
)
288-
if params.get('async_req'):
289-
return api_response.get()
290-
else:
291-
return api_response
285+
api_response.read()
286+
return api_response
292287

293288
def validate(self, definition, version=None, strict=False):
294289
"""validate checks a kubernetes resource definition

0 commit comments

Comments
 (0)