Search in sources :

Example 1 with DeleteConnectionRequest

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()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteConnectionRequest(com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 2 with DeleteConnectionRequest

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();
}
Also used : DeleteConnectionRequest(com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest) After(org.junit.After)

Example 3 with DeleteConnectionRequest

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);
}
Also used : DeleteConnectionRequest(com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest)

Example 4 with DeleteConnectionRequest

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()));
}
Also used : ConnectionName(com.google.cloud.bigquery.connection.v1.ConnectionName) Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteConnectionRequest(com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest) Test(org.junit.Test)

Example 5 with DeleteConnectionRequest

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

Aggregations

DeleteConnectionRequest (com.google.cloud.bigquery.connection.v1.DeleteConnectionRequest)6 ConnectionName (com.google.cloud.bigquery.connection.v1.ConnectionName)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Empty (com.google.protobuf.Empty)2 Test (org.junit.Test)2 ConnectionServiceClient (com.google.cloud.bigqueryconnection.v1.ConnectionServiceClient)1 ByteString (com.google.protobuf.ByteString)1 After (org.junit.After)1