/** * Creates an image for this disk given the image's name. * * @return a global operation if the image creation was successfully requested * @throws ComputeException upon failure */ public Operation createImage(String image, OperationOption... options) { ImageInfo imageInfo = ImageInfo.of(ImageId.of(image), DiskImageConfiguration.of(getDiskId())); return compute.create(imageInfo, options); }
@Override ImageDiskConfiguration setProjectId(String projectId) { Builder builder = toBuilder().setSourceImage(sourceImage.setProjectId(projectId)); if (getDiskType() != null) { builder.setDiskType(getDiskType().setProjectId(projectId)); } return builder.build(); }
SubnetworkInfo setProjectId(String projectId) { return toBuilder() .setSubnetworkId(subnetworkId.setProjectId(projectId)) .setNetwork(network.setProjectId(projectId)) .build(); }
@Test public void testSetProjectId() { InstanceInfo instance = InstanceInfo.of( InstanceId.of("zone", "instance"), MachineTypeId.of("zone", "type"), AttachedDisk.of(AttachedDisk.PersistentDiskConfiguration.of(DiskId.of("zone", "disk"))), NetworkInterface.of(NetworkId.of("project", "network"))); InstanceInfo instanceWithProject = InstanceInfo.of(INSTANCE_ID, MACHINE_TYPE, ATTACHED_DISK, NETWORK_INTERFACE); compareInstanceInfo(instanceWithProject, instance.setProjectId("project")); }
@Test public void testSetProjectId() { ImageInfo imageInfo = DISK_IMAGE .toBuilder() .setImageId(ImageId.of("image")) .setConfiguration( DISK_CONFIGURATION.toBuilder().setSourceDisk(DiskId.of("zone", "disk")).build()) .build(); compareImageInfo(DISK_IMAGE, imageInfo.setProjectId("project")); }
/** * Creates an image for this disk given the image's name and description. * * @return a global operation if the image creation was successfully requested * @throws ComputeException upon failure */ public Operation createImage(String image, String description, OperationOption... options) { ImageInfo imageInfo = ImageInfo.newBuilder(ImageId.of(image), DiskImageConfiguration.of(getDiskId())) .setDescription(description) .build(); return compute.create(imageInfo, options); }
@Override SnapshotDiskConfiguration setProjectId(String projectId) { Builder builder = toBuilder().setSourceSnapshot(sourceSnapshot.setProjectId(projectId)); if (getDiskType() != null) { builder.setDiskType(getDiskType().setProjectId(projectId)); } return builder.build(); }
NetworkInterface setProjectId(String projectId) { Builder builder = toBuilder(); builder.setNetwork(network.setProjectId(projectId)); if (subnetwork != null) { builder.setSubnetwork(subnetwork.setProjectId(projectId)); } return builder.build(); }
SnapshotInfo setProjectId(String projectId) { return toBuilder() .setSnapshotId(snapshotId.setProjectId(projectId)) .setSourceDisk(sourceDisk.setProjectId(projectId)) .build(); }
@Override CreateDiskConfiguration setProjectId(String projectId) { Builder builder = toBuilder(); if (builder.diskType != null) { builder.setDiskType(diskType.setProjectId(projectId)); } if (builder.sourceImage != null) { builder.setSourceImage(sourceImage.setProjectId(projectId)); } return builder.build(); }
@Override StandardDiskConfiguration setProjectId(String projectId) { if (getDiskType() == null || getDiskType().getProject() != null) { return this; } return toBuilder().setDiskType(getDiskType().setProjectId(projectId)).build(); }
ImageInfo setProjectId(String projectId) { return toBuilder() .setImageId(imageId.setProjectId(projectId)) .setConfiguration(configuration.setProjectId(projectId)) .build(); }
DiskInfo setProjectId(String projectId) { return toBuilder() .setDiskId(diskId.setProjectId(projectId)) .setConfiguration(configuration.setProjectId(projectId)) .build(); }
/** * Creates a snapshot for this disk given the snapshot's name. * * @return a zone operation for snapshot creation * @throws ComputeException upon failure */ public Operation createSnapshot(String snapshot, OperationOption... options) { return compute.create(SnapshotInfo.of(SnapshotId.of(snapshot), getDiskId()), options); }
/** * Sets the tags for this instance, fingerprint value is taken from this instance's {@code * tags().fingerprint()}. * * @return a zone operation if the set request was issued correctly, {@code null} if the instance * was not found * @throws ComputeException upon failure */ public Operation setTags(Iterable<String> tags, OperationOption... options) { return setTags(getTags().toBuilder().setValues(tags).build(), options); }
/** * Sets the metadata for this instance, fingerprint value is taken from this instance's {@code * tags().fingerprint()}. * * @return a zone operation if the set request was issued correctly, {@code null} if the instance * was not found * @throws ComputeException upon failure */ public Operation setMetadata(Map<String, String> metadata, OperationOption... options) { return setMetadata(getMetadata().toBuilder().setValues(metadata).build(), options); }
AddressInfo setProjectId(String projectId) { if (getAddressId().getProject() != null) { return this; } return toBuilder().setAddressId(addressId.setProjectId(projectId)).build(); }
@Override DiskImageConfiguration setProjectId(String projectId) { if (sourceDisk.getProject() != null) { return this; } return toBuilder().setSourceDisk(sourceDisk.setProjectId(projectId)).build(); }
/** * Fetches current network' latest information. Returns {@code null} if the network does not * exist. * * @param options network options * @return a {@code Network} object with latest information or {@code null} if not found * @throws ComputeException upon failure */ public Network reload(NetworkOption... options) { return compute.getNetwork(getNetworkId().getNetwork(), options); }
@Override public Operation attachDisk( InstanceId instance, String deviceName, PersistentDiskConfiguration configuration, int index, OperationOption... options) { AttachedDisk attachedDisk = AttachedDisk.newBuilder(configuration).setDeviceName(deviceName).setIndex(index).build(); return attachDisk(instance, attachedDisk, options); }