use of com.google.cloud.spanner.InstanceConfig 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.InstanceConfig in project google-cloud-java by GoogleCloudPlatform.
the class ITInstanceAdminTest method instanceConfigOperations.
@Test
public void instanceConfigOperations() {
List<InstanceConfig> configs = new ArrayList<>();
Iterators.addAll(configs, instanceClient.listInstanceConfigs().iterateAll().iterator());
assertThat(configs.isEmpty()).isFalse();
InstanceConfig config = instanceClient.getInstanceConfig(configs.get(0).getId().getInstanceConfig());
assertThat(config.getId()).isEqualTo(configs.get(0).getId());
config = config.reload();
assertThat(config.getId()).isEqualTo(configs.get(0).getId());
}
use of com.google.cloud.spanner.InstanceConfig in project google-cloud-java by GoogleCloudPlatform.
the class InstanceAdminClientSnippets method getInstanceConfig.
/**
* Example to get instance config.
*/
public InstanceConfig getInstanceConfig(final String my_config_id) {
// [START instance_admin_client_get_instance_config]
final String configId = my_config_id;
InstanceConfig instanceConfig = instanceAdminClient.getInstanceConfig(configId);
// [END instance_admin_client_get_instance_config]
return instanceConfig;
}
use of com.google.cloud.spanner.InstanceConfig 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.InstanceConfig 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