Search in sources :

Example 1 with ListConnectionsRequest

use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.

the class ITSystemTest method testListConnections.

@Test
public void testListConnections() {
    int pageSize = 10;
    ListConnectionsRequest request = ListConnectionsRequest.newBuilder().setParent(PARENT).setPageSize(pageSize).build();
    for (Connection actualConnection : client.listConnections(request).iterateAll()) {
        if (connection.getName().equals(actualConnection.getName())) {
            assertEquals(connection, actualConnection);
        }
    }
}
Also used : ListConnectionsRequest(com.google.cloud.bigquery.connection.v1.ListConnectionsRequest) Connection(com.google.cloud.bigquery.connection.v1.Connection) Test(org.junit.Test)

Example 2 with ListConnectionsRequest

use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.

the class ConnectionServiceClientTest method listConnectionsTest.

@Test
public void listConnectionsTest() throws Exception {
    Connection responsesElement = Connection.newBuilder().build();
    ListConnectionsResponse expectedResponse = ListConnectionsResponse.newBuilder().setNextPageToken("").addAllConnections(Arrays.asList(responsesElement)).build();
    mockConnectionService.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListConnectionsPagedResponse pagedListResponse = client.listConnections(parent);
    List<Connection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getConnectionsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListConnectionsRequest actualRequest = ((ListConnectionsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListConnectionsRequest(com.google.cloud.bigquery.connection.v1.ListConnectionsRequest) ListConnectionsResponse(com.google.cloud.bigquery.connection.v1.ListConnectionsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Connection(com.google.cloud.bigquery.connection.v1.Connection) ListConnectionsPagedResponse(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse) LocationName(com.google.cloud.bigquery.connection.v1.LocationName) Test(org.junit.Test)

Example 3 with ListConnectionsRequest

use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.

the class ConnectionServiceClientTest method listConnectionsTest2.

@Test
public void listConnectionsTest2() throws Exception {
    Connection responsesElement = Connection.newBuilder().build();
    ListConnectionsResponse expectedResponse = ListConnectionsResponse.newBuilder().setNextPageToken("").addAllConnections(Arrays.asList(responsesElement)).build();
    mockConnectionService.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListConnectionsPagedResponse pagedListResponse = client.listConnections(parent);
    List<Connection> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getConnectionsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListConnectionsRequest actualRequest = ((ListConnectionsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListConnectionsRequest(com.google.cloud.bigquery.connection.v1.ListConnectionsRequest) ListConnectionsResponse(com.google.cloud.bigquery.connection.v1.ListConnectionsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Connection(com.google.cloud.bigquery.connection.v1.Connection) ByteString(com.google.protobuf.ByteString) ListConnectionsPagedResponse(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse) Test(org.junit.Test)

Example 4 with ListConnectionsRequest

use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.

the class ListConnections method listConnections.

public static void listConnections(String projectId, String location) throws IOException {
    try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
        LocationName parent = LocationName.of(projectId, location);
        int pageSize = 10;
        ListConnectionsRequest request = ListConnectionsRequest.newBuilder().setParent(parent.toString()).setPageSize(pageSize).build();
        client.listConnections(request).iterateAll().forEach(con -> System.out.println("Connection Id :" + con.getName()));
    }
}
Also used : ListConnectionsRequest(com.google.cloud.bigquery.connection.v1.ListConnectionsRequest) ConnectionServiceClient(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient) LocationName(com.google.cloud.bigquery.connection.v1.LocationName)

Example 5 with ListConnectionsRequest

use of com.google.cloud.bigquery.connection.v1.ListConnectionsRequest in project java-bigqueryconnection by googleapis.

the class QuickstartSample method listConnections.

public static void listConnections(String projectId, String location) throws IOException {
    try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
        LocationName parent = LocationName.of(projectId, location);
        int pageSize = 10;
        ListConnectionsRequest request = ListConnectionsRequest.newBuilder().setParent(parent.toString()).setPageSize(pageSize).build();
        ConnectionServiceClient.ListConnectionsPagedResponse response = connectionServiceClient.listConnections(request);
        // Print the results.
        System.out.println("List of connections:");
        response.iterateAll().forEach(connection -> System.out.println("Connection Name: " + connection.getName()));
    }
}
Also used : ListConnectionsRequest(com.google.cloud.bigquery.connection.v1.ListConnectionsRequest) ConnectionServiceClient(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient) LocationName(com.google.cloud.bigquery.connection.v1.LocationName)

Aggregations

ListConnectionsRequest (com.google.cloud.bigquery.connection.v1.ListConnectionsRequest)5 Connection (com.google.cloud.bigquery.connection.v1.Connection)3 LocationName (com.google.cloud.bigquery.connection.v1.LocationName)3 Test (org.junit.Test)3 ListConnectionsResponse (com.google.cloud.bigquery.connection.v1.ListConnectionsResponse)2 ConnectionServiceClient (com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient)2 ListConnectionsPagedResponse (com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient.ListConnectionsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 ByteString (com.google.protobuf.ByteString)1