Search in sources :

Example 1 with GetConnectionRequest

use of com.google.cloud.bigquery.connection.v1.GetConnectionRequest in project java-spring-boot-2021 by hocyadav.

the class GoogleBigQueryImpl method getConnection.

public static void getConnection(String projectId, String location, String connectionId) throws IOException {
    try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
        ConnectionName name = ConnectionName.of(projectId, location, connectionId);
        GetConnectionRequest request = GetConnectionRequest.newBuilder().setName(name.toString()).build();
        Connection response = client.getConnection(request);
        System.out.println("Connection info retrieved successfully :" + response.getName());
    }
}
Also used : ConnectionName(com.google.cloud.bigquery.connection.v1.ConnectionName) ConnectionServiceClient(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient) Connection(com.google.cloud.bigquery.connection.v1.Connection) GetConnectionRequest(com.google.cloud.bigquery.connection.v1.GetConnectionRequest)

Example 2 with GetConnectionRequest

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

the class ConnectionServiceClientTest method getConnectionTest2.

@Test
public void getConnectionTest2() throws Exception {
    Connection expectedResponse = Connection.newBuilder().setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString()).setFriendlyName("friendlyName461933014").setDescription("description-1724546052").setCreationTime(1932333101).setLastModifiedTime(-671513446).setHasCredential(true).build();
    mockConnectionService.addResponse(expectedResponse);
    String name = "name3373707";
    Connection actualResponse = client.getConnection(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetConnectionRequest actualRequest = ((GetConnectionRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Connection(com.google.cloud.bigquery.connection.v1.Connection) ByteString(com.google.protobuf.ByteString) GetConnectionRequest(com.google.cloud.bigquery.connection.v1.GetConnectionRequest) Test(org.junit.Test)

Example 3 with GetConnectionRequest

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

the class ConnectionServiceClientTest method getConnectionTest.

@Test
public void getConnectionTest() throws Exception {
    Connection expectedResponse = Connection.newBuilder().setName(ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString()).setFriendlyName("friendlyName461933014").setDescription("description-1724546052").setCreationTime(1932333101).setLastModifiedTime(-671513446).setHasCredential(true).build();
    mockConnectionService.addResponse(expectedResponse);
    ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
    Connection actualResponse = client.getConnection(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetConnectionRequest actualRequest = ((GetConnectionRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ConnectionName(com.google.cloud.bigquery.connection.v1.ConnectionName) AbstractMessage(com.google.protobuf.AbstractMessage) Connection(com.google.cloud.bigquery.connection.v1.Connection) GetConnectionRequest(com.google.cloud.bigquery.connection.v1.GetConnectionRequest) Test(org.junit.Test)

Example 4 with GetConnectionRequest

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

the class ITSystemTest method testGetConnection.

@Test
public void testGetConnection() {
    GetConnectionRequest request = GetConnectionRequest.newBuilder().setName(connection.getName()).build();
    Connection actualConnection = client.getConnection(request);
    assertEquals(connection, actualConnection);
}
Also used : Connection(com.google.cloud.bigquery.connection.v1.Connection) GetConnectionRequest(com.google.cloud.bigquery.connection.v1.GetConnectionRequest) Test(org.junit.Test)

Example 5 with GetConnectionRequest

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

the class GetConnection method getConnection.

public static void getConnection(String projectId, String location, String connectionId) throws IOException {
    try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
        ConnectionName name = ConnectionName.of(projectId, location, connectionId);
        GetConnectionRequest request = GetConnectionRequest.newBuilder().setName(name.toString()).build();
        Connection response = client.getConnection(request);
        System.out.println("Connection info retrieved successfully :" + response.getName());
    }
}
Also used : ConnectionName(com.google.cloud.bigquery.connection.v1.ConnectionName) ConnectionServiceClient(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient) Connection(com.google.cloud.bigquery.connection.v1.Connection) GetConnectionRequest(com.google.cloud.bigquery.connection.v1.GetConnectionRequest)

Aggregations

Connection (com.google.cloud.bigquery.connection.v1.Connection)5 GetConnectionRequest (com.google.cloud.bigquery.connection.v1.GetConnectionRequest)5 ConnectionName (com.google.cloud.bigquery.connection.v1.ConnectionName)3 Test (org.junit.Test)3 ConnectionServiceClient (com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 ByteString (com.google.protobuf.ByteString)1