Skip to content

Commit 6bc343e

Browse files
committed
Adapt stream to legacy raw-response methods
The legacy-compatible modern generator preserves raw responses through the ordinary method's _preload_content=False option instead of emitting *_without_preload_content siblings. Route WebSocket requests through that generated path so request serialization remains generated while the stream adapter supplies the response wrapper expected by the legacy compatibility helper.
1 parent d0ecd55 commit 6bc343e

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

kubernetes/base/stream/stream.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ def _websocket_request(websocket_request, force_kwargs, api_method, *args, **kwa
2525
kwargs[kwarg] = value
2626
api_client = api_method.__self__.api_client
2727
configuration = api_client.configuration
28-
raw_api_method = getattr(
29-
api_method.__self__,
30-
f'{api_method.__name__}_without_preload_content',
31-
)
3228
preload_content = kwargs.pop('_preload_content', True)
29+
kwargs['_preload_content'] = False
3330
binary = kwargs.pop('binary', False)
3431
previous_call_api = api_client.call_api
3532

36-
# v7 raw generated methods unwrap call_api(...).response. Adapt the
37-
# websocket result to that one-field protocol while keeping the generated
38-
# method responsible for request serialization.
33+
# Legacy-compatible generated methods preserve _preload_content=False
34+
# instead of emitting *_without_preload_content siblings. Keep generated
35+
# request serialization, then satisfy the raw-response shape it expects.
3936
def call_api(
4037
method,
4138
url,
@@ -55,11 +52,16 @@ def call_api(
5552
_preload_content=preload_content,
5653
binary=binary,
5754
)
58-
return SimpleNamespace(response=response)
55+
return SimpleNamespace(
56+
response=response,
57+
status=response.status
58+
if isinstance(response, ws_client.WSResponse)
59+
else 200,
60+
)
5961

6062
try:
6163
api_client.call_api = call_api
62-
response = raw_api_method(*args, **kwargs)
64+
response = api_method(*args, **kwargs)
6365
finally:
6466
api_client.call_api = previous_call_api
6567

0 commit comments

Comments
 (0)