1 | /** |
2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
3 | * contributor license agreements. See the NOTICE file |
4 | * distributed with this work for additional information |
5 | * regarding copyright ownership. jclouds licenses this file |
6 | * to you under the Apache License, Version 2.0 (the |
7 | * "License"); you may not use this file except in compliance |
8 | * with the License. You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, |
13 | * software distributed under the License is distributed on an |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 | * KIND, either express or implied. See the License for the |
16 | * specific language governing permissions and limitations |
17 | * under the License. |
18 | */ |
19 | package org.jclouds.ec2.domain; |
20 | |
21 | import static com.google.common.base.Preconditions.checkNotNull; |
22 | |
23 | import org.jclouds.javax.annotation.Nullable; |
24 | |
25 | /** |
26 | * |
27 | * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-BundleInstanceS3StorageType.html" |
28 | * /> |
29 | * @author Adrian Cole |
30 | */ |
31 | public class BundleInstanceS3Storage { |
32 | private final String ccessKeyId; |
33 | private final String bucket; |
34 | private final String prefix; |
35 | private final String secretAccessKey; |
36 | private final String uploadPolicy; |
37 | private final String uploadPolicySignature; |
38 | |
39 | public BundleInstanceS3Storage(@Nullable String ccessKeyId, String bucket, String prefix, |
40 | @Nullable String secretAccessKey, @Nullable String uploadPolicy, @Nullable String uploadPolicySignature) { |
41 | this.ccessKeyId = ccessKeyId; |
42 | this.bucket = checkNotNull(bucket, "bucket"); |
43 | this.prefix = checkNotNull(prefix, "prefix"); |
44 | this.secretAccessKey = secretAccessKey; |
45 | this.uploadPolicy = uploadPolicy; |
46 | this.uploadPolicySignature = uploadPolicySignature; |
47 | } |
48 | |
49 | @Override |
50 | public int hashCode() { |
51 | final int prime = 31; |
52 | int result = 1; |
53 | result = prime * result + ((ccessKeyId == null) ? 0 : ccessKeyId.hashCode()); |
54 | result = prime * result + ((bucket == null) ? 0 : bucket.hashCode()); |
55 | result = prime * result + ((prefix == null) ? 0 : prefix.hashCode()); |
56 | result = prime * result + ((secretAccessKey == null) ? 0 : secretAccessKey.hashCode()); |
57 | result = prime * result + ((uploadPolicy == null) ? 0 : uploadPolicy.hashCode()); |
58 | result = prime * result + ((uploadPolicySignature == null) ? 0 : uploadPolicySignature.hashCode()); |
59 | return result; |
60 | } |
61 | |
62 | @Override |
63 | public boolean equals(Object obj) { |
64 | if (this == obj) |
65 | return true; |
66 | if (obj == null) |
67 | return false; |
68 | if (getClass() != obj.getClass()) |
69 | return false; |
70 | BundleInstanceS3Storage other = (BundleInstanceS3Storage) obj; |
71 | if (ccessKeyId == null) { |
72 | if (other.ccessKeyId != null) |
73 | return false; |
74 | } else if (!ccessKeyId.equals(other.ccessKeyId)) |
75 | return false; |
76 | if (bucket == null) { |
77 | if (other.bucket != null) |
78 | return false; |
79 | } else if (!bucket.equals(other.bucket)) |
80 | return false; |
81 | if (prefix == null) { |
82 | if (other.prefix != null) |
83 | return false; |
84 | } else if (!prefix.equals(other.prefix)) |
85 | return false; |
86 | if (secretAccessKey == null) { |
87 | if (other.secretAccessKey != null) |
88 | return false; |
89 | } else if (!secretAccessKey.equals(other.secretAccessKey)) |
90 | return false; |
91 | if (uploadPolicy == null) { |
92 | if (other.uploadPolicy != null) |
93 | return false; |
94 | } else if (!uploadPolicy.equals(other.uploadPolicy)) |
95 | return false; |
96 | if (uploadPolicySignature == null) { |
97 | if (other.uploadPolicySignature != null) |
98 | return false; |
99 | } else if (!uploadPolicySignature.equals(other.uploadPolicySignature)) |
100 | return false; |
101 | return true; |
102 | } |
103 | |
104 | @Override |
105 | public String toString() { |
106 | return "[ccessKeyId=" + ccessKeyId + ", bucket=" + bucket + ", prefix=" + prefix + ", secreAccessKey=" |
107 | + secretAccessKey + ", uploadPolicy=" + uploadPolicy + ", uploadPolicySignature=" + uploadPolicySignature |
108 | + "]"; |
109 | } |
110 | |
111 | |
112 | /** |
113 | * |
114 | * @returnThe bucket in which to store the AMI. You can specify a bucket that |
115 | * you already own or a new bucket that Amazon EC2 creates on your |
116 | * behalf. If you specify a bucket that belongs to someone else, |
117 | * Amazon EC2 returns an error. |
118 | */ |
119 | public String getBucket() { |
120 | return bucket; |
121 | } |
122 | |
123 | /** |
124 | * |
125 | * @return Specifies the beginning of the file name of the AMI. |
126 | */ |
127 | public String getPrefix() { |
128 | return prefix; |
129 | } |
130 | |
131 | |
132 | |
133 | /** |
134 | * |
135 | * @return An Amazon S3 upload policy that gives Amazon EC2 permission to |
136 | * upload items into Amazon S3 on the user's behalf. For more |
137 | * information on bundling in Windows, go to the Amazon Elastic |
138 | * Compute Cloud Developer Guide and Amazon Elastic Compute Cloud |
139 | * Getting Started |
140 | */ |
141 | public String getUploadPolicy() { |
142 | return uploadPolicy; |
143 | } |
144 | |
145 | /** |
146 | * |
147 | * @return The signature of the Base64 encoded JSON document. |
148 | */ |
149 | public String getUploadPolicySignature() { |
150 | return uploadPolicySignature; |
151 | } |
152 | } |