Search in sources :

Example 1 with CreateInstanceRequest

use of com.google.cloud.notebooks.v1beta1.CreateInstanceRequest in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method createInstanceTest2.

@Test
public void createInstanceTest2() 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);
    String parent = "parent-995424086";
    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, 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) 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)

Example 2 with CreateInstanceRequest

use of com.google.cloud.notebooks.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)

Example 3 with CreateInstanceRequest

use of com.google.cloud.notebooks.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 4 with CreateInstanceRequest

use of com.google.cloud.notebooks.v1beta1.CreateInstanceRequest in project java-notebooks by googleapis.

the class ITNotebookServiceClientTest method setUp.

@BeforeClass
public static void setUp() throws IOException, ExecutionException, InterruptedException {
    // Create Test Notebook Instance
    client = NotebookServiceClient.create();
    ContainerImage containerImage = ContainerImage.newBuilder().setRepository(FieldBehavior.OPTIONAL.name()).build();
    Environment environment = Environment.newBuilder().setName(ENVIRONMENT_NAME).setContainerImage(containerImage).build();
    CreateEnvironmentRequest environmentRequest = CreateEnvironmentRequest.newBuilder().setParent(PARENT).setEnvironmentId(ENVIRONMENT_ID).setEnvironment(environment).build();
    expectedEnvironmentResponse = client.createEnvironmentAsync(environmentRequest).get();
    Instance notebookInstance = Instance.newBuilder().setContainerImage(containerImage).setMachineType(MACHINE_TYPE_A).build();
    CreateInstanceRequest instanceRequest = CreateInstanceRequest.newBuilder().setParent(PARENT).setInstanceId(NOTEBOOK_INSTANCE_ID).setInstance(notebookInstance).build();
    expectedNotebookInstance = client.createInstanceAsync(instanceRequest).get();
}
Also used : CreateEnvironmentRequest(com.google.cloud.notebooks.v1beta1.CreateEnvironmentRequest) Instance(com.google.cloud.notebooks.v1beta1.Instance) ContainerImage(com.google.cloud.notebooks.v1beta1.ContainerImage) Environment(com.google.cloud.notebooks.v1beta1.Environment) CreateInstanceRequest(com.google.cloud.notebooks.v1beta1.CreateInstanceRequest) BeforeClass(org.junit.BeforeClass)

Example 5 with CreateInstanceRequest

use of com.google.cloud.notebooks.v1beta1.CreateInstanceRequest in project java-spanner by googleapis.

the class GapicSpannerRpc method createInstance.

@Override
public OperationFuture<Instance, CreateInstanceMetadata> createInstance(String parent, String instanceId, Instance instance) throws SpannerException {
    CreateInstanceRequest request = CreateInstanceRequest.newBuilder().setParent(parent).setInstanceId(instanceId).setInstance(instance).build();
    GrpcCallContext context = newCallContext(null, parent, request, InstanceAdminGrpc.getCreateInstanceMethod());
    return instanceAdminStub.createInstanceOperationCallable().futureCall(request, context);
}
Also used : GrpcCallContext(com.google.api.gax.grpc.GrpcCallContext) CreateInstanceRequest(com.google.spanner.admin.instance.v1.CreateInstanceRequest)

Aggregations

Operation (com.google.longrunning.Operation)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 ByteString (com.google.protobuf.ByteString)4 Test (org.junit.Test)4 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.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 Instance (com.google.cloud.notebooks.v1beta1.Instance)1 ProjectName (com.google.spanner.admin.instance.v1.ProjectName)1 BeforeClass (org.junit.BeforeClass)1