Search in sources :

Example 41 with Instance

use of com.google.spanner.admin.instance.v1.Instance in project java-spanner by googleapis.

the class InstanceAdminClient method deleteInstance.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes an instance.
 *
 * <p>Immediately upon completion of the request:
 *
 * <p>&#42; Billing ceases for all of the instance's reserved resources.
 *
 * <p>Soon afterward:
 *
 * <p>&#42; The instance and &#42;all of its databases&#42; immediately and irrevocably disappear
 * from the API. All data in the databases is permanently deleted.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
 *   InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
 *   instanceAdminClient.deleteInstance(name);
 * }
 * }</pre>
 *
 * @param name Required. The name of the instance to be deleted. Values are of the form
 *     `projects/&lt;project&gt;/instances/&lt;instance&gt;`
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteInstance(InstanceName name) {
    DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder().setName(name == null ? null : name.toString()).build();
    deleteInstance(request);
}
Also used : DeleteInstanceRequest(com.google.spanner.admin.instance.v1.DeleteInstanceRequest)

Example 42 with Instance

use of com.google.spanner.admin.instance.v1.Instance in project java-notebooks by googleapis.

the class ITNotebookServiceClientTest method testSetInstanceMachineType.

@Test
public void testSetInstanceMachineType() throws ExecutionException, InterruptedException {
    this.stopInstance();
    SetInstanceMachineTypeRequest request = SetInstanceMachineTypeRequest.newBuilder().setName(INSTANCE_NAME).setMachineType(MACHINE_TYPE_B).build();
    Instance response = client.setInstanceMachineTypeAsync(request).get();
    assertTrue(response.getMachineType().endsWith(MACHINE_TYPE_B));
    this.startInstance();
}
Also used : Instance(com.google.cloud.notebooks.v1beta1.Instance) SetInstanceMachineTypeRequest(com.google.cloud.notebooks.v1beta1.SetInstanceMachineTypeRequest) Test(org.junit.Test)

Example 43 with Instance

use of com.google.spanner.admin.instance.v1.Instance in project java-notebooks by googleapis.

the class ITNotebookServiceClientTest method testSetInstanceAccelarator.

@Test
public void testSetInstanceAccelarator() throws ExecutionException, InterruptedException {
    this.stopInstance();
    SetInstanceAcceleratorRequest request = SetInstanceAcceleratorRequest.newBuilder().setName(INSTANCE_NAME).setType(Instance.AcceleratorType.NVIDIA_TESLA_P4).setCoreCount(1L).build();
    Instance response = client.setInstanceAcceleratorAsync(request).get();
    this.startInstance();
    assertEquals(response.getAcceleratorConfig().getType().name(), Instance.AcceleratorType.NVIDIA_TESLA_P4.name());
}
Also used : Instance(com.google.cloud.notebooks.v1beta1.Instance) SetInstanceAcceleratorRequest(com.google.cloud.notebooks.v1beta1.SetInstanceAcceleratorRequest) Test(org.junit.Test)

Example 44 with Instance

use of com.google.spanner.admin.instance.v1.Instance in project java-notebooks by googleapis.

the class ITNotebookServiceClientTest method testResetInstance.

@Test
public void testResetInstance() throws ExecutionException, InterruptedException {
    ResetInstanceRequest request = ResetInstanceRequest.newBuilder().setName(INSTANCE_NAME).build();
    Instance response = client.resetInstanceAsync(request).get();
    assertTrue(response.getMachineType().endsWith(MACHINE_TYPE_B));
}
Also used : ResetInstanceRequest(com.google.cloud.notebooks.v1beta1.ResetInstanceRequest) Instance(com.google.cloud.notebooks.v1beta1.Instance) Test(org.junit.Test)

Example 45 with Instance

use of com.google.spanner.admin.instance.v1.Instance in project java-notebooks by googleapis.

the class ITNotebookServiceClientTest method testSetInstanceLabels.

@Test
public void testSetInstanceLabels() throws ExecutionException, InterruptedException {
    SetInstanceLabelsRequest setInstanceLabelsRequest = SetInstanceLabelsRequest.newBuilder().setName(INSTANCE_NAME).putLabels("a", "100").build();
    Instance response = client.setInstanceLabelsAsync(setInstanceLabelsRequest).get();
    assertEquals(response.getLabelsMap().get("a"), "100");
}
Also used : Instance(com.google.cloud.notebooks.v1beta1.Instance) SetInstanceLabelsRequest(com.google.cloud.notebooks.v1beta1.SetInstanceLabelsRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)50 AbstractMessage (com.google.protobuf.AbstractMessage)19 ByteString (com.google.protobuf.ByteString)17 ExecutionException (java.util.concurrent.ExecutionException)16 Instance (com.google.cloud.spanner.Instance)15 StatusRuntimeException (io.grpc.StatusRuntimeException)14 Instance (com.google.cloud.compute.v1.Instance)11 InstancesClient (com.google.cloud.compute.v1.InstancesClient)11 CreateInstanceMetadata (com.google.spanner.admin.instance.v1.CreateInstanceMetadata)11 Instance (com.google.spanner.admin.instance.v1.Instance)11 Instance (com.google.bigtable.admin.v2.Instance)10 InstanceAdminClient (com.google.cloud.spanner.InstanceAdminClient)10 InstanceInfo (com.google.cloud.spanner.InstanceInfo)10 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)9 Instance (com.google.cloud.notebooks.v1beta1.Instance)9 Spanner (com.google.cloud.spanner.Spanner)8 ArrayList (java.util.ArrayList)8 Operation (com.google.cloud.compute.v1.Operation)7 FieldMask (com.google.protobuf.FieldMask)7 InstanceName (com.google.spanner.admin.instance.v1.InstanceName)7