Search in sources :

Example 1 with ListSchemasRequest

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

the class AsyncListSchemas method asyncListSchemas.

public static void asyncListSchemas() 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();
        ApiFuture<Schema> future = schemaServiceClient.listSchemasPagedCallable().futureCall(request);
        // Do something.
        for (Schema element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) Schema(com.google.pubsub.v1.Schema) SchemaServiceClient(com.google.cloud.pubsub.v1.SchemaServiceClient)

Example 2 with ListSchemasRequest

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

the class SchemaServiceClientTest method listSchemasTest2.

@Test
public void listSchemasTest2() throws Exception {
    Schema responsesElement = Schema.newBuilder().build();
    ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
    mockSchemaService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
    List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) ListSchemasPagedResponse(com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 3 with ListSchemasRequest

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

the class SchemaServiceClientTest method listSchemasTest.

@Test
public void listSchemasTest() throws Exception {
    Schema responsesElement = Schema.newBuilder().build();
    ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
    mockSchemaService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
    List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) ListSchemasPagedResponse(com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.pubsub.v1.ProjectName) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) Test(org.junit.Test)

Example 4 with ListSchemasRequest

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

the class SchemaServiceClientTest method listSchemasTest2.

@Test
public void listSchemasTest2() throws Exception {
    Schema responsesElement = Schema.newBuilder().build();
    ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
    mockSchemaService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
    List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) ListSchemasPagedResponse(com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 5 with ListSchemasRequest

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

the class SchemaServiceClientTest method listSchemasTest.

@Test
public void listSchemasTest() throws Exception {
    Schema responsesElement = Schema.newBuilder().build();
    ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
    mockSchemaService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
    List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) ListSchemasPagedResponse(com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.pubsub.v1.ProjectName) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) Test(org.junit.Test)

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