Skip to content

Commit

Permalink
Minor changes to AttachedDisk
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Apr 20, 2016
1 parent 6e93362 commit c15cd91
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public AttachedDisk apply(
};
static final Function<AttachedDisk, com.google.api.services.compute.model.AttachedDisk>
TO_PB_FUNCTION =
new Function<AttachedDisk,
com.google.api.services.compute.model.AttachedDisk>() {
new Function<AttachedDisk, com.google.api.services.compute.model.AttachedDisk>() {
@Override
public com.google.api.services.compute.model.AttachedDisk apply(
AttachedDisk attachedDisk) {
Expand Down Expand Up @@ -233,7 +232,9 @@ public static final class Builder {
private Boolean boot;
private Boolean autoDelete;

private Builder() {}
private Builder(DiskId sourceDisk) {
this.sourceDisk = checkNotNull(sourceDisk);
}

private Builder(PersistentDiskConfiguration configuration) {
sourceDisk = configuration.sourceDisk;
Expand Down Expand Up @@ -261,8 +262,8 @@ public Builder mode(Mode mode) {

/**
* Sets whether to use the attached disk as a boot disk. If {@code true} the virtual machine
* will use the first partition of the disk for its root filesystem. If not specified, the
* disk is not used as a boot disk.
* instance will use the first partition of the disk for its root filesystem. If not
* specified, the isk is not used as a boot disk.
*/
public Builder boot(boolean boot) {
this.boot = boot;
Expand All @@ -288,7 +289,7 @@ public PersistentDiskConfiguration build() {

PersistentDiskConfiguration(Builder builder) {
super(Type.PERSISTENT, null, builder.boot, builder.autoDelete);
this.sourceDisk = checkNotNull(builder.sourceDisk);
this.sourceDisk = builder.sourceDisk;
this.mode = builder.mode;
}

Expand Down Expand Up @@ -353,7 +354,7 @@ com.google.api.services.compute.model.AttachedDisk toPb() {
* persistent disk to attach.
*/
public static Builder builder(DiskId sourceDisk) {
return new Builder().sourceDisk(sourceDisk);
return new Builder(sourceDisk);
}

/**
Expand All @@ -367,8 +368,7 @@ public static PersistentDiskConfiguration of(DiskId sourceDisk) {
@SuppressWarnings("unchecked")
static PersistentDiskConfiguration fromPb(
com.google.api.services.compute.model.AttachedDisk diskPb) {
Builder builder = new Builder();
builder.sourceDisk(DiskId.fromUrl(diskPb.getSource()));
Builder builder = new Builder(DiskId.fromUrl(diskPb.getSource()));
if (diskPb.getMode() != null) {
builder.mode(Mode.valueOf(diskPb.getMode()));
}
Expand All @@ -385,7 +385,9 @@ static PersistentDiskConfiguration fromPb(
/**
* An attached disk configuration for bootable persistent disks that must be created with the
* instance they are attached to. Attached disks that use this configuration can only be attached
* to an instance upon creation.
* to an instance upon creation. A {@code CreateDiskConfiguration} object is never returned by the
* service: after the instance is created the corresponding attached disk will be returned with a
* {@link PersistentDiskConfiguration}.
*/
public static final class CreateDiskConfiguration extends AttachedDiskConfiguration {

Expand All @@ -407,7 +409,9 @@ public static final class Builder {
private ImageId sourceImage;
private Boolean autoDelete;

private Builder() {}
private Builder(ImageId sourceImage) {
this.sourceImage = checkNotNull(sourceImage);
}

private Builder(CreateDiskConfiguration configuration) {
this.diskName = configuration.diskName;
Expand Down Expand Up @@ -474,7 +478,7 @@ public CreateDiskConfiguration build() {
this.diskName = builder.diskName;
this.diskType = builder.diskType;
this.diskSizeGb = builder.diskSizeGb;
this.sourceImage = checkNotNull(builder.sourceImage);
this.sourceImage = builder.sourceImage;
}

/**
Expand Down Expand Up @@ -568,7 +572,7 @@ com.google.api.services.compute.model.AttachedDisk toPb() {
* will be used to create the disk.
*/
public static Builder builder(ImageId sourceImage) {
return new Builder().sourceImage(sourceImage);
return new Builder(sourceImage);
}

/**
Expand Down Expand Up @@ -623,7 +627,7 @@ private Builder(ScratchDiskConfiguration configuration) {
}

/**
* Sets the identity of the disk type.
* Sets the identity of the disk type for the scratch disk to attach.
*/
public Builder diskType(DiskTypeId diskType) {
this.diskType = diskType;
Expand Down Expand Up @@ -827,7 +831,7 @@ public Integer index() {
}

/**
* Sets the attached disk configuration. Returns {@link ScratchDiskConfiguration} to attach a
* Returns the attached disk configuration. Returns {@link ScratchDiskConfiguration} to attach a
* scratch disk to the instance. Returns {@link PersistentDiskConfiguration} to attach a
* persistent disk to the instance. Returns {@link CreateDiskConfiguration} to create and attach
* a new persistent disk.
Expand Down Expand Up @@ -903,7 +907,7 @@ public static AttachedDisk of(AttachedDiskConfiguration configuration) {
}

/**
* Returns an {@code AttachedDisk} object given its configuration and the device name.
* Returns an {@code AttachedDisk} object given the device name and its configuration.
*/
public static AttachedDisk of(String deviceName, AttachedDiskConfiguration configuration) {
return builder(configuration).deviceName(deviceName).build();
Expand Down

0 comments on commit c15cd91

Please sign in to comment.