-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathImage.java
More file actions
293 lines (234 loc) · 7.37 KB
/
Image.java
File metadata and controls
293 lines (234 loc) · 7.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/**
* The MIT License
*
* <p>Copyright (c) 2013-2020 Jeevanandam M. (jeeva@myjeeva.com)
*
* <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* <p>The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.myjeeva.digitalocean.pojo;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.myjeeva.digitalocean.common.ImageStatus;
import com.myjeeva.digitalocean.common.ImageType;
/**
* Represents Droplet Image (also public images aka Distribution) attributes of DigitalOcean
* (distribution, snapshots or backups). Revised as per v2 API data structure.
*
* @author Jeevanandam M. (jeeva@myjeeva.com)
*/
public class Image extends Base {
private static final long serialVersionUID = 1321111459154107563L;
private String id;
@Expose private String name;
@Expose private String distribution;
private String slug;
@SerializedName("public")
private boolean availablePublic;
private List<String> regions;
@SerializedName("created_at")
private Date createdDate;
@SerializedName("min_disk_size")
private Integer minDiskSize;
@SerializedName("size_gigabytes")
private Double size;
private ImageType type;
// #89 - start
// https://developers.digitalocean.com/documentation/changelog/api-v2/support-for-custom-images-and-image-tagging/
@Expose private String url;
@Expose private String region;
@Expose private String description;
@Expose private List<String> tags;
private ImageStatus status;
@SerializedName("error_message")
private String errorMessage;
// #89 - end
public Image() {
// Default constructor
}
public Image(String id) {
this.id = id;
}
public Image(String name, String url, String region) {
this.name = name;
this.url = url;
this.region = region;
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
/** @return true if image is snapshot */
public boolean isSnapshot() {
return ImageType.SNAPSHOT == type;
}
/** @return true if image is backup */
public boolean isBackup() {
return ImageType.BACKUP == type;
}
/** @return the id */
public String getId() {
return id;
}
/** @param id the id to set */
public void setId(String id) {
this.id = id;
}
/** @return the name */
public String getName() {
return name;
}
/** @param name the name to set */
public void setName(String name) {
this.name = name;
}
/**
* The name of a custom image's distribution.
*
* <p>Currently, the valid values are "Arch Linux", "CentOS", "CoreOS", "Debian", "Fedora",
* "Fedora Atomic", "FreeBSD", "Gentoo", "openSUSE", "RancherOS", "Ubuntu", and "Unknown". Any
* other value will be accepted but ignored, and "Unknown" will be used in its place.
*
* @return the distribution
*/
public String getDistribution() {
return distribution;
}
/**
* The name of a custom image's distribution.
*
* <p>Currently, the valid values are "Arch Linux", "CentOS", "CoreOS", "Debian", "Fedora",
* "Fedora Atomic", "FreeBSD", "Gentoo", "openSUSE", "RancherOS", "Ubuntu", and "Unknown". Any
* other value will be accepted but ignored, and "Unknown" will be used in its place.
*
* @param distribution the distribution to set
*/
public void setDistribution(String distribution) {
this.distribution = distribution;
}
/** @return the slug */
public String getSlug() {
return slug;
}
/** @param slug the slug to set */
public void setSlug(String slug) {
this.slug = slug;
}
/** @return the availablePublic */
public boolean isAvailablePublic() {
return availablePublic;
}
/** @param availablePublic the availablePublic to set */
public void setAvailablePublic(boolean availablePublic) {
this.availablePublic = availablePublic;
}
/** @return the regions */
public List<String> getRegions() {
return regions;
}
/** @param regions the regions to set */
public void setRegions(List<String> regions) {
this.regions = regions;
}
/** @return the createdDate */
public Date getCreatedDate() {
return createdDate;
}
/** @param createdDate the createdDate to set */
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
/** @return the type */
public ImageType getType() {
return type;
}
/** @param type the type to set */
public void setType(ImageType type) {
this.type = type;
}
/** @return the min Disk Size */
public Integer getMinDiskSize() {
return minDiskSize;
}
/** @param minDiskSize the minDiskSize to set */
public void setMinDiskSize(Integer minDiskSize) {
this.minDiskSize = minDiskSize;
}
/** @return the size */
public Double getSize() {
return size;
}
/** @param size the size to set */
public void setSize(Double size) {
this.size = size;
}
/** @return the url */
public String getUrl() {
return url;
}
/**
* A URL from which the custom Linux virtual machine image may be retrieved. The image it points
* to must be in the raw, qcow2, vhdx, vdi, or vmdk format. It may be compressed using gzip or
* bzip2 and must be smaller than 100 GB after being decompressed.
*
* @param url the url to set
*/
public void setUrl(String url) {
this.url = url;
}
/** @return the region */
public String getRegion() {
return region;
}
/** @param region the region to set */
public void setRegion(String region) {
this.region = region;
}
/** @return the description */
public String getDescription() {
return description;
}
/** @param description the description to set */
public void setDescription(String description) {
this.description = description;
}
/** @return the status */
public ImageStatus getStatus() {
return status;
}
/** @param status the status to set */
public void setStatus(ImageStatus status) {
this.status = status;
}
/** @return the tags */
public List<String> getTags() {
return tags;
}
/** @param tags the tags to set */
public void setTags(List<String> tags) {
this.tags = tags;
}
/** @return the errorMessage */
public String getErrorMessage() {
return errorMessage;
}
/** @param errorMessage the errorMessage to set */
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}