use of com.google.cloud.spanner.InstanceAdminClient in project spanner-jdbc by olavloite.
the class AbstractSpecificIntegrationTest method createInstance.
private static void createInstance() {
InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient();
InstanceConfig config = instanceAdminClient.getInstanceConfig("regional-europe-west1");
Instance instance = instanceAdminClient.newInstanceBuilder(InstanceId.of(projectId, instanceId)).setDisplayName("Test Instance").setInstanceConfigId(config.getId()).setNodeCount(1).build();
Operation<Instance, CreateInstanceMetadata> createInstance = instanceAdminClient.createInstance(instance);
createInstance = createInstance.waitFor();
}
use of com.google.cloud.spanner.InstanceAdminClient in project google-cloud-java by GoogleCloudPlatform.
the class SpannerSnippets method getInstanceAdminClient.
InstanceAdminClient getInstanceAdminClient() {
// [START get_instance_admin_client]
SpannerOptions options = SpannerOptions.newBuilder().build();
Spanner spanner = options.getService();
InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient();
return instanceAdminClient;
}
use of com.google.cloud.spanner.InstanceAdminClient 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();
}
use of com.google.cloud.spanner.InstanceAdminClient in project spanner-jdbc by olavloite.
the class InstanceConfigIT method testEuropeWestSingleNodeConfig.
@Test
public void testEuropeWestSingleNodeConfig() {
String credentialsPath = "cloudspanner-emulator-key.json";
String projectId = "test-project";
GoogleCredentials credentials = null;
try {
credentials = CloudSpannerConnection.getCredentialsFromFile(credentialsPath);
} catch (IOException e) {
throw new RuntimeException("Could not read key file " + credentialsPath, e);
}
Builder builder = SpannerOptions.newBuilder();
builder.setProjectId(projectId);
builder.setCredentials(credentials);
builder.setHost(CloudSpannerIT.getHost());
SpannerOptions options = builder.build();
Spanner spanner = options.getService();
InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient();
InstanceConfig config = instanceAdminClient.getInstanceConfig("regional-europe-west1");
assertEquals("regional-europe-west1", config.getId().getInstanceConfig());
spanner.close();
}
Aggregations