Search in sources :

Example 1 with CreateInstanceRequest

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.spanner.admin.instance.v1.Instance) ProjectName(com.google.spanner.admin.instance.v1.ProjectName) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) CreateInstanceRequest(com.google.spanner.admin.instance.v1.CreateInstanceRequest) Test(org.junit.Test)

Example 2 with CreateInstanceRequest

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();
    }
}
Also used : CloudRedisClient(com.google.cloud.redis.v1beta1.CloudRedisClient) Operation(com.google.longrunning.Operation) CreateInstanceRequest(com.google.cloud.redis.v1beta1.CreateInstanceRequest)

Example 3 with CreateInstanceRequest

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();
    }
}
Also used : CloudRedisClient(com.google.cloud.redis.v1beta1.CloudRedisClient) Instance(com.google.cloud.redis.v1beta1.Instance) CreateInstanceRequest(com.google.cloud.redis.v1beta1.CreateInstanceRequest) Any(com.google.protobuf.Any)

Example 4 with CreateInstanceRequest

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();
    }
}
Also used : CloudRedisClient(com.google.cloud.redis.v1beta1.CloudRedisClient) Instance(com.google.cloud.redis.v1beta1.Instance) CreateInstanceRequest(com.google.cloud.redis.v1beta1.CreateInstanceRequest)

Example 5 with CreateInstanceRequest

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.bigtable.admin.v2.Instance) ProjectName(com.google.bigtable.admin.v2.ProjectName) HashMap(java.util.HashMap) Cluster(com.google.bigtable.admin.v2.Cluster) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) CreateInstanceRequest(com.google.bigtable.admin.v2.CreateInstanceRequest) Test(org.junit.Test)

Aggregations

Operation (com.google.longrunning.Operation)5 AbstractMessage (com.google.protobuf.AbstractMessage)4 ByteString (com.google.protobuf.ByteString)4 Test (org.junit.Test)4 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)3 CreateInstanceRequest (com.google.cloud.redis.v1beta1.CreateInstanceRequest)3 CreateInstanceRequest (com.google.spanner.admin.instance.v1.CreateInstanceRequest)3 Cluster (com.google.bigtable.admin.v2.Cluster)2 CreateInstanceRequest (com.google.bigtable.admin.v2.CreateInstanceRequest)2 Instance (com.google.bigtable.admin.v2.Instance)2 Instance (com.google.cloud.redis.v1beta1.Instance)2 Instance (com.google.spanner.admin.instance.v1.Instance)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 ProjectName (com.google.bigtable.admin.v2.ProjectName)1 ContainerImage (com.google.cloud.notebooks.v1beta1.ContainerImage)1 CreateEnvironmentRequest (com.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest)1 CreateInstanceRequest (com.google.cloud.notebooks.v1beta1.CreateInstanceRequest)1 Environment (com.google.cloud.notebooks.v1beta1.Environment)1