Search in sources :

Example 6 with ConnectionServiceClient

use of com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient in project java-bigqueryconnection by googleapis.

the class DeleteConnection method deleteConnection.

public static void deleteConnection(String projectId, String location, String connectionName) throws IOException {
    try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
        ConnectionName name = ConnectionName.of(projectId, location, connectionName);
        DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder().setName(name.toString()).build();
        client.deleteConnection(request);
        System.out.println("Connection deleted successfully");
    }
}
Also used : ConnectionName(com.google.cloud.bigquery.connection.v1.ConnectionName) ConnectionServiceClient(com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient) DeleteConnectionRequest(com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest)

Example 7 with ConnectionServiceClient

use of com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient 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)

Example 8 with ConnectionServiceClient

use of com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient 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 9 with ConnectionServiceClient

use of com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient 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

ConnectionServiceClient (com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient)9 Connection (com.google.cloud.bigquery.connection.v1.Connection)5 ConnectionName (com.google.cloud.bigquery.connection.v1.ConnectionName)4 LocationName (com.google.cloud.bigquery.connection.v1.LocationName)4 CreateConnectionRequest (com.google.cloud.bigquery.connection.v1.CreateConnectionRequest)2 GetConnectionRequest (com.google.cloud.bigquery.connection.v1.GetConnectionRequest)2 ListConnectionsRequest (com.google.cloud.bigquery.connection.v1.ListConnectionsRequest)2 ResourceName (com.google.api.resourcenames.ResourceName)1 AwsAccessRole (com.google.cloud.bigquery.connection.v1.AwsAccessRole)1 DeleteConnectionRequest (com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest)1 UpdateConnectionRequest (com.google.cloud.bigquery.connection.v1.UpdateConnectionRequest)1 Binding (com.google.iam.v1.Binding)1 Policy (com.google.iam.v1.Policy)1 SetIamPolicyRequest (com.google.iam.v1.SetIamPolicyRequest)1 FieldMask (com.google.protobuf.FieldMask)1