1 package org.kuali.common.aws.ec2.model; 2 3 import static org.kuali.common.util.FormatUtils.getMillis; 4 5 import org.kuali.common.core.build.ValidatingBuilder; 6 import org.kuali.common.core.validate.annotation.IdiotProofImmutable; 7 8 @IdiotProofImmutable 9 public final class VolumeRequest { 10 11 private final String instanceId; 12 private final String volumeId; 13 private final String device; 14 private final long timeout; 15 16 private VolumeRequest(Builder builder) { 17 this.instanceId = builder.instanceId; 18 this.volumeId = builder.volumeId; 19 this.device = builder.device; 20 this.timeout = builder.timeout; 21 } 22 23 public static Builder builder() { 24 return new Builder(); 25 } 26 27 public static class Builder extends ValidatingBuilder<VolumeRequest> { 28 29 private String instanceId; 30 private String volumeId; 31 private String device = "/dev/xvdf"; 32 private long timeout = getMillis("15m"); 33 34 public Builder withInstanceId(String instanceId) { 35 this.instanceId = instanceId; 36 return this; 37 } 38 39 public Builder withVolumeId(String volumeId) { 40 this.volumeId = volumeId; 41 return this; 42 } 43 44 public Builder withDevice(String device) { 45 this.device = device; 46 return this; 47 } 48 49 public Builder withTimeout(long timeout) { 50 this.timeout = timeout; 51 return this; 52 } 53 54 @Override 55 public VolumeRequest build() { 56 return validate(new VolumeRequest(this)); 57 } 58 59 } 60 61 public String getInstanceId() { 62 return instanceId; 63 } 64 65 public String getVolumeId() { 66 return volumeId; 67 } 68 69 public String getDevice() { 70 return device; 71 } 72 73 public long getTimeout() { 74 return timeout; 75 } 76 77 }