kubernetes_asyncio.watch.watch module

class kubernetes_asyncio.watch.watch.Stream(func, *args, **kwargs)

Bases: object

class kubernetes_asyncio.watch.watch.Watch(return_type: str | None = None)

Bases: object

async close() None
get_return_type(func: object) str
get_watch_argument_name(func: object) str
async next() Any
stop() None
stream(func, *args, **kwargs) Watch

Watch an API resource and stream the result back via a generator.

Parameters:

func – The API function pointer. Any parameter to the function can be passed after this parameter.

Returns:

Event object with these keys: ‘type’: The type of event such as “ADDED”, “DELETED”, etc. ‘raw_object’: a dict representing the watched object. ‘object’: A model representation of raw_object. The name of

model will be determined based on the func’s doc string. If it cannot be determined, ‘object’ value will be the same as ‘raw_object’.

Example:

v1 = kubernetes_asyncio.client.CoreV1Api() watch = kubernetes_asyncio.watch.Watch() async for e in watch.stream(v1.list_namespace, timeout_seconds=10):

type = e[‘type’] object = e[‘object’] # object is one of type return_type raw_object = e[‘raw_object’] # raw_object is a dict … if should_stop:

watch.stop()

unmarshal_event(data: str | bytes, response_type: str | None) Any

Return the K8s response data in JSON format.