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");
}
}
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());
}
}
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()));
}
}
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()));
}
}
Aggregations