Search in sources :

Example 6 with ListSchemasRequest

use of com.google.pubsub.v1.ListSchemasRequest in project gapic-generator-java by googleapis.

the class AsyncListSchemasPaged method asyncListSchemasPaged.

public static void asyncListSchemasPaged() throws Exception {
    // It may require modifications to work in your environment.
    try (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) {
        ListSchemasRequest request = ListSchemasRequest.newBuilder().setParent(ProjectName.of("[PROJECT]").toString()).setView(SchemaView.forNumber(0)).setPageSize(883849137).setPageToken("pageToken873572522").build();
        while (true) {
            ListSchemasResponse response = schemaServiceClient.listSchemasCallable().call(request);
            for (Schema element : response.getResponsesList()) {
            // doThingsWith(element);
            }
            String nextPageToken = response.getNextPageToken();
            if (!Strings.isNullOrEmpty(nextPageToken)) {
                request = request.toBuilder().setPageToken(nextPageToken).build();
            } else {
                break;
            }
        }
    }
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) SchemaServiceClient(com.google.cloud.pubsub.v1.SchemaServiceClient)

Aggregations

ListSchemasRequest (com.google.pubsub.v1.ListSchemasRequest)6 Schema (com.google.pubsub.v1.Schema)6 ListSchemasResponse (com.google.pubsub.v1.ListSchemasResponse)5 ListSchemasPagedResponse (com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Test (org.junit.Test)4 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)2 ByteString (com.google.protobuf.ByteString)2 ProjectName (com.google.pubsub.v1.ProjectName)2