use of com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method deleteConnectionTest2.
@Test
public void deleteConnectionTest2() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockConnectionService.addResponse(expectedResponse);
String name = "name3373707";
client.deleteConnection(name);
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteConnectionRequest actualRequest = ((DeleteConnectionRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest in project java-bigqueryconnection by googleapis.
the class ITSystemTest method tearDown.
@After
public void tearDown() {
// delete a connection
DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder().setName(connection.getName()).build();
client.deleteConnection(request);
client.close();
}
use of com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClient method deleteConnection.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes connection and associated credential.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (ConnectionServiceClient connectionServiceClient = ConnectionServiceClient.create()) {
* String name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]").toString();
* connectionServiceClient.deleteConnection(name);
* }
* }</pre>
*
* @param name Required. Name of the deleted connection, for example:
* `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteConnection(String name) {
DeleteConnectionRequest request = DeleteConnectionRequest.newBuilder().setName(name).build();
deleteConnection(request);
}
use of com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method deleteConnectionTest.
@Test
public void deleteConnectionTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockConnectionService.addResponse(expectedResponse);
ConnectionName name = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
client.deleteConnection(name);
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteConnectionRequest actualRequest = ((DeleteConnectionRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest 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