Search in sources :

Example 6 with Instance

use of com.google.cloud.spanner.Instance in project google-cloud-java by GoogleCloudPlatform.

the class InstanceAdminClientSnippets method getInstance.

/**
 * Example to get an instance.
 */
public Instance getInstance(final String my_instance_id) {
    // [START instance_admin_client_get_instance]
    final String instanceId = my_instance_id;
    Instance ins = instanceAdminClient.getInstance(instanceId);
    // [END instance_admin_client_get_instance]
    return ins;
}
Also used : Instance(com.google.cloud.spanner.Instance)

Example 7 with Instance

use of com.google.cloud.spanner.Instance in project spanner-jdbc by olavloite.

the class CloudSpannerIT method createInstance.

private void createInstance() {
    InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient();
    InstanceConfig config = instanceAdminClient.getInstanceConfig("regional-europe-west1");
    Instance instance = instanceAdminClient.newInstanceBuilder(InstanceId.of(getProject(), instanceId)).setDisplayName("Test Instance").setInstanceConfigId(config.getId()).setNodeCount(1).build();
    Operation<Instance, CreateInstanceMetadata> createInstance = instanceAdminClient.createInstance(instance);
    createInstance = createInstance.waitFor();
}
Also used : InstanceConfig(com.google.cloud.spanner.InstanceConfig) Instance(com.google.cloud.spanner.Instance) InstanceAdminClient(com.google.cloud.spanner.InstanceAdminClient) CreateInstanceMetadata(com.google.spanner.admin.instance.v1.CreateInstanceMetadata)

Aggregations

Instance (com.google.cloud.spanner.Instance)7 IntegrationTest (com.google.cloud.spanner.IntegrationTest)3 UpdateInstanceMetadata (com.google.spanner.admin.instance.v1.UpdateInstanceMetadata)3 Test (org.junit.Test)3 InstanceAdminClient (com.google.cloud.spanner.InstanceAdminClient)2 InstanceConfig (com.google.cloud.spanner.InstanceConfig)2 InstanceInfo (com.google.cloud.spanner.InstanceInfo)2 CreateInstanceMetadata (com.google.spanner.admin.instance.v1.CreateInstanceMetadata)2 Random (java.util.Random)2 ExecutionException (java.util.concurrent.ExecutionException)1