use of com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient in project java-bigqueryconnection by googleapis.
the class CreateConnection method createConnection.
public static void createConnection(String projectId, String location, String connectionId, Connection connection) throws IOException {
try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of(projectId, location);
CreateConnectionRequest request = CreateConnectionRequest.newBuilder().setParent(parent.toString()).setConnection(connection).setConnectionId(connectionId).build();
Connection response = client.createConnection(request);
System.out.println("Connection created successfully :" + response.getName());
}
}
use of com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient in project java-bigqueryconnection by googleapis.
the class ShareConnection method shareConnection.
public static void shareConnection(String projectId, String location, String connectionId) throws IOException {
try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of(projectId, location, connectionId);
Binding binding = Binding.newBuilder().addMembers("group:example-analyst-group@google.com").setRole("roles/bigquery.connectionUser").build();
Policy policy = Policy.newBuilder().addBindings(binding).build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder().setResource(resource.toString()).setPolicy(policy).build();
client.setIamPolicy(request);
System.out.println("Connection shared successfully");
}
}
use of com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient in project java-bigqueryconnection by googleapis.
the class UpdateConnection method updateConnection.
public static void updateConnection(String projectId, String location, String connectionId, Connection connection) throws IOException {
try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
ConnectionName name = ConnectionName.of(projectId, location, connectionId);
FieldMask updateMask = FieldMaskUtil.fromString("description");
UpdateConnectionRequest request = UpdateConnectionRequest.newBuilder().setName(name.toString()).setConnection(connection).setUpdateMask(updateMask).build();
Connection response = client.updateConnection(request);
System.out.println("Connection updated successfully :" + response.getDescription());
}
}
use of com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient 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());
}
}
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");
}
}
Aggregations