Search in sources :

Example 1 with DeleteInstanceRequest

use of com.google.cloud.notebooks.v1beta1.DeleteInstanceRequest in project java-docs-samples by GoogleCloudPlatform.

the class DeleteInstance method deleteInstance.

// Delete the instance specified by `instanceName`
// if it's present in the given project and zone.
public static void deleteInstance(String project, String zone, String instanceName) throws IOException, InterruptedException, ExecutionException {
    // clean up any remaining background resources.
    try (InstancesClient instancesClient = InstancesClient.create()) {
        System.out.printf("Deleting instance: %s ", instanceName);
        // Describe which instance is to be deleted.
        DeleteInstanceRequest deleteInstanceRequest = DeleteInstanceRequest.newBuilder().setProject(project).setZone(zone).setInstance(instanceName).build();
        OperationFuture<Operation, Operation> operation = instancesClient.deleteAsync(deleteInstanceRequest);
        // Wait for the operation to complete.
        Operation response = operation.get();
        if (response.hasError()) {
            System.out.println("Instance deletion failed ! ! " + response);
            return;
        }
        System.out.println("Operation Status: " + response.getStatus());
    }
}
Also used : InstancesClient(com.google.cloud.compute.v1.InstancesClient) Operation(com.google.cloud.compute.v1.Operation) DeleteInstanceRequest(com.google.cloud.compute.v1.DeleteInstanceRequest)

Example 2 with DeleteInstanceRequest

use of com.google.cloud.notebooks.v1beta1.DeleteInstanceRequest in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClient method deleteInstance.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Delete an instance from a project.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient =
 *     BaseBigtableInstanceAdminClient.create()) {
 *   String name = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
 *   baseBigtableInstanceAdminClient.deleteInstance(name);
 * }
 * }</pre>
 *
 * @param name Required. The unique name of the instance to be deleted. Values are of the form
 *     `projects/{project}/instances/{instance}`.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteInstance(String name) {
    DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder().setName(name).build();
    deleteInstance(request);
}
Also used : DeleteInstanceRequest(com.google.bigtable.admin.v2.DeleteInstanceRequest)

Example 3 with DeleteInstanceRequest

use of com.google.cloud.notebooks.v1beta1.DeleteInstanceRequest in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method deleteInstanceTest2.

@Test
public void deleteInstanceTest2() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    client.deleteInstance(name);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteInstanceRequest actualRequest = ((DeleteInstanceRequest) 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) ByteString(com.google.protobuf.ByteString) DeleteInstanceRequest(com.google.bigtable.admin.v2.DeleteInstanceRequest) Test(org.junit.Test)

Example 4 with DeleteInstanceRequest

use of com.google.cloud.notebooks.v1beta1.DeleteInstanceRequest in project java-spanner by googleapis.

the class InstanceAdminClientTest method deleteInstanceTest.

@Test
public void deleteInstanceTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockInstanceAdmin.addResponse(expectedResponse);
    InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
    client.deleteInstance(name);
    List<AbstractMessage> actualRequests = mockInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteInstanceRequest actualRequest = ((DeleteInstanceRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : InstanceName(com.google.spanner.admin.instance.v1.InstanceName) Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteInstanceRequest(com.google.spanner.admin.instance.v1.DeleteInstanceRequest) Test(org.junit.Test)

Example 5 with DeleteInstanceRequest

use of com.google.cloud.notebooks.v1beta1.DeleteInstanceRequest in project java-spanner by googleapis.

the class GapicSpannerRpc method deleteInstance.

@Override
public void deleteInstance(String instanceName) throws SpannerException {
    DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder().setName(instanceName).build();
    GrpcCallContext context = newCallContext(null, instanceName, request, InstanceAdminGrpc.getDeleteInstanceMethod());
    get(instanceAdminStub.deleteInstanceCallable().futureCall(request, context));
}
Also used : GrpcCallContext(com.google.api.gax.grpc.GrpcCallContext) DeleteInstanceRequest(com.google.spanner.admin.instance.v1.DeleteInstanceRequest)

Aggregations

DeleteInstanceRequest (com.google.spanner.admin.instance.v1.DeleteInstanceRequest)5 DeleteInstanceRequest (com.google.bigtable.admin.v2.DeleteInstanceRequest)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 Empty (com.google.protobuf.Empty)4 Test (org.junit.Test)4 ByteString (com.google.protobuf.ByteString)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 InstanceName (com.google.bigtable.admin.v2.InstanceName)1 DeleteInstanceRequest (com.google.cloud.compute.v1.DeleteInstanceRequest)1 InstancesClient (com.google.cloud.compute.v1.InstancesClient)1 Operation (com.google.cloud.compute.v1.Operation)1 DeleteEnvironmentRequest (com.google.cloud.notebooks.v1beta1.DeleteEnvironmentRequest)1 DeleteInstanceRequest (com.google.cloud.notebooks.v1beta1.DeleteInstanceRequest)1 InstanceName (com.google.spanner.admin.instance.v1.InstanceName)1 AfterClass (org.junit.AfterClass)1