| 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.rimuhosting.miro.domain; |
| 20 | |
| 21 | import java.util.List; |
| 22 | |
| 23 | import com.google.gson.annotations.SerializedName; |
| 24 | import org.jclouds.rimuhosting.miro.data.NewServerData; |
| 25 | import org.jclouds.rimuhosting.miro.domain.internal.RunningState; |
| 26 | |
| 27 | /** |
| 28 | * Instance Object. |
| 29 | * TODO: javadoc |
| 30 | * |
| 31 | * @author Ivan Meredith |
| 32 | */ |
| 33 | public class Server implements Comparable<Server> { |
| 34 | |
| 35 | @SerializedName("allocated_ips") |
| 36 | private IpAddresses ipAddresses; |
| 37 | @SerializedName("billing_oid") |
| 38 | private Long billingId; |
| 39 | @SerializedName("data_transfer_allowance") |
| 40 | private DataTransferAllowance allowance; |
| 41 | @SerializedName("distro") |
| 42 | private String imageId; |
| 43 | @SerializedName("domain_name") |
| 44 | private String name; |
| 45 | |
| 46 | @SerializedName("host_server_oid") |
| 47 | private String hostServerId; |
| 48 | @SerializedName("is_on_customers_own_physical_server") |
| 49 | private Boolean onDedicatedHardware; |
| 50 | @SerializedName("order_oid") |
| 51 | private Long id; |
| 52 | @SerializedName("running_state") |
| 53 | private RunningState state; |
| 54 | @SerializedName("server_type") |
| 55 | private String type; |
| 56 | private String slug; |
| 57 | @SerializedName("vps_parameters") |
| 58 | private ServerParameters serverParameters; |
| 59 | @SerializedName("billing_info") |
| 60 | private BillingData billingData; |
| 61 | |
| 62 | private DataCenter location; |
| 63 | |
| 64 | @SerializedName("meta_data") |
| 65 | private List<MetaData> metaData; |
| 66 | //Object returned back with |
| 67 | private transient NewServerData serverDataRequest; |
| 68 | |
| 69 | |
| 70 | public IpAddresses getIpAddresses() { |
| 71 | return ipAddresses; |
| 72 | } |
| 73 | |
| 74 | public void setIpAddresses(IpAddresses ipAddresses) { |
| 75 | this.ipAddresses = ipAddresses; |
| 76 | } |
| 77 | |
| 78 | public Long getBillingId() { |
| 79 | return billingId; |
| 80 | } |
| 81 | |
| 82 | public void setBillingId(Long billingId) { |
| 83 | this.billingId = billingId; |
| 84 | } |
| 85 | |
| 86 | public DataTransferAllowance getAllowance() { |
| 87 | return allowance; |
| 88 | } |
| 89 | |
| 90 | public void setAllowance(DataTransferAllowance allowance) { |
| 91 | this.allowance = allowance; |
| 92 | } |
| 93 | |
| 94 | public String getImageId() { |
| 95 | return imageId; |
| 96 | } |
| 97 | |
| 98 | public void setImageId(String imageId) { |
| 99 | this.imageId = imageId; |
| 100 | } |
| 101 | |
| 102 | public String getName() { |
| 103 | return name; |
| 104 | } |
| 105 | |
| 106 | public void setName(String name) { |
| 107 | this.name = name; |
| 108 | } |
| 109 | |
| 110 | public String getHostServerId() { |
| 111 | return hostServerId; |
| 112 | } |
| 113 | |
| 114 | public void setHostServerId(String hostServerId) { |
| 115 | this.hostServerId = hostServerId; |
| 116 | } |
| 117 | |
| 118 | public Boolean isOnDedicatedHardware() { |
| 119 | return onDedicatedHardware; |
| 120 | } |
| 121 | |
| 122 | public void setOnDedicatedHardware(Boolean onDedicatedHardware) { |
| 123 | this.onDedicatedHardware = onDedicatedHardware; |
| 124 | } |
| 125 | |
| 126 | public Long getId() { |
| 127 | return id; |
| 128 | } |
| 129 | |
| 130 | public void setId(Long id) { |
| 131 | this.id = id; |
| 132 | } |
| 133 | |
| 134 | public RunningState getState() { |
| 135 | return state; |
| 136 | } |
| 137 | |
| 138 | public void setState(RunningState state) { |
| 139 | this.state = state; |
| 140 | } |
| 141 | |
| 142 | public String getType() { |
| 143 | return type; |
| 144 | } |
| 145 | |
| 146 | public void setType(String type) { |
| 147 | this.type = type; |
| 148 | } |
| 149 | |
| 150 | public String getSlug() { |
| 151 | return slug; |
| 152 | } |
| 153 | |
| 154 | public void setSlug(String slug) { |
| 155 | this.slug = slug; |
| 156 | } |
| 157 | |
| 158 | public ServerParameters getInstanceParameters() { |
| 159 | return serverParameters; |
| 160 | } |
| 161 | |
| 162 | public void setInstanceParameters(ServerParameters serverParameters) { |
| 163 | this.serverParameters = serverParameters; |
| 164 | } |
| 165 | |
| 166 | public NewServerData getInstanceRequest() { |
| 167 | return serverDataRequest; |
| 168 | } |
| 169 | |
| 170 | public void setInstanceRequest(NewServerData serverDataRequest) { |
| 171 | this.serverDataRequest = serverDataRequest; |
| 172 | } |
| 173 | |
| 174 | @Override |
| 175 | public int compareTo(Server server) { |
| 176 | return name.compareTo(server.getName()); |
| 177 | } |
| 178 | |
| 179 | public void setLocation(DataCenter location) { |
| 180 | this.location = location; |
| 181 | } |
| 182 | |
| 183 | public DataCenter getLocation() { |
| 184 | return location; |
| 185 | } |
| 186 | |
| 187 | public void setMetaData(List<MetaData> metaData) { |
| 188 | this.metaData = metaData; |
| 189 | } |
| 190 | |
| 191 | public List<MetaData> getMetaData() { |
| 192 | return metaData; |
| 193 | } |
| 194 | |
| 195 | public Boolean getOnDedicatedHardware() { |
| 196 | return onDedicatedHardware; |
| 197 | } |
| 198 | |
| 199 | public BillingData getBillingData() { |
| 200 | return billingData; |
| 201 | } |
| 202 | |
| 203 | @Override |
| 204 | public int hashCode() { |
| 205 | final int prime = 31; |
| 206 | int result = 1; |
| 207 | result = prime * result + ((id == null) ? 0 : id.hashCode()); |
| 208 | return result; |
| 209 | } |
| 210 | |
| 211 | @Override |
| 212 | public boolean equals(Object obj) { |
| 213 | if (this == obj) |
| 214 | return true; |
| 215 | if (obj == null) |
| 216 | return false; |
| 217 | if (getClass() != obj.getClass()) |
| 218 | return false; |
| 219 | Server other = (Server) obj; |
| 220 | if (id == null) { |
| 221 | if (other.id != null) |
| 222 | return false; |
| 223 | } else if (!id.equals(other.id)) |
| 224 | return false; |
| 225 | return true; |
| 226 | } |
| 227 | } |