Here are the examples of the java api class com.google.cloud.compute.Image taken from open source projects.
1. ITComputeTest#testCreateGetAndDeprecateImage()
Project: gcloud-java
File: ITComputeTest.java
File: ITComputeTest.java
@Test public void testCreateGetAndDeprecateImage() throws InterruptedException, TimeoutException { String diskName = BASE_RESOURCE_NAME + "create-and-get-image-disk"; String imageName = BASE_RESOURCE_NAME + "create-and-get-image"; DiskId diskId = DiskId.of(ZONE, diskName); ImageId imageId = ImageId.of(imageName); DiskInfo diskInfo = DiskInfo.of(diskId, StandardDiskConfiguration.of(DiskTypeId.of(ZONE, "pd-ssd"), 100L)); Operation operation = compute.create(diskInfo); operation.waitFor(); Disk remoteDisk = compute.getDisk(diskId); ImageInfo imageInfo = ImageInfo.of(imageId, DiskImageConfiguration.of(diskId)); operation = compute.create(imageInfo); operation.waitFor(); // test get image with selected fields Image image = compute.getImage(imageId, Compute.ImageOption.fields(Compute.ImageField.CREATION_TIMESTAMP)); assertNull(image.generatedId()); assertNotNull(image.imageId()); assertNotNull(image.creationTimestamp()); assertNull(image.description()); assertNotNull(image.configuration()); assertTrue(image.configuration() instanceof DiskImageConfiguration); DiskImageConfiguration remoteConfiguration = image.configuration(); Assert.assertEquals(ImageConfiguration.Type.DISK, remoteConfiguration.type()); assertEquals(diskName, remoteConfiguration.sourceDisk().disk()); assertNull(image.status()); assertNull(image.diskSizeGb()); assertNull(image.licenses()); assertNull(image.deprecationStatus()); // test get image image = compute.getImage(imageId); assertNotNull(image.generatedId()); assertNotNull(image.imageId()); assertNotNull(image.creationTimestamp()); assertNotNull(image.configuration()); assertTrue(image.configuration() instanceof DiskImageConfiguration); remoteConfiguration = image.configuration(); assertEquals(ImageConfiguration.Type.DISK, remoteConfiguration.type()); assertEquals(diskName, remoteConfiguration.sourceDisk().disk()); assertEquals(100L, (long) image.diskSizeGb()); assertNotNull(image.status()); assertNull(image.deprecationStatus()); // test deprecate image DeprecationStatus<ImageId> deprecationStatus = DeprecationStatus.builder(DeprecationStatus.Status.DEPRECATED, imageId).deprecated(System.currentTimeMillis()).build(); operation = image.deprecate(deprecationStatus); operation.waitFor(); image = compute.getImage(imageId); assertEquals(deprecationStatus, image.deprecationStatus()); remoteDisk.delete(); operation = image.delete(); operation.waitFor(); assertNull(compute.getImage(imageId)); }