Search in sources :

Example 1 with Pager

use of io.kubernetes.client.extended.pager.Pager in project java by kubernetes-client.

the class PagerExample method main.

public static void main(String[] args) throws IOException {
    ApiClient client = Config.defaultClient();
    OkHttpClient httpClient = client.getHttpClient().newBuilder().readTimeout(60, TimeUnit.SECONDS).build();
    client.setHttpClient(httpClient);
    Configuration.setDefaultApiClient(client);
    CoreV1Api api = new CoreV1Api();
    int i = 0;
    Pager<V1Namespace, V1NamespaceList> pager = new Pager<V1Namespace, V1NamespaceList>((Pager.PagerParams param) -> {
        try {
            return api.listNamespaceCall(null, null, param.getContinueToken(), null, null, param.getLimit(), null, null, 1, null, null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }, client, 10, V1NamespaceList.class);
    for (V1Namespace namespace : pager) {
        System.out.println(namespace.getMetadata().getName());
    }
    System.out.println("------------------");
}
Also used : V1NamespaceList(io.kubernetes.client.openapi.models.V1NamespaceList) OkHttpClient(okhttp3.OkHttpClient) Pager(io.kubernetes.client.extended.pager.Pager) V1Namespace(io.kubernetes.client.openapi.models.V1Namespace) ApiClient(io.kubernetes.client.openapi.ApiClient) CoreV1Api(io.kubernetes.client.openapi.apis.CoreV1Api) IOException(java.io.IOException)

Aggregations

Pager (io.kubernetes.client.extended.pager.Pager)1 ApiClient (io.kubernetes.client.openapi.ApiClient)1 CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)1 V1Namespace (io.kubernetes.client.openapi.models.V1Namespace)1 V1NamespaceList (io.kubernetes.client.openapi.models.V1NamespaceList)1 IOException (java.io.IOException)1 OkHttpClient (okhttp3.OkHttpClient)1