use of com.google.cloud.redis.v1beta1.CreateInstanceRequest in project java-spanner by googleapis.
the class InstanceAdminClientTest method createInstanceTest.
@Test
public void createInstanceTest() throws Exception {
Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setConfig(InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]").toString()).setDisplayName("displayName1714148973").setNodeCount(1539922066).setProcessingUnits(-329117885).putAllLabels(new HashMap<String, String>()).addAllEndpointUris(new ArrayList<String>()).build();
Operation resultOperation = Operation.newBuilder().setName("createInstanceTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockInstanceAdmin.addResponse(resultOperation);
ProjectName parent = ProjectName.of("[PROJECT]");
String instanceId = "instanceId902024336";
Instance instance = Instance.newBuilder().build();
Instance actualResponse = client.createInstanceAsync(parent, instanceId, instance).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateInstanceRequest actualRequest = ((CreateInstanceRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(instanceId, actualRequest.getInstanceId());
Assert.assertEquals(instance, actualRequest.getInstance());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.CreateInstanceRequest in project gapic-generator-java by googleapis.
the class AsyncCreateInstance method asyncCreateInstance.
public static void asyncCreateInstance() throws Exception {
// It may require modifications to work in your environment.
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
CreateInstanceRequest request = CreateInstanceRequest.newBuilder().setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()).setInstanceId("instanceId902024336").setInstance(Instance.newBuilder().build()).build();
ApiFuture<Operation> future = cloudRedisClient.createInstanceCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
}
use of com.google.cloud.redis.v1beta1.CreateInstanceRequest in project gapic-generator-java by googleapis.
the class AsyncCreateInstanceLRO method asyncCreateInstanceLRO.
public static void asyncCreateInstanceLRO() throws Exception {
// It may require modifications to work in your environment.
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
CreateInstanceRequest request = CreateInstanceRequest.newBuilder().setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()).setInstanceId("instanceId902024336").setInstance(Instance.newBuilder().build()).build();
OperationFuture<Instance, Any> future = cloudRedisClient.createInstanceOperationCallable().futureCall(request);
// Do something.
Instance response = future.get();
}
}
use of com.google.cloud.redis.v1beta1.CreateInstanceRequest in project gapic-generator-java by googleapis.
the class SyncCreateInstance method syncCreateInstance.
public static void syncCreateInstance() throws Exception {
// It may require modifications to work in your environment.
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
CreateInstanceRequest request = CreateInstanceRequest.newBuilder().setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()).setInstanceId("instanceId902024336").setInstance(Instance.newBuilder().build()).build();
Instance response = cloudRedisClient.createInstanceAsync(request).get();
}
}
use of com.google.cloud.redis.v1beta1.CreateInstanceRequest in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method createInstanceTest.
@Test
public void createInstanceTest() throws Exception {
Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
Operation resultOperation = Operation.newBuilder().setName("createInstanceTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableInstanceAdmin.addResponse(resultOperation);
ProjectName parent = ProjectName.of("[PROJECT]");
String instanceId = "instanceId902024336";
Instance instance = Instance.newBuilder().build();
Map<String, Cluster> clusters = new HashMap<>();
Instance actualResponse = client.createInstanceAsync(parent, instanceId, instance, clusters).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateInstanceRequest actualRequest = ((CreateInstanceRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(instanceId, actualRequest.getInstanceId());
Assert.assertEquals(instance, actualRequest.getInstance());
Assert.assertEquals(clusters, actualRequest.getClustersMap());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations