use of com.google.cloud.redis.v1beta1.Instance in project gapic-generator-java by googleapis.
the class SyncRescheduleMaintenanceInstancenameReschedulemaintenancerequestrescheduletypeTimestamp method syncRescheduleMaintenanceInstancenameReschedulemaintenancerequestrescheduletypeTimestamp.
public static void syncRescheduleMaintenanceInstancenameReschedulemaintenancerequestrescheduletypeTimestamp() throws Exception {
// It may require modifications to work in your environment.
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
RescheduleMaintenanceRequest.RescheduleType rescheduleType = RescheduleMaintenanceRequest.RescheduleType.forNumber(0);
Timestamp scheduleTime = Timestamp.newBuilder().build();
Instance response = cloudRedisClient.rescheduleMaintenanceAsync(name, rescheduleType, scheduleTime).get();
}
}
use of com.google.cloud.redis.v1beta1.Instance in project gapic-generator-java by googleapis.
the class CloudRedisClientTest method listInstancesTest2.
@Test
public void listInstancesTest2() throws Exception {
Instance responsesElement = Instance.newBuilder().build();
ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
mockCloudRedis.addResponse(expectedResponse);
String parent = "parent-995424086";
ListInstancesPagedResponse pagedListResponse = client.listInstances(parent);
List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockCloudRedis.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.redis.v1beta1.Instance in project java-compute by googleapis.
the class ITSmokeInstancesTest method testInsertInstance.
@Test
public void testInsertInstance() throws ExecutionException, InterruptedException {
Instance resultInstance = insertInstance();
assertInstanceDetails(resultInstance);
}
use of com.google.cloud.redis.v1beta1.Instance in project java-compute by googleapis.
the class ITSmokeInstancesTest method testDefaultClient.
@Test
public void testDefaultClient() throws IOException, ExecutionException, InterruptedException {
InstancesClient defaultClient = InstancesClient.create();
Instance instanceResource = Instance.newBuilder().setName(INSTANCE).setMachineType(MACHINE_TYPE).addDisks(DISK).addNetworkInterfaces(NETWORK_INTERFACE).build();
defaultClient.insertAsync(DEFAULT_PROJECT, DEFAULT_ZONE, instanceResource).get();
instances.add(instanceResource);
assertInstanceDetails(getInstance());
}
use of com.google.cloud.redis.v1beta1.Instance in project TOSCAna by StuPro-TOSCAna.
the class CapabilityMapper method mapDiskSize.
/**
* Maps the disk_size property of a {@link ComputeCapability} to an EC2 Instance.
*
* @param computeCapability {@link ComputeCapability} containing the disk_size property
* @param cfnModule {@link CloudFormationModule} containing the Instance
* @param nodeName name of the Instance
*/
public void mapDiskSize(ComputeCapability computeCapability, CloudFormationModule cfnModule, String nodeName) {
// If disk_size is not set, default to 8000 Mb
Integer diskSizeInMb = computeCapability.getDiskSizeInMb().orElse(8000);
// Convert disk_size to Gb
Integer diskSizeInGb = diskSizeInMb / 1000;
logger.debug("Check diskSize: '{}' Gb", diskSizeInGb);
if (diskSizeInGb < 8) {
logger.warn("Disk size of '{}' smaller than the minimum value required by EC2 Instances. Setting the disk size of '{}' to the minimum allowed value of 8 Gb.", nodeName, nodeName);
diskSizeInGb = 8;
}
// Add BlockDeviceMapping if needed
if (diskSizeInGb > 8) {
logger.debug("Disk size of '{}' bigger than the default value of EC2 Instances. Adding a BlockDeviceMapping to '{}'.", nodeName, nodeName);
Instance computeAsInstance = (Instance) cfnModule.getResource(nodeName);
computeAsInstance.blockDeviceMappings(new EC2BlockDeviceMapping().deviceName("/dev/sda1").ebs(new EC2EBSBlockDevice().volumeSize(diskSizeInGb.toString())));
}
}
Aggregations