use of com.google.cloud.redis.v1beta1.GetInstanceRequest in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method getInstanceTest.
@Test
public void getInstanceTest() throws Exception {
Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance actualResponse = client.getInstance(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetInstanceRequest actualRequest = ((GetInstanceRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.GetInstanceRequest in project java-docs-samples by GoogleCloudPlatform.
the class StartEncryptedInstance method startEncryptedInstance.
// Starts a stopped Google Compute Engine instance (with encrypted disks).
public static void startEncryptedInstance(String project, String zone, String instanceName, String key) throws IOException, ExecutionException, InterruptedException, TimeoutException {
/* Initialize client that will be used to send requests. This client only needs to be created
once, and can be reused for multiple requests. After completing all of your requests, call
the `instancesClient.close()` method on the client to safely
clean up any remaining background resources. */
try (InstancesClient instancesClient = InstancesClient.create()) {
GetInstanceRequest getInstanceRequest = GetInstanceRequest.newBuilder().setProject(project).setZone(zone).setInstance(instanceName).build();
Instance instance = instancesClient.get(getInstanceRequest);
// Prepare the information about disk encryption.
CustomerEncryptionKeyProtectedDisk protectedDisk = CustomerEncryptionKeyProtectedDisk.newBuilder().setDiskEncryptionKey(CustomerEncryptionKey.newBuilder().setRawKey(key).build()).setSource(instance.getDisks(0).getSource()).build();
InstancesStartWithEncryptionKeyRequest startWithEncryptionKeyRequest = InstancesStartWithEncryptionKeyRequest.newBuilder().addDisks(protectedDisk).build();
StartWithEncryptionKeyInstanceRequest encryptionKeyInstanceRequest = StartWithEncryptionKeyInstanceRequest.newBuilder().setProject(project).setZone(zone).setInstance(instanceName).setInstancesStartWithEncryptionKeyRequestResource(startWithEncryptionKeyRequest).build();
OperationFuture<Operation, Operation> operation = instancesClient.startWithEncryptionKeyAsync(encryptionKeyInstanceRequest);
Operation response = operation.get(3, TimeUnit.MINUTES);
if (response.getStatus() == Status.DONE) {
System.out.println("Encrypted instance started successfully ! ");
}
}
}
use of com.google.cloud.redis.v1beta1.GetInstanceRequest in project java-bigtable by googleapis.
the class BigtableInstanceAdminClientTests method testGetInstance.
@Test
public void testGetInstance() {
// Setup
Mockito.when(mockStub.getInstanceCallable()).thenReturn(mockGetInstanceCallable);
com.google.bigtable.admin.v2.GetInstanceRequest expectedRequest = com.google.bigtable.admin.v2.GetInstanceRequest.newBuilder().setName(INSTANCE_NAME).build();
com.google.bigtable.admin.v2.Instance expectedResponse = com.google.bigtable.admin.v2.Instance.newBuilder().setName(INSTANCE_NAME).build();
Mockito.when(mockGetInstanceCallable.futureCall(expectedRequest)).thenReturn(ApiFutures.immediateFuture(expectedResponse));
// Execute
Instance actualResult = adminClient.getInstance(INSTANCE_ID);
// Verify
assertThat(actualResult).isEqualTo(Instance.fromProto(expectedResponse));
}
use of com.google.cloud.redis.v1beta1.GetInstanceRequest in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method getInstanceTest2.
@Test
public void getInstanceTest2() throws Exception {
Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
String name = "name3373707";
Instance actualResponse = client.getInstance(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetInstanceRequest actualRequest = ((GetInstanceRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.GetInstanceRequest in project java-notebooks by googleapis.
the class ITNotebookServiceClientTest method testGetInstance.
@Test
public void testGetInstance() {
GetInstanceRequest request = GetInstanceRequest.newBuilder().setName(INSTANCE_NAME).build();
Instance actualNotebookInstance = client.getInstance(request);
assertEquals(expectedNotebookInstance.getContainerImage(), actualNotebookInstance.getContainerImage());
assertEquals(expectedNotebookInstance.getName(), actualNotebookInstance.getName());
assertEquals(expectedNotebookInstance.getNetwork(), actualNotebookInstance.getNetwork());
assertEquals(expectedNotebookInstance.getSubnet(), actualNotebookInstance.getSubnet());
}
Aggregations