Package io.kubernetes.client.util
Class Watch<T>
java.lang.Object
io.kubernetes.client.util.Watch<T>
- All Implemented Interfaces:
Watchable<T>
,Closeable
,AutoCloseable
,Iterable<Watch.Response<T>>
,Iterator<Watch.Response<T>>
Watch class implements watch mechansim of kubernetes. For every list API call with a watch
parameter you should be able to pass its call to this class and watch changes to that list. For
example CoreV1Api.listNamespace has watch parameter, so you can create a call using
CoreV1Api.listNamespaceCall and set watch to True and watch the changes to namespaces.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Response class holds a watch response that has a `type` that can be ADDED, MODIFIED, DELETED and ERROR. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static <T> Watch<T>
createWatch
(io.kubernetes.client.openapi.ApiClient client, okhttp3.Call call, Type watchType) Creates a watch on a TYPENAME (T) using an API Client and a Call object.boolean
hasNext()
protected boolean
iterator()
next()
protected Watch.Response<T>
void
remove()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
Watch
protected Watch(io.kubernetes.client.openapi.JSON json, okhttp3.ResponseBody body, Type watchType, okhttp3.Call call)
-
-
Method Details
-
createWatch
public static <T> Watch<T> createWatch(io.kubernetes.client.openapi.ApiClient client, okhttp3.Call call, Type watchType) throws io.kubernetes.client.openapi.ApiException Creates a watch on a TYPENAME (T) using an API Client and a Call object.- Type Parameters:
T
- TYPENAME.- Parameters:
client
- the API clientcall
- the call object returned by api.{ListOperation}Call(...) method. Make sure watch flag is set in the call.watchType
- The type of the WatchResponse<T>. Use something like new TypeToken<Watch.Response<TYPENAME>>(){}.getType()- Returns:
- Watch object on TYPENAME
- Throws:
io.kubernetes.client.openapi.ApiException
- on IO exceptions.
-
next
-
isStatus
- Throws:
IOException
-
parseLine
- Throws:
IOException
-
hasNext
public boolean hasNext() -
iterator
-
remove
public void remove() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-