View Javadoc
1   package org.kuali.common.devops.ubuntu;
2   
3   import static com.google.common.base.Optional.absent;
4   
5   import java.util.List;
6   
7   import org.kuali.common.aws.ec2.model.ImmutableTag;
8   import org.kuali.common.core.build.ValidatingBuilder;
9   import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
10  
11  import com.amazonaws.services.ec2.model.Tag;
12  import com.google.common.base.Optional;
13  import com.google.common.collect.ImmutableList;
14  
15  @IdiotProofImmutable
16  public final class MountVolumeRequest {
17  
18  	/**
19  	 * The tags are used to locate the volume to attach. The volume must already exist, must exactly match all of the tags, and there must only be one volume that matches.
20  	 */
21  	private final ImmutableList<Tag> volumeTags;
22  
23  	/**
24  	 * The instance to attach the volume to
25  	 */
26  	private final String instanceId;
27  
28  	/**
29  	 * The name of the device to attach the volume as
30  	 */
31  	private final String device;
32  
33  	/**
34  	 * The path to mount the volume on
35  	 */
36  	private final String path;
37  
38  	/**
39  	 * For example, {@code tomcat7:tomcat7}. This value is passed directly to the Unix {@code chown} command
40  	 */
41  	private final Optional<String> ownership;
42  
43  	private MountVolumeRequest(Builder builder) {
44  		this.volumeTags = ImmutableList.copyOf(ImmutableTag.copyOf(builder.volumeTags));
45  		this.instanceId = builder.instanceId;
46  		this.device = builder.device;
47  		this.path = builder.path;
48  		this.ownership = builder.ownership;
49  	}
50  
51  	public static Builder builder() {
52  		return new Builder();
53  	}
54  
55  	public static class Builder extends ValidatingBuilder<MountVolumeRequest> {
56  
57  		private List<Tag> volumeTags;
58  		private String instanceId;
59  		private String device;
60  		private String path;
61  		private Optional<String> ownership = absent();
62  
63  		public Builder withVolumeTags(List<Tag> volumeTags) {
64  			this.volumeTags = volumeTags;
65  			return this;
66  		}
67  
68  		public Builder withOwnership(Optional<String> ownership) {
69  			this.ownership = ownership;
70  			return this;
71  		}
72  
73  		public Builder withOwnership(String ownership) {
74  			return withOwnership(Optional.of(ownership));
75  		}
76  
77  		public Builder withInstanceId(String instanceId) {
78  			this.instanceId = instanceId;
79  			return this;
80  		}
81  
82  		public Builder withPath(String path) {
83  			this.path = path;
84  			return this;
85  		}
86  
87  		public Builder withDevice(String device) {
88  			this.device = device;
89  			return this;
90  		}
91  
92  		@Override
93  		public MountVolumeRequest build() {
94  			return validate(new MountVolumeRequest(this));
95  		}
96  	}
97  
98  	public List<Tag> getVolumeTags() {
99  		return volumeTags;
100 	}
101 
102 	public String getInstanceId() {
103 		return instanceId;
104 	}
105 
106 	public String getDevice() {
107 		return device;
108 	}
109 
110 	public String getPath() {
111 		return path;
112 	}
113 
114 	public Optional<String> getOwnership() {
115 		return ownership;
116 	}
117 
118 }