PageRenderTime 44ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/aws-android-sdk-ec2/src/main/java/com/amazonaws/services/ec2/model/ImportInstanceRequest.java

https://gitlab.com/github-cloud-corp/aws-sdk-android
Java | 348 lines | 124 code | 32 blank | 192 comment | 56 complexity | 4c276f4eb4970e4abf98177eff265006 MD5 | raw file
  1. /*
  2. * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. package com.amazonaws.services.ec2.model;
  16. import java.io.Serializable;
  17. import com.amazonaws.AmazonWebServiceRequest;
  18. import com.amazonaws.Request;
  19. import com.amazonaws.services.ec2.model.transform.ImportInstanceRequestMarshaller;
  20. /**
  21. * Container for the parameters to the {@link com.amazonaws.services.ec2.AmazonEC2#importInstance(ImportInstanceRequest) ImportInstance operation}.
  22. * <p>
  23. * Creates an import instance task using metadata from the specified disk
  24. * image. <code>ImportInstance</code> only supports single-volume VMs. To
  25. * import multi-volume VMs, use ImportImage. After importing the image,
  26. * you then upload it using the <code>ec2-import-volume</code> command in
  27. * the EC2 command line tools. For more information, see
  28. * <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UploadingYourInstancesandVolumes.html"> Using the Command Line Tools to Import Your Virtual Machine to Amazon EC2 </a>
  29. * in the <i>Amazon Elastic Compute Cloud User Guide</i> .
  30. * </p>
  31. * <p>
  32. * For information about the import manifest referenced by this API
  33. * action, see
  34. * <a href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/manifest.html"> VM Import Manifest </a>
  35. * .
  36. * </p>
  37. *
  38. * @see com.amazonaws.services.ec2.AmazonEC2#importInstance(ImportInstanceRequest)
  39. */
  40. public class ImportInstanceRequest extends AmazonWebServiceRequest implements Serializable, DryRunSupportedRequest<ImportInstanceRequest> {
  41. /**
  42. * A description for the instance being imported.
  43. */
  44. private String description;
  45. /**
  46. * The launch specification.
  47. */
  48. private ImportInstanceLaunchSpecification launchSpecification;
  49. /**
  50. * The disk image.
  51. */
  52. private com.amazonaws.internal.ListWithAutoConstructFlag<DiskImage> diskImages;
  53. /**
  54. * The instance operating system.
  55. * <p>
  56. * <b>Constraints:</b><br/>
  57. * <b>Allowed Values: </b>Windows
  58. */
  59. private String platform;
  60. /**
  61. * A description for the instance being imported.
  62. *
  63. * @return A description for the instance being imported.
  64. */
  65. public String getDescription() {
  66. return description;
  67. }
  68. /**
  69. * A description for the instance being imported.
  70. *
  71. * @param description A description for the instance being imported.
  72. */
  73. public void setDescription(String description) {
  74. this.description = description;
  75. }
  76. /**
  77. * A description for the instance being imported.
  78. * <p>
  79. * Returns a reference to this object so that method calls can be chained together.
  80. *
  81. * @param description A description for the instance being imported.
  82. *
  83. * @return A reference to this updated object so that method calls can be chained
  84. * together.
  85. */
  86. public ImportInstanceRequest withDescription(String description) {
  87. this.description = description;
  88. return this;
  89. }
  90. /**
  91. * The launch specification.
  92. *
  93. * @return The launch specification.
  94. */
  95. public ImportInstanceLaunchSpecification getLaunchSpecification() {
  96. return launchSpecification;
  97. }
  98. /**
  99. * The launch specification.
  100. *
  101. * @param launchSpecification The launch specification.
  102. */
  103. public void setLaunchSpecification(ImportInstanceLaunchSpecification launchSpecification) {
  104. this.launchSpecification = launchSpecification;
  105. }
  106. /**
  107. * The launch specification.
  108. * <p>
  109. * Returns a reference to this object so that method calls can be chained together.
  110. *
  111. * @param launchSpecification The launch specification.
  112. *
  113. * @return A reference to this updated object so that method calls can be chained
  114. * together.
  115. */
  116. public ImportInstanceRequest withLaunchSpecification(ImportInstanceLaunchSpecification launchSpecification) {
  117. this.launchSpecification = launchSpecification;
  118. return this;
  119. }
  120. /**
  121. * The disk image.
  122. *
  123. * @return The disk image.
  124. */
  125. public java.util.List<DiskImage> getDiskImages() {
  126. if (diskImages == null) {
  127. diskImages = new com.amazonaws.internal.ListWithAutoConstructFlag<DiskImage>();
  128. diskImages.setAutoConstruct(true);
  129. }
  130. return diskImages;
  131. }
  132. /**
  133. * The disk image.
  134. *
  135. * @param diskImages The disk image.
  136. */
  137. public void setDiskImages(java.util.Collection<DiskImage> diskImages) {
  138. if (diskImages == null) {
  139. this.diskImages = null;
  140. return;
  141. }
  142. com.amazonaws.internal.ListWithAutoConstructFlag<DiskImage> diskImagesCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<DiskImage>(diskImages.size());
  143. diskImagesCopy.addAll(diskImages);
  144. this.diskImages = diskImagesCopy;
  145. }
  146. /**
  147. * The disk image.
  148. * <p>
  149. * Returns a reference to this object so that method calls can be chained together.
  150. *
  151. * @param diskImages The disk image.
  152. *
  153. * @return A reference to this updated object so that method calls can be chained
  154. * together.
  155. */
  156. public ImportInstanceRequest withDiskImages(DiskImage... diskImages) {
  157. if (getDiskImages() == null) setDiskImages(new java.util.ArrayList<DiskImage>(diskImages.length));
  158. for (DiskImage value : diskImages) {
  159. getDiskImages().add(value);
  160. }
  161. return this;
  162. }
  163. /**
  164. * The disk image.
  165. * <p>
  166. * Returns a reference to this object so that method calls can be chained together.
  167. *
  168. * @param diskImages The disk image.
  169. *
  170. * @return A reference to this updated object so that method calls can be chained
  171. * together.
  172. */
  173. public ImportInstanceRequest withDiskImages(java.util.Collection<DiskImage> diskImages) {
  174. if (diskImages == null) {
  175. this.diskImages = null;
  176. } else {
  177. com.amazonaws.internal.ListWithAutoConstructFlag<DiskImage> diskImagesCopy = new com.amazonaws.internal.ListWithAutoConstructFlag<DiskImage>(diskImages.size());
  178. diskImagesCopy.addAll(diskImages);
  179. this.diskImages = diskImagesCopy;
  180. }
  181. return this;
  182. }
  183. /**
  184. * The instance operating system.
  185. * <p>
  186. * <b>Constraints:</b><br/>
  187. * <b>Allowed Values: </b>Windows
  188. *
  189. * @return The instance operating system.
  190. *
  191. * @see PlatformValues
  192. */
  193. public String getPlatform() {
  194. return platform;
  195. }
  196. /**
  197. * The instance operating system.
  198. * <p>
  199. * <b>Constraints:</b><br/>
  200. * <b>Allowed Values: </b>Windows
  201. *
  202. * @param platform The instance operating system.
  203. *
  204. * @see PlatformValues
  205. */
  206. public void setPlatform(String platform) {
  207. this.platform = platform;
  208. }
  209. /**
  210. * The instance operating system.
  211. * <p>
  212. * Returns a reference to this object so that method calls can be chained together.
  213. * <p>
  214. * <b>Constraints:</b><br/>
  215. * <b>Allowed Values: </b>Windows
  216. *
  217. * @param platform The instance operating system.
  218. *
  219. * @return A reference to this updated object so that method calls can be chained
  220. * together.
  221. *
  222. * @see PlatformValues
  223. */
  224. public ImportInstanceRequest withPlatform(String platform) {
  225. this.platform = platform;
  226. return this;
  227. }
  228. /**
  229. * The instance operating system.
  230. * <p>
  231. * <b>Constraints:</b><br/>
  232. * <b>Allowed Values: </b>Windows
  233. *
  234. * @param platform The instance operating system.
  235. *
  236. * @see PlatformValues
  237. */
  238. public void setPlatform(PlatformValues platform) {
  239. this.platform = platform.toString();
  240. }
  241. /**
  242. * The instance operating system.
  243. * <p>
  244. * Returns a reference to this object so that method calls can be chained together.
  245. * <p>
  246. * <b>Constraints:</b><br/>
  247. * <b>Allowed Values: </b>Windows
  248. *
  249. * @param platform The instance operating system.
  250. *
  251. * @return A reference to this updated object so that method calls can be chained
  252. * together.
  253. *
  254. * @see PlatformValues
  255. */
  256. public ImportInstanceRequest withPlatform(PlatformValues platform) {
  257. this.platform = platform.toString();
  258. return this;
  259. }
  260. /**
  261. * This method is intended for internal use only.
  262. * Returns the marshaled request configured with additional parameters to
  263. * enable operation dry-run.
  264. */
  265. @Override
  266. public Request<ImportInstanceRequest> getDryRunRequest() {
  267. Request<ImportInstanceRequest> request = new ImportInstanceRequestMarshaller().marshall(this);
  268. request.addParameter("DryRun", Boolean.toString(true));
  269. return request;
  270. }
  271. /**
  272. * Returns a string representation of this object; useful for testing and
  273. * debugging.
  274. *
  275. * @return A string representation of this object.
  276. *
  277. * @see java.lang.Object#toString()
  278. */
  279. @Override
  280. public String toString() {
  281. StringBuilder sb = new StringBuilder();
  282. sb.append("{");
  283. if (getDescription() != null) sb.append("Description: " + getDescription() + ",");
  284. if (getLaunchSpecification() != null) sb.append("LaunchSpecification: " + getLaunchSpecification() + ",");
  285. if (getDiskImages() != null) sb.append("DiskImages: " + getDiskImages() + ",");
  286. if (getPlatform() != null) sb.append("Platform: " + getPlatform() );
  287. sb.append("}");
  288. return sb.toString();
  289. }
  290. @Override
  291. public int hashCode() {
  292. final int prime = 31;
  293. int hashCode = 1;
  294. hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode());
  295. hashCode = prime * hashCode + ((getLaunchSpecification() == null) ? 0 : getLaunchSpecification().hashCode());
  296. hashCode = prime * hashCode + ((getDiskImages() == null) ? 0 : getDiskImages().hashCode());
  297. hashCode = prime * hashCode + ((getPlatform() == null) ? 0 : getPlatform().hashCode());
  298. return hashCode;
  299. }
  300. @Override
  301. public boolean equals(Object obj) {
  302. if (this == obj) return true;
  303. if (obj == null) return false;
  304. if (obj instanceof ImportInstanceRequest == false) return false;
  305. ImportInstanceRequest other = (ImportInstanceRequest)obj;
  306. if (other.getDescription() == null ^ this.getDescription() == null) return false;
  307. if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false) return false;
  308. if (other.getLaunchSpecification() == null ^ this.getLaunchSpecification() == null) return false;
  309. if (other.getLaunchSpecification() != null && other.getLaunchSpecification().equals(this.getLaunchSpecification()) == false) return false;
  310. if (other.getDiskImages() == null ^ this.getDiskImages() == null) return false;
  311. if (other.getDiskImages() != null && other.getDiskImages().equals(this.getDiskImages()) == false) return false;
  312. if (other.getPlatform() == null ^ this.getPlatform() == null) return false;
  313. if (other.getPlatform() != null && other.getPlatform().equals(this.getPlatform()) == false) return false;
  314. return true;
  315. }
  316. }