kubernetes.stream.ws_client module

class kubernetes.stream.ws_client.PortForward(websocket, ports)

Bases: object

close()
property connected
error(port_number)
socket(port_number)
class kubernetes.stream.ws_client.WSClient(configuration, url, headers, capture_all, binary=False)

Bases: object

close(**kwargs)

close websocket connection.

close_channel(channel)

Close a channel (v5 protocol only).

is_open()

True if the connection is still alive.

peek_channel(channel, timeout=0)

Peek a channel and return part of the input, empty string otherwise.

peek_stderr(timeout=0)

Same as peek_channel with channel=2.

peek_stdout(timeout=0)

Same as peek_channel with channel=1.

read_all()

Return buffered data received on stdout and stderr channels. This is useful for non-interactive call where a set of command passed to the API call and their result is needed after the call is concluded. Should be called after run_forever() or update()

TODO: Maybe we can process this and return a more meaningful map with channels mapped for each input.

read_channel(channel, timeout=0)

Read data from a channel.

read_stderr(timeout=None)

Same as read_channel with channel=2.

read_stdout(timeout=None)

Same as read_channel with channel=1.

readline_channel(channel, timeout=None)

Read a line from a channel.

readline_stderr(timeout=None)

Same as readline_channel with channel=2.

readline_stdout(timeout=None)

Same as readline_channel with channel=1.

property returncode

The return code, A None value indicates that the process hasn’t terminated yet.

run_forever(timeout=None)

Wait till connection is closed or timeout reached. Buffer any input received during this time.

update(timeout=0)

Update channel buffers with all complete frames of input that are available, waiting at most timeout seconds for the first one.

write_channel(channel, data)

Write data to a channel.

write_stdin(data)

The same as write_channel with channel=0.

class kubernetes.stream.ws_client.WSResponse(data, status)

Bases: object

getheader(name, default=None)

Returns a given response header.

kubernetes.stream.ws_client.create_websocket(configuration, url, headers=None)
kubernetes.stream.ws_client.get_websocket_url(url, query_params=None)
kubernetes.stream.ws_client.portforward_call(configuration, _method, url, **kwargs)

An internal function to be called in api-client when a websocket connection is required for port forwarding. args and kwargs are the parameters of apiClient.request method.

kubernetes.stream.ws_client.websocket_call(configuration, _method, url, **kwargs)

An internal function to be called in api-client when a websocket connection is required. method, url, and kwargs are the parameters of apiClient.request method.

kubernetes.stream.ws_client.websocket_proxycare(connect_opt, configuration, url, headers)

An internal function to be called in api-client when a websocket create is requested.