Search in sources :

Example 31 with Instance

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

Example 32 with Instance

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesPagedResponse(com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse) Test(org.junit.Test)

Example 33 with Instance

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);
}
Also used : Instance(com.google.cloud.compute.v1.Instance) Test(org.junit.Test)

Example 34 with Instance

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());
}
Also used : Instance(com.google.cloud.compute.v1.Instance) InstancesClient(com.google.cloud.compute.v1.InstancesClient) Test(org.junit.Test)

Example 35 with Instance

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())));
    }
}
Also used : EC2BlockDeviceMapping(com.scaleset.cfbuilder.ec2.instance.EC2BlockDeviceMapping) EC2EBSBlockDevice(com.scaleset.cfbuilder.ec2.instance.ec2blockdevicemapping.EC2EBSBlockDevice) Instance(com.scaleset.cfbuilder.ec2.Instance)

Aggregations

Test (org.junit.Test)43 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)42 Instance (com.google.cloud.redis.v1beta1.Instance)34 Instance (com.google.cloud.compute.v1.Instance)25 InstancesClient (com.google.cloud.compute.v1.InstancesClient)19 AbstractMessage (com.google.protobuf.AbstractMessage)17 ByteString (com.google.protobuf.ByteString)17 Operation (com.google.cloud.compute.v1.Operation)13 Instance (com.google.spanner.admin.instance.v1.Instance)11 Instance (com.google.bigtable.admin.v2.Instance)10 InsertInstanceRequest (com.google.cloud.compute.v1.InsertInstanceRequest)10 Operation (com.google.longrunning.Operation)10 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)9 Instance (com.google.cloud.notebooks.v1beta1.Instance)9 Any (com.google.protobuf.Any)8 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 FieldMask (com.google.protobuf.FieldMask)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 ArrayList (java.util.ArrayList)7 NetworkInterface (com.google.cloud.compute.v1.NetworkInterface)6