use of com.google.spanner.admin.instance.v1.InstanceName in project java-spanner by googleapis.
the class InstanceAdminClientTest method deleteInstanceExceptionTest.
@Test
public void deleteInstanceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockInstanceAdmin.addException(exception);
try {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
client.deleteInstance(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.spanner.admin.instance.v1.InstanceName 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()));
}
use of com.google.spanner.admin.instance.v1.InstanceName 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));
}
use of com.google.spanner.admin.instance.v1.InstanceName in project java-spanner by googleapis.
the class GapicSpannerRpc method getInstance.
@Override
public Instance getInstance(String instanceName) throws SpannerException {
GetInstanceRequest request = GetInstanceRequest.newBuilder().setName(instanceName).build();
GrpcCallContext context = newCallContext(null, instanceName, request, InstanceAdminGrpc.getGetInstanceMethod());
return get(instanceAdminStub.getInstanceCallable().futureCall(request, context));
}
use of com.google.spanner.admin.instance.v1.InstanceName 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>* Billing ceases for all of the instance's reserved resources.
*
* <p>Soon afterward:
*
* <p>* The instance and *all of its databases* 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/<project>/instances/<instance>`
* @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);
}
Aggregations