mirror of https://github.com/apache/jclouds.git
cloudstack: adjusting beans to use newer de/serialization annotations
This commit is contained in:
parent
b84a923615
commit
d9c65046d0
|
@ -57,8 +57,8 @@ public class BindTemplateMetadataToQueryParams implements Binder {
|
|||
if (metadata.getVirtualMachineId() != null) {
|
||||
request = ModifyRequest.addQueryParam(request, "virtualmachineid", metadata.getVirtualMachineId(), uriBuilderProvider.get());
|
||||
}
|
||||
if (metadata.getPasswordEnabled() != null) {
|
||||
request = ModifyRequest.addQueryParam(request, "passwordenabled", metadata.getPasswordEnabled(), uriBuilderProvider.get());
|
||||
if (metadata.isPasswordEnabled() != null) {
|
||||
request = ModifyRequest.addQueryParam(request, "passwordenabled", metadata.isPasswordEnabled(), uriBuilderProvider.get());
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,117 +18,149 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents an alert issued by Cloudstack
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class Alert implements Comparable<Alert> {
|
||||
public class Alert {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String description;
|
||||
private Date sent;
|
||||
private String type;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAlert(this);
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String description;
|
||||
protected Date sent;
|
||||
protected String type;
|
||||
|
||||
/**
|
||||
* @see Alert#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see Alert#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder sent(Date sent) {
|
||||
/**
|
||||
* @see Alert#getSent()
|
||||
*/
|
||||
public T sent(Date sent) {
|
||||
this.sent = sent;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder type(String type) {
|
||||
/**
|
||||
* @see Alert#getType()
|
||||
*/
|
||||
public T type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Alert build() {
|
||||
return new Alert(id, description, sent, type);
|
||||
}
|
||||
|
||||
public T fromAlert(Alert in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.description(in.getDescription())
|
||||
.sent(in.getSent())
|
||||
.type(in.getType());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
private Date sent;
|
||||
private String type;
|
||||
|
||||
/* exists for the deserializer, only */
|
||||
Alert() {
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private Alert(String id, String description, Date sent, String type) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String description;
|
||||
private final Date sent;
|
||||
private final String type;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "description", "sent", "type"
|
||||
})
|
||||
protected Alert(String id, @Nullable String description, @Nullable Date sent, @Nullable String type) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.description = description;
|
||||
this.sent = sent;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getSent() {
|
||||
return sent;
|
||||
return this.sent;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Alert that = (Alert) o;
|
||||
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(description, that.description)) return false;
|
||||
if (!Objects.equal(sent, that.sent)) return false;
|
||||
if (!Objects.equal(type, that.type)) return false;
|
||||
|
||||
return true;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, description, sent, type);
|
||||
return Objects.hashCode(id, description, sent, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Alert that = Alert.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.sent, that.sent)
|
||||
&& Objects.equal(this.type, that.type);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("description", description).add("sent", sent).add("type", type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Alert{" +
|
||||
"id=" + id +
|
||||
", description='" + description + '\'' +
|
||||
", sent=" + sent +
|
||||
", type='" + type + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Alert other) {
|
||||
return this.getId().compareTo(other.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,94 +16,117 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Representation of the API keypair response
|
||||
*
|
||||
* @author Andrei Savu
|
||||
*/
|
||||
public class ApiKeyPair implements Comparable<ApiKeyPair> {
|
||||
public class ApiKeyPair {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromApiKeyPair(this);
|
||||
}
|
||||
|
||||
private String apiKey;
|
||||
private String secretKey;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder apiKey(String apiKey) {
|
||||
protected String apiKey;
|
||||
protected String secretKey;
|
||||
|
||||
/**
|
||||
* @see ApiKeyPair#getApiKey()
|
||||
*/
|
||||
public T apiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder secretKey(String secretKey) {
|
||||
/**
|
||||
* @see ApiKeyPair#getSecretKey()
|
||||
*/
|
||||
public T secretKey(String secretKey) {
|
||||
this.secretKey = secretKey;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ApiKeyPair build() {
|
||||
return new ApiKeyPair(apiKey, secretKey);
|
||||
}
|
||||
|
||||
public T fromApiKeyPair(ApiKeyPair in) {
|
||||
return this
|
||||
.apiKey(in.getApiKey())
|
||||
.secretKey(in.getSecretKey());
|
||||
}
|
||||
}
|
||||
|
||||
// for deserialization
|
||||
ApiKeyPair() {
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("apikey")
|
||||
private String apiKey;
|
||||
@SerializedName("secretkey")
|
||||
private String secretKey;
|
||||
@Named("apikey")
|
||||
private final String apiKey;
|
||||
@Named("secretkey")
|
||||
private final String secretKey;
|
||||
|
||||
public ApiKeyPair(String apiKey, String secretKey) {
|
||||
@ConstructorProperties({
|
||||
"apikey", "secretkey"
|
||||
})
|
||||
protected ApiKeyPair(@Nullable String apiKey, @Nullable String secretKey) {
|
||||
this.apiKey = apiKey;
|
||||
this.secretKey = secretKey;
|
||||
}
|
||||
|
||||
public String getSecretKey() {
|
||||
return secretKey;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
return this.apiKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ApiKeyPair that = (ApiKeyPair) o;
|
||||
|
||||
if (!Objects.equal(apiKey, that.apiKey)) return false;
|
||||
if (!Objects.equal(secretKey, that.secretKey)) return false;
|
||||
|
||||
return true;
|
||||
@Nullable
|
||||
public String getSecretKey() {
|
||||
return this.secretKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(apiKey, secretKey);
|
||||
return Objects.hashCode(apiKey, secretKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ApiKeyPair that = ApiKeyPair.class.cast(obj);
|
||||
return Objects.equal(this.apiKey, that.apiKey)
|
||||
&& Objects.equal(this.secretKey, that.secretKey);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("apiKey", apiKey).add("secretKey", secretKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApiKeyPair{" +
|
||||
"apiKey='" + apiKey + '\'' +
|
||||
", secretKey='" + secretKey + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ApiKeyPair arg0) {
|
||||
return apiKey.compareTo(arg0.getApiKey());
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,29 +18,79 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class AsyncCreateResponse
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AsyncCreateResponse {
|
||||
public static final AsyncCreateResponse UNINITIALIZED = new AsyncCreateResponse();
|
||||
|
||||
private String id;
|
||||
@SerializedName("jobid")
|
||||
private String jobId;
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*
|
||||
*/
|
||||
AsyncCreateResponse() {
|
||||
public static final AsyncCreateResponse UNINITIALIZED = new AsyncCreateResponse(null, null);
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public AsyncCreateResponse(String id, String jobId) {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAsyncCreateResponse(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String jobId;
|
||||
|
||||
/**
|
||||
* @see AsyncCreateResponse#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AsyncCreateResponse#getJobId()
|
||||
*/
|
||||
public T jobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
return self();
|
||||
}
|
||||
|
||||
public AsyncCreateResponse build() {
|
||||
return new AsyncCreateResponse(id, jobId);
|
||||
}
|
||||
|
||||
public T fromAsyncCreateResponse(AsyncCreateResponse in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.jobId(in.getJobId());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String id;
|
||||
@Named("jobid")
|
||||
private final String jobId;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "jobid"
|
||||
})
|
||||
protected AsyncCreateResponse(@Nullable String id, @Nullable String jobId) {
|
||||
this.id = id;
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
@ -48,44 +98,41 @@ public class AsyncCreateResponse {
|
|||
/**
|
||||
* @return id of the resource being created
|
||||
*/
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id of the job in progress
|
||||
*/
|
||||
@Nullable
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
return this.jobId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, jobId);
|
||||
return Objects.hashCode(id, jobId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
AsyncCreateResponse that = (AsyncCreateResponse) obj;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
AsyncCreateResponse that = AsyncCreateResponse.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.jobId, that.jobId);
|
||||
}
|
||||
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(jobId, that.jobId)) return false;
|
||||
|
||||
return true;
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("jobId", jobId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AsyncCreateResponse{" +
|
||||
"id=" + id +
|
||||
", jobId=" + jobId +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,16 +18,24 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class AsyncJob
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AsyncJob<T> {
|
||||
public class AsyncJob<S> {
|
||||
|
||||
/**
|
||||
* Valid job result codes
|
||||
|
@ -98,132 +106,205 @@ public class AsyncJob<T> {
|
|||
}
|
||||
}
|
||||
|
||||
public static <T> Builder<T> builder() {
|
||||
return new Builder<T>();
|
||||
public static <T> Builder<?,T> builder() {
|
||||
return new ConcreteBuilder<T>();
|
||||
}
|
||||
|
||||
public static class Builder<T> {
|
||||
private String accountId;
|
||||
private String cmd;
|
||||
private Date created;
|
||||
private String id;
|
||||
private String instanceId;
|
||||
private String instanceType;
|
||||
private int progress;
|
||||
private T result;
|
||||
private ResultCode resultCode = ResultCode.UNKNOWN;
|
||||
private String resultType;
|
||||
private AsyncJobError error;
|
||||
private Status status = Status.UNKNOWN;
|
||||
private String userId;
|
||||
public Builder toBuilder() {
|
||||
return new ConcreteBuilder<S>().fromAsyncJob(this);
|
||||
}
|
||||
|
||||
public Builder<T> accountId(String accountId) {
|
||||
public static abstract class Builder<T extends Builder<T,S>, S> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String accountId;
|
||||
protected String cmd;
|
||||
protected Date created;
|
||||
protected String id;
|
||||
protected String instanceId;
|
||||
protected String instanceType;
|
||||
protected int progress;
|
||||
protected S result;
|
||||
protected AsyncJob.ResultCode resultCode;
|
||||
protected String resultType;
|
||||
protected AsyncJob.Status status;
|
||||
protected String userId;
|
||||
protected AsyncJobError error;
|
||||
|
||||
/**
|
||||
* @see AsyncJob#getAccountId()
|
||||
*/
|
||||
public T accountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> cmd(String cmd) {
|
||||
/**
|
||||
* @see AsyncJob#getCmd()
|
||||
*/
|
||||
public T cmd(String cmd) {
|
||||
this.cmd = cmd;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> created(Date created) {
|
||||
/**
|
||||
* @see AsyncJob#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> id(String id) {
|
||||
/**
|
||||
* @see AsyncJob#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> instanceId(String instanceId) {
|
||||
/**
|
||||
* @see AsyncJob#getInstanceId()
|
||||
*/
|
||||
public T instanceId(String instanceId) {
|
||||
this.instanceId = instanceId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> error(AsyncJobError error) {
|
||||
this.error = error;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> instanceType(String instanceType) {
|
||||
/**
|
||||
* @see AsyncJob#getInstanceType()
|
||||
*/
|
||||
public T instanceType(String instanceType) {
|
||||
this.instanceType = instanceType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> progress(int progress) {
|
||||
/**
|
||||
* @see AsyncJob#getProgress()
|
||||
*/
|
||||
public T progress(int progress) {
|
||||
this.progress = progress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> result(T result) {
|
||||
/**
|
||||
* @see AsyncJob#getResult()
|
||||
*/
|
||||
public T result(S result) {
|
||||
this.result = result;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> resultCode(ResultCode resultCode) {
|
||||
/**
|
||||
* @see AsyncJob#getResultCode()
|
||||
*/
|
||||
public T resultCode(AsyncJob.ResultCode resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> resultType(String resultType) {
|
||||
/**
|
||||
* @see AsyncJob#getResultType()
|
||||
*/
|
||||
public T resultType(String resultType) {
|
||||
this.resultType = resultType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> status(Status status) {
|
||||
/**
|
||||
* @see AsyncJob#getStatus()
|
||||
*/
|
||||
public T status(AsyncJob.Status status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder<T> userId(String userId) {
|
||||
/**
|
||||
* @see AsyncJob#getUserId()
|
||||
*/
|
||||
public T userId(String userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public AsyncJob<T> build() {
|
||||
return new AsyncJob<T>(accountId, cmd, created, id, instanceId, instanceType, progress, result, resultCode,
|
||||
/**
|
||||
* @see AsyncJob#getError()
|
||||
*/
|
||||
public T error(AsyncJobError error) {
|
||||
this.error = error;
|
||||
return self();
|
||||
}
|
||||
|
||||
public AsyncJob build() {
|
||||
return new AsyncJob<S>(accountId, cmd, created, id, instanceId, instanceType, progress, result, resultCode,
|
||||
resultType, status, userId, error);
|
||||
}
|
||||
|
||||
public static <T> Builder<T> fromAsyncJobUntyped(AsyncJob<T> in) {
|
||||
return new Builder<T>().accountId(in.accountId).cmd(in.cmd).created(in.created).id(in.id)
|
||||
.instanceId(in.instanceId).instanceType(in.instanceType).progress(in.progress).result(in.result)
|
||||
.resultCode(in.resultCode).resultType(in.resultType).status(in.status).userId(in.userId).error(in.error);
|
||||
public T fromAsyncJob(AsyncJob<S> in) {
|
||||
return this
|
||||
.accountId(in.getAccountId())
|
||||
.cmd(in.getCmd())
|
||||
.created(in.getCreated())
|
||||
.id(in.getId())
|
||||
.instanceId(in.getInstanceId())
|
||||
.instanceType(in.getInstanceType())
|
||||
.progress(in.getProgress())
|
||||
.result(in.getResult())
|
||||
.resultCode(in.getResultCode())
|
||||
.resultType(in.getResultType())
|
||||
.status(in.getStatus())
|
||||
.userId(in.getUserId())
|
||||
.error(in.getError());
|
||||
}
|
||||
|
||||
public static Builder<?, Object> fromAsyncJobUntyped(AsyncJob in) {
|
||||
return new ConcreteBuilder().fromAsyncJob(in);
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("accountid")
|
||||
private String accountId;
|
||||
private String cmd;
|
||||
private Date created;
|
||||
@SerializedName("jobid")
|
||||
private String id;
|
||||
@SerializedName("jobinstanceid")
|
||||
private String instanceId;
|
||||
@SerializedName("jobinstancetype")
|
||||
private String instanceType;
|
||||
@SerializedName("jobprocstatus")
|
||||
private int progress;
|
||||
@SerializedName("jobresult")
|
||||
private T result;
|
||||
@SerializedName("jobresultcode")
|
||||
private ResultCode resultCode = ResultCode.UNKNOWN;
|
||||
@SerializedName("jobresulttype")
|
||||
private String resultType;
|
||||
@SerializedName("jobstatus")
|
||||
private Status status = Status.UNKNOWN;
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
private AsyncJobError error;
|
||||
private static class ConcreteBuilder<T> extends Builder<ConcreteBuilder<T>,T> {
|
||||
@Override
|
||||
protected ConcreteBuilder<T> self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public AsyncJob(String accountId, String cmd, Date created, String id, String instanceId, String instanceType,
|
||||
int progress, T result, ResultCode resultCode, String resultType, Status status, String userId, AsyncJobError error) {
|
||||
@Named("accountid")
|
||||
private final String accountId;
|
||||
private final String cmd;
|
||||
private final Date created;
|
||||
@Named("jobid")
|
||||
private final String id;
|
||||
@Named("jobinstanceid")
|
||||
private final String instanceId;
|
||||
@Named("jobinstancetype")
|
||||
private final String instanceType;
|
||||
@Named("jobprocstatus")
|
||||
private final int progress;
|
||||
@Named("jobresult")
|
||||
private final S result;
|
||||
@Named("jobresultcode")
|
||||
private final AsyncJob.ResultCode resultCode;
|
||||
@Named("jobresulttype")
|
||||
private final String resultType;
|
||||
@Named("jobstatus")
|
||||
private final AsyncJob.Status status;
|
||||
@Named("userid")
|
||||
private final String userId;
|
||||
private final AsyncJobError error;
|
||||
|
||||
@ConstructorProperties({
|
||||
"accountid", "cmd", "created", "jobid", "jobinstanceid", "jobinstancetype", "jobprocstatus", "jobresult",
|
||||
"jobresultcode", "jobresulttype", "jobstatus", "userid", "error"
|
||||
})
|
||||
protected AsyncJob(@Nullable String accountId, @Nullable String cmd, @Nullable Date created, String id,
|
||||
@Nullable String instanceId, @Nullable String instanceType, int progress, @Nullable S result,
|
||||
@Nullable AsyncJob.ResultCode resultCode, @Nullable String resultType, @Nullable AsyncJob.Status status,
|
||||
@Nullable String userId, @Nullable AsyncJobError error) {
|
||||
this.accountId = accountId;
|
||||
this.cmd = cmd;
|
||||
this.created = created;
|
||||
this.id = id;
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.instanceId = instanceId;
|
||||
this.instanceType = instanceType;
|
||||
this.progress = progress;
|
||||
|
@ -235,106 +316,107 @@ public class AsyncJob<T> {
|
|||
this.error = error;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*
|
||||
*/
|
||||
AsyncJob() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account that executed the async command
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
return this.accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the async command executed
|
||||
*/
|
||||
@Nullable
|
||||
public String getCmd() {
|
||||
return cmd;
|
||||
return this.cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the created date of the job
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return async job ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unique ID of the instance/entity object related to the job
|
||||
*/
|
||||
@Nullable
|
||||
public String getInstanceId() {
|
||||
return instanceId;
|
||||
return this.instanceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the instance/entity object related to the job
|
||||
*/
|
||||
@Nullable
|
||||
public String getInstanceType() {
|
||||
return instanceType;
|
||||
return this.instanceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the progress information of the PENDING job
|
||||
*/
|
||||
public int getProgress() {
|
||||
return progress;
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the result reason
|
||||
*/
|
||||
public T getResult() {
|
||||
return result;
|
||||
@Nullable
|
||||
public S getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the result code for the job
|
||||
*/
|
||||
public ResultCode getResultCode() {
|
||||
return resultCode;
|
||||
@Nullable
|
||||
public AsyncJob.ResultCode getResultCode() {
|
||||
return this.resultCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the result type
|
||||
*/
|
||||
@Nullable
|
||||
public String getResultType() {
|
||||
return resultType;
|
||||
return this.resultType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current job status-should be 0 for PENDING
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
@Nullable
|
||||
public AsyncJob.Status getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user that executed the async command
|
||||
*/
|
||||
@Nullable
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the error related to this command, or null if no error or error
|
||||
* not yet encountered.
|
||||
not yet encountered.
|
||||
*/
|
||||
@Nullable
|
||||
public AsyncJobError getError() {
|
||||
return error;
|
||||
return this.error;
|
||||
}
|
||||
|
||||
public boolean hasFailed() {
|
||||
|
@ -347,55 +429,39 @@ public class AsyncJob<T> {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(accountId, cmd, created, id, instanceId, instanceType, error, progress,
|
||||
result, resultCode, resultType, status, userId);
|
||||
return Objects.hashCode(accountId, cmd, created, id, instanceId, instanceType, progress, result, resultCode, resultType, status, userId, error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
AsyncJob that = AsyncJob.class.cast(obj);
|
||||
return Objects.equal(this.accountId, that.accountId)
|
||||
&& Objects.equal(this.cmd, that.cmd)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.instanceId, that.instanceId)
|
||||
&& Objects.equal(this.instanceType, that.instanceType)
|
||||
&& Objects.equal(this.progress, that.progress)
|
||||
&& Objects.equal(this.result, that.result)
|
||||
&& Objects.equal(this.resultCode, that.resultCode)
|
||||
&& Objects.equal(this.resultType, that.resultType)
|
||||
&& Objects.equal(this.status, that.status)
|
||||
&& Objects.equal(this.userId, that.userId)
|
||||
&& Objects.equal(this.error, that.error);
|
||||
}
|
||||
|
||||
AsyncJob<?> that = (AsyncJob<?>) obj;
|
||||
|
||||
if (!Objects.equal(accountId, that.accountId)) return false;
|
||||
if (!Objects.equal(cmd, that.cmd)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(instanceId, that.instanceId)) return false;
|
||||
if (!Objects.equal(instanceType, that.instanceType)) return false;
|
||||
if (!Objects.equal(error, that.error)) return false;
|
||||
if (!Objects.equal(progress, that.progress)) return false;
|
||||
if (!Objects.equal(result, that.result)) return false;
|
||||
if (!Objects.equal(resultCode, that.resultCode)) return false;
|
||||
if (!Objects.equal(resultType, that.resultType)) return false;
|
||||
if (!Objects.equal(status, that.status)) return false;
|
||||
if (!Objects.equal(userId, that.userId)) return false;
|
||||
|
||||
return true;
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("accountId", accountId).add("cmd", cmd).add("created", created).add("id", id).add("instanceId", instanceId)
|
||||
.add("instanceType", instanceType).add("progress", progress).add("result", result).add("resultCode", resultCode)
|
||||
.add("resultType", resultType).add("status", status).add("userId", userId).add("error", error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AsyncJob{" +
|
||||
"accountId=" + accountId +
|
||||
", cmd='" + cmd + '\'' +
|
||||
", created=" + created +
|
||||
", id=" + id +
|
||||
", instanceId=" + instanceId +
|
||||
", instanceType='" + instanceType + '\'' +
|
||||
", progress=" + progress +
|
||||
", result=" + result +
|
||||
", resultCode=" + resultCode +
|
||||
", resultType='" + resultType + '\'' +
|
||||
", status=" + status +
|
||||
", userId=" + userId +
|
||||
", error=" + error +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,8 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -65,59 +71,99 @@ public class AsyncJobError {
|
|||
}
|
||||
}
|
||||
|
||||
@SerializedName("errorcode")
|
||||
private ErrorCode errorCode;
|
||||
@SerializedName("errortext")
|
||||
private String errorText;
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*
|
||||
*/
|
||||
AsyncJobError() {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public AsyncJobError(ErrorCode errorCode, String errorText) {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAsyncJobError(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected AsyncJobError.ErrorCode errorCode;
|
||||
protected String errorText;
|
||||
|
||||
/**
|
||||
* @see AsyncJobError#getErrorCode()
|
||||
*/
|
||||
public T errorCode(ErrorCode errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AsyncJobError#getErrorText()
|
||||
*/
|
||||
public T errorText(String errorText) {
|
||||
this.errorText = errorText;
|
||||
return self();
|
||||
}
|
||||
|
||||
public AsyncJobError build() {
|
||||
return new AsyncJobError(errorCode, errorText);
|
||||
}
|
||||
|
||||
public T fromAsyncJobError(AsyncJobError in) {
|
||||
return this
|
||||
.errorCode(in.getErrorCode())
|
||||
.errorText(in.getErrorText());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Named("errorcode")
|
||||
private final ErrorCode errorCode;
|
||||
@Named("errortext")
|
||||
private final String errorText;
|
||||
|
||||
@ConstructorProperties({
|
||||
"errorcode", "errortext"
|
||||
})
|
||||
protected AsyncJobError(@Nullable ErrorCode errorCode, @Nullable String errorText) {
|
||||
this.errorCode = errorCode;
|
||||
this.errorText = errorText;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ErrorCode getErrorCode() {
|
||||
return errorCode;
|
||||
return this.errorCode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getErrorText() {
|
||||
return errorText;
|
||||
return this.errorText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(errorCode, errorText);
|
||||
return Objects.hashCode(errorCode, errorText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
AsyncJobError that = (AsyncJobError) obj;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
AsyncJobError that = AsyncJobError.class.cast(obj);
|
||||
return Objects.equal(this.errorCode, that.errorCode)
|
||||
&& Objects.equal(this.errorText, that.errorText);
|
||||
}
|
||||
|
||||
if (!Objects.equal(errorCode, that.errorCode)) return false;
|
||||
if (!Objects.equal(errorText, that.errorText)) return false;
|
||||
|
||||
return true;
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("errorCode", errorCode).add("errorText", errorText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AsyncJobError{" +
|
||||
"errorCode=" + errorCode +
|
||||
", errorText='" + errorText + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,73 +18,114 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class Capabilities
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Capabilities {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String cloudStackVersion;
|
||||
private boolean securityGroupsEnabled;
|
||||
private boolean canShareTemplates;
|
||||
private boolean firewallRuleUiEnabled;
|
||||
private boolean supportELB;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromCapabilities(this);
|
||||
}
|
||||
|
||||
public Builder cloudStackVersion(String cloudStackVersion) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String cloudStackVersion;
|
||||
protected boolean securityGroupsEnabled;
|
||||
protected boolean canShareTemplates;
|
||||
protected boolean firewallRuleUiEnabled;
|
||||
protected boolean supportELB;
|
||||
|
||||
/**
|
||||
* @see Capabilities#getCloudStackVersion()
|
||||
*/
|
||||
public T cloudStackVersion(String cloudStackVersion) {
|
||||
this.cloudStackVersion = cloudStackVersion;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder securityGroupsEnabled(boolean securityGroupsEnabled) {
|
||||
/**
|
||||
* @see Capabilities#isSecurityGroupsEnabled()
|
||||
*/
|
||||
public T securityGroupsEnabled(boolean securityGroupsEnabled) {
|
||||
this.securityGroupsEnabled = securityGroupsEnabled;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder sharedTemplatesEnabled(boolean canShareTemplates) {
|
||||
/**
|
||||
* @see Capabilities#canShareTemplates()
|
||||
*/
|
||||
public T canShareTemplates(boolean canShareTemplates) {
|
||||
this.canShareTemplates = canShareTemplates;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder firewallRuleUiEnabled(boolean firewallRuleUiEnabled) {
|
||||
/**
|
||||
* @see Capabilities#isFirewallRuleUiEnabled()
|
||||
*/
|
||||
public T firewallRuleUiEnabled(boolean firewallRuleUiEnabled) {
|
||||
this.firewallRuleUiEnabled = firewallRuleUiEnabled;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder supportELB(boolean supportELB) {
|
||||
/**
|
||||
* @see Capabilities#isSupportELB()
|
||||
*/
|
||||
public T supportELB(boolean supportELB) {
|
||||
this.supportELB = supportELB;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Capabilities build() {
|
||||
return new Capabilities(cloudStackVersion, securityGroupsEnabled, canShareTemplates, firewallRuleUiEnabled, supportELB);
|
||||
}
|
||||
|
||||
public T fromCapabilities(Capabilities in) {
|
||||
return this
|
||||
.cloudStackVersion(in.getCloudStackVersion())
|
||||
.securityGroupsEnabled(in.isSecurityGroupsEnabled())
|
||||
.canShareTemplates(in.canShareTemplates())
|
||||
.firewallRuleUiEnabled(in.isFirewallRuleUiEnabled())
|
||||
.supportELB(in.isSupportELB());
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("cloudstackversion")
|
||||
private String cloudStackVersion;
|
||||
@SerializedName("securitygroupsenabled")
|
||||
private boolean securityGroupsEnabled;
|
||||
@SerializedName("userpublictemplateenabled")
|
||||
private boolean canShareTemplates;
|
||||
private boolean firewallRuleUiEnabled;
|
||||
private boolean supportELB;
|
||||
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
Capabilities() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Capabilities(String cloudStackVersion, boolean securityGroupsEnabled, boolean canShareTemplates,
|
||||
boolean firewallRuleUiEnabled, boolean supportELB) {
|
||||
@Named("cloudstackversion")
|
||||
private final String cloudStackVersion;
|
||||
@Named("securitygroupsenabled")
|
||||
private final boolean securityGroupsEnabled;
|
||||
@Named("userpublictemplateenabled")
|
||||
private final boolean canShareTemplates;
|
||||
private final boolean firewallRuleUiEnabled;
|
||||
private final boolean supportELB;
|
||||
|
||||
@ConstructorProperties({
|
||||
"cloudstackversion", "securitygroupsenabled", "userpublictemplateenabled", "firewallRuleUiEnabled", "supportELB"
|
||||
})
|
||||
protected Capabilities(@Nullable String cloudStackVersion, boolean securityGroupsEnabled, boolean canShareTemplates,
|
||||
boolean firewallRuleUiEnabled, boolean supportELB) {
|
||||
this.cloudStackVersion = cloudStackVersion;
|
||||
this.securityGroupsEnabled = securityGroupsEnabled;
|
||||
this.canShareTemplates = canShareTemplates;
|
||||
|
@ -95,71 +136,61 @@ public class Capabilities {
|
|||
/**
|
||||
* @return version of the cloud stack
|
||||
*/
|
||||
@Nullable
|
||||
public String getCloudStackVersion() {
|
||||
return cloudStackVersion;
|
||||
return this.cloudStackVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if security groups support is enabled, false otherwise
|
||||
*/
|
||||
public boolean isSecurityGroupsEnabled() {
|
||||
return securityGroupsEnabled;
|
||||
return this.securityGroupsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if user and domain admins can set templates to be shared,
|
||||
* false otherwise
|
||||
*/
|
||||
public boolean isSharedTemplatesEnabled() {
|
||||
return canShareTemplates;
|
||||
public boolean canShareTemplates() {
|
||||
return this.canShareTemplates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the firewall rule UI is enabled
|
||||
*/
|
||||
public boolean isFirewallRuleUiEnabled() {
|
||||
return firewallRuleUiEnabled;
|
||||
return this.firewallRuleUiEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if region supports elastic load balancer on basic zones
|
||||
*/
|
||||
public boolean isSupportELB() {
|
||||
return supportELB;
|
||||
return this.supportELB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(canShareTemplates, cloudStackVersion, securityGroupsEnabled, firewallRuleUiEnabled, supportELB);
|
||||
return Objects.hashCode(cloudStackVersion, securityGroupsEnabled, canShareTemplates, firewallRuleUiEnabled, supportELB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Capabilities that = (Capabilities) obj;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Capabilities that = Capabilities.class.cast(obj);
|
||||
return Objects.equal(this.cloudStackVersion, that.cloudStackVersion)
|
||||
&& Objects.equal(this.securityGroupsEnabled, that.securityGroupsEnabled)
|
||||
&& Objects.equal(this.canShareTemplates, that.canShareTemplates)
|
||||
&& Objects.equal(this.firewallRuleUiEnabled, that.firewallRuleUiEnabled)
|
||||
&& Objects.equal(this.supportELB, that.supportELB);
|
||||
}
|
||||
|
||||
if (!Objects.equal(canShareTemplates, that.canShareTemplates)) return false;
|
||||
if (!Objects.equal(cloudStackVersion, that.cloudStackVersion)) return false;
|
||||
if (!Objects.equal(securityGroupsEnabled, that.securityGroupsEnabled)) return false;
|
||||
if (!Objects.equal(firewallRuleUiEnabled, that.firewallRuleUiEnabled)) return false;
|
||||
if (!Objects.equal(supportELB, that.supportELB)) return false;
|
||||
|
||||
return true;
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("cloudStackVersion", cloudStackVersion).add("securityGroupsEnabled", securityGroupsEnabled).add("canShareTemplates", canShareTemplates).add("firewallRuleUiEnabled", firewallRuleUiEnabled).add("supportELB", supportELB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Capabilities{" +
|
||||
"cloudStackVersion='" + cloudStackVersion + '\'' +
|
||||
", securityGroupsEnabled=" + securityGroupsEnabled +
|
||||
", canShareTemplates=" + canShareTemplates +
|
||||
", firewallRuleUiEnabled=" + firewallRuleUiEnabled +
|
||||
", supportELB=" + supportELB +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,13 +20,18 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Information about a dimension of the capacity
|
||||
|
@ -35,67 +40,9 @@ import com.google.gson.annotations.SerializedName;
|
|||
*/
|
||||
public class Capacity implements Comparable<Capacity> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private long capacityTotal;
|
||||
private long capacityUsed;
|
||||
private double percentUsed;
|
||||
private String podId;
|
||||
private String podName;
|
||||
private Type type;
|
||||
private String zoneId;
|
||||
private String zoneName;
|
||||
|
||||
public Builder capacityTotal(long capacityTotal) {
|
||||
this.capacityTotal = capacityTotal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder capacityUsed(long capacityUsed) {
|
||||
this.capacityUsed = capacityUsed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder percentUsed(double percentUsed) {
|
||||
this.percentUsed = percentUsed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder podId(String podId) {
|
||||
this.podId = podId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder podName(String podName) {
|
||||
this.podName = podName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder type(Type type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Capacity build() {
|
||||
return new Capacity(capacityTotal, capacityUsed, percentUsed, podId, podName, type, zoneId, zoneName);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
/**
|
||||
*/
|
||||
public static enum Type {
|
||||
MEMORY_ALLOCATED_BYTES(0),
|
||||
CPU_ALLOCATED_MHZ(1),
|
||||
PRIMARY_STORAGE_USED_BYTES(2),
|
||||
|
@ -111,14 +58,14 @@ public class Capacity implements Comparable<Capacity> {
|
|||
private int code;
|
||||
|
||||
private static final Map<Integer, Type> INDEX = Maps.uniqueIndex(ImmutableSet.copyOf(Type.values()),
|
||||
new Function<Type, Integer>() {
|
||||
new Function<Type, Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer apply(Type input) {
|
||||
return input.code;
|
||||
}
|
||||
@Override
|
||||
public Integer apply(Type input) {
|
||||
return input.code;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Type(int code) {
|
||||
this.code = code;
|
||||
|
@ -135,27 +82,135 @@ public class Capacity implements Comparable<Capacity> {
|
|||
}
|
||||
}
|
||||
|
||||
@SerializedName("capacitytotal")
|
||||
private long capacityTotal;
|
||||
@SerializedName("capacityused")
|
||||
private long capacityUsed;
|
||||
@SerializedName("percentused")
|
||||
private double percentUsed;
|
||||
@SerializedName("podid")
|
||||
private String podId;
|
||||
@SerializedName("podname")
|
||||
private String podName;
|
||||
private Capacity.Type type;
|
||||
@SerializedName("zoneid")
|
||||
private String zoneId;
|
||||
@SerializedName("zonename")
|
||||
private String zoneName;
|
||||
|
||||
/* exists for the deserializer, only */
|
||||
Capacity() {
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Capacity(long capacityTotal, long capacityUsed, double percentUsed, String podId, String podName, Type type, String zoneId, String zoneName) {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromCapacity(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected long capacityTotal;
|
||||
protected long capacityUsed;
|
||||
protected double percentUsed;
|
||||
protected String podId;
|
||||
protected String podName;
|
||||
protected Capacity.Type type;
|
||||
protected String zoneId;
|
||||
protected String zoneName;
|
||||
|
||||
/**
|
||||
* @see Capacity#getCapacityTotal()
|
||||
*/
|
||||
public T capacityTotal(long capacityTotal) {
|
||||
this.capacityTotal = capacityTotal;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capacity#getCapacityUsed()
|
||||
*/
|
||||
public T capacityUsed(long capacityUsed) {
|
||||
this.capacityUsed = capacityUsed;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capacity#getPercentUsed()
|
||||
*/
|
||||
public T percentUsed(double percentUsed) {
|
||||
this.percentUsed = percentUsed;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capacity#getPodId()
|
||||
*/
|
||||
public T podId(String podId) {
|
||||
this.podId = podId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capacity#getPodName()
|
||||
*/
|
||||
public T podName(String podName) {
|
||||
this.podName = podName;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capacity#getType()
|
||||
*/
|
||||
public T type(Capacity.Type type) {
|
||||
this.type = type;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capacity#getZoneId()
|
||||
*/
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capacity#getZoneName()
|
||||
*/
|
||||
public T zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Capacity build() {
|
||||
return new Capacity(capacityTotal, capacityUsed, percentUsed, podId, podName, type, zoneId, zoneName);
|
||||
}
|
||||
|
||||
public T fromCapacity(Capacity in) {
|
||||
return this
|
||||
.capacityTotal(in.getCapacityTotal())
|
||||
.capacityUsed(in.getCapacityUsed())
|
||||
.percentUsed(in.getPercentUsed())
|
||||
.podId(in.getPodId())
|
||||
.podName(in.getPodName())
|
||||
.type(in.getType())
|
||||
.zoneId(in.getZoneId())
|
||||
.zoneName(in.getZoneName());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Named("capacitytotal")
|
||||
private final long capacityTotal;
|
||||
@Named("capacityused")
|
||||
private final long capacityUsed;
|
||||
@Named("percentused")
|
||||
private final double percentUsed;
|
||||
@Named("podid")
|
||||
private final String podId;
|
||||
@Named("podname")
|
||||
private final String podName;
|
||||
private final Capacity.Type type;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
@Named("zonename")
|
||||
private final String zoneName;
|
||||
|
||||
@ConstructorProperties({
|
||||
"capacitytotal", "capacityused", "percentused", "podid", "podname", "type", "zoneid", "zonename"
|
||||
})
|
||||
protected Capacity(long capacityTotal, long capacityUsed, double percentUsed, @Nullable String podId,
|
||||
@Nullable String podName, @Nullable Capacity.Type type, @Nullable String zoneId, @Nullable String zoneName) {
|
||||
this.capacityTotal = capacityTotal;
|
||||
this.capacityUsed = capacityUsed;
|
||||
this.percentUsed = percentUsed;
|
||||
|
@ -167,83 +222,78 @@ public class Capacity implements Comparable<Capacity> {
|
|||
}
|
||||
|
||||
public long getCapacityTotal() {
|
||||
return capacityTotal;
|
||||
return this.capacityTotal;
|
||||
}
|
||||
|
||||
public long getCapacityUsed() {
|
||||
return capacityUsed;
|
||||
return this.capacityUsed;
|
||||
}
|
||||
|
||||
public double getPercentUsed() {
|
||||
return percentUsed;
|
||||
return this.percentUsed;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPodId() {
|
||||
return podId;
|
||||
return this.podId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPodName() {
|
||||
return podName;
|
||||
return this.podName;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
@Nullable
|
||||
public Capacity.Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Capacity that = (Capacity) o;
|
||||
|
||||
if (!Objects.equal(capacityTotal, that.capacityTotal)) return false;
|
||||
if (!Objects.equal(capacityUsed, that.capacityUsed)) return false;
|
||||
if (!Objects.equal(percentUsed, that.percentUsed)) return false;
|
||||
if (!Objects.equal(podId, that.podId)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(podName, that.podName)) return false;
|
||||
if (!Objects.equal(type, that.type)) return false;
|
||||
if (!Objects.equal(zoneName, that.zoneName)) return false;
|
||||
|
||||
return true;
|
||||
return this.zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(capacityTotal, capacityUsed, percentUsed, podId, podName,
|
||||
type, zoneId, zoneName);
|
||||
return Objects.hashCode(capacityTotal, capacityUsed, percentUsed, podId, podName, type, zoneId, zoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Capacity that = Capacity.class.cast(obj);
|
||||
return Objects.equal(this.capacityTotal, that.capacityTotal)
|
||||
&& Objects.equal(this.capacityUsed, that.capacityUsed)
|
||||
&& Objects.equal(this.percentUsed, that.percentUsed)
|
||||
&& Objects.equal(this.podId, that.podId)
|
||||
&& Objects.equal(this.podName, that.podName)
|
||||
&& Objects.equal(this.type, that.type)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.zoneName, that.zoneName);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("capacityTotal", capacityTotal).add("capacityUsed", capacityUsed).add("percentUsed", percentUsed)
|
||||
.add("podId", podId).add("podName", podName).add("type", type).add("zoneId", zoneId).add("zoneName", zoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Capacity{" +
|
||||
"capacityTotal=" + capacityTotal +
|
||||
", capacityUsed=" + capacityUsed +
|
||||
", percentUsed=" + percentUsed +
|
||||
", podId=" + podId +
|
||||
", podName='" + podName + '\'' +
|
||||
", type=" + type +
|
||||
", zoneId=" + zoneId +
|
||||
", zoneName='" + zoneName + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Capacity other) {
|
||||
int comparison = this.zoneId.compareTo(other.zoneId);
|
||||
if (comparison != 0) return comparison;
|
||||
comparison = this.podId.compareTo(other.podId);
|
||||
if (comparison != 0) return comparison;
|
||||
return Integer.valueOf(this.type.code).compareTo(other.type.code);
|
||||
if (comparison == 0) comparison = this.podId.compareTo(other.podId);
|
||||
if (comparison == 0) Integer.valueOf(this.type.code).compareTo(other.type.code);
|
||||
return comparison;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,9 +20,16 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents a CloudStack Cluster.
|
||||
|
@ -31,7 +38,9 @@ import com.google.gson.annotations.SerializedName;
|
|||
*/
|
||||
public class Cluster implements Comparable<Cluster> {
|
||||
|
||||
public enum ManagedState {
|
||||
/**
|
||||
*/
|
||||
public static enum ManagedState {
|
||||
MANAGED,
|
||||
PREPARE_UNMANAGED,
|
||||
UNMANAGED,
|
||||
|
@ -52,93 +61,160 @@ public class Cluster implements Comparable<Cluster> {
|
|||
}
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private AllocationState allocationState;
|
||||
private Host.ClusterType clusterType;
|
||||
private String hypervisor;
|
||||
private ManagedState managedState;
|
||||
private String name;
|
||||
private String podId;
|
||||
private String podName;
|
||||
private String zoneId;
|
||||
private String zoneName;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromCluster(this);
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected AllocationState allocationState;
|
||||
protected Host.ClusterType clusterType;
|
||||
protected String hypervisor;
|
||||
protected Cluster.ManagedState managedState;
|
||||
protected String name;
|
||||
protected String podId;
|
||||
protected String podName;
|
||||
protected String zoneId;
|
||||
protected String zoneName;
|
||||
|
||||
/**
|
||||
* @see Cluster#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder allocationState(AllocationState allocationState) {
|
||||
/**
|
||||
* @see Cluster#getAllocationState()
|
||||
*/
|
||||
public T allocationState(AllocationState allocationState) {
|
||||
this.allocationState = allocationState;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder clusterType(Host.ClusterType clusterType) {
|
||||
/**
|
||||
* @see Cluster#getClusterType()
|
||||
*/
|
||||
public T clusterType(Host.ClusterType clusterType) {
|
||||
this.clusterType = clusterType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder hypervisor(String hypervisor) {
|
||||
/**
|
||||
* @see Cluster#getHypervisor()
|
||||
*/
|
||||
public T hypervisor(String hypervisor) {
|
||||
this.hypervisor = hypervisor;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder managedState(ManagedState managedState) {
|
||||
/**
|
||||
* @see Cluster#getManagedState()
|
||||
*/
|
||||
public T managedState(Cluster.ManagedState managedState) {
|
||||
this.managedState = managedState;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see Cluster#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder podId(String podId) {
|
||||
/**
|
||||
* @see Cluster#getPodId()
|
||||
*/
|
||||
public T podId(String podId) {
|
||||
this.podId = podId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder podName(String podName) {
|
||||
/**
|
||||
* @see Cluster#getPodName()
|
||||
*/
|
||||
public T podName(String podName) {
|
||||
this.podName = podName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneId(String zoneId) {
|
||||
/**
|
||||
* @see Cluster#getZoneId()
|
||||
*/
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneName(String zoneName) {
|
||||
/**
|
||||
* @see Cluster#getZoneName()
|
||||
*/
|
||||
public T zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Cluster build() {
|
||||
return new Cluster(id, allocationState, clusterType, hypervisor, managedState, name, podId, podName, zoneId, zoneName);
|
||||
}
|
||||
|
||||
public T fromCluster(Cluster in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.allocationState(in.getAllocationState())
|
||||
.clusterType(in.getClusterType())
|
||||
.hypervisor(in.getHypervisor())
|
||||
.managedState(in.getManagedState())
|
||||
.name(in.getName())
|
||||
.podId(in.getPodId())
|
||||
.podName(in.getPodName())
|
||||
.zoneId(in.getZoneId())
|
||||
.zoneName(in.getZoneName());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("allocationstate") private AllocationState allocationState;
|
||||
@SerializedName("clustertype") private Host.ClusterType clusterType;
|
||||
@SerializedName("hypervisortype") private String hypervisor;
|
||||
@SerializedName("managedstate") private ManagedState managedState;
|
||||
private String name;
|
||||
@SerializedName("podid") private String podId;
|
||||
@SerializedName("podname") private String podName;
|
||||
@SerializedName("zoneid") private String zoneId;
|
||||
@SerializedName("zonename") private String zoneName;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// Just for the serializer
|
||||
Cluster() {}
|
||||
private final String id;
|
||||
@Named("allocationstate")
|
||||
private final AllocationState allocationState;
|
||||
@Named("clustertype")
|
||||
private final Host.ClusterType clusterType;
|
||||
@Named("hypervisortype")
|
||||
private final String hypervisor;
|
||||
@Named("managedstate")
|
||||
private final Cluster.ManagedState managedState;
|
||||
private final String name;
|
||||
@Named("podid")
|
||||
private final String podId;
|
||||
@Named("podname")
|
||||
private final String podName;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
@Named("zonename")
|
||||
private final String zoneName;
|
||||
|
||||
public Cluster(String id, AllocationState allocationState, Host.ClusterType clusterType, String hypervisor, ManagedState managedState, String name, String podId, String podName, String zoneId, String zoneName) {
|
||||
this.id = id;
|
||||
@ConstructorProperties({
|
||||
"id", "allocationstate", "clustertype", "hypervisortype", "managedstate", "name", "podid", "podname", "zoneid", "zonename"
|
||||
})
|
||||
protected Cluster(String id, @Nullable AllocationState allocationState, @Nullable Host.ClusterType clusterType,
|
||||
@Nullable String hypervisor, @Nullable Cluster.ManagedState managedState, @Nullable String name,
|
||||
@Nullable String podId, @Nullable String podName, @Nullable String zoneId, @Nullable String zoneName) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.allocationState = allocationState;
|
||||
this.clusterType = clusterType;
|
||||
this.hypervisor = hypervisor;
|
||||
|
@ -151,86 +227,85 @@ public class Cluster implements Comparable<Cluster> {
|
|||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AllocationState getAllocationState() {
|
||||
return allocationState;
|
||||
return this.allocationState;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Host.ClusterType getClusterType() {
|
||||
return clusterType;
|
||||
return this.clusterType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getHypervisor() {
|
||||
return hypervisor;
|
||||
return this.hypervisor;
|
||||
}
|
||||
|
||||
public ManagedState getManagedState() {
|
||||
return managedState;
|
||||
@Nullable
|
||||
public Cluster.ManagedState getManagedState() {
|
||||
return this.managedState;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPodId() {
|
||||
return podId;
|
||||
return this.podId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPodName() {
|
||||
return podName;
|
||||
return this.podName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Cluster that = (Cluster) o;
|
||||
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(podId, that.podId)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(allocationState, that.allocationState)) return false;
|
||||
if (!Objects.equal(clusterType, that.clusterType)) return false;
|
||||
if (!Objects.equal(hypervisor, that.hypervisor)) return false;
|
||||
if (!Objects.equal(managedState, that.managedState)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(podName, that.podName)) return false;
|
||||
if (!Objects.equal(zoneName, that.zoneName)) return false;
|
||||
|
||||
return true;
|
||||
return this.zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, allocationState, clusterType, hypervisor, managedState, name, podId, podName,
|
||||
zoneId, zoneName);
|
||||
return Objects.hashCode(id, allocationState, clusterType, hypervisor, managedState, name, podId, podName, zoneId, zoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Cluster that = Cluster.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.allocationState, that.allocationState)
|
||||
&& Objects.equal(this.clusterType, that.clusterType)
|
||||
&& Objects.equal(this.hypervisor, that.hypervisor)
|
||||
&& Objects.equal(this.managedState, that.managedState)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.podId, that.podId)
|
||||
&& Objects.equal(this.podName, that.podName)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.zoneName, that.zoneName);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("allocationState", allocationState).add("clusterType", clusterType).add("hypervisor", hypervisor)
|
||||
.add("managedState", managedState).add("name", name).add("podId", podId).add("podName", podName).add("zoneId", zoneId).add("zoneName", zoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cluster{" +
|
||||
"id=" + id +
|
||||
", allocationState=" + allocationState +
|
||||
", clusterType=" + clusterType +
|
||||
", hypervisor='" + hypervisor + '\'' +
|
||||
", managedState=" + managedState +
|
||||
", name='" + name + '\'' +
|
||||
", podId=" + podId +
|
||||
", podName='" + podName + '\'' +
|
||||
", zoneId=" + zoneId +
|
||||
", zoneName='" + zoneName + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,10 +16,16 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Representation of the API configuration entry response
|
||||
|
@ -28,106 +34,136 @@ import com.google.common.base.Objects;
|
|||
*/
|
||||
public class ConfigurationEntry implements Comparable<ConfigurationEntry> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromConfigurationEntry(this);
|
||||
}
|
||||
|
||||
private String category;
|
||||
private String description;
|
||||
private String name;
|
||||
private String value;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder category(String category) {
|
||||
protected String category;
|
||||
protected String description;
|
||||
protected String name;
|
||||
protected String value;
|
||||
|
||||
/**
|
||||
* @see ConfigurationEntry#getCategory()
|
||||
*/
|
||||
public T category(String category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see ConfigurationEntry#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see ConfigurationEntry#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder value(String value) {
|
||||
/**
|
||||
* @see ConfigurationEntry#getValue()
|
||||
*/
|
||||
public T value(String value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ConfigurationEntry build() {
|
||||
return new ConfigurationEntry(category, description, name, value);
|
||||
}
|
||||
|
||||
public T fromConfigurationEntry(ConfigurationEntry in) {
|
||||
return this
|
||||
.category(in.getCategory())
|
||||
.description(in.getDescription())
|
||||
.name(in.getName())
|
||||
.value(in.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// for deserialization
|
||||
ConfigurationEntry() {
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private String category;
|
||||
private String description;
|
||||
private String name;
|
||||
private String value;
|
||||
private final String category;
|
||||
private final String description;
|
||||
private final String name;
|
||||
private final String value;
|
||||
|
||||
public ConfigurationEntry(String category, String description, String name, String value) {
|
||||
@ConstructorProperties({
|
||||
"category", "description", "name", "value"
|
||||
})
|
||||
protected ConfigurationEntry(@Nullable String category, @Nullable String description, String name, @Nullable String value) {
|
||||
this.category = category;
|
||||
this.description = description;
|
||||
this.name = name;
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ConfigurationEntry arg0) {
|
||||
return name.compareTo(arg0.getName());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCategory() {
|
||||
return category;
|
||||
return this.category;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ConfigurationEntry that = (ConfigurationEntry) o;
|
||||
|
||||
if (!Objects.equal(category, that.category)) return false;
|
||||
if (!Objects.equal(description, that.description)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(value, that.value)) return false;
|
||||
|
||||
return true;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(category, description, name, value);
|
||||
return Objects.hashCode(category, description, name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ConfigurationEntry that = ConfigurationEntry.class.cast(obj);
|
||||
return Objects.equal(this.category, that.category)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.value, that.value);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("category", category).add("description", description).add("name", name).add("value", value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigurationEntry{" +
|
||||
"category='" + category + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ConfigurationEntry other) {
|
||||
return name.compareTo(other.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,103 +20,162 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class DiskOffering
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DiskOffering implements Comparable<DiskOffering> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String name;
|
||||
private String displayText;
|
||||
private Date created;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private int diskSize;
|
||||
private boolean customized;
|
||||
private Set<String> tags = ImmutableSet.of();
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromDiskOffering(this);
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String displayText;
|
||||
protected Date created;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected int diskSize;
|
||||
protected boolean customized;
|
||||
protected String tags;
|
||||
|
||||
/**
|
||||
* @see DiskOffering#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see DiskOffering#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder displayText(String displayText) {
|
||||
/**
|
||||
* @see DiskOffering#getDisplayText()
|
||||
*/
|
||||
public T displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder created(Date created) {
|
||||
/**
|
||||
* @see DiskOffering#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see DiskOffering#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see DiskOffering#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder diskSize(int diskSize) {
|
||||
/**
|
||||
* @see DiskOffering#getDiskSize()
|
||||
*/
|
||||
public T diskSize(int diskSize) {
|
||||
this.diskSize = diskSize;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder customized(boolean customized) {
|
||||
/**
|
||||
* @see DiskOffering#isCustomized()
|
||||
*/
|
||||
public T customized(boolean customized) {
|
||||
this.customized = customized;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder tags(Set<String> tags) {
|
||||
this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
|
||||
return this;
|
||||
/**
|
||||
* @see DiskOffering#getTags()
|
||||
*/
|
||||
public T tags(String tags) {
|
||||
this.tags = tags;
|
||||
return self();
|
||||
}
|
||||
|
||||
public DiskOffering build() {
|
||||
return new DiskOffering(id, name, displayText, created, domain, domainId, diskSize, customized, tags);
|
||||
}
|
||||
|
||||
public T fromDiskOffering(DiskOffering in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.displayText(in.getDisplayText())
|
||||
.created(in.getCreated())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.diskSize(in.getDiskSize())
|
||||
.customized(in.isCustomized())
|
||||
.tags(in.getTags());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@SerializedName("displaytext")
|
||||
private String displayText;
|
||||
private Date created;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("disksize")
|
||||
private int diskSize;
|
||||
@SerializedName("iscustomized")
|
||||
private boolean customized;
|
||||
private String tags;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public DiskOffering(String id, String name, String displayText, Date created, String domain, String domainId,
|
||||
int diskSize, boolean customized, Set<String> tags) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String name;
|
||||
@Named("displaytext")
|
||||
private final String displayText;
|
||||
private final Date created;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("disksize")
|
||||
private final int diskSize;
|
||||
@Named("iscustomized")
|
||||
private final boolean customized;
|
||||
private final String tags;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "displaytext", "created", "domain", "domainid", "disksize", "iscustomized", "tags"
|
||||
})
|
||||
protected DiskOffering(String id, @Nullable String name, @Nullable String displayText, @Nullable Date created,
|
||||
@Nullable String domain, @Nullable String domainId, int diskSize, boolean customized,
|
||||
@Nullable String tags) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.created = created;
|
||||
|
@ -124,136 +183,113 @@ public class DiskOffering implements Comparable<DiskOffering> {
|
|||
this.domainId = domainId;
|
||||
this.diskSize = diskSize;
|
||||
this.customized = customized;
|
||||
this.tags = tags.size() == 0 ? null : Joiner.on(',').join(tags);
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*
|
||||
*/
|
||||
DiskOffering() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the id of the disk offering
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the name of the disk offering
|
||||
*/
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an alternate display text of the disk offering.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return this.displayText;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the date this disk offering was created
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Domain name for the offering
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the domain id of the disk offering
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the size of the disk offering in GB
|
||||
*/
|
||||
public int getDiskSize() {
|
||||
return diskSize;
|
||||
return this.diskSize;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the ha support in the disk offering
|
||||
*/
|
||||
public boolean isCustomized() {
|
||||
return customized;
|
||||
return this.customized;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the tags for the disk offering
|
||||
*/
|
||||
public Set<String> getTags() {
|
||||
return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet.<String> of();
|
||||
@Nullable
|
||||
public String getTags() {
|
||||
return this.tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(created, customized, diskSize, displayText, domain, domainId, id, name, tags);
|
||||
return Objects.hashCode(id, name, displayText, created, domain, domainId, diskSize, customized, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DiskOffering that = (DiskOffering) obj;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
DiskOffering that = DiskOffering.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.displayText, that.displayText)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.diskSize, that.diskSize)
|
||||
&& Objects.equal(this.customized, that.customized)
|
||||
&& Objects.equal(this.tags, that.tags);
|
||||
}
|
||||
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(customized, that.customized)) return false;
|
||||
if (!Objects.equal(diskSize, that.diskSize)) return false;
|
||||
if (!Objects.equal(displayText, that.displayText)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(tags, that.tags)) return false;
|
||||
|
||||
return true;
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("displayText", displayText).add("created", created).add("domain", domain)
|
||||
.add("domainId", domainId).add("diskSize", diskSize).add("customized", customized).add("tags", tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DiskOffering{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", displayText='" + displayText + '\'' +
|
||||
", created=" + created +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", diskSize=" + diskSize +
|
||||
", customized=" + customized +
|
||||
", tags='" + tags + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(DiskOffering arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
public int compareTo(DiskOffering other) {
|
||||
return id.compareTo(other.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,11 +16,18 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Representation of the API domain response
|
||||
|
@ -29,80 +36,122 @@ import com.google.gson.annotations.SerializedName;
|
|||
*/
|
||||
public class Domain implements Comparable<Domain> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromDomain(this);
|
||||
}
|
||||
|
||||
private String id;
|
||||
private boolean hasChild;
|
||||
private long level;
|
||||
private String name;
|
||||
private String networkDomain;
|
||||
private String parentDomainId;
|
||||
private String parentDomainName;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected boolean hasChild;
|
||||
protected long level;
|
||||
protected String name;
|
||||
protected String networkDomain;
|
||||
protected String parentDomainId;
|
||||
protected String parentDomainName;
|
||||
|
||||
/**
|
||||
* @see Domain#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder hasChild(boolean hasChild) {
|
||||
/**
|
||||
* @see Domain#hasChild()
|
||||
*/
|
||||
public T hasChild(boolean hasChild) {
|
||||
this.hasChild = hasChild;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder level(long level) {
|
||||
/**
|
||||
* @see Domain#getLevel()
|
||||
*/
|
||||
public T level(long level) {
|
||||
this.level = level;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see Domain#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder networkDomain(String networkDomain) {
|
||||
/**
|
||||
* @see Domain#getNetworkDomain()
|
||||
*/
|
||||
public T networkDomain(String networkDomain) {
|
||||
this.networkDomain = networkDomain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder parentDomainId(String parentDomainId) {
|
||||
/**
|
||||
* @see Domain#getParentDomainId()
|
||||
*/
|
||||
public T parentDomainId(String parentDomainId) {
|
||||
this.parentDomainId = parentDomainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder parentDomainName(String parentDomainName) {
|
||||
/**
|
||||
* @see Domain#getParentDomainName()
|
||||
*/
|
||||
public T parentDomainName(String parentDomainName) {
|
||||
this.parentDomainName = parentDomainName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Domain build() {
|
||||
return new Domain(id, hasChild, level, name, networkDomain,
|
||||
parentDomainId, parentDomainName);
|
||||
return new Domain(id, hasChild, level, name, networkDomain, parentDomainId, parentDomainName);
|
||||
}
|
||||
|
||||
public T fromDomain(Domain in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.hasChild(in.hasChild())
|
||||
.level(in.getLevel())
|
||||
.name(in.getName())
|
||||
.networkDomain(in.getNetworkDomain())
|
||||
.parentDomainId(in.getParentDomainId())
|
||||
.parentDomainName(in.getParentDomainName());
|
||||
}
|
||||
}
|
||||
|
||||
// for deserialization
|
||||
Domain() {
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("haschild")
|
||||
private boolean hasChild;
|
||||
private long level;
|
||||
private String name;
|
||||
@SerializedName("networkdomain")
|
||||
private String networkDomain;
|
||||
@SerializedName("parentdomainid")
|
||||
private String parentDomainId;
|
||||
@SerializedName("parentdomainname")
|
||||
private String parentDomainName;
|
||||
private final String id;
|
||||
@Named("haschild")
|
||||
private final boolean hasChild;
|
||||
private final long level;
|
||||
private final String name;
|
||||
@Named("networkdomain")
|
||||
private final String networkDomain;
|
||||
@Named("parentdomainid")
|
||||
private final String parentDomainId;
|
||||
@Named("parentdomainname")
|
||||
private final String parentDomainName;
|
||||
|
||||
public Domain(String id, boolean hasChild, long level, String name, String networkDomain,
|
||||
String parentDomainId, String parentDomainName) {
|
||||
this.id = id;
|
||||
@ConstructorProperties({
|
||||
"id", "haschild", "level", "name", "networkdomain", "parentdomainid", "parentdomainname"
|
||||
})
|
||||
protected Domain(String id, boolean hasChild, long level, @Nullable String name, @Nullable String networkDomain,
|
||||
@Nullable String parentDomainId, @Nullable String parentDomainName) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.hasChild = hasChild;
|
||||
this.level = level;
|
||||
this.name = name;
|
||||
|
@ -112,72 +161,69 @@ public class Domain implements Comparable<Domain> {
|
|||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean hasChild() {
|
||||
return hasChild;
|
||||
return this.hasChild;
|
||||
}
|
||||
|
||||
public long getLevel() {
|
||||
return level;
|
||||
return this.level;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNetworkDomain() {
|
||||
return networkDomain;
|
||||
return this.networkDomain;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getParentDomainId() {
|
||||
return parentDomainId;
|
||||
return this.parentDomainId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getParentDomainName() {
|
||||
return parentDomainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Domain that = (Domain) o;
|
||||
|
||||
if (!Objects.equal(hasChild, that.hasChild)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(level, that.level)) return false;
|
||||
if (!Objects.equal(parentDomainId, that.parentDomainId)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(networkDomain, that.networkDomain)) return false;
|
||||
if (!Objects.equal(parentDomainName, that.parentDomainName)) return false;
|
||||
|
||||
return true;
|
||||
return this.parentDomainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, hasChild, level, name, networkDomain, parentDomainId, parentDomainName);
|
||||
return Objects.hashCode(id, hasChild, level, name, networkDomain, parentDomainId, parentDomainName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Domain that = Domain.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.hasChild, that.hasChild)
|
||||
&& Objects.equal(this.level, that.level)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.networkDomain, that.networkDomain)
|
||||
&& Objects.equal(this.parentDomainId, that.parentDomainId)
|
||||
&& Objects.equal(this.parentDomainName, that.parentDomainName);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("hasChild", hasChild).add("level", level).add("name", name).add("networkDomain", networkDomain).add("parentDomainId", parentDomainId).add("parentDomainName", parentDomainName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Domain{" +
|
||||
"id='" + id + '\'' +
|
||||
", hasChild=" + hasChild +
|
||||
", level=" + level +
|
||||
", name='" + name + '\'' +
|
||||
", networkDomain='" + networkDomain + '\'' +
|
||||
", parentDomainId='" + parentDomainId + '\'' +
|
||||
", parentDomainName='" + parentDomainName + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Domain arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
public int compareTo(Domain other) {
|
||||
return id.compareTo(other.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,17 +18,75 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class EncryptedPasswordAndPrivateKey
|
||||
*
|
||||
* @author Andrei Savu
|
||||
*/
|
||||
public class EncryptedPasswordAndPrivateKey {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEncryptedPasswordAndPrivateKey(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String encryptedPassword;
|
||||
protected String privateKey;
|
||||
|
||||
/**
|
||||
* @see EncryptedPasswordAndPrivateKey#getEncryptedPassword()
|
||||
*/
|
||||
public T encryptedPassword(String encryptedPassword) {
|
||||
this.encryptedPassword = encryptedPassword;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EncryptedPasswordAndPrivateKey#getPrivateKey()
|
||||
*/
|
||||
public T privateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
return self();
|
||||
}
|
||||
|
||||
public EncryptedPasswordAndPrivateKey build() {
|
||||
return new EncryptedPasswordAndPrivateKey(encryptedPassword, privateKey);
|
||||
}
|
||||
|
||||
public T fromEncryptedPasswordAndPrivateKey(EncryptedPasswordAndPrivateKey in) {
|
||||
return this
|
||||
.encryptedPassword(in.getEncryptedPassword())
|
||||
.privateKey(in.getPrivateKey());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String encryptedPassword;
|
||||
private final String privateKey;
|
||||
|
||||
public EncryptedPasswordAndPrivateKey(String encryptedPassword, String privateKey) {
|
||||
@ConstructorProperties({
|
||||
"encryptedPassword", "privateKey"
|
||||
})
|
||||
protected EncryptedPasswordAndPrivateKey(@Nullable String encryptedPassword, @Nullable String privateKey) {
|
||||
this.encryptedPassword = encryptedPassword;
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
@ -36,40 +94,41 @@ public class EncryptedPasswordAndPrivateKey {
|
|||
/**
|
||||
* @return the encrypted password String representation
|
||||
*/
|
||||
@Nullable
|
||||
public String getEncryptedPassword() {
|
||||
return encryptedPassword;
|
||||
return this.encryptedPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return get the string representation of the private key
|
||||
*/
|
||||
@Nullable
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
EncryptedPasswordAndPrivateKey that = (EncryptedPasswordAndPrivateKey) o;
|
||||
|
||||
if (!Objects.equal(encryptedPassword, that.encryptedPassword)) return false;
|
||||
if (!Objects.equal(privateKey, that.privateKey)) return false;
|
||||
|
||||
return true;
|
||||
return this.privateKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(encryptedPassword, privateKey);
|
||||
return Objects.hashCode(encryptedPassword, privateKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
EncryptedPasswordAndPrivateKey that = EncryptedPasswordAndPrivateKey.class.cast(obj);
|
||||
return Objects.equal(this.encryptedPassword, that.encryptedPassword)
|
||||
&& Objects.equal(this.privateKey, that.privateKey);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("encryptedPassword", encryptedPassword).add("privateKey", privateKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EncryptedPasswordAndPrivateKey{" +
|
||||
"encryptedPassword='" + encryptedPassword + '\'' +
|
||||
", privateKey='" + privateKey + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,112 +18,180 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class Event
|
||||
*
|
||||
* @author Vijay Kiran
|
||||
*/
|
||||
public class Event implements Comparable<Event> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String account;
|
||||
private String description;
|
||||
private Date created;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
//TODO Change to enum : the event level (INFO, WARN, ERROR)
|
||||
private String level;
|
||||
private String parentId;
|
||||
private String state;
|
||||
//Event Type
|
||||
private String type;
|
||||
private String username;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEvent(this);
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String account;
|
||||
protected String description;
|
||||
protected Date created;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected String level;
|
||||
protected String parentId;
|
||||
protected String state;
|
||||
protected String type;
|
||||
protected String username;
|
||||
|
||||
/**
|
||||
* @see Event#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
/**
|
||||
* @see Event#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see Event#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder created(Date created) {
|
||||
/**
|
||||
* @see Event#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see Event#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see Event#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder level(String level) {
|
||||
/**
|
||||
* @see Event#getLevel()
|
||||
*/
|
||||
public T level(String level) {
|
||||
this.level = level;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder parentId(String parentId) {
|
||||
/**
|
||||
* @see Event#getParentId()
|
||||
*/
|
||||
public T parentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(String state) {
|
||||
/**
|
||||
* @see Event#getState()
|
||||
*/
|
||||
public T state(String state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder type(String type) {
|
||||
/**
|
||||
* @see Event#getType()
|
||||
*/
|
||||
public T type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder username(String username) {
|
||||
/**
|
||||
* @see Event#getUsername()
|
||||
*/
|
||||
public T username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Event build() {
|
||||
return new Event(id, account, description, created, domain, domainId, level, parentId, state, type, username);
|
||||
}
|
||||
|
||||
public T fromEvent(Event in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.account(in.getAccount())
|
||||
.description(in.getDescription())
|
||||
.created(in.getCreated())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.level(in.getLevel())
|
||||
.parentId(in.getParentId())
|
||||
.state(in.getState())
|
||||
.type(in.getType())
|
||||
.username(in.getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private String description;
|
||||
private Date created;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
//TODO Change to enum : the event level (INFO, WARN, ERROR)
|
||||
private String level;
|
||||
private String parentId;
|
||||
private String state;
|
||||
//Event Type
|
||||
private String type;
|
||||
private String username;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Event(String id, String account, String description, Date created, String domain, String domainId, String level,
|
||||
String parentId, String state, String type, String username) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String account;
|
||||
private final String description;
|
||||
private final Date created;
|
||||
private final String domain;
|
||||
private final String domainId;
|
||||
private final String level;
|
||||
private final String parentId;
|
||||
private final String state;
|
||||
private final String type;
|
||||
private final String username;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "account", "description", "created", "domain", "domainId", "level", "parentId", "state", "type", "username"
|
||||
})
|
||||
protected Event(String id, @Nullable String account, @Nullable String description, @Nullable Date created,
|
||||
@Nullable String domain, @Nullable String domainId, @Nullable String level, @Nullable String parentId,
|
||||
@Nullable String state, @Nullable String type, @Nullable String username) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.account = account;
|
||||
this.description = description;
|
||||
this.created = created;
|
||||
|
@ -136,140 +204,133 @@ public class Event implements Comparable<Event> {
|
|||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
Event() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the event
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account name for the account that owns the object being acted on in the event
|
||||
* (e.g. the owner of the virtual machine, ip address, or security group)
|
||||
(e.g. the owner of the virtual machine, ip address, or security group)
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date the event was created
|
||||
*/
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description of the event
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date the event was created
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the account's domain
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the account's domain
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the event level (INFO, WARN, ERROR)
|
||||
*/
|
||||
@Nullable
|
||||
public String getLevel() {
|
||||
return level;
|
||||
return this.level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the event is parented
|
||||
*/
|
||||
@Nullable
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the event
|
||||
*/
|
||||
@Nullable
|
||||
public String getState() {
|
||||
return state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of the event (see event types)
|
||||
*/
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the user who performed the action (can be different from the account if
|
||||
* an admin is performing an action for a user, e.g. starting/stopping a user's virtual machine)
|
||||
an admin is performing an action for a user, e.g. starting/stopping a user's virtual machine)
|
||||
*/
|
||||
@Nullable
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Event arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Event that = (Event) o;
|
||||
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(description, that.description)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(level, that.level)) return false;
|
||||
if (!Objects.equal(parentId, that.parentId)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
if (!Objects.equal(type, that.type)) return false;
|
||||
if (!Objects.equal(username, that.username)) return false;
|
||||
|
||||
return true;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, account, description, created, domain, domainId, level, parentId, state, type, username);
|
||||
return Objects.hashCode(id, account, description, created, domain, domainId, level, parentId, state, type, username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Event that = Event.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.level, that.level)
|
||||
&& Objects.equal(this.parentId, that.parentId)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.type, that.type)
|
||||
&& Objects.equal(this.username, that.username);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("account", account).add("description", description).add("created", created)
|
||||
.add("domain", domain).add("domainId", domainId).add("level", level).add("parentId", parentId)
|
||||
.add("state", state).add("type", type).add("username", username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Event{" +
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", created=" + created +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", level='" + level + '\'' +
|
||||
", parentId='" + parentId + '\'' +
|
||||
", state='" + state + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", username='" + username + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Event other) {
|
||||
return id.compareTo(other.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,18 +18,29 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class FirewallRule
|
||||
*
|
||||
* @author Andrei Savu
|
||||
*/
|
||||
public class FirewallRule implements Comparable<FirewallRule> {
|
||||
|
||||
/**
|
||||
*/
|
||||
public static enum Protocol {
|
||||
TCP,
|
||||
UDP,
|
||||
|
@ -73,105 +84,164 @@ public class FirewallRule implements Comparable<FirewallRule> {
|
|||
}
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private Set<String> CIDRs;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromFirewallRule(this);
|
||||
}
|
||||
|
||||
private int startPort;
|
||||
private int endPort;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String icmpCode;
|
||||
private String icmpType;
|
||||
protected String id;
|
||||
protected Set<String> CIDRs = ImmutableSet.of();
|
||||
protected int startPort;
|
||||
protected int endPort;
|
||||
protected String icmpCode;
|
||||
protected String icmpType;
|
||||
protected String ipAddress;
|
||||
protected String ipAddressId;
|
||||
protected FirewallRule.Protocol protocol;
|
||||
protected FirewallRule.State state;
|
||||
|
||||
private String ipAddress;
|
||||
private String ipAddressId;
|
||||
|
||||
private Protocol protocol;
|
||||
private State state;
|
||||
|
||||
public Builder id(String id) {
|
||||
/**
|
||||
* @see FirewallRule#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder CIDRs(Set<String> CIDRs) {
|
||||
this.CIDRs = ImmutableSet.copyOf(CIDRs);
|
||||
return this;
|
||||
/**
|
||||
* @see FirewallRule#getCIDRs()
|
||||
*/
|
||||
public T CIDRs(Set<String> CIDRs) {
|
||||
this.CIDRs = ImmutableSet.copyOf(checkNotNull(CIDRs, "CIDRs"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder startPort(int startPort) {
|
||||
public T CIDRs(String... in) {
|
||||
return CIDRs(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FirewallRule#getStartPort()
|
||||
*/
|
||||
public T startPort(int startPort) {
|
||||
this.startPort = startPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder endPort(int endPort) {
|
||||
/**
|
||||
* @see FirewallRule#getEndPort()
|
||||
*/
|
||||
public T endPort(int endPort) {
|
||||
this.endPort = endPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder icmpCode(String icmpCode) {
|
||||
/**
|
||||
* @see FirewallRule#getIcmpCode()
|
||||
*/
|
||||
public T icmpCode(String icmpCode) {
|
||||
this.icmpCode = icmpCode;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder icmpType(String icmpType) {
|
||||
/**
|
||||
* @see FirewallRule#getIcmpType()
|
||||
*/
|
||||
public T icmpType(String icmpType) {
|
||||
this.icmpType = icmpType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ipAddress(String ipAddress) {
|
||||
/**
|
||||
* @see FirewallRule#getIpAddress()
|
||||
*/
|
||||
public T ipAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ipAddressId(String ipAddressId) {
|
||||
/**
|
||||
* @see FirewallRule#getIpAddressId()
|
||||
*/
|
||||
public T ipAddressId(String ipAddressId) {
|
||||
this.ipAddressId = ipAddressId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder protocol(Protocol protocol) {
|
||||
/**
|
||||
* @see FirewallRule#getProtocol()
|
||||
*/
|
||||
public T protocol(FirewallRule.Protocol protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(State state) {
|
||||
/**
|
||||
* @see FirewallRule#getState()
|
||||
*/
|
||||
public T state(FirewallRule.State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public FirewallRule build() {
|
||||
return new FirewallRule(id, CIDRs, startPort, endPort, icmpCode,
|
||||
icmpType, ipAddress, ipAddressId, protocol, state);
|
||||
return new FirewallRule(id, CIDRs, startPort, endPort, icmpCode, icmpType, ipAddress, ipAddressId, protocol, state);
|
||||
}
|
||||
|
||||
public T fromFirewallRule(FirewallRule in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.CIDRs(in.getCIDRs())
|
||||
.startPort(in.getStartPort())
|
||||
.endPort(in.getEndPort())
|
||||
.icmpCode(in.getIcmpCode())
|
||||
.icmpType(in.getIcmpType())
|
||||
.ipAddress(in.getIpAddress())
|
||||
.ipAddressId(in.getIpAddressId())
|
||||
.protocol(in.getProtocol())
|
||||
.state(in.getState());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("cidrlist")
|
||||
private Set<String> CIDRs;
|
||||
@SerializedName("startport")
|
||||
private int startPort;
|
||||
@SerializedName("endport")
|
||||
private int endPort;
|
||||
@SerializedName("icmpcode")
|
||||
private String icmpCode;
|
||||
@SerializedName("icmptype")
|
||||
private String icmpType;
|
||||
@SerializedName("ipaddress")
|
||||
private String ipAddress;
|
||||
@SerializedName("ipaddressid")
|
||||
private String ipAddressId;
|
||||
private Protocol protocol;
|
||||
private State state;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public FirewallRule(String id, Set<String> CIDRs, int startPort, int endPort,
|
||||
String icmpCode, String icmpType, String ipAddress, String ipAddressId,
|
||||
Protocol protocol, State state) {
|
||||
this.id = id;
|
||||
this.CIDRs = ImmutableSet.copyOf(CIDRs);
|
||||
private final String id;
|
||||
@Named("cidrlist")
|
||||
private final Set<String> CIDRs;
|
||||
@Named("startport")
|
||||
private final int startPort;
|
||||
@Named("endport")
|
||||
private final int endPort;
|
||||
@Named("icmpcode")
|
||||
private final String icmpCode;
|
||||
@Named("icmptype")
|
||||
private final String icmpType;
|
||||
@Named("ipaddress")
|
||||
private final String ipAddress;
|
||||
@Named("ipaddressid")
|
||||
private final String ipAddressId;
|
||||
private final FirewallRule.Protocol protocol;
|
||||
private final FirewallRule.State state;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "cidrlist", "startport", "endport", "icmpcode", "icmptype", "ipaddress", "ipaddressid", "protocol", "state"
|
||||
})
|
||||
protected FirewallRule(String id, @Nullable Set<String> CIDRs, int startPort, int endPort, @Nullable String icmpCode,
|
||||
@Nullable String icmpType, @Nullable String ipAddress, @Nullable String ipAddressId,
|
||||
@Nullable FirewallRule.Protocol protocol, @Nullable FirewallRule.State state) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.CIDRs = CIDRs == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(CIDRs);
|
||||
this.startPort = startPort;
|
||||
this.endPort = endPort;
|
||||
this.icmpCode = icmpCode;
|
||||
|
@ -182,90 +252,88 @@ public class FirewallRule implements Comparable<FirewallRule> {
|
|||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(FirewallRule arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Set<String> getCIDRs() {
|
||||
return CIDRs;
|
||||
return this.CIDRs;
|
||||
}
|
||||
|
||||
public int getStartPort() {
|
||||
return startPort;
|
||||
return this.startPort;
|
||||
}
|
||||
|
||||
public int getEndPort() {
|
||||
return endPort;
|
||||
return this.endPort;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIcmpCode() {
|
||||
return icmpCode;
|
||||
return this.icmpCode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIcmpType() {
|
||||
return icmpType;
|
||||
return this.icmpType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
return this.ipAddress;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIpAddressId() {
|
||||
return ipAddressId;
|
||||
return this.ipAddressId;
|
||||
}
|
||||
|
||||
public Protocol getProtocol() {
|
||||
return protocol;
|
||||
@Nullable
|
||||
public FirewallRule.Protocol getProtocol() {
|
||||
return this.protocol;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
FirewallRule that = (FirewallRule) o;
|
||||
|
||||
if (!Objects.equal(endPort, that.endPort)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(startPort, that.startPort)) return false;
|
||||
if (!Objects.equal(CIDRs, that.CIDRs)) return false;
|
||||
if (!Objects.equal(icmpCode, that.icmpCode)) return false;
|
||||
if (!Objects.equal(icmpType, that.icmpType)) return false;
|
||||
if (!Objects.equal(ipAddress, that.ipAddress)) return false;
|
||||
if (!Objects.equal(ipAddressId, that.ipAddressId)) return false;
|
||||
if (!Objects.equal(protocol, that.protocol)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
|
||||
return true;
|
||||
@Nullable
|
||||
public FirewallRule.State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(endPort, id, startPort, CIDRs, icmpCode, icmpType, ipAddress, ipAddressId, protocol, state);
|
||||
return Objects.hashCode(id, CIDRs, startPort, endPort, icmpCode, icmpType, ipAddress, ipAddressId, protocol, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
FirewallRule that = FirewallRule.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.CIDRs, that.CIDRs)
|
||||
&& Objects.equal(this.startPort, that.startPort)
|
||||
&& Objects.equal(this.endPort, that.endPort)
|
||||
&& Objects.equal(this.icmpCode, that.icmpCode)
|
||||
&& Objects.equal(this.icmpType, that.icmpType)
|
||||
&& Objects.equal(this.ipAddress, that.ipAddress)
|
||||
&& Objects.equal(this.ipAddressId, that.ipAddressId)
|
||||
&& Objects.equal(this.protocol, that.protocol)
|
||||
&& Objects.equal(this.state, that.state);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("CIDRs", CIDRs).add("startPort", startPort).add("endPort", endPort).add("icmpCode", icmpCode)
|
||||
.add("icmpType", icmpType).add("ipAddress", ipAddress).add("ipAddressId", ipAddressId).add("protocol", protocol).add("state", state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FirewallRule{" +
|
||||
"id=" + id +
|
||||
", CIDRs='" + CIDRs + '\'' +
|
||||
", startPort=" + startPort +
|
||||
", endPort=" + endPort +
|
||||
", icmpCode='" + icmpCode + '\'' +
|
||||
", icmpType='" + icmpType + '\'' +
|
||||
", ipAddress='" + ipAddress + '\'' +
|
||||
", ipAddressId='" + ipAddressId + '\'' +
|
||||
", protocol='" + protocol + '\'' +
|
||||
", state='" + state + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(FirewallRule other) {
|
||||
return id.compareTo(other.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.google.common.base.CaseFormat;
|
|||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see NetworkOfferingClient#listNetworkOfferings
|
||||
* @see org.jclouds.cloudstack.features.OfferingClient#listNetworkOfferings
|
||||
*/
|
||||
public enum GuestIPType {
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,151 +18,236 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.util.Collections;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class IPForwardingRule
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
*/
|
||||
public class IPForwardingRule implements Comparable<IPForwardingRule> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromIPForwardingRule(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String IPAddress;
|
||||
private String IPAddressId;
|
||||
private int startPort;
|
||||
private String protocol;
|
||||
public int endPort;
|
||||
private String state;
|
||||
private String virtualMachineDisplayName;
|
||||
public String virtualMachineId;
|
||||
private String virtualMachineName;
|
||||
private Set<String> CIDRs = ImmutableSet.of();
|
||||
private int privateEndPort;
|
||||
private int publicEndPort;
|
||||
public int publicPort;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String IPAddress;
|
||||
protected String IPAddressId;
|
||||
protected int startPort;
|
||||
protected String protocol;
|
||||
protected int endPort;
|
||||
protected String state;
|
||||
protected String virtualMachineDisplayName;
|
||||
protected String virtualMachineId;
|
||||
protected String virtualMachineName;
|
||||
protected int publicPort;
|
||||
protected Set<String> CIDRs = ImmutableSet.of();
|
||||
protected int privateEndPort;
|
||||
protected int publicEndPort;
|
||||
|
||||
/**
|
||||
* @see IPForwardingRule#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder IPAddress(String IPAddress) {
|
||||
/**
|
||||
* @see IPForwardingRule#getIPAddress()
|
||||
*/
|
||||
public T IPAddress(String IPAddress) {
|
||||
this.IPAddress = IPAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder IPAddressId(String IPAddressId) {
|
||||
/**
|
||||
* @see IPForwardingRule#getIPAddressId()
|
||||
*/
|
||||
public T IPAddressId(String IPAddressId) {
|
||||
this.IPAddressId = IPAddressId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder startPort(int startPort) {
|
||||
/**
|
||||
* @see IPForwardingRule#getStartPort()
|
||||
*/
|
||||
public T startPort(int startPort) {
|
||||
this.startPort = startPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder protocol(String protocol) {
|
||||
/**
|
||||
* @see IPForwardingRule#getProtocol()
|
||||
*/
|
||||
public T protocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder endPort(int endPort) {
|
||||
/**
|
||||
* @see IPForwardingRule#getEndPort()
|
||||
*/
|
||||
public T endPort(int endPort) {
|
||||
this.endPort = endPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(String state) {
|
||||
/**
|
||||
* @see IPForwardingRule#getState()
|
||||
*/
|
||||
public T state(String state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineDisplayName(String virtualMachineDisplayName) {
|
||||
/**
|
||||
* @see IPForwardingRule#getVirtualMachineDisplayName()
|
||||
*/
|
||||
public T virtualMachineDisplayName(String virtualMachineDisplayName) {
|
||||
this.virtualMachineDisplayName = virtualMachineDisplayName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineId(String virtualMachineId) {
|
||||
/**
|
||||
* @see IPForwardingRule#getVirtualMachineId()
|
||||
*/
|
||||
public T virtualMachineId(String virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineName(String virtualMachineName) {
|
||||
/**
|
||||
* @see IPForwardingRule#getVirtualMachineName()
|
||||
*/
|
||||
public T virtualMachineName(String virtualMachineName) {
|
||||
this.virtualMachineName = virtualMachineName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder publicPort(int publicPort) {
|
||||
/**
|
||||
* @see IPForwardingRule#getPublicPort()
|
||||
*/
|
||||
public T publicPort(int publicPort) {
|
||||
this.publicPort = publicPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder CIDRs(Set<String> CIDRs) {
|
||||
this.CIDRs = CIDRs;
|
||||
return this;
|
||||
/**
|
||||
* @see IPForwardingRule#getCIDRs()
|
||||
*/
|
||||
public T CIDRs(Set<String> CIDRs) {
|
||||
this.CIDRs = ImmutableSet.copyOf(checkNotNull(CIDRs, "CIDRs"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder privateEndPort(int privateEndPort) {
|
||||
public T CIDRs(String... in) {
|
||||
return CIDRs(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IPForwardingRule#getPrivateEndPort()
|
||||
*/
|
||||
public T privateEndPort(int privateEndPort) {
|
||||
this.privateEndPort = privateEndPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder publicEndPort(int publicEndPort) {
|
||||
/**
|
||||
* @see IPForwardingRule#getPublicEndPort()
|
||||
*/
|
||||
public T publicEndPort(int publicEndPort) {
|
||||
this.publicEndPort = publicEndPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public IPForwardingRule build() {
|
||||
return new IPForwardingRule(id, IPAddress, IPAddressId, startPort, protocol, endPort, state,
|
||||
virtualMachineDisplayName, virtualMachineId, virtualMachineName, publicEndPort, publicPort, CIDRs, privateEndPort);
|
||||
return new IPForwardingRule(id, IPAddress, IPAddressId, startPort, protocol, endPort, state, virtualMachineDisplayName,
|
||||
virtualMachineId, virtualMachineName, publicPort, CIDRs, privateEndPort, publicEndPort);
|
||||
}
|
||||
|
||||
public T fromIPForwardingRule(IPForwardingRule in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.IPAddress(in.getIPAddress())
|
||||
.IPAddressId(in.getIPAddressId())
|
||||
.startPort(in.getStartPort())
|
||||
.protocol(in.getProtocol())
|
||||
.endPort(in.getEndPort())
|
||||
.state(in.getState())
|
||||
.virtualMachineDisplayName(in.getVirtualMachineDisplayName())
|
||||
.virtualMachineId(in.getVirtualMachineId())
|
||||
.virtualMachineName(in.getVirtualMachineName())
|
||||
.publicPort(in.getPublicPort())
|
||||
.CIDRs(in.getCIDRs())
|
||||
.privateEndPort(in.getPrivateEndPort())
|
||||
.publicEndPort(in.getPublicEndPort());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("ipaddress")
|
||||
private String IPAddress;
|
||||
@SerializedName("ipaddressid")
|
||||
private String IPAddressId;
|
||||
@SerializedName("startport")
|
||||
private int startPort;
|
||||
private String protocol;
|
||||
@SerializedName("endport")
|
||||
public int endPort;
|
||||
private String state;
|
||||
@SerializedName("virtualmachinedisplayname")
|
||||
private String virtualMachineDisplayName;
|
||||
@SerializedName("virtualmachineid")
|
||||
public String virtualMachineId;
|
||||
@SerializedName("virtualmachinename")
|
||||
private String virtualMachineName;
|
||||
@SerializedName("publicport")
|
||||
public int publicPort;
|
||||
@SerializedName("cidrlist")
|
||||
private Set<String> CIDRs;
|
||||
@SerializedName("privateendport")
|
||||
private int privateEndPort;
|
||||
@SerializedName("publicendport")
|
||||
private int publicEndPort;
|
||||
|
||||
// for deserializer
|
||||
IPForwardingRule() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public IPForwardingRule(String id, String iPAddress, String iPAddressId, int startPort, String protocol, int endPort,
|
||||
String state, String virtualMachineDisplayName, String virtualMachineId, String virtualMachineName,
|
||||
int publicEndPort, int publicPort, Set<String> CIDRs, int privateEndPort) {
|
||||
this.id = id;
|
||||
this.IPAddress = iPAddress;
|
||||
this.IPAddressId = iPAddressId;
|
||||
private final String id;
|
||||
@Named("ipaddress")
|
||||
private final String IPAddress;
|
||||
@Named("ipaddressid")
|
||||
private final String IPAddressId;
|
||||
@Named("startport")
|
||||
private final int startPort;
|
||||
private final String protocol;
|
||||
@Named("endport")
|
||||
private final int endPort;
|
||||
private final String state;
|
||||
@Named("virtualmachinedisplayname")
|
||||
private final String virtualMachineDisplayName;
|
||||
@Named("virtualmachineid")
|
||||
private final String virtualMachineId;
|
||||
@Named("virtualmachinename")
|
||||
private final String virtualMachineName;
|
||||
@Named("publicport")
|
||||
private final int publicPort;
|
||||
@Named("cidrlist")
|
||||
private final Set<String> CIDRs;
|
||||
@Named("privateendport")
|
||||
private final int privateEndPort;
|
||||
@Named("publicendport")
|
||||
private final int publicEndPort;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "ipaddress", "ipaddressid", "startport", "protocol", "endport", "state", "virtualmachinedisplayname",
|
||||
"virtualmachineid", "virtualmachinename", "publicport", "cidrlist", "privateendport", "publicendport"
|
||||
})
|
||||
protected IPForwardingRule(String id, String IPAddress, String IPAddressId, int startPort, @Nullable String protocol,
|
||||
int endPort, @Nullable String state, @Nullable String virtualMachineDisplayName,
|
||||
@Nullable String virtualMachineId, @Nullable String virtualMachineName, int publicPort,
|
||||
@Nullable Set<String> CIDRs, int privateEndPort, int publicEndPort) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.IPAddress = IPAddress;
|
||||
this.IPAddressId = IPAddressId;
|
||||
this.startPort = startPort;
|
||||
this.protocol = protocol;
|
||||
this.endPort = endPort;
|
||||
|
@ -170,153 +255,158 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
|
|||
this.virtualMachineDisplayName = virtualMachineDisplayName;
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
this.virtualMachineName = virtualMachineName;
|
||||
this.CIDRs = Sets.newHashSet(CIDRs);
|
||||
this.publicPort = publicPort;
|
||||
this.CIDRs = CIDRs == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(CIDRs);
|
||||
this.privateEndPort = privateEndPort;
|
||||
this.publicEndPort = publicEndPort;
|
||||
this.publicPort = publicPort;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IPForwardingRule arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the ip forwarding rule
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public ip address for the ip forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getIPAddress() {
|
||||
return IPAddress;
|
||||
return this.IPAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public ip address id for the ip forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getIPAddressId() {
|
||||
return IPAddressId;
|
||||
return this.IPAddressId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the private port for the ip forwarding rule
|
||||
*/
|
||||
public int getStartPort() {
|
||||
return startPort;
|
||||
return this.startPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the protocol of the ip forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
return this.protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public port for the ip forwarding rule
|
||||
*/
|
||||
public int getEndPort() {
|
||||
return endPort;
|
||||
return this.endPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getState() {
|
||||
return state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VM display name for the ip forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineDisplayName() {
|
||||
return virtualMachineDisplayName;
|
||||
return this.virtualMachineDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VM ID for the ip forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
return this.virtualMachineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VM name for the ip forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineName() {
|
||||
return virtualMachineName;
|
||||
return this.virtualMachineName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the starting port of port forwarding rule's public port range
|
||||
*/
|
||||
public int getPublicPort() {
|
||||
return publicPort;
|
||||
return this.publicPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cidr list to forward traffic from
|
||||
*/
|
||||
public Set<String> getCIDRs() {
|
||||
return Collections.unmodifiableSet(CIDRs);
|
||||
return this.CIDRs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ending port of port forwarding rule's private port range
|
||||
*/
|
||||
public int getPrivateEndPort() {
|
||||
return privateEndPort;
|
||||
return this.privateEndPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ending port of port forwarding rule's private port range
|
||||
*/
|
||||
public int getPublicEndPort() {
|
||||
return publicEndPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
IPForwardingRule that = (IPForwardingRule) o;
|
||||
|
||||
if (!Objects.equal(IPAddress, that.IPAddress)) return false;
|
||||
if (!Objects.equal(IPAddressId, that.IPAddressId)) return false;
|
||||
if (!Objects.equal(endPort, that.endPort)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(protocol, that.protocol)) return false;
|
||||
if (!Objects.equal(startPort, that.startPort)) return false;
|
||||
if (!Objects.equal(publicEndPort, that.publicEndPort)) return false;
|
||||
if (!Objects.equal(privateEndPort, that.privateEndPort)) return false;
|
||||
if (!Objects.equal(publicPort, that.publicPort)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false;
|
||||
if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false;
|
||||
if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false;
|
||||
|
||||
return true;
|
||||
return this.publicEndPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(IPAddress, IPAddressId, endPort, id, protocol, startPort, publicEndPort,
|
||||
privateEndPort, publicPort, state, virtualMachineDisplayName,
|
||||
virtualMachineId, virtualMachineName);
|
||||
return Objects.hashCode(id, IPAddress, IPAddressId, startPort, protocol, endPort, state, virtualMachineDisplayName, virtualMachineId, virtualMachineName, publicPort, CIDRs, privateEndPort, publicEndPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
IPForwardingRule that = IPForwardingRule.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.IPAddress, that.IPAddress)
|
||||
&& Objects.equal(this.IPAddressId, that.IPAddressId)
|
||||
&& Objects.equal(this.startPort, that.startPort)
|
||||
&& Objects.equal(this.protocol, that.protocol)
|
||||
&& Objects.equal(this.endPort, that.endPort)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.virtualMachineDisplayName, that.virtualMachineDisplayName)
|
||||
&& Objects.equal(this.virtualMachineId, that.virtualMachineId)
|
||||
&& Objects.equal(this.virtualMachineName, that.virtualMachineName)
|
||||
&& Objects.equal(this.publicPort, that.publicPort)
|
||||
&& Objects.equal(this.CIDRs, that.CIDRs)
|
||||
&& Objects.equal(this.privateEndPort, that.privateEndPort)
|
||||
&& Objects.equal(this.publicEndPort, that.publicEndPort);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("IPAddress", IPAddress).add("IPAddressId", IPAddressId).add("startPort", startPort)
|
||||
.add("protocol", protocol).add("endPort", endPort).add("state", state).add("virtualMachineDisplayName", virtualMachineDisplayName)
|
||||
.add("virtualMachineId", virtualMachineId).add("virtualMachineName", virtualMachineName).add("publicPort", publicPort)
|
||||
.add("CIDRs", CIDRs).add("privateEndPort", privateEndPort).add("publicEndPort", publicEndPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[IPAddress=" + IPAddress + ", IPAddressId=" + IPAddressId + ", id=" + id + ", startPort=" + startPort
|
||||
+ ", protocol=" + protocol + ", endPort=" + endPort + ", state=" + state + ", virtualMachineDisplayName="
|
||||
+ virtualMachineDisplayName + ", virtualMachineId=" + virtualMachineId + ", virtualMachineName="
|
||||
+ virtualMachineName + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IPForwardingRule o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,309 +18,361 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class ISOExtraction
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class ISOExtraction implements Comparable<ISOExtraction> {
|
||||
*/
|
||||
public class ISOExtraction {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromISOExtraction(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String accountId;
|
||||
private Date created;
|
||||
private String extractId;
|
||||
private ExtractMode extractMode;
|
||||
private String name;
|
||||
private String state;
|
||||
private String status;
|
||||
private String storageType;
|
||||
private int uploadPercentage;
|
||||
private String url;
|
||||
private String zoneId;
|
||||
private String zoneName;
|
||||
|
||||
/**
|
||||
* @param id the id of extracted object
|
||||
protected String id;
|
||||
protected String accountId;
|
||||
protected Date created;
|
||||
protected String extractId;
|
||||
protected ExtractMode extractMode;
|
||||
protected String name;
|
||||
protected String state;
|
||||
protected String status;
|
||||
protected String storageType;
|
||||
protected int uploadPercentage;
|
||||
protected String url;
|
||||
protected String zoneId;
|
||||
protected String zoneName;
|
||||
|
||||
/**
|
||||
* @see ISOExtraction#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param accountId the account id to which the extracted object belongs
|
||||
/**
|
||||
* @see ISOExtraction#getAccountId()
|
||||
*/
|
||||
public Builder accountId(String accountId) {
|
||||
public T accountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param created the time and date the object was created
|
||||
/**
|
||||
* @see ISOExtraction#getCreated()
|
||||
*/
|
||||
public Builder created(Date created) {
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param extractId the upload id of extracted object
|
||||
/**
|
||||
* @see ISOExtraction#getExtractId()
|
||||
*/
|
||||
public Builder extractId(String extractId) {
|
||||
public T extractId(String extractId) {
|
||||
this.extractId = extractId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param extractMode the mode of extraction - upload or download
|
||||
/**
|
||||
* @see ISOExtraction#getExtractMode()
|
||||
*/
|
||||
public Builder extractMode(ExtractMode extractMode) {
|
||||
public T extractMode(ExtractMode extractMode) {
|
||||
this.extractMode = extractMode;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name of the extracted object
|
||||
/**
|
||||
* @see ISOExtraction#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state the state of the extracted object
|
||||
/**
|
||||
* @see ISOExtraction#getState()
|
||||
*/
|
||||
public Builder state(String state) {
|
||||
public T state(String state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status the status of the extraction
|
||||
/**
|
||||
* @see ISOExtraction#getStatus()
|
||||
*/
|
||||
public Builder status(String status) {
|
||||
public T status(String status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storageType type of the storage
|
||||
/**
|
||||
* @see ISOExtraction#getStorageType()
|
||||
*/
|
||||
public Builder storageType(String storageType) {
|
||||
public T storageType(String storageType) {
|
||||
this.storageType = storageType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uploadPercentage the percentage of the entity uploaded to the specified location
|
||||
/**
|
||||
* @see ISOExtraction#getUploadPercentage()
|
||||
*/
|
||||
public Builder uploadPercentage(int uploadPercentage) {
|
||||
public T uploadPercentage(int uploadPercentage) {
|
||||
this.uploadPercentage = uploadPercentage;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url if mode = upload then url of the uploaded entity. if mode = download the url from which the entity can be downloaded
|
||||
/**
|
||||
* @see ISOExtraction#getUrl()
|
||||
*/
|
||||
public Builder url(String url) {
|
||||
public T url(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zoneId zone ID the object was extracted from
|
||||
/**
|
||||
* @see ISOExtraction#getZoneId()
|
||||
*/
|
||||
public Builder zoneId(String zoneId) {
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zoneName zone name the object was extracted from
|
||||
/**
|
||||
* @see ISOExtraction#getZoneName()
|
||||
*/
|
||||
public Builder zoneName(String zoneName) {
|
||||
public T zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ISOExtraction build() {
|
||||
return new ISOExtraction(id, accountId, created, extractId, extractMode, name, state, status, storageType, uploadPercentage, url, zoneId, zoneName);
|
||||
}
|
||||
|
||||
public T fromISOExtraction(ISOExtraction in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.accountId(in.getAccountId())
|
||||
.created(in.getCreated())
|
||||
.extractId(in.getExtractId())
|
||||
.extractMode(in.getExtractMode())
|
||||
.name(in.getName())
|
||||
.state(in.getState())
|
||||
.status(in.getStatus())
|
||||
.storageType(in.getStorageType())
|
||||
.uploadPercentage(in.getUploadPercentage())
|
||||
.url(in.getUrl())
|
||||
.zoneId(in.getZoneId())
|
||||
.zoneName(in.getZoneName());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("accountid")
|
||||
private String accountId;
|
||||
private Date created;
|
||||
private String extractId;
|
||||
private ExtractMode extractMode;
|
||||
private String name;
|
||||
private String state;
|
||||
private String status;
|
||||
@SerializedName("storagetype")
|
||||
private String storageType;
|
||||
@SerializedName("uploadpercentage")
|
||||
private int uploadPercentage;
|
||||
private String url;
|
||||
@SerializedName("zoneid")
|
||||
private String zoneId;
|
||||
@SerializedName("zonename")
|
||||
private String zoneName;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
ISOExtraction() {
|
||||
private final String id;
|
||||
@Named("accountid")
|
||||
private final String accountId;
|
||||
private final Date created;
|
||||
private final String extractId;
|
||||
private final ExtractMode extractMode;
|
||||
private final String name;
|
||||
private final String state;
|
||||
private final String status;
|
||||
@Named("storagetype")
|
||||
private final String storageType;
|
||||
@Named("uploadpercentage")
|
||||
private final int uploadPercentage;
|
||||
private final String url;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
@Named("zonename")
|
||||
private final String zoneName;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "accountid", "created", "extractId", "extractMode", "name", "state", "status", "storagetype", "uploadpercentage", "url", "zoneid", "zonename"
|
||||
})
|
||||
protected ISOExtraction(String id, @Nullable String accountId, @Nullable Date created, @Nullable String extractId,
|
||||
@Nullable ExtractMode extractMode, @Nullable String name, @Nullable String state, @Nullable String status,
|
||||
@Nullable String storageType, int uploadPercentage, @Nullable String url, @Nullable String zoneId,
|
||||
@Nullable String zoneName) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.accountId = accountId;
|
||||
this.created = created;
|
||||
this.extractId = extractId;
|
||||
this.extractMode = extractMode;
|
||||
this.name = name;
|
||||
this.state = state;
|
||||
this.status = status;
|
||||
this.storageType = storageType;
|
||||
this.uploadPercentage = uploadPercentage;
|
||||
this.url = url;
|
||||
this.zoneId = zoneId;
|
||||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of extracted object
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account id to which the extracted object belongs
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
return this.accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time and date the object was created
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the upload id of extracted object
|
||||
*/
|
||||
@Nullable
|
||||
public String getExtractId() {
|
||||
return extractId;
|
||||
return this.extractId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mode of extraction - upload or download
|
||||
*/
|
||||
@Nullable
|
||||
public ExtractMode getExtractMode() {
|
||||
return extractMode;
|
||||
return this.extractMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the extracted object
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the extracted object
|
||||
*/
|
||||
@Nullable
|
||||
public String getState() {
|
||||
return state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the status of the extraction
|
||||
*/
|
||||
@Nullable
|
||||
public String getStatus() {
|
||||
return status;
|
||||
return this.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type of the storage
|
||||
*/
|
||||
@Nullable
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
return this.storageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the percentage of the entity uploaded to the specified location
|
||||
*/
|
||||
public int getUploadPercentage() {
|
||||
return uploadPercentage;
|
||||
return this.uploadPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if mode = upload then url of the uploaded entity. if mode = download the url from which the entity can be downloaded
|
||||
*/
|
||||
@Nullable
|
||||
public String getUrl() {
|
||||
return url;
|
||||
return this.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return zone ID the object was extracted from
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return zone name the object was extracted from
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ISOExtraction that = (ISOExtraction) o;
|
||||
|
||||
if (!Objects.equal(accountId, that.accountId)) return false;
|
||||
if (!Objects.equal(extractId, that.extractId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(uploadPercentage, that.uploadPercentage)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(extractMode, that.extractMode)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
if (!Objects.equal(status, that.status)) return false;
|
||||
if (!Objects.equal(storageType, that.storageType)) return false;
|
||||
if (!Objects.equal(url, that.url)) return false;
|
||||
if (!Objects.equal(zoneName, that.zoneName)) return false;
|
||||
|
||||
return true;
|
||||
return this.zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(accountId, extractId, id, uploadPercentage, zoneId, created, extractMode, name, state, status, storageType, url, zoneName);
|
||||
return Objects.hashCode(id, accountId, created, extractId, extractMode, name, state, status, storageType, uploadPercentage, url, zoneId, zoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ISOExtraction that = ISOExtraction.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.accountId, that.accountId)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.extractId, that.extractId)
|
||||
&& Objects.equal(this.extractMode, that.extractMode)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.status, that.status)
|
||||
&& Objects.equal(this.storageType, that.storageType)
|
||||
&& Objects.equal(this.uploadPercentage, that.uploadPercentage)
|
||||
&& Objects.equal(this.url, that.url)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.zoneName, that.zoneName);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("accountId", accountId).add("created", created).add("extractId", extractId).add("extractMode", extractMode)
|
||||
.add("name", name).add("state", state).add("status", status).add("storageType", storageType).add("uploadPercentage", uploadPercentage)
|
||||
.add("url", url).add("zoneId", zoneId).add("zoneName", zoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ISOExtraction{" +
|
||||
"id=" + id +
|
||||
", accountId=" + accountId +
|
||||
", created=" + created +
|
||||
", extractId=" + extractId +
|
||||
", extractMode=" + extractMode +
|
||||
", name='" + name + '\'' +
|
||||
", state='" + state + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
", storageType='" + storageType + '\'' +
|
||||
", uploadPercentage=" + uploadPercentage +
|
||||
", url='" + url + '\'' +
|
||||
", zoneId=" + zoneId +
|
||||
", zoneName='" + zoneName + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ISOExtraction other) {
|
||||
return id.compareTo(other.getId());
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,136 +18,169 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Class ISOPermissions
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class ISOPermissions implements Comparable<ISOPermissions> {
|
||||
*/
|
||||
public class ISOPermissions {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromISOPermissions(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private String domainId;
|
||||
private boolean isPublic;
|
||||
|
||||
/**
|
||||
* @param id the template ID
|
||||
protected String id;
|
||||
protected Set<String> accounts = ImmutableSet.of();
|
||||
protected String domainId;
|
||||
protected boolean isPublic;
|
||||
|
||||
/**
|
||||
* @see ISOPermissions#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param account the list of accounts the template is available for
|
||||
/**
|
||||
* @see ISOPermissions#getAccounts()
|
||||
*/
|
||||
public Builder account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
public T accounts(Set<String> accounts) {
|
||||
this.accounts = ImmutableSet.copyOf(checkNotNull(accounts, "accounts"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param domainId the ID of the domain to which the template belongs
|
||||
public T accounts(String... in) {
|
||||
return accounts(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ISOPermissions#getDomainId()
|
||||
*/
|
||||
public Builder domainId(String domainId) {
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isPublic true if this template is a public template, false otherwise
|
||||
/**
|
||||
* @see ISOPermissions#isPublic()
|
||||
*/
|
||||
public Builder isPublic(boolean isPublic) {
|
||||
public T isPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ISOPermissions build() {
|
||||
return new ISOPermissions(id, accounts, domainId, isPublic);
|
||||
}
|
||||
|
||||
public T fromISOPermissions(ISOPermissions in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.accounts(in.getAccounts())
|
||||
.domainId(in.getDomainId())
|
||||
.isPublic(in.isPublic());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("account")
|
||||
private Set<String> accounts;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("ispublic")
|
||||
private boolean isPublic;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
ISOPermissions() {
|
||||
private final String id;
|
||||
@Named("account")
|
||||
private final Set<String> accounts;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("ispublic")
|
||||
private final boolean isPublic;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "account", "domainid", "ispublic"
|
||||
})
|
||||
protected ISOPermissions(String id, @Nullable Set<String> accounts, @Nullable String domainId, boolean isPublic) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.accounts = accounts == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(accounts);
|
||||
this.domainId = domainId;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the template ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of accounts the template is available for
|
||||
*/
|
||||
public Set<String> getAccounts() {
|
||||
return accounts;
|
||||
return this.accounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the domain to which the template belongs
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this template is a public template, false otherwise
|
||||
*/
|
||||
public boolean getIsPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ISOPermissions that = (ISOPermissions) o;
|
||||
|
||||
if (!Objects.equal(accounts, that.accounts)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(isPublic, that.isPublic)) return false;
|
||||
|
||||
return true;
|
||||
public boolean isPublic() {
|
||||
return this.isPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(accounts, domainId, id, isPublic);
|
||||
return Objects.hashCode(id, accounts, domainId, isPublic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ISOPermissions that = ISOPermissions.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.accounts, that.accounts)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.isPublic, that.isPublic);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("accounts", accounts).add("domainId", domainId).add("isPublic", isPublic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ISOPermissions{" +
|
||||
"id=" + id +
|
||||
", accounts='" + accounts + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", isPublic=" + isPublic +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ISOPermissions other) {
|
||||
return id.compareTo(other.getId());
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,118 +18,170 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
*/
|
||||
public class IngressRule implements Comparable<IngressRule> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromIngressRule(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String account;
|
||||
private String CIDR;
|
||||
private int endPort = -1;
|
||||
private int ICMPCode = -1;
|
||||
private int ICMPType = -1;
|
||||
private String protocol;
|
||||
private String id;
|
||||
private String securityGroupName;
|
||||
private int startPort = -1;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder account(String account) {
|
||||
protected String account;
|
||||
protected String CIDR;
|
||||
protected int endPort;
|
||||
protected int ICMPCode;
|
||||
protected int ICMPType;
|
||||
protected String protocol;
|
||||
protected String id;
|
||||
protected String securityGroupName;
|
||||
protected int startPort;
|
||||
|
||||
/**
|
||||
* @see IngressRule#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder CIDR(String CIDR) {
|
||||
/**
|
||||
* @see IngressRule#getCIDR()
|
||||
*/
|
||||
public T CIDR(String CIDR) {
|
||||
this.CIDR = CIDR;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder endPort(int endPort) {
|
||||
/**
|
||||
* @see IngressRule#getEndPort()
|
||||
*/
|
||||
public T endPort(int endPort) {
|
||||
this.endPort = endPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ICMPCode(int ICMPCode) {
|
||||
/**
|
||||
* @see IngressRule#getICMPCode()
|
||||
*/
|
||||
public T ICMPCode(int ICMPCode) {
|
||||
this.ICMPCode = ICMPCode;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ICMPType(int ICMPType) {
|
||||
/**
|
||||
* @see IngressRule#getICMPType()
|
||||
*/
|
||||
public T ICMPType(int ICMPType) {
|
||||
this.ICMPType = ICMPType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder protocol(String protocol) {
|
||||
/**
|
||||
* @see IngressRule#getProtocol()
|
||||
*/
|
||||
public T protocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
/**
|
||||
* @see IngressRule#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder securityGroupName(String securityGroupName) {
|
||||
/**
|
||||
* @see IngressRule#getSecurityGroupName()
|
||||
*/
|
||||
public T securityGroupName(String securityGroupName) {
|
||||
this.securityGroupName = securityGroupName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder startPort(int startPort) {
|
||||
/**
|
||||
* @see IngressRule#getStartPort()
|
||||
*/
|
||||
public T startPort(int startPort) {
|
||||
this.startPort = startPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public IngressRule build() {
|
||||
return new IngressRule(account, CIDR, endPort, ICMPCode, ICMPType, protocol, id, securityGroupName, startPort);
|
||||
}
|
||||
|
||||
public T fromIngressRule(IngressRule in) {
|
||||
return this
|
||||
.account(in.getAccount())
|
||||
.CIDR(in.getCIDR())
|
||||
.endPort(in.getEndPort())
|
||||
.ICMPCode(in.getICMPCode())
|
||||
.ICMPType(in.getICMPType())
|
||||
.protocol(in.getProtocol())
|
||||
.id(in.getId())
|
||||
.securityGroupName(in.getSecurityGroupName())
|
||||
.startPort(in.getStartPort());
|
||||
}
|
||||
}
|
||||
|
||||
private String account;
|
||||
@SerializedName("cidr")
|
||||
private String CIDR;
|
||||
@SerializedName("endport")
|
||||
private int endPort = -1;
|
||||
@SerializedName("icmpcode")
|
||||
private int ICMPCode = -1;
|
||||
@SerializedName("icmptype")
|
||||
private int ICMPType = -1;
|
||||
private String protocol;
|
||||
@SerializedName("ruleid")
|
||||
private String id;
|
||||
@SerializedName("securitygroupname")
|
||||
private String securityGroupName;
|
||||
@SerializedName("startport")
|
||||
private int startPort = -1;
|
||||
|
||||
// for serialization
|
||||
IngressRule() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public IngressRule(String account, String CIDR, int endPort, int iCMPCode, int iCMPType, String protocol, String id,
|
||||
String securityGroupName, int startPort) {
|
||||
if (account == null)
|
||||
checkArgument(securityGroupName == null && CIDR != null,
|
||||
"if you do not specify an account and security group, you must specify a CIDR range");
|
||||
if (CIDR == null)
|
||||
checkArgument(account != null && securityGroupName != null,
|
||||
"if you do not specify an account and security group, you must specify a CIDR range");
|
||||
private final String account;
|
||||
@Named("cidr")
|
||||
private final String CIDR;
|
||||
@Named("endport")
|
||||
private final int endPort;
|
||||
@Named("icmpcode")
|
||||
private final int ICMPCode;
|
||||
@Named("icmptype")
|
||||
private final int ICMPType;
|
||||
private final String protocol;
|
||||
@Named("ruleid")
|
||||
private final String id;
|
||||
@Named("securitygroupname")
|
||||
private final String securityGroupName;
|
||||
@Named("startport")
|
||||
private final int startPort;
|
||||
|
||||
@ConstructorProperties({
|
||||
"account", "cidr", "endport", "icmpcode", "icmptype", "protocol", "ruleid", "securitygroupname", "startport"
|
||||
})
|
||||
protected IngressRule(@Nullable String account, @Nullable String CIDR, int endPort, int ICMPCode, int ICMPType,
|
||||
@Nullable String protocol, String id, @Nullable String securityGroupName, int startPort) {
|
||||
this.account = account;
|
||||
this.CIDR = CIDR;
|
||||
this.endPort = endPort;
|
||||
this.ICMPCode = iCMPCode;
|
||||
this.ICMPType = iCMPType;
|
||||
this.ICMPCode = ICMPCode;
|
||||
this.ICMPType = ICMPType;
|
||||
this.protocol = protocol;
|
||||
this.id = id;
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.securityGroupName = securityGroupName;
|
||||
this.startPort = startPort;
|
||||
}
|
||||
|
@ -137,108 +189,104 @@ public class IngressRule implements Comparable<IngressRule> {
|
|||
/**
|
||||
* @return account owning the ingress rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the CIDR notation for the base IP address of the ingress rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getCIDR() {
|
||||
return CIDR;
|
||||
return this.CIDR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ending IP of the ingress rule
|
||||
*/
|
||||
public int getEndPort() {
|
||||
return endPort;
|
||||
return this.endPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the code for the ICMP message response
|
||||
*/
|
||||
public int getICMPCode() {
|
||||
return ICMPCode;
|
||||
return this.ICMPCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of the ICMP message response
|
||||
*/
|
||||
public int getICMPType() {
|
||||
return ICMPType;
|
||||
return this.ICMPType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the protocol of the ingress rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
return this.protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the ingress rule
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return security group name
|
||||
*/
|
||||
@Nullable
|
||||
public String getSecurityGroupName() {
|
||||
return securityGroupName;
|
||||
return this.securityGroupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the starting IP of the ingress rule
|
||||
*/
|
||||
public int getStartPort() {
|
||||
return startPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
IngressRule that = (IngressRule) o;
|
||||
|
||||
if (!Objects.equal(CIDR, that.CIDR)) return false;
|
||||
if (!Objects.equal(ICMPCode, that.ICMPCode)) return false;
|
||||
if (!Objects.equal(ICMPType, that.ICMPType)) return false;
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(endPort, that.endPort)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(protocol, that.protocol)) return false;
|
||||
if (!Objects.equal(securityGroupName, that.securityGroupName)) return false;
|
||||
if (!Objects.equal(startPort, that.startPort)) return false;
|
||||
|
||||
return true;
|
||||
return this.startPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(CIDR, ICMPCode, ICMPType, account, endPort, id, protocol, securityGroupName, startPort);
|
||||
return Objects.hashCode(account, CIDR, endPort, ICMPCode, ICMPType, protocol, id, securityGroupName, startPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
IngressRule that = IngressRule.class.cast(obj);
|
||||
return Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.CIDR, that.CIDR)
|
||||
&& Objects.equal(this.endPort, that.endPort)
|
||||
&& Objects.equal(this.ICMPCode, that.ICMPCode)
|
||||
&& Objects.equal(this.ICMPType, that.ICMPType)
|
||||
&& Objects.equal(this.protocol, that.protocol)
|
||||
&& Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.securityGroupName, that.securityGroupName)
|
||||
&& Objects.equal(this.startPort, that.startPort);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("account", account).add("CIDR", CIDR).add("endPort", endPort).add("ICMPCode", ICMPCode)
|
||||
.add("ICMPType", ICMPType).add("protocol", protocol).add("id", id).add("securityGroupName", securityGroupName).add("startPort", startPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IngressRule{" +
|
||||
"account='" + account + '\'' +
|
||||
", CIDR='" + CIDR + '\'' +
|
||||
", endPort=" + endPort +
|
||||
", ICMPCode=" + ICMPCode +
|
||||
", ICMPType=" + ICMPType +
|
||||
", protocol='" + protocol + '\'' +
|
||||
", id=" + id +
|
||||
", securityGroupName='" + securityGroupName + '\'' +
|
||||
", startPort=" + startPort +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IngressRule arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
public int compareTo(IngressRule o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,73 +18,115 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The result of an operation.
|
||||
*
|
||||
*
|
||||
* A handful of Cloudstack API calls return this structure when there is no domain model data to return - for example,
|
||||
* when deleting an object.
|
||||
*
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class JobResult implements Comparable<JobResult> {
|
||||
*/
|
||||
public class JobResult {
|
||||
|
||||
private boolean success;
|
||||
@SerializedName("displaytext")
|
||||
private String displayText;
|
||||
|
||||
/**
|
||||
* present only for the serializer
|
||||
*/
|
||||
JobResult() {
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromJobResult(this);
|
||||
}
|
||||
|
||||
public JobResult(boolean success, String displayText) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected boolean success;
|
||||
protected String displayText;
|
||||
|
||||
/**
|
||||
* @see JobResult#isSuccess()
|
||||
*/
|
||||
public T success(boolean success) {
|
||||
this.success = success;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see JobResult#getDisplayText()
|
||||
*/
|
||||
public T displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return self();
|
||||
}
|
||||
|
||||
public JobResult build() {
|
||||
return new JobResult(success, displayText);
|
||||
}
|
||||
|
||||
public T fromJobResult(JobResult in) {
|
||||
return this
|
||||
.success(in.isSuccess())
|
||||
.displayText(in.getDisplayText());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean success;
|
||||
@Named("displaytext")
|
||||
private final String displayText;
|
||||
|
||||
@ConstructorProperties({
|
||||
"success", "displaytext"
|
||||
})
|
||||
protected JobResult(boolean success, @Nullable String displayText) {
|
||||
this.success = success;
|
||||
this.displayText = displayText;
|
||||
}
|
||||
|
||||
public boolean getSuccess() {
|
||||
return success;
|
||||
public boolean isSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
JobResult that = (JobResult) o;
|
||||
|
||||
if (!Objects.equal(success, that.success)) return false;
|
||||
if (!Objects.equal(displayText, that.displayText)) return false;
|
||||
|
||||
return true;
|
||||
return this.displayText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(success, displayText);
|
||||
return Objects.hashCode(success, displayText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
JobResult that = JobResult.class.cast(obj);
|
||||
return Objects.equal(this.success, that.success)
|
||||
&& Objects.equal(this.displayText, that.displayText);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).add("success", success).add("displayText", displayText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JobResult{" +
|
||||
"success=" + success +
|
||||
", displayText='" + displayText + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(JobResult other) {
|
||||
int comparison = Boolean.valueOf(success).compareTo(other.success);
|
||||
if (comparison == 0)
|
||||
comparison = displayText.compareTo(other.displayText);
|
||||
return comparison;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,180 +20,264 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class LoadBalancerRule
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
|
||||
*/
|
||||
public class LoadBalancerRule {
|
||||
|
||||
/**
|
||||
*/
|
||||
public static enum State {
|
||||
ADD, ACTIVE, UNRECOGNIZED;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||
}
|
||||
|
||||
|
||||
public static State fromValue(String state) {
|
||||
try {
|
||||
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
try {
|
||||
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static enum Algorithm {
|
||||
SOURCE, ROUNDROBIN, LEASTCONN, UNRECOGNIZED;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
public static Algorithm fromValue(String algorithm) {
|
||||
try {
|
||||
return Algorithm.valueOf(checkNotNull(algorithm, "algorithm").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
try {
|
||||
return Algorithm.valueOf(checkNotNull(algorithm, "algorithm").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromLoadBalancerRule(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String account;
|
||||
private Algorithm algorithm;
|
||||
private String description;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private String name;
|
||||
private int privatePort;
|
||||
private String publicIP;
|
||||
private String publicIPId;
|
||||
private int publicPort;
|
||||
private State state;
|
||||
private Set<String> CIDRs = ImmutableSet.of();
|
||||
private String zoneId;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String account;
|
||||
protected LoadBalancerRule.Algorithm algorithm;
|
||||
protected String description;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected String name;
|
||||
protected int privatePort;
|
||||
protected String publicIP;
|
||||
protected String publicIPId;
|
||||
protected int publicPort;
|
||||
protected LoadBalancerRule.State state;
|
||||
protected Set<String> CIDRs = ImmutableSet.of();
|
||||
protected String zoneId;
|
||||
|
||||
/**
|
||||
* @see LoadBalancerRule#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder algorithm(Algorithm algorithm) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getAlgorithm()
|
||||
*/
|
||||
public T algorithm(LoadBalancerRule.Algorithm algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder privatePort(int privatePort) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getPrivatePort()
|
||||
*/
|
||||
public T privatePort(int privatePort) {
|
||||
this.privatePort = privatePort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder publicIP(String publicIP) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getPublicIP()
|
||||
*/
|
||||
public T publicIP(String publicIP) {
|
||||
this.publicIP = publicIP;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder publicIPId(String publicIPId) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getPublicIPId()
|
||||
*/
|
||||
public T publicIPId(String publicIPId) {
|
||||
this.publicIPId = publicIPId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder publicPort(int publicPort) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getPublicPort()
|
||||
*/
|
||||
public T publicPort(int publicPort) {
|
||||
this.publicPort = publicPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(State state) {
|
||||
/**
|
||||
* @see LoadBalancerRule#getState()
|
||||
*/
|
||||
public T state(LoadBalancerRule.State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder CIDRs(Set<String> CIDRs) {
|
||||
this.CIDRs = CIDRs;
|
||||
return this;
|
||||
/**
|
||||
* @see LoadBalancerRule#getCIDRs()
|
||||
*/
|
||||
public T CIDRs(Set<String> CIDRs) {
|
||||
this.CIDRs = ImmutableSet.copyOf(checkNotNull(CIDRs, "CIDRs"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneId(String zoneId) {
|
||||
public T CIDRs(String... in) {
|
||||
return CIDRs(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancerRule#getZoneId()
|
||||
*/
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public LoadBalancerRule build() {
|
||||
return new LoadBalancerRule(id, account, algorithm, description, domain, domainId, name, privatePort,
|
||||
publicIP, publicIPId, publicPort, state, zoneId, CIDRs);
|
||||
return new LoadBalancerRule(id, account, algorithm, description, domain, domainId, name, privatePort, publicIP, publicIPId, publicPort, state, CIDRs, zoneId);
|
||||
}
|
||||
|
||||
public T fromLoadBalancerRule(LoadBalancerRule in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.account(in.getAccount())
|
||||
.algorithm(in.getAlgorithm())
|
||||
.description(in.getDescription())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.name(in.getName())
|
||||
.privatePort(in.getPrivatePort())
|
||||
.publicIP(in.getPublicIP())
|
||||
.publicIPId(in.getPublicIPId())
|
||||
.publicPort(in.getPublicPort())
|
||||
.state(in.getState())
|
||||
.CIDRs(in.getCIDRs())
|
||||
.zoneId(in.getZoneId());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private Algorithm algorithm;
|
||||
private String description;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
private String name;
|
||||
@SerializedName("privateport")
|
||||
private int privatePort;
|
||||
@SerializedName("publicip")
|
||||
private String publicIP;
|
||||
@SerializedName("publicipid")
|
||||
private String publicIPId;
|
||||
@SerializedName("publicport")
|
||||
private int publicPort;
|
||||
private State state;
|
||||
@SerializedName("cidrlist")
|
||||
private Set<String> CIDRs;
|
||||
@SerializedName("zoneId")
|
||||
private String zoneId;
|
||||
|
||||
// for deserializer
|
||||
LoadBalancerRule() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public LoadBalancerRule(String id, String account, Algorithm algorithm, String description, String domain,
|
||||
String domainId, String name, int privatePort, String publicIP, String publicIPId, int publicPort, State state,
|
||||
String zoneId, Set<String> CIDRs) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String account;
|
||||
private final LoadBalancerRule.Algorithm algorithm;
|
||||
private final String description;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
private final String name;
|
||||
@Named("privateport")
|
||||
private final int privatePort;
|
||||
@Named("publicip")
|
||||
private final String publicIP;
|
||||
@Named("publicipid")
|
||||
private final String publicIPId;
|
||||
@Named("publicport")
|
||||
private final int publicPort;
|
||||
private final LoadBalancerRule.State state;
|
||||
@Named("cidrlist")
|
||||
private final Set<String> CIDRs;
|
||||
private final String zoneId;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "account", "algorithm", "description", "domain", "domainid", "name", "privateport", "publicip", "publicipid", "publicport", "state", "cidrlist", "zoneId"
|
||||
})
|
||||
protected LoadBalancerRule(String id, @Nullable String account, @Nullable LoadBalancerRule.Algorithm algorithm,
|
||||
@Nullable String description, @Nullable String domain, @Nullable String domainId, @Nullable String name,
|
||||
int privatePort, @Nullable String publicIP, @Nullable String publicIPId, int publicPort,
|
||||
@Nullable LoadBalancerRule.State state, @Nullable Set<String> CIDRs, @Nullable String zoneId) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.account = account;
|
||||
this.algorithm = algorithm;
|
||||
this.description = description;
|
||||
|
@ -205,162 +289,152 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
|
|||
this.publicIPId = publicIPId;
|
||||
this.publicPort = publicPort;
|
||||
this.state = state;
|
||||
this.CIDRs = CIDRs == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(CIDRs);
|
||||
this.zoneId = zoneId;
|
||||
this.CIDRs = ImmutableSet.copyOf(CIDRs);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the load balancer rule ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account of the load balancer rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the load balancer algorithm (source, roundrobin, leastconn)
|
||||
*/
|
||||
public Algorithm getAlgorithm() {
|
||||
return algorithm;
|
||||
@Nullable
|
||||
public LoadBalancerRule.Algorithm getAlgorithm() {
|
||||
return this.algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description of the load balancer
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain of the load balancer rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain ID of the load balancer rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the load balancer
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the private port
|
||||
*/
|
||||
public int getPrivatePort() {
|
||||
return privatePort;
|
||||
return this.privatePort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public ip address
|
||||
*/
|
||||
@Nullable
|
||||
public String getPublicIP() {
|
||||
return publicIP;
|
||||
return this.publicIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public ip address id
|
||||
*/
|
||||
@Nullable
|
||||
public String getPublicIPId() {
|
||||
return publicIPId;
|
||||
return this.publicIPId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public port
|
||||
*/
|
||||
public int getPublicPort() {
|
||||
return publicPort;
|
||||
return this.publicPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the rule
|
||||
*/
|
||||
public State getState() {
|
||||
return state;
|
||||
@Nullable
|
||||
public LoadBalancerRule.State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cidr list to forward traffic from
|
||||
*/
|
||||
public Set<String> getCIDRs() {
|
||||
return CIDRs;
|
||||
return this.CIDRs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the zone the rule beStrings to
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LoadBalancerRule arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
LoadBalancerRule that = (LoadBalancerRule) o;
|
||||
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(algorithm, that.algorithm)) return false;
|
||||
if (!Objects.equal(description, that.description)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(privatePort, that.privatePort)) return false;
|
||||
if (!Objects.equal(publicIP, that.publicIP)) return false;
|
||||
if (!Objects.equal(publicIPId, that.publicIPId)) return false;
|
||||
if (!Objects.equal(publicPort, that.publicPort)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
|
||||
return true;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(account, algorithm, description, domain, domainId, id, name, privatePort, publicIP, publicIPId, publicPort, zoneId, state);
|
||||
return Objects.hashCode(id, account, algorithm, description, domain, domainId, name, privatePort, publicIP, publicIPId, publicPort, state, CIDRs, zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
LoadBalancerRule that = LoadBalancerRule.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.algorithm, that.algorithm)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.privatePort, that.privatePort)
|
||||
&& Objects.equal(this.publicIP, that.publicIP)
|
||||
&& Objects.equal(this.publicIPId, that.publicIPId)
|
||||
&& Objects.equal(this.publicPort, that.publicPort)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.CIDRs, that.CIDRs)
|
||||
&& Objects.equal(this.zoneId, that.zoneId);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("account", account).add("algorithm", algorithm).add("description", description).add("domain", domain).add("domainId", domainId).add("name", name).add("privatePort", privatePort).add("publicIP", publicIP).add("publicIPId", publicIPId).add("publicPort", publicPort).add("state", state).add("CIDRs", CIDRs).add("zoneId", zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LoadBalancerRule{" +
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", algorithm=" + algorithm +
|
||||
", description='" + description + '\'' +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", name='" + name + '\'' +
|
||||
", privatePort=" + privatePort +
|
||||
", publicIP='" + publicIP + '\'' +
|
||||
", publicIPId=" + publicIPId +
|
||||
", publicPort=" + publicPort +
|
||||
", state=" + state +
|
||||
", CIDRs=" + CIDRs +
|
||||
", zoneId=" + zoneId +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,160 +16,219 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Representation of the login API call response
|
||||
*
|
||||
* @author Andrei Savu
|
||||
*/
|
||||
public class LoginResponse implements Comparable<LoginResponse> {
|
||||
*/
|
||||
public class LoginResponse {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromLoginResponse(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String username;
|
||||
private String userId;
|
||||
private String password;
|
||||
private String domainId;
|
||||
private long timeout;
|
||||
private boolean registered;
|
||||
private String accountName;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private Account.Type accountType;
|
||||
private String timezone;
|
||||
private String timezoneOffset;
|
||||
private String sessionKey;
|
||||
private String jSessionId;
|
||||
|
||||
public Builder copyOf(LoginResponse r) {
|
||||
this.username = r.username;
|
||||
this.userId = r.userId;
|
||||
this.password = r.password;
|
||||
this.domainId = r.domainId;
|
||||
this.timeout = r.timeout;
|
||||
this.registered = r.registered;
|
||||
this.accountName = r.accountName;
|
||||
this.firstName = r.firstName;
|
||||
this.lastName = r.lastName;
|
||||
this.accountType = r.accountType;
|
||||
this.timezone = r.timezone;
|
||||
this.timezoneOffset = r.timezoneOffset;
|
||||
this.sessionKey = r.sessionKey;
|
||||
this.jSessionId = r.jSessionId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder username(String username) {
|
||||
protected String username;
|
||||
protected String userId;
|
||||
protected String password;
|
||||
protected String domainId;
|
||||
protected long timeout;
|
||||
protected boolean registered;
|
||||
protected String accountName;
|
||||
protected String firstName;
|
||||
protected String lastName;
|
||||
protected Account.Type accountType;
|
||||
protected String timezone;
|
||||
protected String timezoneOffset;
|
||||
protected String sessionKey;
|
||||
protected String jSessionId;
|
||||
|
||||
/**
|
||||
* @see LoginResponse#getUsername()
|
||||
*/
|
||||
public T username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder userId(String userId) {
|
||||
/**
|
||||
* @see LoginResponse#getUserId()
|
||||
*/
|
||||
public T userId(String userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder password(String password) {
|
||||
/**
|
||||
* @see LoginResponse#getPassword()
|
||||
*/
|
||||
public T password(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see LoginResponse#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder timeout(long timeout) {
|
||||
/**
|
||||
* @see LoginResponse#getTimeout()
|
||||
*/
|
||||
public T timeout(long timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder registered(boolean registered) {
|
||||
/**
|
||||
* @see LoginResponse#isRegistered()
|
||||
*/
|
||||
public T registered(boolean registered) {
|
||||
this.registered = registered;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder accountName(String accountName) {
|
||||
/**
|
||||
* @see LoginResponse#getAccountName()
|
||||
*/
|
||||
public T accountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder firstName(String firstName) {
|
||||
/**
|
||||
* @see LoginResponse#getFirstName()
|
||||
*/
|
||||
public T firstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder lastName(String lastName) {
|
||||
/**
|
||||
* @see LoginResponse#getLastName()
|
||||
*/
|
||||
public T lastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder accountType(Account.Type accountType) {
|
||||
/**
|
||||
* @see LoginResponse#getAccountType()
|
||||
*/
|
||||
public T accountType(Account.Type accountType) {
|
||||
this.accountType = accountType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder timezone(String timezone) {
|
||||
/**
|
||||
* @see LoginResponse#getTimezone()
|
||||
*/
|
||||
public T timezone(String timezone) {
|
||||
this.timezone = timezone;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder timezoneOffset(String timezoneOffset) {
|
||||
/**
|
||||
* @see LoginResponse#getTimezoneOffset()
|
||||
*/
|
||||
public T timezoneOffset(String timezoneOffset) {
|
||||
this.timezoneOffset = timezoneOffset;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder sessionKey(String sessionKey) {
|
||||
/**
|
||||
* @see LoginResponse#getSessionKey()
|
||||
*/
|
||||
public T sessionKey(String sessionKey) {
|
||||
this.sessionKey = sessionKey;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder jSessionId(String jSessionId) {
|
||||
/**
|
||||
* @see LoginResponse#getJSessionId()
|
||||
*/
|
||||
public T jSessionId(String jSessionId) {
|
||||
this.jSessionId = jSessionId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public LoginResponse build() {
|
||||
return new LoginResponse(username, userId, password, domainId, timeout, registered, accountName, firstName,
|
||||
lastName, accountType, timezone, timezoneOffset, sessionKey, jSessionId);
|
||||
return new LoginResponse(username, userId, password, domainId, timeout, registered, accountName, firstName, lastName, accountType, timezone, timezoneOffset, sessionKey, jSessionId);
|
||||
}
|
||||
|
||||
public T fromLoginResponse(LoginResponse in) {
|
||||
return this
|
||||
.username(in.getUsername())
|
||||
.userId(in.getUserId())
|
||||
.password(in.getPassword())
|
||||
.domainId(in.getDomainId())
|
||||
.timeout(in.getTimeout())
|
||||
.registered(in.isRegistered())
|
||||
.accountName(in.getAccountName())
|
||||
.firstName(in.getFirstName())
|
||||
.lastName(in.getLastName())
|
||||
.accountType(in.getAccountType())
|
||||
.timezone(in.getTimezone())
|
||||
.timezoneOffset(in.getTimezoneOffset())
|
||||
.sessionKey(in.getSessionKey())
|
||||
.jSessionId(in.getJSessionId());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String username;
|
||||
@SerializedName("userid")
|
||||
@Named("userid")
|
||||
private final String userId;
|
||||
private final String password;
|
||||
@SerializedName("domainid")
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
private final long timeout;
|
||||
private final boolean registered;
|
||||
@SerializedName("account")
|
||||
@Named("account")
|
||||
private final String accountName;
|
||||
@SerializedName("firstname")
|
||||
@Named("firstname")
|
||||
private final String firstName;
|
||||
@SerializedName("lastname")
|
||||
@Named("lastname")
|
||||
private final String lastName;
|
||||
@SerializedName("type")
|
||||
@Named("type")
|
||||
private final Account.Type accountType;
|
||||
private final String timezone;
|
||||
@SerializedName("timezoneoffset")
|
||||
@Named("timezoneoffset")
|
||||
private final String timezoneOffset;
|
||||
@SerializedName("sessionkey")
|
||||
@Named("sessionkey")
|
||||
private final String sessionKey;
|
||||
private final String jSessionId;
|
||||
|
||||
public LoginResponse(String username, String userId, String password, String domainId, long timeout, boolean registered,
|
||||
String accountName, String firstName, String lastName, Account.Type accountType, String timezone,
|
||||
String timezoneOffset, String sessionKey, String jSessionId) {
|
||||
@ConstructorProperties({
|
||||
"username", "userid", "password", "domainid", "timeout", "registered", "account", "firstname", "lastname", "type", "timezone", "timezoneoffset", "sessionkey", "jSessionId"
|
||||
})
|
||||
protected LoginResponse(@Nullable String username, @Nullable String userId, @Nullable String password, @Nullable String domainId, long timeout, boolean registered, @Nullable String accountName, @Nullable String firstName, @Nullable String lastName, @Nullable Account.Type accountType, @Nullable String timezone, @Nullable String timezoneOffset, @Nullable String sessionKey, @Nullable String jSessionId) {
|
||||
this.username = username;
|
||||
this.userId = userId;
|
||||
this.password = password;
|
||||
|
@ -186,107 +245,108 @@ public class LoginResponse implements Comparable<LoginResponse> {
|
|||
this.jSessionId = jSessionId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUsername() {
|
||||
return username;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPassword() {
|
||||
return password;
|
||||
return this.password;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
public long getTimeout() {
|
||||
return timeout;
|
||||
return this.timeout;
|
||||
}
|
||||
|
||||
public boolean isRegistered() {
|
||||
return registered;
|
||||
return this.registered;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
return this.accountName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
return this.firstName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
return this.lastName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Account.Type getAccountType() {
|
||||
return accountType;
|
||||
return this.accountType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTimezone() {
|
||||
return timezone;
|
||||
return this.timezone;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTimezoneOffset() {
|
||||
return timezoneOffset;
|
||||
return this.timezoneOffset;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSessionKey() {
|
||||
return sessionKey;
|
||||
return this.sessionKey;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getJSessionId() {
|
||||
return jSessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
LoginResponse that = (LoginResponse) o;
|
||||
|
||||
if (!Objects.equal(accountName, that.accountName)) return false;
|
||||
if (!Objects.equal(accountType, that.accountType)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(firstName, that.firstName)) return false;
|
||||
if (!Objects.equal(jSessionId, that.jSessionId)) return false;
|
||||
if (!Objects.equal(lastName, that.lastName)) return false;
|
||||
if (!Objects.equal(password, that.password)) return false;
|
||||
if (!Objects.equal(registered, that.registered)) return false;
|
||||
if (!Objects.equal(sessionKey, that.sessionKey)) return false;
|
||||
if (!Objects.equal(timeout, that.timeout)) return false;
|
||||
if (!Objects.equal(timezone, that.timezone)) return false;
|
||||
if (!Objects.equal(timezoneOffset, that.timezoneOffset)) return false;
|
||||
if (!Objects.equal(userId, that.userId)) return false;
|
||||
if (!Objects.equal(username, that.username)) return false;
|
||||
|
||||
return true;
|
||||
return this.jSessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(accountName, accountType, domainId, firstName, jSessionId, lastName,
|
||||
password, registered, sessionKey, timeout, timezone, timezoneOffset,
|
||||
userId, username);
|
||||
return Objects.hashCode(username, userId, password, domainId, timeout, registered, accountName, firstName, lastName, accountType, timezone, timezoneOffset, sessionKey, jSessionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
LoginResponse that = LoginResponse.class.cast(obj);
|
||||
return Objects.equal(this.username, that.username)
|
||||
&& Objects.equal(this.userId, that.userId)
|
||||
&& Objects.equal(this.password, that.password)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.timeout, that.timeout)
|
||||
&& Objects.equal(this.registered, that.registered)
|
||||
&& Objects.equal(this.accountName, that.accountName)
|
||||
&& Objects.equal(this.firstName, that.firstName)
|
||||
&& Objects.equal(this.lastName, that.lastName)
|
||||
&& Objects.equal(this.accountType, that.accountType)
|
||||
&& Objects.equal(this.timezone, that.timezone)
|
||||
&& Objects.equal(this.timezoneOffset, that.timezoneOffset)
|
||||
&& Objects.equal(this.sessionKey, that.sessionKey)
|
||||
&& Objects.equal(this.jSessionId, that.jSessionId);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("username", username).add("userId", userId).add("password", password).add("domainId", domainId).add("timeout", timeout).add("registered", registered).add("accountName", accountName).add("firstName", firstName).add("lastName", lastName).add("accountType", accountType).add("timezone", timezone).add("timezoneOffset", timezoneOffset).add("sessionKey", sessionKey).add("jSessionId", jSessionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LoginResponse{" + "username='" + username + '\'' + ", userId=" + userId + ", password='" + password
|
||||
+ '\'' + ", domainId=" + domainId + ", timeout=" + timeout + ", registered=" + registered
|
||||
+ ", accountName='" + accountName + '\'' + ", firstName='" + firstName + '\'' + ", lastName='"
|
||||
+ lastName + '\'' + ", accountType=" + accountType + ", timezone='" + timezone + '\''
|
||||
+ ", timezoneOffset='" + timezoneOffset + '\'' + ", sessionKey='" + sessionKey + '\'' + ", jSessionId='"
|
||||
+ jSessionId + '\'' + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LoginResponse arg0) {
|
||||
return sessionKey.compareTo(arg0.getSessionKey());
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,128 +18,193 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class NIC
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
*/
|
||||
public class NIC {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromNIC(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private URI broadcastURI;
|
||||
private String gateway;
|
||||
private String IPAddress;
|
||||
private boolean isDefault;
|
||||
private URI isolationURI;
|
||||
private String netmask;
|
||||
private String macAddress;
|
||||
private String networkId;
|
||||
private TrafficType trafficType;
|
||||
private GuestIPType guestIPType;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected URI broadcastURI;
|
||||
protected String gateway;
|
||||
protected String IPAddress;
|
||||
protected boolean isDefault;
|
||||
protected URI isolationURI;
|
||||
protected String netmask;
|
||||
protected String macAddress;
|
||||
protected String networkId;
|
||||
protected TrafficType trafficType;
|
||||
protected GuestIPType guestIPType;
|
||||
|
||||
/**
|
||||
* @see NIC#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder broadcastURI(URI broadcastURI) {
|
||||
/**
|
||||
* @see NIC#getBroadcastURI()
|
||||
*/
|
||||
public T broadcastURI(URI broadcastURI) {
|
||||
this.broadcastURI = broadcastURI;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder gateway(String gateway) {
|
||||
/**
|
||||
* @see NIC#getGateway()
|
||||
*/
|
||||
public T gateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder IPAddress(String IPAddress) {
|
||||
/**
|
||||
* @see NIC#getIPAddress()
|
||||
*/
|
||||
public T IPAddress(String IPAddress) {
|
||||
this.IPAddress = IPAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder isDefault(boolean isDefault) {
|
||||
/**
|
||||
* @see NIC#isDefault()
|
||||
*/
|
||||
public T isDefault(boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder isolationURI(URI isolationURI) {
|
||||
/**
|
||||
* @see NIC#getIsolationURI()
|
||||
*/
|
||||
public T isolationURI(URI isolationURI) {
|
||||
this.isolationURI = isolationURI;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder netmask(String netmask) {
|
||||
/**
|
||||
* @see NIC#getNetmask()
|
||||
*/
|
||||
public T netmask(String netmask) {
|
||||
this.netmask = netmask;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder macAddress(String macAddress) {
|
||||
/**
|
||||
* @see NIC#getMacAddress()
|
||||
*/
|
||||
public T macAddress(String macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder networkId(String networkId) {
|
||||
/**
|
||||
* @see NIC#getNetworkId()
|
||||
*/
|
||||
public T networkId(String networkId) {
|
||||
this.networkId = networkId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder trafficType(TrafficType trafficType) {
|
||||
/**
|
||||
* @see NIC#getTrafficType()
|
||||
*/
|
||||
public T trafficType(TrafficType trafficType) {
|
||||
this.trafficType = trafficType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder guestIPType(GuestIPType guestIPType) {
|
||||
/**
|
||||
* @see NIC#getGuestIPType()
|
||||
*/
|
||||
public T guestIPType(GuestIPType guestIPType) {
|
||||
this.guestIPType = guestIPType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public NIC build() {
|
||||
return new NIC(id, broadcastURI, gateway, IPAddress, isDefault, isolationURI, netmask, macAddress, networkId,
|
||||
trafficType, guestIPType);
|
||||
|
||||
return new NIC(id, broadcastURI, gateway, IPAddress, isDefault, isolationURI, netmask, macAddress, networkId, trafficType, guestIPType);
|
||||
}
|
||||
|
||||
public T fromNIC(NIC in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.broadcastURI(in.getBroadcastURI())
|
||||
.gateway(in.getGateway())
|
||||
.IPAddress(in.getIPAddress())
|
||||
.isDefault(in.isDefault())
|
||||
.isolationURI(in.getIsolationURI())
|
||||
.netmask(in.getNetmask())
|
||||
.macAddress(in.getMacAddress())
|
||||
.networkId(in.getNetworkId())
|
||||
.trafficType(in.getTrafficType())
|
||||
.guestIPType(in.getGuestIPType());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("broadcasturi")
|
||||
private URI broadcastURI;
|
||||
private String gateway;
|
||||
@SerializedName("ipaddress")
|
||||
private String IPAddress;
|
||||
@SerializedName("isdefault")
|
||||
private boolean isDefault;
|
||||
@SerializedName("isolationuri")
|
||||
private URI isolationURI;
|
||||
private String netmask;
|
||||
@SerializedName("macaddress")
|
||||
private String macAddress;
|
||||
@SerializedName("networkid")
|
||||
private String networkId;
|
||||
@SerializedName("traffictype")
|
||||
private TrafficType trafficType;
|
||||
@SerializedName("type")
|
||||
private GuestIPType guestIPType;
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
NIC() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public NIC(String id, URI broadcastURI, String gateway, String iPAddress, boolean isDefault, URI isolationURI,
|
||||
String netmask, String macAddress, String networkId, TrafficType trafficType, GuestIPType guestIPType) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
@Named("broadcasturi")
|
||||
private final URI broadcastURI;
|
||||
private final String gateway;
|
||||
@Named("ipaddress")
|
||||
private final String IPAddress;
|
||||
@Named("isdefault")
|
||||
private final boolean isDefault;
|
||||
@Named("isolationuri")
|
||||
private final URI isolationURI;
|
||||
private final String netmask;
|
||||
@Named("macaddress")
|
||||
private final String macAddress;
|
||||
@Named("networkid")
|
||||
private final String networkId;
|
||||
@Named("traffictype")
|
||||
private final TrafficType trafficType;
|
||||
@Named("type")
|
||||
private final GuestIPType guestIPType;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "broadcasturi", "gateway", "ipaddress", "isdefault", "isolationuri", "netmask", "macaddress", "networkid", "traffictype", "type"
|
||||
})
|
||||
protected NIC(String id, @Nullable URI broadcastURI, @Nullable String gateway, @Nullable String IPAddress, boolean isDefault,
|
||||
@Nullable URI isolationURI, @Nullable String netmask, @Nullable String macAddress, @Nullable String networkId,
|
||||
@Nullable TrafficType trafficType, @Nullable GuestIPType guestIPType) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.broadcastURI = broadcastURI;
|
||||
this.gateway = gateway;
|
||||
this.IPAddress = iPAddress;
|
||||
this.IPAddress = IPAddress;
|
||||
this.isDefault = isDefault;
|
||||
this.isolationURI = isolationURI;
|
||||
this.netmask = netmask;
|
||||
|
@ -153,121 +218,121 @@ public class NIC {
|
|||
* the ID of the nic
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* the broadcast uri of the nic
|
||||
*/
|
||||
@Nullable
|
||||
public URI getBroadcastURI() {
|
||||
return broadcastURI;
|
||||
return this.broadcastURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* the gateway of the nic
|
||||
*/
|
||||
@Nullable
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
return this.gateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* the ip address of the nic
|
||||
*/
|
||||
@Nullable
|
||||
public String getIPAddress() {
|
||||
return IPAddress;
|
||||
return this.IPAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* true if nic is default, false otherwise
|
||||
*/
|
||||
public boolean isDefault() {
|
||||
return isDefault;
|
||||
return this.isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* the isolation uri of the nic
|
||||
*/
|
||||
@Nullable
|
||||
public URI getIsolationURI() {
|
||||
return isolationURI;
|
||||
return this.isolationURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* the netmask of the nic
|
||||
*/
|
||||
@Nullable
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
return this.netmask;
|
||||
}
|
||||
|
||||
/**
|
||||
* the MAC Address of the NIC
|
||||
*/
|
||||
@Nullable
|
||||
public String getMacAddress() {
|
||||
return macAddress;
|
||||
return this.macAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* the ID of the corresponding network
|
||||
*/
|
||||
@Nullable
|
||||
public String getNetworkId() {
|
||||
return networkId;
|
||||
return this.networkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* the traffic type of the nic
|
||||
*/
|
||||
@Nullable
|
||||
public TrafficType getTrafficType() {
|
||||
return trafficType;
|
||||
return this.trafficType;
|
||||
}
|
||||
|
||||
/**
|
||||
* the type of the nic
|
||||
*/
|
||||
@Nullable
|
||||
public GuestIPType getGuestIPType() {
|
||||
return guestIPType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
NIC that = (NIC) o;
|
||||
|
||||
if (!Objects.equal(IPAddress, that.IPAddress)) return false;
|
||||
if (!Objects.equal(broadcastURI, that.broadcastURI)) return false;
|
||||
if (!Objects.equal(gateway, that.gateway)) return false;
|
||||
if (!Objects.equal(guestIPType, that.guestIPType)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(isDefault, that.isDefault)) return false;
|
||||
if (!Objects.equal(isolationURI, that.isolationURI)) return false;
|
||||
if (!Objects.equal(netmask, that.netmask)) return false;
|
||||
if (!Objects.equal(macAddress, that.macAddress)) return false;
|
||||
if (!Objects.equal(networkId, that.networkId)) return false;
|
||||
if (!Objects.equal(trafficType, that.trafficType)) return false;
|
||||
|
||||
return true;
|
||||
return this.guestIPType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(IPAddress, broadcastURI, gateway, guestIPType, id, isDefault, isolationURI, netmask, macAddress, networkId, trafficType);
|
||||
return Objects.hashCode(id, broadcastURI, gateway, IPAddress, isDefault, isolationURI, netmask, macAddress, networkId, trafficType, guestIPType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
NIC that = NIC.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.broadcastURI, that.broadcastURI)
|
||||
&& Objects.equal(this.gateway, that.gateway)
|
||||
&& Objects.equal(this.IPAddress, that.IPAddress)
|
||||
&& Objects.equal(this.isDefault, that.isDefault)
|
||||
&& Objects.equal(this.isolationURI, that.isolationURI)
|
||||
&& Objects.equal(this.netmask, that.netmask)
|
||||
&& Objects.equal(this.macAddress, that.macAddress)
|
||||
&& Objects.equal(this.networkId, that.networkId)
|
||||
&& Objects.equal(this.trafficType, that.trafficType)
|
||||
&& Objects.equal(this.guestIPType, that.guestIPType);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("broadcastURI", broadcastURI).add("gateway", gateway).add("IPAddress", IPAddress)
|
||||
.add("isDefault", isDefault).add("isolationURI", isolationURI).add("netmask", netmask).add("macAddress", macAddress)
|
||||
.add("networkId", networkId).add("trafficType", trafficType).add("guestIPType", guestIPType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NIC{" +
|
||||
"id=" + id +
|
||||
", broadcastURI=" + broadcastURI +
|
||||
", gateway='" + gateway + '\'' +
|
||||
", IPAddress='" + IPAddress + '\'' +
|
||||
", isDefault=" + isDefault +
|
||||
", isolationURI=" + isolationURI +
|
||||
", netmask='" + netmask + '\'' +
|
||||
", macAddress='" + macAddress + '\'' +
|
||||
", networkId=" + networkId +
|
||||
", trafficType=" + trafficType +
|
||||
", guestIPType=" + guestIPType +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,299 +20,339 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class NetworkOffering
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
*/
|
||||
public class NetworkOffering implements Comparable<NetworkOffering> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromNetworkOffering(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String name;
|
||||
private String displayText;
|
||||
private Date created;
|
||||
private NetworkOfferingAvailabilityType availability;
|
||||
private Integer maxConnections;
|
||||
private int networkRate;
|
||||
private boolean isDefault;
|
||||
private boolean supportsVLAN;
|
||||
private TrafficType trafficType;
|
||||
private GuestIPType guestIPType;
|
||||
private Set<String> tags = ImmutableSet.of();
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String displayText;
|
||||
protected Date created;
|
||||
protected NetworkOfferingAvailabilityType availability;
|
||||
protected Integer maxConnections;
|
||||
protected boolean isDefault;
|
||||
protected boolean supportsVLAN;
|
||||
protected TrafficType trafficType;
|
||||
protected GuestIPType guestIPType;
|
||||
protected int networkRate;
|
||||
protected String tags;
|
||||
|
||||
/**
|
||||
* @see NetworkOffering#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see NetworkOffering#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder displayText(String displayText) {
|
||||
/**
|
||||
* @see NetworkOffering#getDisplayText()
|
||||
*/
|
||||
public T displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder created(Date created) {
|
||||
/**
|
||||
* @see NetworkOffering#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder availability(NetworkOfferingAvailabilityType availability) {
|
||||
/**
|
||||
* @see NetworkOffering#getAvailability()
|
||||
*/
|
||||
public T availability(NetworkOfferingAvailabilityType availability) {
|
||||
this.availability = availability;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder maxConnections(Integer maxConnections) {
|
||||
/**
|
||||
* @see NetworkOffering#getMaxConnections()
|
||||
*/
|
||||
public T maxConnections(Integer maxConnections) {
|
||||
this.maxConnections = maxConnections;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder isDefault(boolean isDefault) {
|
||||
/**
|
||||
* @see NetworkOffering#isDefault()
|
||||
*/
|
||||
public T isDefault(boolean isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder networkRate(int networkRate) {
|
||||
this.networkRate = networkRate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder supportsVLAN(boolean supportsVLAN) {
|
||||
/**
|
||||
* @see NetworkOffering#supportsVLAN()
|
||||
*/
|
||||
public T supportsVLAN(boolean supportsVLAN) {
|
||||
this.supportsVLAN = supportsVLAN;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder trafficType(TrafficType trafficType) {
|
||||
/**
|
||||
* @see NetworkOffering#getTrafficType()
|
||||
*/
|
||||
public T trafficType(TrafficType trafficType) {
|
||||
this.trafficType = trafficType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder guestIPType(GuestIPType guestIPType) {
|
||||
/**
|
||||
* @see NetworkOffering#getGuestIPType()
|
||||
*/
|
||||
public T guestIPType(GuestIPType guestIPType) {
|
||||
this.guestIPType = guestIPType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder tags(Set<String> tags) {
|
||||
this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
|
||||
return this;
|
||||
/**
|
||||
* @see NetworkOffering#getNetworkRate()
|
||||
*/
|
||||
public T networkRate(int networkRate) {
|
||||
this.networkRate = networkRate;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NetworkOffering#getTags()
|
||||
*/
|
||||
public T tags(String tags) {
|
||||
this.tags = tags;
|
||||
return self();
|
||||
}
|
||||
|
||||
public NetworkOffering build() {
|
||||
return new NetworkOffering(id, name, displayText, created, availability, supportsVLAN, maxConnections,
|
||||
isDefault, trafficType, guestIPType, networkRate, tags);
|
||||
return new NetworkOffering(id, name, displayText, created, availability, maxConnections, isDefault, supportsVLAN, trafficType, guestIPType, networkRate, tags);
|
||||
}
|
||||
|
||||
public T fromNetworkOffering(NetworkOffering in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.displayText(in.getDisplayText())
|
||||
.created(in.getCreated())
|
||||
.availability(in.getAvailability())
|
||||
.maxConnections(in.getMaxConnections())
|
||||
.isDefault(in.isDefault())
|
||||
.supportsVLAN(in.supportsVLAN())
|
||||
.trafficType(in.getTrafficType())
|
||||
.guestIPType(in.getGuestIPType())
|
||||
.networkRate(in.getNetworkRate())
|
||||
.tags(in.getTags());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@SerializedName("displaytext")
|
||||
private String displayText;
|
||||
private Date created;
|
||||
@SerializedName("availability")
|
||||
private NetworkOfferingAvailabilityType availability;
|
||||
@SerializedName("maxconnections")
|
||||
private Integer maxConnections;
|
||||
@SerializedName("isdefault")
|
||||
private boolean isDefault;
|
||||
@SerializedName("specifyvlan")
|
||||
private boolean supportsVLAN;
|
||||
@SerializedName("traffictype")
|
||||
private TrafficType trafficType;
|
||||
@SerializedName("guestiptype")
|
||||
private GuestIPType guestIPType;
|
||||
@SerializedName("networkrate")
|
||||
private int networkRate = -1;
|
||||
private String tags;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkOffering(String id, String name, String displayText, @Nullable Date created,
|
||||
NetworkOfferingAvailabilityType availability, boolean supportsVLAN, @Nullable Integer maxConnections,
|
||||
boolean isDefault, TrafficType trafficType, GuestIPType guestIPType, int networkRate, Set<String> tags) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String name;
|
||||
@Named("displaytext")
|
||||
private final String displayText;
|
||||
private final Date created;
|
||||
private final NetworkOfferingAvailabilityType availability;
|
||||
@Named("maxconnections")
|
||||
private final Integer maxConnections;
|
||||
@Named("isdefault")
|
||||
private final boolean isDefault;
|
||||
@Named("specifyvlan")
|
||||
private final boolean supportsVLAN;
|
||||
@Named("traffictype")
|
||||
private final TrafficType trafficType;
|
||||
@Named("guestiptype")
|
||||
private final GuestIPType guestIPType;
|
||||
@Named("networkrate")
|
||||
private final int networkRate;
|
||||
private final String tags;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "displaytext", "created", "availability", "maxconnections", "isdefault", "specifyvlan", "traffictype", "guestiptype", "networkrate", "tags"
|
||||
})
|
||||
protected NetworkOffering(String id, @Nullable String name, @Nullable String displayText, @Nullable Date created, @Nullable NetworkOfferingAvailabilityType availability, @Nullable Integer maxConnections, boolean isDefault, boolean supportsVLAN, @Nullable TrafficType trafficType, @Nullable GuestIPType guestIPType, int networkRate, @Nullable String tags) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.created = created;
|
||||
this.availability = availability;
|
||||
this.supportsVLAN = supportsVLAN;
|
||||
this.maxConnections = maxConnections;
|
||||
this.isDefault = isDefault;
|
||||
this.supportsVLAN = supportsVLAN;
|
||||
this.trafficType = trafficType;
|
||||
this.guestIPType = guestIPType;
|
||||
this.networkRate = networkRate;
|
||||
this.tags = tags.size() == 0 ? null : Joiner.on(',').join(tags);
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*
|
||||
*/
|
||||
NetworkOffering() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the id of the network offering
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the name of the network offering
|
||||
*/
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an alternate display text of the network offering.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return this.displayText;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the date this network offering was created
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Availability name for the offering
|
||||
*/
|
||||
@Nullable
|
||||
public NetworkOfferingAvailabilityType getAvailability() {
|
||||
return availability;
|
||||
return this.availability;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if network offering supports vlans, false otherwise
|
||||
*/
|
||||
public boolean supportsVLAN() {
|
||||
return supportsVLAN;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the max number of concurrent connection the network offering
|
||||
* supports
|
||||
supports
|
||||
*/
|
||||
@Nullable
|
||||
public Integer getMaxConnections() {
|
||||
return maxConnections;
|
||||
return this.maxConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if network offering is default, false otherwise
|
||||
*/
|
||||
public boolean isDefault() {
|
||||
return isDefault;
|
||||
return this.isDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if network offering supports vlans, false otherwise
|
||||
*/
|
||||
public boolean supportsVLAN() {
|
||||
return this.supportsVLAN;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the traffic type for this network offering
|
||||
*/
|
||||
@Nullable
|
||||
public TrafficType getTrafficType() {
|
||||
return trafficType;
|
||||
return this.trafficType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the guest ip type for this network offering
|
||||
*/
|
||||
@Nullable
|
||||
public GuestIPType getGuestIPType() {
|
||||
return guestIPType;
|
||||
return this.guestIPType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return data transfer rate in megabits per second allowed.
|
||||
*/
|
||||
public int getNetworkRate() {
|
||||
return networkRate;
|
||||
return this.networkRate;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the tags for the network offering
|
||||
*/
|
||||
public Set<String> getTags() {
|
||||
return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet.<String> of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
NetworkOffering that = (NetworkOffering) o;
|
||||
|
||||
if (!Objects.equal(availability, that.availability)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(displayText, that.displayText)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(isDefault, that.isDefault)) return false;
|
||||
if (!Objects.equal(maxConnections, that.maxConnections)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(supportsVLAN, that.supportsVLAN)) return false;
|
||||
if (!Objects.equal(tags, that.tags)) return false;
|
||||
if (!Objects.equal(trafficType, that.trafficType)) return false;
|
||||
|
||||
return true;
|
||||
@Nullable
|
||||
public String getTags() {
|
||||
return this.tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(availability, created, displayText, id, isDefault, maxConnections, name, supportsVLAN, tags, trafficType);
|
||||
return Objects.hashCode(id, name, displayText, created, availability, maxConnections, isDefault, supportsVLAN, trafficType, guestIPType, networkRate, tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
NetworkOffering that = NetworkOffering.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.displayText, that.displayText)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.availability, that.availability)
|
||||
&& Objects.equal(this.maxConnections, that.maxConnections)
|
||||
&& Objects.equal(this.isDefault, that.isDefault)
|
||||
&& Objects.equal(this.supportsVLAN, that.supportsVLAN)
|
||||
&& Objects.equal(this.trafficType, that.trafficType)
|
||||
&& Objects.equal(this.guestIPType, that.guestIPType)
|
||||
&& Objects.equal(this.networkRate, that.networkRate)
|
||||
&& Objects.equal(this.tags, that.tags);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("displayText", displayText).add("created", created).add("availability", availability).add("maxConnections", maxConnections).add("isDefault", isDefault).add("supportsVLAN", supportsVLAN).add("trafficType", trafficType).add("guestIPType", guestIPType).add("networkRate", networkRate).add("tags", tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NetworkOffering{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", displayText='" + displayText + '\'' +
|
||||
", created=" + created +
|
||||
", availability=" + availability +
|
||||
", maxConnections=" + maxConnections +
|
||||
", isDefault=" + isDefault +
|
||||
", supportsVLAN=" + supportsVLAN +
|
||||
", trafficType=" + trafficType +
|
||||
", guestIPType=" + guestIPType +
|
||||
", networkRate=" + networkRate +
|
||||
", tags='" + tags + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NetworkOffering arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
public int compareTo(NetworkOffering o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,129 +20,229 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class NetworkService
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkService implements Comparable<NetworkService> {
|
||||
// internal only to match json type
|
||||
private static class Capability implements Comparable<Capability> {
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
|
||||
private Capability() {
|
||||
public static class Capability implements Comparable<Capability> {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
private Capability(String name, String value) {
|
||||
this.name = name;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromCapability(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String name;
|
||||
protected String value;
|
||||
|
||||
/**
|
||||
* @see Capability#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capability#getValue()
|
||||
*/
|
||||
public T value(String value) {
|
||||
this.value = value;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Capability build() {
|
||||
return new Capability(name, value);
|
||||
}
|
||||
|
||||
public T fromCapability(Capability in) {
|
||||
return this
|
||||
.name(in.getName())
|
||||
.value(in.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final String value;
|
||||
|
||||
@ConstructorProperties({
|
||||
"name", "value"
|
||||
})
|
||||
protected Capability(String name, @Nullable String value) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
NetworkService.Capability that = (NetworkService.Capability) o;
|
||||
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(value, that.value)) return false;
|
||||
|
||||
return true;
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, value);
|
||||
return Objects.hashCode(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Capability that = Capability.class.cast(obj);
|
||||
return Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.value, that.value);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("name", name).add("value", value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[name=" + name + ", value=" + value + "]";
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Capability o) {
|
||||
return name.compareTo(o.name);
|
||||
return name.compareTo(o.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromNetworkService(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String name;
|
||||
protected Set<Capability> capabilities = Sets.newHashSet();
|
||||
|
||||
/**
|
||||
* @see NetworkService#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NetworkService#getCapabilities()
|
||||
*/
|
||||
public T capabilities(Map<String, String> capabilities) {
|
||||
for (Map.Entry<String, String> entry : capabilities.entrySet()) {
|
||||
this.capabilities.add(Capability.builder().name(entry.getKey()).value(entry.getValue()).build());
|
||||
}
|
||||
return self();
|
||||
}
|
||||
|
||||
public NetworkService build() {
|
||||
return new NetworkService(name, capabilities);
|
||||
}
|
||||
|
||||
public T fromNetworkService(NetworkService in) {
|
||||
return this
|
||||
.name(in.getName())
|
||||
.capabilities(in.getCapabilities());
|
||||
}
|
||||
}
|
||||
|
||||
private String name;
|
||||
@SerializedName("capability")
|
||||
// so tests and serialization comes out expected
|
||||
private SortedSet<? extends NetworkService.Capability> capabilities = ImmutableSortedSet.of();
|
||||
|
||||
NetworkService() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkService(String name) {
|
||||
this(name, ImmutableMap.<String, String> of());
|
||||
}
|
||||
private final String name;
|
||||
@Named("capability")
|
||||
private final Set<Capability> capabilities;
|
||||
|
||||
public NetworkService(String name, Map<String, String> capabilities) {
|
||||
@ConstructorProperties({
|
||||
"name", "capability"
|
||||
})
|
||||
protected NetworkService(String name, @Nullable Set<Capability> capabilities) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
ImmutableSortedSet.Builder<Capability> internal = ImmutableSortedSet.naturalOrder();
|
||||
for (Entry<String, String> capabililty : checkNotNull(capabilities, "capabilities").entrySet())
|
||||
internal.add(new Capability(capabililty.getKey(), capabililty.getValue()));
|
||||
this.capabilities = internal.build();
|
||||
this.capabilities = capabilities == null ? ImmutableSet.<Capability>of() : ImmutableSortedSet.copyOf(capabilities);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Map<String, String> getCapabilities() {
|
||||
// so tests and serialization comes out expected
|
||||
Builder<String, String> returnVal = ImmutableSortedMap.naturalOrder();
|
||||
ImmutableSortedMap.Builder<String, String> returnVal = ImmutableSortedMap.naturalOrder();
|
||||
for (Capability capability : capabilities) {
|
||||
returnVal.put(capability.name, capability.value);
|
||||
}
|
||||
return returnVal.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
NetworkService that = (NetworkService) o;
|
||||
|
||||
if (!Objects.equal(capabilities, that.capabilities)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
|
||||
return true;
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, capabilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(capabilities, name);
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
NetworkService that = NetworkService.class.cast(obj);
|
||||
return Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.capabilities, that.capabilities);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).add("name", name).add("capabilities", capabilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NetworkService{" +
|
||||
"name='" + name + '\'' +
|
||||
", capabilities=" + capabilities +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(NetworkService o) {
|
||||
return name.compareTo(o.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,56 +18,92 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class OSType
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OSType implements Comparable<OSType> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String OSCategoryId;
|
||||
private String description;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromOSType(this);
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String OSCategoryId;
|
||||
protected String description;
|
||||
|
||||
/**
|
||||
* @see OSType#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder OSCategoryId(String OSCategoryId) {
|
||||
/**
|
||||
* @see OSType#getOSCategoryId()
|
||||
*/
|
||||
public T OSCategoryId(String OSCategoryId) {
|
||||
this.OSCategoryId = OSCategoryId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see OSType#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public OSType build() {
|
||||
return new OSType(id, OSCategoryId, description);
|
||||
}
|
||||
|
||||
public T fromOSType(OSType in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.OSCategoryId(in.getOSCategoryId())
|
||||
.description(in.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
// for deserialization
|
||||
OSType() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("oscategoryid")
|
||||
private String OSCategoryId;
|
||||
private String description;
|
||||
private final String id;
|
||||
@Named("oscategoryid")
|
||||
private final String OSCategoryId;
|
||||
private final String description;
|
||||
|
||||
public OSType(String id, String OSCategoryId, String description) {
|
||||
this.id = id;
|
||||
@ConstructorProperties({
|
||||
"id", "oscategoryid", "description"
|
||||
})
|
||||
protected OSType(String id, @Nullable String OSCategoryId, @Nullable String description) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.OSCategoryId = OSCategoryId;
|
||||
this.description = description;
|
||||
}
|
||||
|
@ -76,54 +112,51 @@ public class OSType implements Comparable<OSType> {
|
|||
* @return the ID of the OS type
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the OS category
|
||||
*/
|
||||
@Nullable
|
||||
public String getOSCategoryId() {
|
||||
return OSCategoryId;
|
||||
return this.OSCategoryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name/description of the OS type
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
OSType that = (OSType) o;
|
||||
|
||||
if (!Objects.equal(OSCategoryId, that.OSCategoryId)) return false;
|
||||
if (!Objects.equal(description, that.description)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
|
||||
return true;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(OSCategoryId, description, id);
|
||||
return Objects.hashCode(id, OSCategoryId, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
OSType that = OSType.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.OSCategoryId, that.OSCategoryId)
|
||||
&& Objects.equal(this.description, that.description);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).add("id", id).add("OSCategoryId", OSCategoryId).add("description", description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OSType{" +
|
||||
"id=" + id +
|
||||
", OSCategoryId=" + OSCategoryId +
|
||||
", description='" + description + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(OSType arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
public int compareTo(OSType o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,130 +18,162 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents a Pod in CloudStack.
|
||||
*
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
*/
|
||||
public class Pod implements Comparable<Pod> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromPod(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String zoneId;
|
||||
private String zoneName;
|
||||
private String gateway;
|
||||
private String netmask;
|
||||
private String startIp;
|
||||
private String endIp;
|
||||
private AllocationState allocationState;
|
||||
|
||||
private Builder() {}
|
||||
|
||||
/**
|
||||
* @param id the ID of the Pod
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String zoneId;
|
||||
protected String zoneName;
|
||||
protected String gateway;
|
||||
protected String netmask;
|
||||
protected String startIp;
|
||||
protected String endIp;
|
||||
protected AllocationState allocationState;
|
||||
|
||||
/**
|
||||
* @see Pod#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name of the Pod
|
||||
/**
|
||||
* @see Pod#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zoneId the Zone ID of the Pod
|
||||
/**
|
||||
* @see Pod#getZoneId()
|
||||
*/
|
||||
public Builder zoneId(String zoneId) {
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zoneName the Zone name of the Pod
|
||||
/**
|
||||
* @see Pod#getZoneName()
|
||||
*/
|
||||
public Builder zoneName(String zoneName) {
|
||||
public T zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gateway the gateway of the Pod
|
||||
/**
|
||||
* @see Pod#getGateway()
|
||||
*/
|
||||
public Builder gateway(String gateway) {
|
||||
public T gateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param netmask the netmask of the Pod
|
||||
/**
|
||||
* @see Pod#getNetmask()
|
||||
*/
|
||||
public Builder netmask(String netmask) {
|
||||
public T netmask(String netmask) {
|
||||
this.netmask = netmask;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param startIp the starting IP for the Pod
|
||||
/**
|
||||
* @see Pod#getStartIp()
|
||||
*/
|
||||
public Builder startIp(String startIp) {
|
||||
public T startIp(String startIp) {
|
||||
this.startIp = startIp;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param endIp the ending IP for the Pod
|
||||
/**
|
||||
* @see Pod#getEndIp()
|
||||
*/
|
||||
public Builder endIp(String endIp) {
|
||||
public T endIp(String endIp) {
|
||||
this.endIp = endIp;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allocationState the allocation state of the cluster
|
||||
/**
|
||||
* @see Pod#getAllocationState()
|
||||
*/
|
||||
public Builder allocationState(AllocationState allocationState) {
|
||||
public T allocationState(AllocationState allocationState) {
|
||||
this.allocationState = allocationState;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Pod object
|
||||
* @return the Pod object
|
||||
*/
|
||||
public Pod build() {
|
||||
return new Pod(id, name, zoneId, zoneName, gateway, netmask, startIp, endIp, allocationState);
|
||||
}
|
||||
|
||||
public T fromPod(Pod in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.zoneId(in.getZoneId())
|
||||
.zoneName(in.getZoneName())
|
||||
.gateway(in.getGateway())
|
||||
.netmask(in.getNetmask())
|
||||
.startIp(in.getStartIp())
|
||||
.endIp(in.getEndIp())
|
||||
.allocationState(in.getAllocationState());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@SerializedName("zoneid") private String zoneId;
|
||||
@SerializedName("zonename") private String zoneName;
|
||||
private String gateway;
|
||||
private String netmask;
|
||||
@SerializedName("startip") private String startIp;
|
||||
@SerializedName("endip") private String endIp;
|
||||
@SerializedName("allocationstate") private AllocationState allocationState;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/* Just for the serializer */
|
||||
Pod() {}
|
||||
private final String id;
|
||||
private final String name;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
@Named("zonename")
|
||||
private final String zoneName;
|
||||
private final String gateway;
|
||||
private final String netmask;
|
||||
@Named("startip")
|
||||
private final String startIp;
|
||||
@Named("endip")
|
||||
private final String endIp;
|
||||
@Named("allocationstate")
|
||||
private final AllocationState allocationState;
|
||||
|
||||
public Pod(String id, String name, String zoneId, String zoneName, String gateway, String netmask, String startIp, String endIp, AllocationState allocationState) {
|
||||
this.id = id;
|
||||
@ConstructorProperties({
|
||||
"id", "name", "zoneid", "zonename", "gateway", "netmask", "startip", "endip", "allocationstate"
|
||||
})
|
||||
protected Pod(String id, @Nullable String name, @Nullable String zoneId, @Nullable String zoneName, @Nullable String gateway, @Nullable String netmask, @Nullable String startIp, @Nullable String endIp, @Nullable AllocationState allocationState) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = name;
|
||||
this.zoneId = zoneId;
|
||||
this.zoneName = zoneName;
|
||||
|
@ -156,103 +188,102 @@ public class Pod implements Comparable<Pod> {
|
|||
* @return id the ID of the Pod
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name the name of the Pod
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return zoneId the Zone ID of the Pod
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return zoneName the Zone name of the Pod
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
return this.zoneName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return gateway the gateway of the Pod
|
||||
*/
|
||||
@Nullable
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
return this.gateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return netmask the netmask of the Pod
|
||||
*/
|
||||
@Nullable
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
return this.netmask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return startIp the starting IP for the Pod
|
||||
*/
|
||||
@Nullable
|
||||
public String getStartIp() {
|
||||
return startIp;
|
||||
return this.startIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return endIp the ending IP for the Pod
|
||||
*/
|
||||
@Nullable
|
||||
public String getEndIp() {
|
||||
return endIp;
|
||||
return this.endIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allocationState the allocation state of the cluster
|
||||
* @return the allocation state of the cluster
|
||||
*/
|
||||
@Nullable
|
||||
public AllocationState getAllocationState() {
|
||||
return allocationState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Pod that = (Pod) o;
|
||||
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(allocationState, that.allocationState)) return false;
|
||||
if (!Objects.equal(endIp, that.endIp)) return false;
|
||||
if (!Objects.equal(gateway, that.gateway)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(netmask, that.netmask)) return false;
|
||||
if (!Objects.equal(startIp, that.startIp)) return false;
|
||||
if (!Objects.equal(zoneName, that.zoneName)) return false;
|
||||
|
||||
return true;
|
||||
return this.allocationState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, zoneId, allocationState, endIp, gateway, name, netmask, startIp, zoneName);
|
||||
return Objects.hashCode(id, name, zoneId, zoneName, gateway, netmask, startIp, endIp, allocationState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Pod that = Pod.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.zoneName, that.zoneName)
|
||||
&& Objects.equal(this.gateway, that.gateway)
|
||||
&& Objects.equal(this.netmask, that.netmask)
|
||||
&& Objects.equal(this.startIp, that.startIp)
|
||||
&& Objects.equal(this.endIp, that.endIp)
|
||||
&& Objects.equal(this.allocationState, that.allocationState);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("zoneId", zoneId).add("zoneName", zoneName).add("gateway", gateway).add("netmask", netmask).add("startIp", startIp).add("endIp", endIp).add("allocationState", allocationState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pod{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", zoneId=" + zoneId +
|
||||
", zoneName='" + zoneName + '\'' +
|
||||
", gateway='" + gateway + '\'' +
|
||||
", netmask='" + netmask + '\'' +
|
||||
", startIp='" + startIp + '\'' +
|
||||
", endIp='" + endIp + '\'' +
|
||||
", allocationState=" + allocationState +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,16 +18,25 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class PortForwardingRule
|
||||
*
|
||||
* @author Adrian Cole, Andrei Savu
|
||||
*/
|
||||
*/
|
||||
public class PortForwardingRule implements Comparable<PortForwardingRule> {
|
||||
|
||||
public static enum Protocol {
|
||||
|
@ -73,126 +82,204 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
|
|||
}
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromPortForwardingRule(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String IPAddress;
|
||||
private String IPAddressId;
|
||||
private int privatePort;
|
||||
private Protocol protocol;
|
||||
public int publicPort;
|
||||
private State state;
|
||||
private String virtualMachineDisplayName;
|
||||
public String virtualMachineId;
|
||||
private String virtualMachineName;
|
||||
private Set<String> CIDRs = ImmutableSet.of();
|
||||
private int privateEndPort;
|
||||
private int publicEndPort;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String IPAddress;
|
||||
protected String IPAddressId;
|
||||
protected int privatePort;
|
||||
protected Protocol protocol;
|
||||
protected int publicPort;
|
||||
protected State state;
|
||||
protected String virtualMachineDisplayName;
|
||||
protected String virtualMachineId;
|
||||
protected String virtualMachineName;
|
||||
protected Set<String> CIDRs = ImmutableSet.of();
|
||||
protected int privateEndPort;
|
||||
protected int publicEndPort;
|
||||
|
||||
/**
|
||||
* @see PortForwardingRule#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder IPAddress(String IPAddress) {
|
||||
/**
|
||||
* @see PortForwardingRule#getIPAddress()
|
||||
*/
|
||||
public T IPAddress(String IPAddress) {
|
||||
this.IPAddress = IPAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder IPAddressId(String IPAddressId) {
|
||||
/**
|
||||
* @see PortForwardingRule#getIPAddressId()
|
||||
*/
|
||||
public T IPAddressId(String IPAddressId) {
|
||||
this.IPAddressId = IPAddressId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder privatePort(int privatePort) {
|
||||
/**
|
||||
* @see PortForwardingRule#getPrivatePort()
|
||||
*/
|
||||
public T privatePort(int privatePort) {
|
||||
this.privatePort = privatePort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder protocol(Protocol protocol) {
|
||||
/**
|
||||
* @see PortForwardingRule#getProtocol()
|
||||
*/
|
||||
public T protocol(Protocol protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder publicPort(int publicPort) {
|
||||
/**
|
||||
* @see PortForwardingRule#getPublicPort()
|
||||
*/
|
||||
public T publicPort(int publicPort) {
|
||||
this.publicPort = publicPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(State state) {
|
||||
/**
|
||||
* @see PortForwardingRule#getState()
|
||||
*/
|
||||
public T state(State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineDisplayName(String virtualMachineDisplayName) {
|
||||
/**
|
||||
* @see PortForwardingRule#getVirtualMachineDisplayName()
|
||||
*/
|
||||
public T virtualMachineDisplayName(String virtualMachineDisplayName) {
|
||||
this.virtualMachineDisplayName = virtualMachineDisplayName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineId(String virtualMachineId) {
|
||||
/**
|
||||
* @see PortForwardingRule#getVirtualMachineId()
|
||||
*/
|
||||
public T virtualMachineId(String virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineName(String virtualMachineName) {
|
||||
/**
|
||||
* @see PortForwardingRule#getVirtualMachineName()
|
||||
*/
|
||||
public T virtualMachineName(String virtualMachineName) {
|
||||
this.virtualMachineName = virtualMachineName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder CIDRs(Set<String> CIDRs) {
|
||||
this.CIDRs = CIDRs;
|
||||
return this;
|
||||
/**
|
||||
* @see PortForwardingRule#getCIDRs()
|
||||
*/
|
||||
public T CIDRs(Set<String> CIDRs) {
|
||||
this.CIDRs = ImmutableSet.copyOf(checkNotNull(CIDRs, "CIDRs"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder privateEndPort(int privateEndPort) {
|
||||
public T CIDRs(String... in) {
|
||||
return CIDRs(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PortForwardingRule#getPrivateEndPort()
|
||||
*/
|
||||
public T privateEndPort(int privateEndPort) {
|
||||
this.privateEndPort = privateEndPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder publicEndPort(int publicEndPort) {
|
||||
/**
|
||||
* @see PortForwardingRule#getPublicEndPort()
|
||||
*/
|
||||
public T publicEndPort(int publicEndPort) {
|
||||
this.publicEndPort = publicEndPort;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public PortForwardingRule build() {
|
||||
return new PortForwardingRule(id, IPAddress, IPAddressId, privatePort, protocol, publicPort, state,
|
||||
virtualMachineDisplayName, virtualMachineId, virtualMachineName, CIDRs, privateEndPort, publicEndPort);
|
||||
return new PortForwardingRule(id, IPAddress, IPAddressId, privatePort, protocol, publicPort, state, virtualMachineDisplayName,
|
||||
virtualMachineId, virtualMachineName, CIDRs, privateEndPort, publicEndPort);
|
||||
}
|
||||
|
||||
public T fromPortForwardingRule(PortForwardingRule in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.IPAddress(in.getIPAddress())
|
||||
.IPAddressId(in.getIPAddressId())
|
||||
.privatePort(in.getPrivatePort())
|
||||
.protocol(in.getProtocol())
|
||||
.publicPort(in.getPublicPort())
|
||||
.state(in.getState())
|
||||
.virtualMachineDisplayName(in.getVirtualMachineDisplayName())
|
||||
.virtualMachineId(in.getVirtualMachineId())
|
||||
.virtualMachineName(in.getVirtualMachineName())
|
||||
.CIDRs(in.getCIDRs())
|
||||
.privateEndPort(in.getPrivateEndPort())
|
||||
.publicEndPort(in.getPublicEndPort());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("ipaddress")
|
||||
private String IPAddress;
|
||||
@SerializedName("ipaddressid")
|
||||
private String IPAddressId;
|
||||
@SerializedName("privateport")
|
||||
private int privatePort;
|
||||
private Protocol protocol;
|
||||
@SerializedName("publicport")
|
||||
public int publicPort;
|
||||
private State state;
|
||||
@SerializedName("virtualmachinedisplayname")
|
||||
private String virtualMachineDisplayName;
|
||||
@SerializedName("virtualmachineid")
|
||||
public String virtualMachineId;
|
||||
@SerializedName("virtualmachinename")
|
||||
private String virtualMachineName;
|
||||
@SerializedName("cidrlist")
|
||||
private Set<String> CIDRs;
|
||||
@SerializedName("privateendport")
|
||||
private int privateEndPort;
|
||||
@SerializedName("publicendport")
|
||||
private int publicEndPort;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public PortForwardingRule(String id, String iPAddress, String iPAddressId, int privatePort, Protocol protocol,
|
||||
int publicPort, State state, String virtualMachineDisplayName, String virtualMachineId,
|
||||
String virtualMachineName, Set<String> CIDRs, int privateEndPort, int publicEndPort) {
|
||||
this.id = id;
|
||||
this.IPAddress = iPAddress;
|
||||
this.IPAddressId = iPAddressId;
|
||||
private final String id;
|
||||
@Named("ipaddress")
|
||||
private final String IPAddress;
|
||||
@Named("ipaddressid")
|
||||
private final String IPAddressId;
|
||||
@Named("privateport")
|
||||
private final int privatePort;
|
||||
private final PortForwardingRule.Protocol protocol;
|
||||
@Named("publicport")
|
||||
private final int publicPort;
|
||||
private final PortForwardingRule.State state;
|
||||
@Named("virtualmachinedisplayname")
|
||||
private final String virtualMachineDisplayName;
|
||||
@Named("virtualmachineid")
|
||||
private final String virtualMachineId;
|
||||
@Named("virtualmachinename")
|
||||
private final String virtualMachineName;
|
||||
@Named("cidrlist")
|
||||
private final Set<String> CIDRs;
|
||||
@Named("privateendport")
|
||||
private final int privateEndPort;
|
||||
@Named("publicendport")
|
||||
private final int publicEndPort;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "ipaddress", "ipaddressid", "privateport", "protocol", "publicport", "state", "virtualmachinedisplayname",
|
||||
"virtualmachineid", "virtualmachinename", "cidrlist", "privateendport", "publicendport"
|
||||
})
|
||||
protected PortForwardingRule(String id, @Nullable String IPAddress, @Nullable String IPAddressId, int privatePort,
|
||||
@Nullable Protocol protocol, int publicPort, @Nullable State state,
|
||||
@Nullable String virtualMachineDisplayName, @Nullable String virtualMachineId,
|
||||
@Nullable String virtualMachineName, @Nullable Set<String> CIDRs, int privateEndPort, int publicEndPort) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.IPAddress = IPAddress;
|
||||
this.IPAddressId = IPAddressId;
|
||||
this.privatePort = privatePort;
|
||||
this.protocol = protocol;
|
||||
this.publicPort = publicPort;
|
||||
|
@ -200,150 +287,149 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
|
|||
this.virtualMachineDisplayName = virtualMachineDisplayName;
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
this.virtualMachineName = virtualMachineName;
|
||||
this.CIDRs = CIDRs;
|
||||
this.CIDRs = CIDRs == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(CIDRs);
|
||||
this.privateEndPort = privateEndPort;
|
||||
this.publicEndPort = publicEndPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PortForwardingRule arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the port forwarding rule
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public ip address for the port forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getIPAddress() {
|
||||
return IPAddress;
|
||||
return this.IPAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public ip address id for the port forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getIPAddressId() {
|
||||
return IPAddressId;
|
||||
return this.IPAddressId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the private port for the port forwarding rule
|
||||
*/
|
||||
public int getPrivatePort() {
|
||||
return privatePort;
|
||||
return this.privatePort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the protocol of the port forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public Protocol getProtocol() {
|
||||
return protocol;
|
||||
return this.protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the public port for the port forwarding rule
|
||||
*/
|
||||
public int getPublicPort() {
|
||||
return publicPort;
|
||||
return this.publicPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the rule
|
||||
*/
|
||||
@Nullable
|
||||
public State getState() {
|
||||
return state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VM display name for the port forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineDisplayName() {
|
||||
return virtualMachineDisplayName;
|
||||
return this.virtualMachineDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VM ID for the port forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
return this.virtualMachineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VM name for the port forwarding rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineName() {
|
||||
return virtualMachineName;
|
||||
return this.virtualMachineName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cidr list to forward traffic from
|
||||
*/
|
||||
public Set<String> getCIDRs() {
|
||||
return CIDRs;
|
||||
return this.CIDRs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the starting port of port forwarding rule's private port range
|
||||
*/
|
||||
public int getPrivateEndPort() {
|
||||
return privateEndPort;
|
||||
return this.privateEndPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the starting port of port forwarding rule's public port range
|
||||
*/
|
||||
public int getPublicEndPort() {
|
||||
return publicEndPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PortForwardingRule that = (PortForwardingRule) o;
|
||||
|
||||
if (!Objects.equal(IPAddress, that.IPAddress)) return false;
|
||||
if (!Objects.equal(IPAddressId, that.IPAddressId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(privatePort, that.privatePort)) return false;
|
||||
if (!Objects.equal(protocol, that.protocol)) return false;
|
||||
if (!Objects.equal(publicPort, that.publicPort)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false;
|
||||
if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false;
|
||||
if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false;
|
||||
|
||||
return true;
|
||||
return this.publicEndPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(IPAddress, IPAddressId, id, privatePort, protocol, publicPort, state, virtualMachineDisplayName, virtualMachineId, virtualMachineName);
|
||||
return Objects.hashCode(id, IPAddress, IPAddressId, privatePort, protocol, publicPort, state, virtualMachineDisplayName, virtualMachineId, virtualMachineName, CIDRs, privateEndPort, publicEndPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
PortForwardingRule that = PortForwardingRule.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.IPAddress, that.IPAddress)
|
||||
&& Objects.equal(this.IPAddressId, that.IPAddressId)
|
||||
&& Objects.equal(this.privatePort, that.privatePort)
|
||||
&& Objects.equal(this.protocol, that.protocol)
|
||||
&& Objects.equal(this.publicPort, that.publicPort)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.virtualMachineDisplayName, that.virtualMachineDisplayName)
|
||||
&& Objects.equal(this.virtualMachineId, that.virtualMachineId)
|
||||
&& Objects.equal(this.virtualMachineName, that.virtualMachineName)
|
||||
&& Objects.equal(this.CIDRs, that.CIDRs)
|
||||
&& Objects.equal(this.privateEndPort, that.privateEndPort)
|
||||
&& Objects.equal(this.publicEndPort, that.publicEndPort);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("IPAddress", IPAddress).add("IPAddressId", IPAddressId).add("privatePort", privatePort)
|
||||
.add("protocol", protocol).add("publicPort", publicPort).add("state", state).add("virtualMachineDisplayName", virtualMachineDisplayName)
|
||||
.add("virtualMachineId", virtualMachineId).add("virtualMachineName", virtualMachineName).add("CIDRs", CIDRs)
|
||||
.add("privateEndPort", privateEndPort).add("publicEndPort", publicEndPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PortForwardingRule{" +
|
||||
"id=" + id +
|
||||
", IPAddress='" + IPAddress + '\'' +
|
||||
", IPAddressId=" + IPAddressId +
|
||||
", privatePort=" + privatePort +
|
||||
", protocol='" + protocol + '\'' +
|
||||
", publicPort=" + publicPort +
|
||||
", state='" + state + '\'' +
|
||||
", virtualMachineDisplayName='" + virtualMachineDisplayName + '\'' +
|
||||
", virtualMachineId=" + virtualMachineId +
|
||||
", virtualMachineName='" + virtualMachineName + '\'' +
|
||||
", CIDRs=" + getCIDRs() +
|
||||
", privateEndPort=" + privateEndPort +
|
||||
", publicEndPort=" + publicEndPort +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PortForwardingRule o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,234 +20,339 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class PublicIPAddress
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class PublicIPAddress implements Comparable<PublicIPAddress> {
|
||||
*/
|
||||
public class PublicIPAddress {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
/**
|
||||
*/
|
||||
public static enum State {
|
||||
ALLOCATING, ALLOCATED, RELEASING, UNRECOGNIZED;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||
}
|
||||
|
||||
public static State fromValue(String state) {
|
||||
try {
|
||||
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String account;
|
||||
private Date allocated;
|
||||
private String associatedNetworkId;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private boolean usesVirtualNetwork;
|
||||
private String IPAddress;
|
||||
private boolean isSourceNAT;
|
||||
private boolean isStaticNAT;
|
||||
private String networkId;
|
||||
private State state;
|
||||
private String virtualMachineDisplayName;
|
||||
private String virtualMachineId;
|
||||
private String virtualMachineName;
|
||||
private String VLANId;
|
||||
private String VLANName;
|
||||
private String zoneId;
|
||||
private String zoneName;
|
||||
private String jobId;
|
||||
private Integer jobStatus;
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromPublicIPAddress(this);
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String account;
|
||||
protected Date allocated;
|
||||
protected String associatedNetworkId;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected boolean usesVirtualNetwork;
|
||||
protected String IPAddress;
|
||||
protected boolean isSourceNAT;
|
||||
protected boolean isStaticNAT;
|
||||
protected String networkId;
|
||||
protected PublicIPAddress.State state;
|
||||
protected String virtualMachineDisplayName;
|
||||
protected String virtualMachineId;
|
||||
protected String virtualMachineName;
|
||||
protected String VLANId;
|
||||
protected String VLANName;
|
||||
protected String zoneId;
|
||||
protected String zoneName;
|
||||
protected String jobId;
|
||||
protected Integer jobStatus;
|
||||
|
||||
/**
|
||||
* @see PublicIPAddress#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
/**
|
||||
* @see PublicIPAddress#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder allocated(Date allocated) {
|
||||
/**
|
||||
* @see PublicIPAddress#getAllocated()
|
||||
*/
|
||||
public T allocated(Date allocated) {
|
||||
this.allocated = allocated;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder associatedNetworkId(String associatedNetworkId) {
|
||||
/**
|
||||
* @see PublicIPAddress#getAssociatedNetworkId()
|
||||
*/
|
||||
public T associatedNetworkId(String associatedNetworkId) {
|
||||
this.associatedNetworkId = associatedNetworkId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see PublicIPAddress#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see PublicIPAddress#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder usesVirtualNetwork(boolean usesVirtualNetwork) {
|
||||
/**
|
||||
* @see PublicIPAddress#isUsesVirtualNetwork()
|
||||
*/
|
||||
public T usesVirtualNetwork(boolean usesVirtualNetwork) {
|
||||
this.usesVirtualNetwork = usesVirtualNetwork;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder IPAddress(String IPAddress) {
|
||||
/**
|
||||
* @see PublicIPAddress#getIPAddress()
|
||||
*/
|
||||
public T IPAddress(String IPAddress) {
|
||||
this.IPAddress = IPAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder isSourceNAT(boolean isSourceNAT) {
|
||||
/**
|
||||
* @see PublicIPAddress#isSourceNAT()
|
||||
*/
|
||||
public T isSourceNAT(boolean isSourceNAT) {
|
||||
this.isSourceNAT = isSourceNAT;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder isStaticNAT(boolean isStaticNAT) {
|
||||
/**
|
||||
* @see PublicIPAddress#isStaticNAT()
|
||||
*/
|
||||
public T isStaticNAT(boolean isStaticNAT) {
|
||||
this.isStaticNAT = isStaticNAT;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder networkId(String networkId) {
|
||||
/**
|
||||
* @see PublicIPAddress#getNetworkId()
|
||||
*/
|
||||
public T networkId(String networkId) {
|
||||
this.networkId = networkId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(State state) {
|
||||
/**
|
||||
* @see PublicIPAddress#getState()
|
||||
*/
|
||||
public T state(PublicIPAddress.State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineDisplayName(String virtualMachineDisplayName) {
|
||||
/**
|
||||
* @see PublicIPAddress#getVirtualMachineDisplayName()
|
||||
*/
|
||||
public T virtualMachineDisplayName(String virtualMachineDisplayName) {
|
||||
this.virtualMachineDisplayName = virtualMachineDisplayName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineId(String virtualMachineId) {
|
||||
/**
|
||||
* @see PublicIPAddress#getVirtualMachineId()
|
||||
*/
|
||||
public T virtualMachineId(String virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineName(String virtualMachineName) {
|
||||
/**
|
||||
* @see PublicIPAddress#getVirtualMachineName()
|
||||
*/
|
||||
public T virtualMachineName(String virtualMachineName) {
|
||||
this.virtualMachineName = virtualMachineName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder VLANId(String VLANId) {
|
||||
/**
|
||||
* @see PublicIPAddress#getVLANId()
|
||||
*/
|
||||
public T VLANId(String VLANId) {
|
||||
this.VLANId = VLANId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder VLANName(String VLANName) {
|
||||
/**
|
||||
* @see PublicIPAddress#getVLANName()
|
||||
*/
|
||||
public T VLANName(String VLANName) {
|
||||
this.VLANName = VLANName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneId(String zoneId) {
|
||||
/**
|
||||
* @see PublicIPAddress#getZoneId()
|
||||
*/
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneName(String zoneName) {
|
||||
/**
|
||||
* @see PublicIPAddress#getZoneName()
|
||||
*/
|
||||
public T zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder jobId(String jobId) {
|
||||
/**
|
||||
* @see PublicIPAddress#getJobId()
|
||||
*/
|
||||
public T jobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder jobStatus(int jobStatus) {
|
||||
/**
|
||||
* @see PublicIPAddress#getJobStatus()
|
||||
*/
|
||||
public T jobStatus(Integer jobStatus) {
|
||||
this.jobStatus = jobStatus;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public PublicIPAddress build() {
|
||||
return new PublicIPAddress(id, account, allocated, associatedNetworkId, domain, domainId, usesVirtualNetwork,
|
||||
IPAddress, isSourceNAT, isStaticNAT, networkId, state, virtualMachineDisplayName, virtualMachineId,
|
||||
virtualMachineName, VLANId, VLANName, zoneId, zoneName, jobId, jobStatus);
|
||||
return new PublicIPAddress(id, account, allocated, associatedNetworkId, domain, domainId, usesVirtualNetwork, IPAddress, isSourceNAT, isStaticNAT, networkId, state, virtualMachineDisplayName, virtualMachineId, virtualMachineName, VLANId, VLANName, zoneId, zoneName, jobId, jobStatus);
|
||||
}
|
||||
|
||||
public T fromPublicIPAddress(PublicIPAddress in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.account(in.getAccount())
|
||||
.allocated(in.getAllocated())
|
||||
.associatedNetworkId(in.getAssociatedNetworkId())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.usesVirtualNetwork(in.isUsesVirtualNetwork())
|
||||
.IPAddress(in.getIPAddress())
|
||||
.isSourceNAT(in.isSourceNAT())
|
||||
.isStaticNAT(in.isStaticNAT())
|
||||
.networkId(in.getNetworkId())
|
||||
.state(in.getState())
|
||||
.virtualMachineDisplayName(in.getVirtualMachineDisplayName())
|
||||
.virtualMachineId(in.getVirtualMachineId())
|
||||
.virtualMachineName(in.getVirtualMachineName())
|
||||
.VLANId(in.getVLANId())
|
||||
.VLANName(in.getVLANName())
|
||||
.zoneId(in.getZoneId())
|
||||
.zoneName(in.getZoneName())
|
||||
.jobId(in.getJobId())
|
||||
.jobStatus(in.getJobStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private Date allocated;
|
||||
@SerializedName("associatednetworkid")
|
||||
private String associatedNetworkId;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("forvirtualnetwork")
|
||||
private boolean usesVirtualNetwork;
|
||||
@SerializedName("ipaddress")
|
||||
private String IPAddress;
|
||||
@SerializedName("issourcenat")
|
||||
private boolean isSourceNAT;
|
||||
@SerializedName("isstaticnat")
|
||||
private boolean isStaticNAT;
|
||||
@SerializedName("networkid")
|
||||
private String networkId;
|
||||
private State state;
|
||||
@SerializedName("virtualmachinedisplayname")
|
||||
private String virtualMachineDisplayName;
|
||||
@SerializedName("virtualmachineid")
|
||||
private String virtualMachineId;
|
||||
@SerializedName("virtualmachinename")
|
||||
private String virtualMachineName;
|
||||
@SerializedName("VLANid")
|
||||
private String VLANId;
|
||||
@SerializedName("VLANname")
|
||||
private String VLANName;
|
||||
@SerializedName("zoneid")
|
||||
private String zoneId;
|
||||
@SerializedName("zonename")
|
||||
private String zoneName;
|
||||
@SerializedName("jobid")
|
||||
@Nullable
|
||||
private String jobId;
|
||||
@SerializedName("jobstatus")
|
||||
@Nullable
|
||||
private Integer jobStatus;
|
||||
|
||||
public static enum State {
|
||||
ALLOCATING, ALLOCATED, RELEASING, UNRECOGNIZED;
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
public String toString() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static State fromValue(String state) {
|
||||
try {
|
||||
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// for serialization
|
||||
PublicIPAddress() {
|
||||
private final String id;
|
||||
private final String account;
|
||||
private final Date allocated;
|
||||
@Named("associatednetworkid")
|
||||
private final String associatedNetworkId;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("forvirtualnetwork")
|
||||
private final boolean usesVirtualNetwork;
|
||||
@Named("ipaddress")
|
||||
private final String IPAddress;
|
||||
@Named("issourcenat")
|
||||
private final boolean isSourceNAT;
|
||||
@Named("isstaticnat")
|
||||
private final boolean isStaticNAT;
|
||||
@Named("networkid")
|
||||
private final String networkId;
|
||||
private final PublicIPAddress.State state;
|
||||
@Named("virtualmachinedisplayname")
|
||||
private final String virtualMachineDisplayName;
|
||||
@Named("virtualmachineid")
|
||||
private final String virtualMachineId;
|
||||
@Named("virtualmachinename")
|
||||
private final String virtualMachineName;
|
||||
@Named("VLANid")
|
||||
private final String VLANId;
|
||||
@Named("VLANname")
|
||||
private final String VLANName;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
@Named("zonename")
|
||||
private final String zoneName;
|
||||
@Named("jobid")
|
||||
private final String jobId;
|
||||
@Named("jobstatus")
|
||||
private final Integer jobStatus;
|
||||
|
||||
}
|
||||
|
||||
public PublicIPAddress(String id, String account, Date allocated, String associatedNetworkId, String domain,
|
||||
String domainId, boolean usesVirtualNetwork, String iPAddress, boolean isSourceNAT, boolean isStaticNAT,
|
||||
String networkId, State state, String virtualMachineDisplayName, String virtualMachineId,
|
||||
String virtualMachineName, String VLANId, String VLANName, String zoneId, String zoneName, String jobId,
|
||||
Integer jobStatus) {
|
||||
this.id = id;
|
||||
@ConstructorProperties({
|
||||
"id", "account", "allocated", "associatednetworkid", "domain", "domainid", "forvirtualnetwork", "ipaddress", "issourcenat",
|
||||
"isstaticnat", "networkid", "state", "virtualmachinedisplayname", "virtualmachineid", "virtualmachinename", "VLANid",
|
||||
"VLANname", "zoneid", "zonename", "jobid", "jobstatus"
|
||||
})
|
||||
protected PublicIPAddress(String id, @Nullable String account, @Nullable Date allocated, @Nullable String associatedNetworkId,
|
||||
@Nullable String domain, @Nullable String domainId, boolean usesVirtualNetwork, @Nullable String IPAddress,
|
||||
boolean isSourceNAT, boolean isStaticNAT, @Nullable String networkId, @Nullable PublicIPAddress.State state,
|
||||
@Nullable String virtualMachineDisplayName, @Nullable String virtualMachineId, @Nullable String virtualMachineName,
|
||||
@Nullable String VLANId, @Nullable String VLANName, @Nullable String zoneId, @Nullable String zoneName,
|
||||
@Nullable String jobId, @Nullable Integer jobStatus) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.account = account;
|
||||
this.allocated = allocated;
|
||||
this.associatedNetworkId = associatedNetworkId;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.usesVirtualNetwork = usesVirtualNetwork;
|
||||
this.IPAddress = iPAddress;
|
||||
this.IPAddress = IPAddress;
|
||||
this.isSourceNAT = isSourceNAT;
|
||||
this.isStaticNAT = isStaticNAT;
|
||||
this.networkId = networkId;
|
||||
|
@ -261,43 +366,168 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
|
|||
this.zoneName = zoneName;
|
||||
this.jobId = jobId;
|
||||
this.jobStatus = jobStatus;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PublicIPAddress arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return public IP address id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account the public IP address is associated with
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return date the public IP address was acquired
|
||||
*/
|
||||
@Nullable
|
||||
public Date getAllocated() {
|
||||
return allocated;
|
||||
return this.allocated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the Network associated with the IP address
|
||||
*/
|
||||
@Nullable
|
||||
public String getAssociatedNetworkId() {
|
||||
return this.associatedNetworkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain the public IP address is associated with
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain ID the public IP address is associated with
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return uses virtual network
|
||||
*/
|
||||
public boolean isUsesVirtualNetwork() {
|
||||
return this.usesVirtualNetwork;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return public IP address
|
||||
*/
|
||||
@Nullable
|
||||
public String getIPAddress() {
|
||||
return this.IPAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the IP address is a source nat address, false otherwise
|
||||
*/
|
||||
public boolean isSourceNAT() {
|
||||
return this.isSourceNAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this ip is for static nat, false otherwise
|
||||
*/
|
||||
public boolean isStaticNAT() {
|
||||
return this.isStaticNAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the Network where ip belongs to
|
||||
*/
|
||||
@Nullable
|
||||
public String getNetworkId() {
|
||||
return this.networkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return State of the ip address. Can be: Allocating, Allocated and
|
||||
Releasing
|
||||
*/
|
||||
@Nullable
|
||||
public PublicIPAddress.State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return virtual machine display name the ip address is assigned to (not
|
||||
null only for static nat Ip)
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineDisplayName() {
|
||||
return this.virtualMachineDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return virtual machine id the ip address is assigned to (not null only
|
||||
for static nat Ip)
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineId() {
|
||||
return this.virtualMachineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return virtual machine name the ip address is assigned to (not null only
|
||||
for static nat Ip)
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineName() {
|
||||
return this.virtualMachineName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the VLAN associated with the IP address
|
||||
*/
|
||||
@Nullable
|
||||
public String getVLANId() {
|
||||
return this.VLANId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VLAN associated with the IP address
|
||||
*/
|
||||
@Nullable
|
||||
public String getVLANName() {
|
||||
return this.VLANName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the zone the public IP address belongs to
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the zone the public IP address belongs to
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneName() {
|
||||
return this.zoneName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return shows the current pending asynchronous job ID. This tag is not
|
||||
* returned if no current pending jobs are acting on the virtual
|
||||
* machine
|
||||
returned if no current pending jobs are acting on the virtual
|
||||
machine
|
||||
*/
|
||||
@Nullable
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
return this.jobId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -305,190 +535,55 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
|
|||
*/
|
||||
@Nullable
|
||||
public Integer getJobStatus() {
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the ID of the Network associated with the IP address
|
||||
*/
|
||||
public String getAssociatedNetworkId() {
|
||||
return associatedNetworkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain the public IP address is associated with
|
||||
*/
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain ID the public IP address is associated with
|
||||
*/
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return uses virtual network
|
||||
*/
|
||||
public boolean usesVirtualNetwork() {
|
||||
return usesVirtualNetwork;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return public IP address
|
||||
*/
|
||||
public String getIPAddress() {
|
||||
return IPAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the IP address is a source nat address, false otherwise
|
||||
*/
|
||||
public boolean isSourceNAT() {
|
||||
return isSourceNAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this ip is for static nat, false otherwise
|
||||
*/
|
||||
public boolean isStaticNAT() {
|
||||
return isStaticNAT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the Network where ip belongs to
|
||||
*/
|
||||
public String getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return State of the ip address. Can be: Allocating, Allocated and
|
||||
* Releasing
|
||||
*/
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return virtual machine display name the ip address is assigned to (not
|
||||
* null only for static nat Ip)
|
||||
*/
|
||||
public String getVirtualMachineDisplayName() {
|
||||
return virtualMachineDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return virtual machine id the ip address is assigned to (not null only
|
||||
* for static nat Ip)
|
||||
*/
|
||||
public String getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return virtual machine name the ip address is assigned to (not null only
|
||||
* for static nat Ip)
|
||||
*/
|
||||
public String getVirtualMachineName() {
|
||||
return virtualMachineName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the VLAN associated with the IP address
|
||||
*/
|
||||
public String getVLANId() {
|
||||
return VLANId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VLAN associated with the IP address
|
||||
*/
|
||||
public String getVLANName() {
|
||||
return VLANName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the zone the public IP address belongs to
|
||||
*/
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the zone the public IP address belongs to
|
||||
*/
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PublicIPAddress that = (PublicIPAddress) o;
|
||||
|
||||
if (!Objects.equal(IPAddress, that.IPAddress)) return false;
|
||||
if (!Objects.equal(VLANId, that.VLANId)) return false;
|
||||
if (!Objects.equal(VLANName, that.VLANName)) return false;
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(allocated, that.allocated)) return false;
|
||||
if (!Objects.equal(associatedNetworkId, that.associatedNetworkId)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(isSourceNAT, that.isSourceNAT)) return false;
|
||||
if (!Objects.equal(isStaticNAT, that.isStaticNAT)) return false;
|
||||
if (!Objects.equal(networkId, that.networkId)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
if (!Objects.equal(usesVirtualNetwork, that.usesVirtualNetwork)) return false;
|
||||
if (!Objects.equal(virtualMachineDisplayName, that.virtualMachineDisplayName)) return false;
|
||||
if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false;
|
||||
if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(zoneName, that.zoneName)) return false;
|
||||
if (!Objects.equal(jobStatus, that.jobStatus)) return false;
|
||||
|
||||
return true;
|
||||
return this.jobStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(IPAddress, VLANId, VLANName, account, allocated, associatedNetworkId,
|
||||
domain, domainId, id, isSourceNAT, isStaticNAT, networkId, state,
|
||||
usesVirtualNetwork, virtualMachineDisplayName, virtualMachineId,
|
||||
virtualMachineName, zoneId, zoneName, jobStatus);
|
||||
return Objects.hashCode(id, account, allocated, associatedNetworkId, domain, domainId, usesVirtualNetwork, IPAddress, isSourceNAT, isStaticNAT, networkId, state, virtualMachineDisplayName, virtualMachineId, virtualMachineName, VLANId, VLANName, zoneId, zoneName, jobId, jobStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
PublicIPAddress that = PublicIPAddress.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.allocated, that.allocated)
|
||||
&& Objects.equal(this.associatedNetworkId, that.associatedNetworkId)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.usesVirtualNetwork, that.usesVirtualNetwork)
|
||||
&& Objects.equal(this.IPAddress, that.IPAddress)
|
||||
&& Objects.equal(this.isSourceNAT, that.isSourceNAT)
|
||||
&& Objects.equal(this.isStaticNAT, that.isStaticNAT)
|
||||
&& Objects.equal(this.networkId, that.networkId)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.virtualMachineDisplayName, that.virtualMachineDisplayName)
|
||||
&& Objects.equal(this.virtualMachineId, that.virtualMachineId)
|
||||
&& Objects.equal(this.virtualMachineName, that.virtualMachineName)
|
||||
&& Objects.equal(this.VLANId, that.VLANId)
|
||||
&& Objects.equal(this.VLANName, that.VLANName)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.zoneName, that.zoneName)
|
||||
&& Objects.equal(this.jobId, that.jobId)
|
||||
&& Objects.equal(this.jobStatus, that.jobStatus);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("account", account).add("allocated", allocated).add("associatedNetworkId", associatedNetworkId)
|
||||
.add("domain", domain).add("domainId", domainId).add("usesVirtualNetwork", usesVirtualNetwork).add("IPAddress", IPAddress)
|
||||
.add("isSourceNAT", isSourceNAT).add("isStaticNAT", isStaticNAT).add("networkId", networkId).add("state", state)
|
||||
.add("virtualMachineDisplayName", virtualMachineDisplayName).add("virtualMachineId", virtualMachineId)
|
||||
.add("virtualMachineName", virtualMachineName).add("VLANId", VLANId).add("VLANName", VLANName).add("zoneId", zoneId)
|
||||
.add("zoneName", zoneName).add("jobId", jobId).add("jobStatus", jobStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PublicIPAddress{" +
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", allocated=" + allocated +
|
||||
", associatedNetworkId=" + associatedNetworkId +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", usesVirtualNetwork=" + usesVirtualNetwork +
|
||||
", IPAddress='" + IPAddress + '\'' +
|
||||
", isSourceNAT=" + isSourceNAT +
|
||||
", isStaticNAT=" + isStaticNAT +
|
||||
", networkId=" + networkId +
|
||||
", state=" + state +
|
||||
", virtualMachineDisplayName='" + virtualMachineDisplayName + '\'' +
|
||||
", virtualMachineId=" + virtualMachineId +
|
||||
", virtualMachineName='" + virtualMachineName + '\'' +
|
||||
", VLANId=" + VLANId +
|
||||
", VLANName='" + VLANName + '\'' +
|
||||
", zoneId=" + zoneId +
|
||||
", zoneName='" + zoneName + '\'' +
|
||||
", jobId=" + jobId +
|
||||
", jobStatus=" + jobStatus +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,143 +16,29 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class ResourceLimit
|
||||
*
|
||||
* @author Vijay Kiran
|
||||
*/
|
||||
public class ResourceLimit implements Comparable<ResourceLimit> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String account;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private int max;
|
||||
private ResourceType resourceType;
|
||||
|
||||
public Builder account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder max(int max) {
|
||||
this.max = max;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder resourceType(ResourceType resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceLimit build() {
|
||||
return new ResourceLimit(account, domain, domainId, max, resourceType);
|
||||
}
|
||||
}
|
||||
|
||||
// for deserialization
|
||||
ResourceLimit() {
|
||||
|
||||
}
|
||||
|
||||
private String account;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
private int max;
|
||||
@SerializedName("resourcetype")
|
||||
private ResourceType resourceType;
|
||||
|
||||
public ResourceLimit(String account, String domain, String domainId, int max, ResourceType resourceType) {
|
||||
this.account = account;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.max = max;
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public ResourceType getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ResourceLimit that = (ResourceLimit) o;
|
||||
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(max, that.max)) return false;
|
||||
if (!Objects.equal(resourceType, that.resourceType)) return false;
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(domainId, max, resourceType, account, domain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ResourceLimit that) {
|
||||
return this.account.compareTo(that.account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResourceLimit{" +
|
||||
"account='" + account + '\'' +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", max=" + max +
|
||||
", resourceType=" + resourceType +
|
||||
'}';
|
||||
}
|
||||
*/
|
||||
public class ResourceLimit {
|
||||
|
||||
/**
|
||||
* Type of resource to update.
|
||||
|
@ -200,7 +86,7 @@ public class ResourceLimit implements Comparable<ResourceLimit> {
|
|||
public int getCode(){
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name();
|
||||
|
@ -210,6 +96,155 @@ public class ResourceLimit implements Comparable<ResourceLimit> {
|
|||
Integer code = new Integer(checkNotNull(resourceType, "resourcetype"));
|
||||
return INDEX.containsKey(code) ? INDEX.get(code) : UNRECOGNIZED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromResourceLimit(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String account;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected int max;
|
||||
protected ResourceType resourceType;
|
||||
|
||||
/**
|
||||
* @see ResourceLimit#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResourceLimit#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResourceLimit#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResourceLimit#getMax()
|
||||
*/
|
||||
public T max(int max) {
|
||||
this.max = max;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResourceLimit#getResourceType()
|
||||
*/
|
||||
public T resourceType(ResourceType resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ResourceLimit build() {
|
||||
return new ResourceLimit(account, domain, domainId, max, resourceType);
|
||||
}
|
||||
|
||||
public T fromResourceLimit(ResourceLimit in) {
|
||||
return this
|
||||
.account(in.getAccount())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.max(in.getMax())
|
||||
.resourceType(in.getResourceType());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String account;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
private final int max;
|
||||
@Named("resourcetype")
|
||||
private final ResourceLimit.ResourceType resourceType;
|
||||
|
||||
@ConstructorProperties({
|
||||
"account", "domain", "domainid", "max", "resourcetype"
|
||||
})
|
||||
protected ResourceLimit(@Nullable String account, @Nullable String domain, @Nullable String domainId, int max,
|
||||
@Nullable ResourceType resourceType) {
|
||||
this.account = account;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.max = max;
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return this.account;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceType getResourceType() {
|
||||
return this.resourceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(account, domain, domainId, max, resourceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ResourceLimit that = ResourceLimit.class.cast(obj);
|
||||
return Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.max, that.max)
|
||||
&& Objects.equal(this.resourceType, that.resourceType);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("account", account).add("domain", domain).add("domainId", domainId).add("max", max).add("resourceType", resourceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,106 +20,164 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class SecurityGroup
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
*/
|
||||
public class SecurityGroup implements Comparable<SecurityGroup> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSecurityGroup(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String account;
|
||||
private String name;
|
||||
private String description;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private String jobId;
|
||||
private Integer jobStatus;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private Set<IngressRule> ingressRules = ImmutableSet.of();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String account;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected String jobId;
|
||||
protected Integer jobStatus;
|
||||
protected Set<IngressRule> ingressRules;
|
||||
|
||||
/**
|
||||
* @see SecurityGroup#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
/**
|
||||
* @see SecurityGroup#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see SecurityGroup#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see SecurityGroup#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see SecurityGroup#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see SecurityGroup#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder jobId(String jobId) {
|
||||
/**
|
||||
* @see SecurityGroup#getJobId()
|
||||
*/
|
||||
public T jobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder jobStatus(int jobStatus) {
|
||||
/**
|
||||
* @see SecurityGroup#getJobStatus()
|
||||
*/
|
||||
public T jobStatus(Integer jobStatus) {
|
||||
this.jobStatus = jobStatus;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ingressRules(Set<IngressRule> ingressRules) {
|
||||
this.ingressRules = ImmutableSet.copyOf(checkNotNull(ingressRules, "ingressRules"));
|
||||
return this;
|
||||
/**
|
||||
* @see SecurityGroup#getIngressRules()
|
||||
*/
|
||||
public T ingressRules(Set<IngressRule> ingressRules) {
|
||||
this.ingressRules = ingressRules;
|
||||
return self();
|
||||
}
|
||||
|
||||
public SecurityGroup build() {
|
||||
return new SecurityGroup(id, account, name, description, domain, domainId, jobId, jobStatus, ingressRules);
|
||||
}
|
||||
|
||||
public T fromSecurityGroup(SecurityGroup in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.account(in.getAccount())
|
||||
.name(in.getName())
|
||||
.description(in.getDescription())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.jobId(in.getJobId())
|
||||
.jobStatus(in.getJobStatus())
|
||||
.ingressRules(in.getIngressRules());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private String name;
|
||||
private String description;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("jobid")
|
||||
@Nullable
|
||||
private String jobId;
|
||||
@SerializedName("jobstatus")
|
||||
@Nullable
|
||||
private Integer jobStatus;
|
||||
@SerializedName("ingressrule")
|
||||
// so that tests and serialization come out expected
|
||||
private SortedSet<IngressRule> ingressRules = ImmutableSortedSet.<IngressRule>of();
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public SecurityGroup(String id, String account, String name, String description, String domain, String domainId,
|
||||
String jobId, Integer jobStatus, Set<IngressRule> ingressRules) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String account;
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("jobid")
|
||||
private final String jobId;
|
||||
@Named("jobstatus")
|
||||
private final Integer jobStatus;
|
||||
@Named("ingressrule")
|
||||
private final Set<IngressRule> ingressRules;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "account", "name", "description", "domain", "domainid", "jobid", "jobstatus", "ingressrule"
|
||||
})
|
||||
protected SecurityGroup(String id, @Nullable String account, @Nullable String name, @Nullable String description,
|
||||
@Nullable String domain, @Nullable String domainId, @Nullable String jobId, @Nullable Integer jobStatus,
|
||||
@Nullable Set<IngressRule> ingressRules) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.account = account;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
|
@ -127,60 +185,64 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
this.domainId = domainId;
|
||||
this.jobId = jobId;
|
||||
this.jobStatus = jobStatus;
|
||||
this.ingressRules = ImmutableSortedSet.copyOf(checkNotNull(ingressRules, "ingressRules"));
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
SecurityGroup() {
|
||||
|
||||
this.ingressRules = ingressRules == null ? ImmutableSet.<IngressRule>of() : ImmutableSortedSet.copyOf(ingressRules);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the security group
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account owning the security group
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the security group
|
||||
*/
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an alternate display text of the security group.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Domain name for the security group
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain id of the security group
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return shows the current pending asynchronous job ID. This tag is not
|
||||
* returned if no current pending jobs are acting on the virtual
|
||||
* machine
|
||||
returned if no current pending jobs are acting on the virtual
|
||||
machine
|
||||
*/
|
||||
@Nullable
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
return this.jobId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,59 +250,49 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
*/
|
||||
@Nullable
|
||||
public Integer getJobStatus() {
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account owning the security group
|
||||
*/
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.jobStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of ingress rules associated with the security group
|
||||
*/
|
||||
public Set<IngressRule> getIngressRules() {
|
||||
return ingressRules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SecurityGroup that = (SecurityGroup) o;
|
||||
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(jobStatus, that.jobStatus)) return false;
|
||||
|
||||
return true;
|
||||
return this.ingressRules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(domainId, id, jobStatus);
|
||||
return Objects.hashCode(id, account, name, description, domain, domainId, jobId, jobStatus, ingressRules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
SecurityGroup that = SecurityGroup.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.jobId, that.jobId)
|
||||
&& Objects.equal(this.jobStatus, that.jobStatus)
|
||||
&& Objects.equal(this.ingressRules, that.ingressRules);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).add("id", id).add("account", account).add("name", name).add("description", description)
|
||||
.add("domain", domain).add("domainId", domainId).add("jobId", jobId).add("jobStatus", jobStatus).add("ingressRules", ingressRules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SecurityGroup{" +
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", jobId=" + jobId +
|
||||
", jobStatus=" + jobStatus +
|
||||
", ingressRules=" + ingressRules +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(SecurityGroup arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
public int compareTo(SecurityGroup o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,180 +20,275 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Class ServiceOffering
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ServiceOffering implements Comparable<ServiceOffering> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromServiceOffering(this);
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String displayText;
|
||||
private Date created;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private int cpuNumber;
|
||||
private int cpuSpeed;
|
||||
private int memory;
|
||||
private boolean haSupport;
|
||||
private StorageType storageType;
|
||||
private boolean defaultUse;
|
||||
private String hostTags;
|
||||
private boolean systemOffering;
|
||||
private boolean cpuUseLimited;
|
||||
private long networkRate;
|
||||
private boolean systemVmType;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String displayText;
|
||||
protected Date created;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected int cpuNumber;
|
||||
protected int cpuSpeed;
|
||||
protected int memory;
|
||||
protected boolean haSupport;
|
||||
protected StorageType storageType;
|
||||
protected boolean defaultUse;
|
||||
protected String hostTags;
|
||||
protected boolean systemOffering;
|
||||
protected boolean cpuUseLimited;
|
||||
protected long networkRate;
|
||||
protected boolean systemVmType;
|
||||
private Set<String> tags = ImmutableSet.of();
|
||||
|
||||
public Builder id(String id) {
|
||||
/**
|
||||
* @see ServiceOffering#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see ServiceOffering#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder displayText(String displayText) {
|
||||
/**
|
||||
* @see ServiceOffering#getDisplayText()
|
||||
*/
|
||||
public T displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder created(Date created) {
|
||||
/**
|
||||
* @see ServiceOffering#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see ServiceOffering#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see ServiceOffering#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder cpuNumber(int cpuNumber) {
|
||||
/**
|
||||
* @see ServiceOffering#getCpuNumber()
|
||||
*/
|
||||
public T cpuNumber(int cpuNumber) {
|
||||
this.cpuNumber = cpuNumber;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder cpuSpeed(int cpuSpeed) {
|
||||
/**
|
||||
* @see ServiceOffering#getCpuSpeed()
|
||||
*/
|
||||
public T cpuSpeed(int cpuSpeed) {
|
||||
this.cpuSpeed = cpuSpeed;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder memory(int memory) {
|
||||
/**
|
||||
* @see ServiceOffering#getMemory()
|
||||
*/
|
||||
public T memory(int memory) {
|
||||
this.memory = memory;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder haSupport(boolean haSupport) {
|
||||
/**
|
||||
* @see ServiceOffering#supportsHA()
|
||||
*/
|
||||
public T supportsHA(boolean haSupport) {
|
||||
this.haSupport = haSupport;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder storageType(StorageType storageType) {
|
||||
/**
|
||||
* @see ServiceOffering#getStorageType()
|
||||
*/
|
||||
public T storageType(StorageType storageType) {
|
||||
this.storageType = storageType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder tags(Set<String> tags) {
|
||||
/**
|
||||
* @see ServiceOffering#getTags()
|
||||
*/
|
||||
public T tags(Set<String> tags) {
|
||||
this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder defaultUse(boolean defaultUse) {
|
||||
/**
|
||||
* @see ServiceOffering#isDefaultUse()
|
||||
*/
|
||||
public T defaultUse(boolean defaultUse) {
|
||||
this.defaultUse = defaultUse;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder hostTags(String hostTags) {
|
||||
/**
|
||||
* @see ServiceOffering#getHostTags()
|
||||
*/
|
||||
public T hostTags(String hostTags) {
|
||||
this.hostTags = hostTags;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder systemOffering(boolean systemOffering) {
|
||||
/**
|
||||
* @see ServiceOffering#isSystemOffering()
|
||||
*/
|
||||
public T systemOffering(boolean systemOffering) {
|
||||
this.systemOffering = systemOffering;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder cpuUseLimited(boolean cpuUseLimited) {
|
||||
/**
|
||||
* @see ServiceOffering#isCpuUseLimited()
|
||||
*/
|
||||
public T cpuUseLimited(boolean cpuUseLimited) {
|
||||
this.cpuUseLimited = cpuUseLimited;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder networkRate(long networkRate) {
|
||||
/**
|
||||
* @see ServiceOffering#getNetworkRate()
|
||||
*/
|
||||
public T networkRate(long networkRate) {
|
||||
this.networkRate = networkRate;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder systemVmType(boolean systemVmType) {
|
||||
/**
|
||||
* @see ServiceOffering#isSystemVmType()
|
||||
*/
|
||||
public T systemVmType(boolean systemVmType) {
|
||||
this.systemVmType = systemVmType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
|
||||
public ServiceOffering build() {
|
||||
return new ServiceOffering(id, name, displayText, created, domain, domainId, cpuNumber, cpuSpeed, memory,
|
||||
haSupport, storageType, tags, defaultUse, hostTags, systemOffering, cpuUseLimited, networkRate,
|
||||
systemVmType);
|
||||
return new ServiceOffering(id, name, displayText, created, domain, domainId, cpuNumber, cpuSpeed, memory, haSupport, storageType,
|
||||
Joiner.on(",").join(tags), defaultUse, hostTags, systemOffering, cpuUseLimited, networkRate, systemVmType);
|
||||
}
|
||||
|
||||
public T fromServiceOffering(ServiceOffering in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.displayText(in.getDisplayText())
|
||||
.created(in.getCreated())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.cpuNumber(in.getCpuNumber())
|
||||
.cpuSpeed(in.getCpuSpeed())
|
||||
.memory(in.getMemory())
|
||||
.supportsHA(in.supportsHA())
|
||||
.storageType(in.getStorageType())
|
||||
.tags(in.getTags())
|
||||
.defaultUse(in.isDefaultUse())
|
||||
.hostTags(in.getHostTags())
|
||||
.systemOffering(in.isSystemOffering())
|
||||
.cpuUseLimited(in.isCpuUseLimited())
|
||||
.networkRate(in.getNetworkRate())
|
||||
.systemVmType(in.isSystemVmType());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@SerializedName("displaytext")
|
||||
private String displayText;
|
||||
private Date created;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("cpunumber")
|
||||
private int cpuNumber;
|
||||
@SerializedName("cpuspeed")
|
||||
private int cpuSpeed;
|
||||
private int memory;
|
||||
@SerializedName("offerha")
|
||||
private boolean haSupport;
|
||||
@SerializedName("storagetype")
|
||||
private StorageType storageType;
|
||||
private String tags;
|
||||
@SerializedName("defaultuse")
|
||||
private boolean defaultUse;
|
||||
@SerializedName("hosttags")
|
||||
private String hostTags;
|
||||
@SerializedName("issystem")
|
||||
private boolean systemOffering;
|
||||
@SerializedName("limitcpuuse")
|
||||
private boolean cpuUseLimited;
|
||||
@SerializedName("networkrate")
|
||||
private long networkRate;
|
||||
@SerializedName("systemvmtype")
|
||||
private boolean systemVmType;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String id;
|
||||
private final String name;
|
||||
@Named("displaytext")
|
||||
private final String displayText;
|
||||
private final Date created;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("cpunumber")
|
||||
private final int cpuNumber;
|
||||
@Named("cpuspeed")
|
||||
private final int cpuSpeed;
|
||||
private final int memory;
|
||||
@Named("offerha")
|
||||
private final boolean haSupport;
|
||||
@Named("storagetype")
|
||||
private final StorageType storageType;
|
||||
private final String tags;
|
||||
@Named("defaultuse")
|
||||
private final boolean defaultUse;
|
||||
@Named("hosttags")
|
||||
private final String hostTags;
|
||||
@Named("issystem")
|
||||
private final boolean systemOffering;
|
||||
@Named("limitcpuuse")
|
||||
private final boolean cpuUseLimited;
|
||||
@Named("networkrate")
|
||||
private final long networkRate;
|
||||
@Named("systemvmtype")
|
||||
private final boolean systemVmType;
|
||||
|
||||
public ServiceOffering(String id, String name, String displayText, Date created, String domain, String domainId,
|
||||
int cpuNumber, int cpuSpeed, int memory, boolean haSupport, StorageType storageType, Set<String> tags,
|
||||
boolean defaultUse, String hostTags, boolean systemOffering, boolean cpuUseLimited, long networkRate,
|
||||
boolean systemVmType) {
|
||||
this.id = id;
|
||||
@ConstructorProperties({
|
||||
"id", "name", "displaytext", "created", "domain", "domainid", "cpunumber", "cpuspeed", "memory", "offerha", "storagetype", "tags", "defaultuse", "hosttags", "issystem", "limitcpuuse", "networkrate", "systemvmtype"
|
||||
})
|
||||
protected ServiceOffering(String id, @Nullable String name, @Nullable String displayText, @Nullable Date created,
|
||||
@Nullable String domain, @Nullable String domainId, int cpuNumber, int cpuSpeed, int memory,
|
||||
boolean haSupport, @Nullable StorageType storageType, @Nullable String tags, boolean defaultUse,
|
||||
@Nullable String hostTags, boolean systemOffering, boolean cpuUseLimited, long networkRate, boolean systemVmType) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
this.created = created;
|
||||
|
@ -204,198 +299,191 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
|
|||
this.memory = memory;
|
||||
this.haSupport = haSupport;
|
||||
this.storageType = storageType;
|
||||
this.tags = tags.size() == 0 ? null : Joiner.on(',').join(tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
ServiceOffering() {
|
||||
|
||||
this.tags = tags;
|
||||
this.defaultUse = defaultUse;
|
||||
this.hostTags = hostTags;
|
||||
this.systemOffering = systemOffering;
|
||||
this.cpuUseLimited = cpuUseLimited;
|
||||
this.networkRate = networkRate;
|
||||
this.systemVmType = systemVmType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of the service offering
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the service offering
|
||||
*/
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an alternate display text of the service offering.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return this.displayText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date this service offering was created
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Domain name for the offering
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain id of the service offering
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of CPU
|
||||
*/
|
||||
public int getCpuNumber() {
|
||||
return cpuNumber;
|
||||
return this.cpuNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the clock rate CPU speed in Mhz
|
||||
*/
|
||||
public int getCpuSpeed() {
|
||||
return cpuSpeed;
|
||||
return this.cpuSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory in MB
|
||||
*/
|
||||
public int getMemory() {
|
||||
return memory;
|
||||
return this.memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ha support in the service offering
|
||||
*/
|
||||
public boolean supportsHA() {
|
||||
return haSupport;
|
||||
return this.haSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the storage type for this service offering
|
||||
*/
|
||||
@Nullable
|
||||
public StorageType getStorageType() {
|
||||
return storageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this is a default system vm offering
|
||||
*/
|
||||
public boolean isDefaultUse() {
|
||||
return defaultUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the host tag for the service offering
|
||||
*/
|
||||
public String getHostTags() {
|
||||
return hostTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this is a system vm offering
|
||||
*/
|
||||
public boolean isSystemOffering() {
|
||||
return systemOffering;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether restrict the CPU usage to committed service offering
|
||||
*/
|
||||
public boolean isCpuUseLimited() {
|
||||
return cpuUseLimited;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return data transfer rate in megabits per second allowed.
|
||||
*/
|
||||
public long getNetworkRate() {
|
||||
return networkRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this is a the systemvm type for system vm offering
|
||||
*/
|
||||
public boolean isSystemVmType() {
|
||||
return systemVmType;
|
||||
return this.storageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tags for the service offering
|
||||
*/
|
||||
public Set<String> getTags() {
|
||||
return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet.<String>of();
|
||||
return tags == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(Splitter.on(',').split(tags));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
/**
|
||||
* @return whether this is a default system vm offering
|
||||
*/
|
||||
public boolean isDefaultUse() {
|
||||
return this.defaultUse;
|
||||
}
|
||||
|
||||
ServiceOffering that = (ServiceOffering) o;
|
||||
/**
|
||||
* @return the host tag for the service offering
|
||||
*/
|
||||
@Nullable
|
||||
public String getHostTags() {
|
||||
return this.hostTags;
|
||||
}
|
||||
|
||||
if (!Objects.equal(cpuNumber, that.cpuNumber)) return false;
|
||||
if (!Objects.equal(cpuSpeed, that.cpuSpeed)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(displayText, that.displayText)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(haSupport, that.haSupport)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(memory, that.memory)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(storageType, that.storageType)) return false;
|
||||
if (!Objects.equal(tags, that.tags)) return false;
|
||||
/**
|
||||
* @return whether this is a system vm offering
|
||||
*/
|
||||
public boolean isSystemOffering() {
|
||||
return this.systemOffering;
|
||||
}
|
||||
|
||||
return true;
|
||||
/**
|
||||
* @return whether restrict the CPU usage to committed service offering
|
||||
*/
|
||||
public boolean isCpuUseLimited() {
|
||||
return this.cpuUseLimited;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return data transfer rate in megabits per second allowed.
|
||||
*/
|
||||
public long getNetworkRate() {
|
||||
return this.networkRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this is a the systemvm type for system vm offering
|
||||
*/
|
||||
public boolean isSystemVmType() {
|
||||
return this.systemVmType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(cpuNumber, cpuSpeed, created, displayText, domain, domainId, haSupport, id, memory, name, storageType, tags);
|
||||
return Objects.hashCode(id, name, displayText, created, domain, domainId, cpuNumber, cpuSpeed, memory, haSupport, storageType, tags, defaultUse, hostTags, systemOffering, cpuUseLimited, networkRate, systemVmType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ServiceOffering that = ServiceOffering.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.displayText, that.displayText)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.cpuNumber, that.cpuNumber)
|
||||
&& Objects.equal(this.cpuSpeed, that.cpuSpeed)
|
||||
&& Objects.equal(this.memory, that.memory)
|
||||
&& Objects.equal(this.haSupport, that.haSupport)
|
||||
&& Objects.equal(this.storageType, that.storageType)
|
||||
&& Objects.equal(this.getTags(), that.getTags())
|
||||
&& Objects.equal(this.defaultUse, that.defaultUse)
|
||||
&& Objects.equal(this.hostTags, that.hostTags)
|
||||
&& Objects.equal(this.systemOffering, that.systemOffering)
|
||||
&& Objects.equal(this.cpuUseLimited, that.cpuUseLimited)
|
||||
&& Objects.equal(this.networkRate, that.networkRate)
|
||||
&& Objects.equal(this.systemVmType, that.systemVmType);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("displayText", displayText).add("created", created).add("domain", domain)
|
||||
.add("domainId", domainId).add("cpuNumber", cpuNumber).add("cpuSpeed", cpuSpeed).add("memory", memory)
|
||||
.add("haSupport", haSupport).add("storageType", storageType).add("tags", getTags()).add("defaultUse", defaultUse)
|
||||
.add("hostTags", hostTags).add("systemOffering", systemOffering).add("cpuUseLimited", cpuUseLimited)
|
||||
.add("networkRate", networkRate).add("systemVmType", systemVmType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServiceOffering{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", displayText='" + displayText + '\'' +
|
||||
", created=" + created +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", cpuNumber=" + cpuNumber +
|
||||
", cpuSpeed=" + cpuSpeed +
|
||||
", memory=" + memory +
|
||||
", haSupport=" + haSupport +
|
||||
", storageType=" + storageType +
|
||||
", tags='" + tags + '\'' +
|
||||
", defaultUse=" + defaultUse +
|
||||
", hostTags='" + hostTags + '\'' +
|
||||
", systemOffering=" + systemOffering +
|
||||
", cpuUseLimited=" + cpuUseLimited +
|
||||
", networkRate=" + networkRate +
|
||||
", systemVmType=" + systemVmType +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ServiceOffering arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
public int compareTo(ServiceOffering o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,158 +20,27 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class Snapshot
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class Snapshot implements Comparable<Snapshot> {
|
||||
public class Snapshot {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private Date created;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private Interval interval;
|
||||
private String jobId;
|
||||
private String jobStatus;
|
||||
private String name;
|
||||
private Type snapshotType;
|
||||
private State state;
|
||||
private String volumeId;
|
||||
private String volumeName;
|
||||
private Volume.Type volumeType;
|
||||
|
||||
/**
|
||||
* @param id ID of the snapshot
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param account the account associated with the snapshot
|
||||
*/
|
||||
public Builder account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param created the date the snapshot was created
|
||||
*/
|
||||
public Builder created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param domain the domain name of the snapshot's account
|
||||
*/
|
||||
public Builder domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param domainId the domain ID of the snapshot's account
|
||||
*/
|
||||
public Builder domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param interval valid types are hourly, daily, weekly, monthy, template, and none.
|
||||
*/
|
||||
public Builder interval(Interval interval) {
|
||||
this.interval = interval;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jobId the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.
|
||||
*/
|
||||
public Builder jobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jobStatus the job status associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.
|
||||
*/
|
||||
public Builder jobStatus(String jobStatus) {
|
||||
this.jobStatus = jobStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name name of the snapshot
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param snapshotType the type of the snapshot
|
||||
*/
|
||||
public Builder snapshotType(Type snapshotType) {
|
||||
this.snapshotType = snapshotType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage
|
||||
*/
|
||||
public Builder state(State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param volumeId ID of the disk volume
|
||||
*/
|
||||
public Builder volumeId(String volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param volumeName name of the disk volume
|
||||
*/
|
||||
public Builder volumeName(String volumeName) {
|
||||
this.volumeName = volumeName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param volumeType type of the disk volume
|
||||
*/
|
||||
public Builder volumeType(Volume.Type volumeType) {
|
||||
this.volumeType = volumeType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Snapshot build() {
|
||||
return new Snapshot(id, account, created, domain, domainId, interval, jobId,
|
||||
jobStatus, name, snapshotType, state, volumeId, volumeName, volumeType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum State {
|
||||
/**
|
||||
*/
|
||||
public static enum State {
|
||||
|
||||
BACKED_UP, CREATING, BACKING_UP, UNRECOGNIZED;
|
||||
|
||||
|
@ -189,7 +58,9 @@ public class Snapshot implements Comparable<Snapshot> {
|
|||
}
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
/**
|
||||
*/
|
||||
public static enum Type {
|
||||
|
||||
MANUAL, RECURRING, UNRECOGNIZED;
|
||||
|
||||
|
@ -202,7 +73,9 @@ public class Snapshot implements Comparable<Snapshot> {
|
|||
}
|
||||
}
|
||||
|
||||
public enum Interval {
|
||||
/**
|
||||
*/
|
||||
public static enum Interval {
|
||||
|
||||
HOURLY, DAILY, WEEKLY, MONTHLY, template, none, UNRECOGNIZED;
|
||||
|
||||
|
@ -215,32 +88,206 @@ public class Snapshot implements Comparable<Snapshot> {
|
|||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private Date created;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("intervaltype")
|
||||
private Interval interval;
|
||||
@SerializedName("jobid")
|
||||
private String jobId;
|
||||
@SerializedName("jobstatus")
|
||||
private String jobStatus;
|
||||
private String name;
|
||||
@SerializedName("snapshottype")
|
||||
private Type snapshotType;
|
||||
private State state;
|
||||
@SerializedName("volumeid")
|
||||
private String volumeId;
|
||||
@SerializedName("volumename")
|
||||
private String volumeName;
|
||||
@SerializedName("volumetype")
|
||||
private Volume.Type volumeType;
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Snapshot(String id, String account, Date created, String domain, String domainId, Interval interval, String jobId,
|
||||
String jobStatus, String name, Type snapshotType, State state, String volumeId, String volumeName, Volume.Type volumeType) {
|
||||
this.id = id;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSnapshot(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String account;
|
||||
protected Date created;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected Snapshot.Interval interval;
|
||||
protected String jobId;
|
||||
protected String jobStatus;
|
||||
protected String name;
|
||||
protected Snapshot.Type snapshotType;
|
||||
protected Snapshot.State state;
|
||||
protected String volumeId;
|
||||
protected String volumeName;
|
||||
protected Volume.Type volumeType;
|
||||
|
||||
/**
|
||||
* @see Snapshot#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getInterval()
|
||||
*/
|
||||
public T interval(Snapshot.Interval interval) {
|
||||
this.interval = interval;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getJobId()
|
||||
*/
|
||||
public T jobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getJobStatus()
|
||||
*/
|
||||
public T jobStatus(String jobStatus) {
|
||||
this.jobStatus = jobStatus;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getSnapshotType()
|
||||
*/
|
||||
public T snapshotType(Snapshot.Type snapshotType) {
|
||||
this.snapshotType = snapshotType;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getState()
|
||||
*/
|
||||
public T state(Snapshot.State state) {
|
||||
this.state = state;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getVolumeId()
|
||||
*/
|
||||
public T volumeId(String volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getVolumeName()
|
||||
*/
|
||||
public T volumeName(String volumeName) {
|
||||
this.volumeName = volumeName;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Snapshot#getVolumeType()
|
||||
*/
|
||||
public T volumeType(Volume.Type volumeType) {
|
||||
this.volumeType = volumeType;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Snapshot build() {
|
||||
return new Snapshot(id, account, created, domain, domainId, interval, jobId, jobStatus, name, snapshotType, state,
|
||||
volumeId, volumeName, volumeType);
|
||||
}
|
||||
|
||||
public T fromSnapshot(Snapshot in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.account(in.getAccount())
|
||||
.created(in.getCreated())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.interval(in.getInterval())
|
||||
.jobId(in.getJobId())
|
||||
.jobStatus(in.getJobStatus())
|
||||
.name(in.getName())
|
||||
.snapshotType(in.getSnapshotType())
|
||||
.state(in.getState())
|
||||
.volumeId(in.getVolumeId())
|
||||
.volumeName(in.getVolumeName())
|
||||
.volumeType(in.getVolumeType());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String id;
|
||||
private final String account;
|
||||
private final Date created;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("intervaltype")
|
||||
private final Snapshot.Interval interval;
|
||||
@Named("jobid")
|
||||
private final String jobId;
|
||||
@Named("jobstatus")
|
||||
private final String jobStatus;
|
||||
private final String name;
|
||||
@Named("snapshottype")
|
||||
private final Snapshot.Type snapshotType;
|
||||
private final Snapshot.State state;
|
||||
@Named("volumeid")
|
||||
private final String volumeId;
|
||||
@Named("volumename")
|
||||
private final String volumeName;
|
||||
@Named("volumetype")
|
||||
private final Volume.Type volumeType;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "account", "created", "domain", "domainid", "intervaltype", "jobid", "jobstatus", "name", "snapshottype", "state", "volumeid", "volumename", "volumetype"
|
||||
})
|
||||
protected Snapshot(String id, @Nullable String account, @Nullable Date created, @Nullable String domain, @Nullable String domainId,
|
||||
@Nullable Snapshot.Interval interval, @Nullable String jobId, @Nullable String jobStatus, @Nullable String name,
|
||||
@Nullable Snapshot.Type snapshotType, @Nullable Snapshot.State state, @Nullable String volumeId, @Nullable String volumeName,
|
||||
@Nullable Volume.Type volumeType) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.account = account;
|
||||
this.created = created;
|
||||
this.domain = domain;
|
||||
|
@ -256,164 +303,153 @@ public class Snapshot implements Comparable<Snapshot> {
|
|||
this.volumeType = volumeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
Snapshot() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ID of the snapshot
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account associated with the snapshot
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date the snapshot was created
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain name of the snapshot's account
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain ID of the snapshot's account
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return valid types are hourly, daily, weekly, monthy, template, and none.
|
||||
*/
|
||||
public Interval getInterval() {
|
||||
return interval;
|
||||
@Nullable
|
||||
public Snapshot.Interval getInterval() {
|
||||
return this.interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.
|
||||
*/
|
||||
@Nullable
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
return this.jobId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the job status associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.
|
||||
*/
|
||||
@Nullable
|
||||
public String getJobStatus() {
|
||||
return jobStatus;
|
||||
return this.jobStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the snapshot
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of the snapshot
|
||||
*/
|
||||
public Type getSnapshotType() {
|
||||
return snapshotType;
|
||||
@Nullable
|
||||
public Snapshot.Type getSnapshotType() {
|
||||
return this.snapshotType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage
|
||||
*/
|
||||
public State getState() {
|
||||
return state;
|
||||
@Nullable
|
||||
public Snapshot.State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ID of the disk volume
|
||||
*/
|
||||
@Nullable
|
||||
public String getVolumeId() {
|
||||
return volumeId;
|
||||
return this.volumeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the disk volume
|
||||
*/
|
||||
@Nullable
|
||||
public String getVolumeName() {
|
||||
return volumeName;
|
||||
return this.volumeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type of the disk volume
|
||||
*/
|
||||
@Nullable
|
||||
public Volume.Type getVolumeType() {
|
||||
return volumeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Snapshot that = (Snapshot) o;
|
||||
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(jobId, that.jobId)) return false;
|
||||
if (!Objects.equal(volumeId, that.volumeId)) return false;
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(interval, that.interval)) return false;
|
||||
if (!Objects.equal(jobStatus, that.jobStatus)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(snapshotType, that.snapshotType)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
if (!Objects.equal(volumeName, that.volumeName)) return false;
|
||||
if (!Objects.equal(volumeType, that.volumeType)) return false;
|
||||
|
||||
return true;
|
||||
return this.volumeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(domainId, id, jobId, volumeId, account, created, domain,
|
||||
interval, jobStatus, name, snapshotType, state, volumeName,
|
||||
volumeType);
|
||||
return Objects.hashCode(id, account, created, domain, domainId, interval, jobId, jobStatus, name, snapshotType, state, volumeId, volumeName, volumeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Snapshot that = Snapshot.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.interval, that.interval)
|
||||
&& Objects.equal(this.jobId, that.jobId)
|
||||
&& Objects.equal(this.jobStatus, that.jobStatus)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.snapshotType, that.snapshotType)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.volumeId, that.volumeId)
|
||||
&& Objects.equal(this.volumeName, that.volumeName)
|
||||
&& Objects.equal(this.volumeType, that.volumeType);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("account", account).add("created", created).add("domain", domain).add("domainId", domainId)
|
||||
.add("interval", interval).add("jobId", jobId).add("jobStatus", jobStatus).add("name", name).add("snapshotType", snapshotType)
|
||||
.add("state", state).add("volumeId", volumeId).add("volumeName", volumeName).add("volumeType", volumeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Snapshot{" +
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", created=" + created +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", interval=" + interval +
|
||||
", jobId=" + jobId +
|
||||
", jobStatus='" + jobStatus + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", snapshotType=" + snapshotType +
|
||||
", state=" + state +
|
||||
", volumeId=" + volumeId +
|
||||
", volumeName='" + volumeName + '\'' +
|
||||
", volumeType=" + volumeType +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Snapshot other) {
|
||||
return id.compareTo(other.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,184 +18,208 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class SnapshotPolicy
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class SnapshotPolicy implements Comparable<SnapshotPolicy> {
|
||||
*/
|
||||
public class SnapshotPolicy {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSnapshotPolicy(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private Snapshot.Interval interval;
|
||||
private long numberToRetain;
|
||||
private String schedule;
|
||||
private String timezone;
|
||||
private String volumeId;
|
||||
|
||||
/**
|
||||
* @param id the ID of the snapshot policy
|
||||
protected String id;
|
||||
protected Snapshot.Interval interval;
|
||||
protected long numberToRetain;
|
||||
protected String schedule;
|
||||
protected String timezone;
|
||||
protected String volumeId;
|
||||
|
||||
/**
|
||||
* @see SnapshotPolicy#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param interval valid types are hourly, daily, weekly, monthy, template, and none.
|
||||
/**
|
||||
* @see SnapshotPolicy#getInterval()
|
||||
*/
|
||||
public Builder interval(Snapshot.Interval interval) {
|
||||
public T interval(Snapshot.Interval interval) {
|
||||
this.interval = interval;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param numberToRetain maximum number of snapshots retained
|
||||
/**
|
||||
* @see SnapshotPolicy#getNumberToRetain()
|
||||
*/
|
||||
public Builder numberToRetain(long numberToRetain) {
|
||||
public T numberToRetain(long numberToRetain) {
|
||||
this.numberToRetain = numberToRetain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param schedule time the snapshot is scheduled to be taken.
|
||||
/**
|
||||
* @see SnapshotPolicy#getSchedule()
|
||||
*/
|
||||
public Builder schedule(String schedule) {
|
||||
public T schedule(String schedule) {
|
||||
this.schedule = schedule;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timezone the time zone of the snapshot policy
|
||||
/**
|
||||
* @see SnapshotPolicy#getTimezone()
|
||||
*/
|
||||
public Builder timezone(String timezone) {
|
||||
public T timezone(String timezone) {
|
||||
this.timezone = timezone;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param volumeId ID of the disk volume
|
||||
/**
|
||||
* @see SnapshotPolicy#getVolumeId()
|
||||
*/
|
||||
public Builder volumeId(String volumeId) {
|
||||
public T volumeId(String volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public SnapshotPolicy build() {
|
||||
return new SnapshotPolicy(id, interval, numberToRetain, schedule, timezone, volumeId);
|
||||
}
|
||||
|
||||
public T fromSnapshotPolicy(SnapshotPolicy in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.interval(in.getInterval())
|
||||
.numberToRetain(in.getNumberToRetain())
|
||||
.schedule(in.getSchedule())
|
||||
.timezone(in.getTimezone())
|
||||
.volumeId(in.getVolumeId());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("intervaltype")
|
||||
private Snapshot.Interval interval;
|
||||
@SerializedName("maxsnaps")
|
||||
private long numberToRetain;
|
||||
private String schedule;
|
||||
private String timezone;
|
||||
@SerializedName("volumeid")
|
||||
private String volumeId;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public SnapshotPolicy(String id, Snapshot.Interval interval, long numberToRetain, String schedule, String timezone, String volumeId) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
@Named("intervaltype")
|
||||
private final Snapshot.Interval interval;
|
||||
@Named("maxsnaps")
|
||||
private final long numberToRetain;
|
||||
private final String schedule;
|
||||
private final String timezone;
|
||||
@Named("volumeid")
|
||||
private final String volumeId;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "intervaltype", "maxsnaps", "schedule", "timezone", "volumeid"
|
||||
})
|
||||
protected SnapshotPolicy(String id, @Nullable Snapshot.Interval interval, long numberToRetain, @Nullable String schedule,
|
||||
@Nullable String timezone, @Nullable String volumeId) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.interval = interval;
|
||||
this.numberToRetain = numberToRetain;
|
||||
this.schedule = schedule;
|
||||
this.timezone = timezone;
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
SnapshotPolicy() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the snapshot policy
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return valid types are hourly, daily, weekly, monthy, template, and none.
|
||||
*/
|
||||
@Nullable
|
||||
public Snapshot.Interval getInterval() {
|
||||
return interval;
|
||||
return this.interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return maximum number of snapshots retained
|
||||
*/
|
||||
public long getNumberToRetain() {
|
||||
return numberToRetain;
|
||||
return this.numberToRetain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time the snapshot is scheduled to be taken.
|
||||
*/
|
||||
@Nullable
|
||||
public String getSchedule() {
|
||||
return schedule;
|
||||
return this.schedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time zone of the snapshot policy
|
||||
*/
|
||||
@Nullable
|
||||
public String getTimezone() {
|
||||
return timezone;
|
||||
return this.timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ID of the disk volume
|
||||
*/
|
||||
@Nullable
|
||||
public String getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SnapshotPolicy that = (SnapshotPolicy) o;
|
||||
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(numberToRetain, that.numberToRetain)) return false;
|
||||
if (!Objects.equal(volumeId, that.volumeId)) return false;
|
||||
if (!Objects.equal(interval, that.interval)) return false;
|
||||
if (!Objects.equal(schedule, that.schedule)) return false;
|
||||
if (!Objects.equal(timezone, that.timezone)) return false;
|
||||
|
||||
return true;
|
||||
return this.volumeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, numberToRetain, volumeId, interval, schedule, timezone);
|
||||
return Objects.hashCode(id, interval, numberToRetain, schedule, timezone, volumeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
SnapshotPolicy that = SnapshotPolicy.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.interval, that.interval)
|
||||
&& Objects.equal(this.numberToRetain, that.numberToRetain)
|
||||
&& Objects.equal(this.schedule, that.schedule)
|
||||
&& Objects.equal(this.timezone, that.timezone)
|
||||
&& Objects.equal(this.volumeId, that.volumeId);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("interval", interval).add("numberToRetain", numberToRetain).add("schedule", schedule).add("timezone", timezone)
|
||||
.add("volumeId", volumeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SnapshotPolicy{" +
|
||||
"id=" + id +
|
||||
", interval=" + interval +
|
||||
", numberToRetain=" + numberToRetain +
|
||||
", schedule='" + schedule + '\'' +
|
||||
", timezone='" + timezone + '\'' +
|
||||
", volumeId=" + volumeId +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(SnapshotPolicy other) {
|
||||
return id.compareTo(other.getId());
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,35 +18,112 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Describes the schedule of a snapshot policy.
|
||||
*
|
||||
* @see org.jclouds.cloudstack.util.SnapshotPolicySchedules
|
||||
* @author Richard Downer
|
||||
*/
|
||||
*/
|
||||
public class SnapshotPolicySchedule {
|
||||
|
||||
private Snapshot.Interval interval;
|
||||
private String time;
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSnapshotPolicySchedule(this);
|
||||
}
|
||||
|
||||
public SnapshotPolicySchedule(Snapshot.Interval interval, String time) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected Snapshot.Interval interval;
|
||||
protected String time;
|
||||
|
||||
/**
|
||||
* @see SnapshotPolicySchedule#getInterval()
|
||||
*/
|
||||
public T interval(Snapshot.Interval interval) {
|
||||
this.interval = interval;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SnapshotPolicySchedule#getTime()
|
||||
*/
|
||||
public T time(String time) {
|
||||
this.time = time;
|
||||
return self();
|
||||
}
|
||||
|
||||
public SnapshotPolicySchedule build() {
|
||||
return new SnapshotPolicySchedule(interval, time);
|
||||
}
|
||||
|
||||
public T fromSnapshotPolicySchedule(SnapshotPolicySchedule in) {
|
||||
return this
|
||||
.interval(in.getInterval())
|
||||
.time(in.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final Snapshot.Interval interval;
|
||||
private final String time;
|
||||
|
||||
@ConstructorProperties({
|
||||
"interval", "time"
|
||||
})
|
||||
protected SnapshotPolicySchedule(@Nullable Snapshot.Interval interval, @Nullable String time) {
|
||||
this.interval = interval;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Snapshot.Interval getInterval() {
|
||||
return interval;
|
||||
return this.interval;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTime() {
|
||||
return time;
|
||||
return this.time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SnapshotPolicySchedule{" +
|
||||
"interval=" + interval +
|
||||
", time='" + time + '\'' +
|
||||
'}';
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(interval, time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
SnapshotPolicySchedule that = SnapshotPolicySchedule.class.cast(obj);
|
||||
return Objects.equal(this.interval, that.interval)
|
||||
&& Objects.equal(this.time, that.time);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("interval", interval).add("time", time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,106 +16,135 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class SshKeyPair
|
||||
*
|
||||
* @author Vijay Kiran
|
||||
*/
|
||||
public class SshKeyPair implements Comparable<SshKeyPair> {
|
||||
*/
|
||||
public class SshKeyPair {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSshKeyPair(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String fingerprint;
|
||||
private String name;
|
||||
private String privateKey;
|
||||
|
||||
public Builder fingerprint(String fingerprint) {
|
||||
protected String fingerprint;
|
||||
protected String name;
|
||||
protected String privateKey;
|
||||
|
||||
/**
|
||||
* @see SshKeyPair#getFingerprint()
|
||||
*/
|
||||
public T fingerprint(String fingerprint) {
|
||||
this.fingerprint = fingerprint;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see SshKeyPair#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder privateKey(String privateKey) {
|
||||
/**
|
||||
* @see SshKeyPair#getPrivateKey()
|
||||
*/
|
||||
public T privateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public SshKeyPair build() {
|
||||
return new SshKeyPair(fingerprint, name, privateKey);
|
||||
}
|
||||
|
||||
public T fromSshKeyPair(SshKeyPair in) {
|
||||
return this
|
||||
.fingerprint(in.getFingerprint())
|
||||
.name(in.getName())
|
||||
.privateKey(in.getPrivateKey());
|
||||
}
|
||||
}
|
||||
|
||||
// for deserialization
|
||||
SshKeyPair() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private String fingerprint;
|
||||
private String name;
|
||||
@SerializedName("privatekey")
|
||||
private String privateKey;
|
||||
private final String fingerprint;
|
||||
private final String name;
|
||||
@Named("privatekey")
|
||||
private final String privateKey;
|
||||
|
||||
public SshKeyPair(String fingerprint, String name, String privateKey) {
|
||||
@ConstructorProperties({
|
||||
"fingerprint", "name", "privatekey"
|
||||
})
|
||||
protected SshKeyPair(@Nullable String fingerprint, String name, @Nullable String privateKey) {
|
||||
this.fingerprint = fingerprint;
|
||||
this.name = name;
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getFingerprint() {
|
||||
return fingerprint;
|
||||
return this.fingerprint;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SshKeyPair that = (SshKeyPair) o;
|
||||
|
||||
if (!Objects.equal(fingerprint, that.fingerprint)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(privateKey, that.privateKey)) return false;
|
||||
|
||||
return true;
|
||||
return this.privateKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(fingerprint, name, privateKey);
|
||||
return Objects.hashCode(fingerprint, name, privateKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
SshKeyPair that = SshKeyPair.class.cast(obj);
|
||||
return Objects.equal(this.fingerprint, that.fingerprint)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.privateKey, that.privateKey);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("fingerprint", fingerprint).add("name", name).add("privateKey", privateKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SshKeyPair{" +
|
||||
"fingerprint='" + fingerprint + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", privateKey='" + privateKey + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(SshKeyPair arg0) {
|
||||
return fingerprint.compareTo(arg0.getFingerprint());
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,17 +20,22 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents a storage pool in CloudStack
|
||||
*
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
*/
|
||||
public class StoragePool implements Comparable<StoragePool> {
|
||||
|
||||
public enum State {
|
||||
|
@ -56,7 +61,7 @@ public class StoragePool implements Comparable<StoragePool> {
|
|||
}
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
public enum Type {
|
||||
FILESYSTEM,
|
||||
NETWORK_FILESYSTEM,
|
||||
ISCSI_LUN,
|
||||
|
@ -70,169 +75,264 @@ public class StoragePool implements Comparable<StoragePool> {
|
|||
EXT,
|
||||
OCFS2,
|
||||
UNRECOGNIZED;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||
}
|
||||
|
||||
|
||||
public static Type fromValue(String type) {
|
||||
try {
|
||||
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
try {
|
||||
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromStoragePool(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String path;
|
||||
private String tags;
|
||||
private State state;
|
||||
private Type type;
|
||||
private String zoneId;
|
||||
private String zoneName;
|
||||
private String podId;
|
||||
private String podName;
|
||||
private String clusterId;
|
||||
private String clusterName;
|
||||
private Date created;
|
||||
private long diskSizeAllocated;
|
||||
private long diskSizeTotal;
|
||||
private String ipAddress;
|
||||
private String jobId;
|
||||
private String jobStatus;
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String path;
|
||||
protected String tags;
|
||||
protected StoragePool.State state;
|
||||
protected StoragePool.Type type;
|
||||
protected String zoneId;
|
||||
protected String zoneName;
|
||||
protected String podId;
|
||||
protected String podName;
|
||||
protected String clusterId;
|
||||
protected String clusterName;
|
||||
protected Date created;
|
||||
protected long diskSizeAllocated;
|
||||
protected long diskSizeTotal;
|
||||
protected String ipAddress;
|
||||
protected String jobId;
|
||||
protected String jobStatus;
|
||||
|
||||
/**
|
||||
* @see StoragePool#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see StoragePool#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder path(String path) {
|
||||
/**
|
||||
* @see StoragePool#getPath()
|
||||
*/
|
||||
public T path(String path) {
|
||||
this.path = path;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder tags(String tags) {
|
||||
/**
|
||||
* @see StoragePool#getTags()
|
||||
*/
|
||||
public T tags(String tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(State state) {
|
||||
/**
|
||||
* @see StoragePool#getState()
|
||||
*/
|
||||
public T state(StoragePool.State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder type(Type type) {
|
||||
/**
|
||||
* @see StoragePool#getType()
|
||||
*/
|
||||
public T type(StoragePool.Type type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneId(String zoneId) {
|
||||
/**
|
||||
* @see StoragePool#getZoneId()
|
||||
*/
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneName(String zoneName) {
|
||||
/**
|
||||
* @see StoragePool#getZoneName()
|
||||
*/
|
||||
public T zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder podId(String podId) {
|
||||
/**
|
||||
* @see StoragePool#getPodId()
|
||||
*/
|
||||
public T podId(String podId) {
|
||||
this.podId = podId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder podName(String podName) {
|
||||
/**
|
||||
* @see StoragePool#getPodName()
|
||||
*/
|
||||
public T podName(String podName) {
|
||||
this.podName = podName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder clusterId(String clusterId) {
|
||||
/**
|
||||
* @see StoragePool#getClusterId()
|
||||
*/
|
||||
public T clusterId(String clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder clusterName(String clusterName) {
|
||||
/**
|
||||
* @see StoragePool#getClusterName()
|
||||
*/
|
||||
public T clusterName(String clusterName) {
|
||||
this.clusterName = clusterName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder created(Date created) {
|
||||
/**
|
||||
* @see StoragePool#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder diskSizeAllocated(long diskSizeAllocated) {
|
||||
/**
|
||||
* @see StoragePool#getDiskSizeAllocated()
|
||||
*/
|
||||
public T diskSizeAllocated(long diskSizeAllocated) {
|
||||
this.diskSizeAllocated = diskSizeAllocated;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder diskSizeTotal(long diskSizeTotal) {
|
||||
/**
|
||||
* @see StoragePool#getDiskSizeTotal()
|
||||
*/
|
||||
public T diskSizeTotal(long diskSizeTotal) {
|
||||
this.diskSizeTotal = diskSizeTotal;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ipAddress(String ipAddress) {
|
||||
/**
|
||||
* @see StoragePool#getIpAddress()
|
||||
*/
|
||||
public T ipAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder jobId(String jobId) {
|
||||
/**
|
||||
* @see StoragePool#getJobId()
|
||||
*/
|
||||
public T jobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder jobStatus(String jobStatus) {
|
||||
/**
|
||||
* @see StoragePool#getJobStatus()
|
||||
*/
|
||||
public T jobStatus(String jobStatus) {
|
||||
this.jobStatus = jobStatus;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public StoragePool build() {
|
||||
return new StoragePool(id, name, path, tags, state, type, zoneId, zoneName, podId, podName, clusterId, clusterName, created, diskSizeAllocated, diskSizeTotal, ipAddress, jobId, jobStatus);
|
||||
}
|
||||
|
||||
public T fromStoragePool(StoragePool in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.path(in.getPath())
|
||||
.tags(in.getTags())
|
||||
.state(in.getState())
|
||||
.type(in.getType())
|
||||
.zoneId(in.getZoneId())
|
||||
.zoneName(in.getZoneName())
|
||||
.podId(in.getPodId())
|
||||
.podName(in.getPodName())
|
||||
.clusterId(in.getClusterId())
|
||||
.clusterName(in.getClusterName())
|
||||
.created(in.getCreated())
|
||||
.diskSizeAllocated(in.getDiskSizeAllocated())
|
||||
.diskSizeTotal(in.getDiskSizeTotal())
|
||||
.ipAddress(in.getIpAddress())
|
||||
.jobId(in.getJobId())
|
||||
.jobStatus(in.getJobStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String path;
|
||||
private String tags;
|
||||
private State state;
|
||||
private Type type;
|
||||
@SerializedName("zoneid") private String zoneId;
|
||||
@SerializedName("zonename") private String zoneName;
|
||||
@SerializedName("podid") private String podId;
|
||||
@SerializedName("podname") private String podName;
|
||||
@SerializedName("clusterid") private String clusterId;
|
||||
@SerializedName("clustername") private String clusterName;
|
||||
private Date created;
|
||||
@SerializedName("disksizeallocated") private long diskSizeAllocated;
|
||||
@SerializedName("disksizetotal") private long diskSizeTotal;
|
||||
@SerializedName("ipaddress") private String ipAddress;
|
||||
@SerializedName("jobid") private String jobId;
|
||||
@SerializedName("jobstatus") private String jobStatus;
|
||||
|
||||
/* Exists only for the serializer */
|
||||
StoragePool() {
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public StoragePool(String id, String name, String path, String tags, State state, Type type, String zoneId, String zoneName, String podId, String podName, String clusterId, String clusterName, Date created, long diskSizeAllocated, long diskSizeTotal, String ipAddress, String jobId, String jobStatus) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final String path;
|
||||
private final String tags;
|
||||
private final StoragePool.State state;
|
||||
private final StoragePool.Type type;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
@Named("zonename")
|
||||
private final String zoneName;
|
||||
@Named("podid")
|
||||
private final String podId;
|
||||
@Named("podname")
|
||||
private final String podName;
|
||||
@Named("clusterid")
|
||||
private final String clusterId;
|
||||
@Named("clustername")
|
||||
private final String clusterName;
|
||||
private final Date created;
|
||||
@Named("disksizeallocated")
|
||||
private final long diskSizeAllocated;
|
||||
@Named("disksizetotal")
|
||||
private final long diskSizeTotal;
|
||||
@Named("ipaddress")
|
||||
private final String ipAddress;
|
||||
@Named("jobid")
|
||||
private final String jobId;
|
||||
@Named("jobstatus")
|
||||
private final String jobStatus;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "name", "path", "tags", "state", "type", "zoneid", "zonename", "podid", "podname", "clusterid", "clustername", "created", "disksizeallocated", "disksizetotal", "ipaddress", "jobid", "jobstatus"
|
||||
})
|
||||
protected StoragePool(String id, @Nullable String name, @Nullable String path, @Nullable String tags, @Nullable StoragePool.State state, @Nullable StoragePool.Type type, @Nullable String zoneId, @Nullable String zoneName, @Nullable String podId, @Nullable String podName, @Nullable String clusterId, @Nullable String clusterName, @Nullable Date created, long diskSizeAllocated, long diskSizeTotal, @Nullable String ipAddress, @Nullable String jobId, @Nullable String jobStatus) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.tags = tags;
|
||||
|
@ -253,137 +353,132 @@ public class StoragePool implements Comparable<StoragePool> {
|
|||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPath() {
|
||||
return path;
|
||||
return this.path;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTags() {
|
||||
return tags;
|
||||
return this.tags;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
@Nullable
|
||||
public StoragePool.State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
@Nullable
|
||||
public StoragePool.Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
return this.zoneName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPodId() {
|
||||
return podId;
|
||||
return this.podId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPodName() {
|
||||
return podName;
|
||||
return this.podName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getClusterId() {
|
||||
return clusterId;
|
||||
return this.clusterId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getClusterName() {
|
||||
return clusterName;
|
||||
return this.clusterName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
public long getDiskSizeAllocated() {
|
||||
return diskSizeAllocated;
|
||||
return this.diskSizeAllocated;
|
||||
}
|
||||
|
||||
public long getDiskSizeTotal() {
|
||||
return diskSizeTotal;
|
||||
return this.diskSizeTotal;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
return this.ipAddress;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getJobId() {
|
||||
return jobId;
|
||||
return this.jobId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getJobStatus() {
|
||||
return jobStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
StoragePool that = (StoragePool) o;
|
||||
|
||||
if (!Objects.equal(clusterId, that.clusterId)) return false;
|
||||
if (!Objects.equal(diskSizeAllocated, that.diskSizeAllocated)) return false;
|
||||
if (!Objects.equal(diskSizeTotal, that.diskSizeTotal)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(podId, that.podId)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(clusterName, that.clusterName)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(ipAddress, that.ipAddress)) return false;
|
||||
if (!Objects.equal(jobId, that.jobId)) return false;
|
||||
if (!Objects.equal(jobStatus, that.jobStatus)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(path, that.path)) return false;
|
||||
if (!Objects.equal(podName, that.podName)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
if (!Objects.equal(tags, that.tags)) return false;
|
||||
if (!Objects.equal(type, that.type)) return false;
|
||||
if (!Objects.equal(zoneName, that.zoneName)) return false;
|
||||
|
||||
return true;
|
||||
return this.jobStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(clusterId, diskSizeAllocated, diskSizeTotal, id, podId, zoneId,
|
||||
clusterName, created, ipAddress, jobId, jobStatus, name, path,
|
||||
podName, state, tags, type, zoneName);
|
||||
return Objects.hashCode(id, name, path, tags, state, type, zoneId, zoneName, podId, podName, clusterId, clusterName, created, diskSizeAllocated, diskSizeTotal, ipAddress, jobId, jobStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StoragePool{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", path='" + path + '\'' +
|
||||
", tags='" + tags + '\'' +
|
||||
", state=" + state +
|
||||
", type=" + type +
|
||||
", zoneId=" + zoneId +
|
||||
", zoneName='" + zoneName + '\'' +
|
||||
", podId=" + podId +
|
||||
", podName='" + podName + '\'' +
|
||||
", clusterId=" + clusterId +
|
||||
", clusterName='" + clusterName + '\'' +
|
||||
", created=" + created +
|
||||
", diskSizeAllocated=" + diskSizeAllocated +
|
||||
", diskSizeTotal=" + diskSizeTotal +
|
||||
", ipAddress='" + ipAddress + '\'' +
|
||||
", jobId=" + jobId +
|
||||
", jobStatus='" + jobStatus + '\'' +
|
||||
'}';
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
StoragePool that = StoragePool.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.path, that.path)
|
||||
&& Objects.equal(this.tags, that.tags)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.type, that.type)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.zoneName, that.zoneName)
|
||||
&& Objects.equal(this.podId, that.podId)
|
||||
&& Objects.equal(this.podName, that.podName)
|
||||
&& Objects.equal(this.clusterId, that.clusterId)
|
||||
&& Objects.equal(this.clusterName, that.clusterName)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.diskSizeAllocated, that.diskSizeAllocated)
|
||||
&& Objects.equal(this.diskSizeTotal, that.diskSizeTotal)
|
||||
&& Objects.equal(this.ipAddress, that.ipAddress)
|
||||
&& Objects.equal(this.jobId, that.jobId)
|
||||
&& Objects.equal(this.jobStatus, that.jobStatus);
|
||||
}
|
||||
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("path", path).add("tags", tags).add("state", state).add("type", type).add("zoneId", zoneId).add("zoneName", zoneName).add("podId", podId).add("podName", podName).add("clusterId", clusterId).add("clusterName", clusterName).add("created", created).add("diskSizeAllocated", diskSizeAllocated).add("diskSizeTotal", diskSizeTotal).add("ipAddress", ipAddress).add("jobId", jobId).add("jobStatus", jobStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(StoragePool other) {
|
||||
return this.id.compareTo(other.id);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,172 +18,208 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* @author Richard Downer
|
||||
*/
|
||||
*/
|
||||
public class TemplateExtraction implements Comparable<TemplateExtraction> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromTemplateExtraction(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String accountId;
|
||||
private Date created;
|
||||
private String extractId;
|
||||
private ExtractMode extractMode;
|
||||
private String name;
|
||||
private String state;
|
||||
private String status;
|
||||
private String storageType;
|
||||
private int uploadPercentage;
|
||||
private String url;
|
||||
private String zoneId;
|
||||
private String zoneName;
|
||||
|
||||
/**
|
||||
* @param id the id of extracted object
|
||||
protected String id;
|
||||
protected String accountId;
|
||||
protected Date created;
|
||||
protected String extractId;
|
||||
protected ExtractMode extractMode;
|
||||
protected String name;
|
||||
protected String state;
|
||||
protected String status;
|
||||
protected String storageType;
|
||||
protected int uploadPercentage;
|
||||
protected String url;
|
||||
protected String zoneId;
|
||||
protected String zoneName;
|
||||
|
||||
/**
|
||||
* @see TemplateExtraction#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param accountId the account id to which the extracted object belongs
|
||||
/**
|
||||
* @see TemplateExtraction#getAccountId()
|
||||
*/
|
||||
public Builder accountId(String accountId) {
|
||||
public T accountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param created the time and date the object was created
|
||||
/**
|
||||
* @see TemplateExtraction#getCreated()
|
||||
*/
|
||||
public Builder created(Date created) {
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param extractId the upload id of extracted object
|
||||
/**
|
||||
* @see TemplateExtraction#getExtractId()
|
||||
*/
|
||||
public Builder extractId(String extractId) {
|
||||
public T extractId(String extractId) {
|
||||
this.extractId = extractId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param extractMode the mode of extraction - upload or download
|
||||
/**
|
||||
* @see TemplateExtraction#getExtractMode()
|
||||
*/
|
||||
public Builder extractMode(ExtractMode extractMode) {
|
||||
public T extractMode(ExtractMode extractMode) {
|
||||
this.extractMode = extractMode;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name of the extracted object
|
||||
/**
|
||||
* @see TemplateExtraction#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state the state of the extracted object
|
||||
/**
|
||||
* @see TemplateExtraction#getState()
|
||||
*/
|
||||
public Builder state(String state) {
|
||||
public T state(String state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status the status of the extraction
|
||||
/**
|
||||
* @see TemplateExtraction#getStatus()
|
||||
*/
|
||||
public Builder status(String status) {
|
||||
public T status(String status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storageType type of the storage
|
||||
/**
|
||||
* @see TemplateExtraction#getStorageType()
|
||||
*/
|
||||
public Builder storageType(String storageType) {
|
||||
public T storageType(String storageType) {
|
||||
this.storageType = storageType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uploadPercentage the percentage of the entity uploaded to the specified location
|
||||
/**
|
||||
* @see TemplateExtraction#getUploadPercentage()
|
||||
*/
|
||||
public Builder uploadPercentage(int uploadPercentage) {
|
||||
public T uploadPercentage(int uploadPercentage) {
|
||||
this.uploadPercentage = uploadPercentage;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url if mode = upload then url of the uploaded entity. if mode = download the url from which the entity can be downloaded
|
||||
/**
|
||||
* @see TemplateExtraction#getUrl()
|
||||
*/
|
||||
public Builder url(String url) {
|
||||
public T url(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zoneId zone ID the object was extracted from
|
||||
/**
|
||||
* @see TemplateExtraction#getZoneId()
|
||||
*/
|
||||
public Builder zoneId(String zoneId) {
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param zoneName zone name the object was extracted from
|
||||
/**
|
||||
* @see TemplateExtraction#getZoneName()
|
||||
*/
|
||||
public Builder zoneName(String zoneName) {
|
||||
public T zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public TemplateExtraction build() {
|
||||
return new TemplateExtraction(id, accountId, created, extractId,
|
||||
extractMode, name, state, status, storageType, uploadPercentage,
|
||||
url,zoneId, zoneName);
|
||||
return new TemplateExtraction(id, accountId, created, extractId, extractMode, name, state, status, storageType, uploadPercentage, url, zoneId, zoneName);
|
||||
}
|
||||
|
||||
public T fromTemplateExtraction(TemplateExtraction in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.accountId(in.getAccountId())
|
||||
.created(in.getCreated())
|
||||
.extractId(in.getExtractId())
|
||||
.extractMode(in.getExtractMode())
|
||||
.name(in.getName())
|
||||
.state(in.getState())
|
||||
.status(in.getStatus())
|
||||
.storageType(in.getStorageType())
|
||||
.uploadPercentage(in.getUploadPercentage())
|
||||
.url(in.getUrl())
|
||||
.zoneId(in.getZoneId())
|
||||
.zoneName(in.getZoneName());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("accountid")
|
||||
private String accountId;
|
||||
private Date created;
|
||||
private String extractId;
|
||||
private ExtractMode extractMode;
|
||||
private String name;
|
||||
private String state;
|
||||
private String status;
|
||||
@SerializedName("storagetype")
|
||||
private String storageType;
|
||||
@SerializedName("uploadpercentage")
|
||||
private int uploadPercentage;
|
||||
private String url;
|
||||
@SerializedName("zoneid")
|
||||
private String zoneId;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new TemplateExtraction instance
|
||||
*/
|
||||
public TemplateExtraction(String id, String accountId, Date created, String extractId,
|
||||
ExtractMode extractMode, String name, String state, String status,
|
||||
String storageType, int uploadPercentage, String url,
|
||||
String zoneId, String zoneName) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
@Named("accountid")
|
||||
private final String accountId;
|
||||
private final Date created;
|
||||
private final String extractId;
|
||||
private final ExtractMode extractMode;
|
||||
private final String name;
|
||||
private final String state;
|
||||
private final String status;
|
||||
@Named("storagetype")
|
||||
private final String storageType;
|
||||
@Named("uploadpercentage")
|
||||
private final int uploadPercentage;
|
||||
private final String url;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
@Named("zonename")
|
||||
private final String zoneName;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "accountid", "created", "extractId", "extractMode", "name", "state", "status", "storagetype", "uploadpercentage", "url", "zoneid", "zonename"
|
||||
})
|
||||
protected TemplateExtraction(String id, @Nullable String accountId, @Nullable Date created, @Nullable String extractId,
|
||||
@Nullable ExtractMode extractMode, @Nullable String name, @Nullable String state, @Nullable String status,
|
||||
@Nullable String storageType, int uploadPercentage, @Nullable String url, @Nullable String zoneId,
|
||||
@Nullable String zoneName) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.accountId = accountId;
|
||||
this.created = created;
|
||||
this.extractId = extractId;
|
||||
|
@ -198,153 +234,141 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
|
|||
this.zoneName = zoneName;
|
||||
}
|
||||
|
||||
@SerializedName("zonename")
|
||||
private String zoneName;
|
||||
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
TemplateExtraction() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id of extracted object
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account id to which the extracted object belongs
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
return this.accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time and date the object was created
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the upload id of extracted object
|
||||
*/
|
||||
@Nullable
|
||||
public String getExtractId() {
|
||||
return extractId;
|
||||
return this.extractId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mode of extraction - upload or download
|
||||
*/
|
||||
@Nullable
|
||||
public ExtractMode getExtractMode() {
|
||||
return extractMode;
|
||||
return this.extractMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the extracted object
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the extracted object
|
||||
*/
|
||||
@Nullable
|
||||
public String getState() {
|
||||
return state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the status of the extraction
|
||||
*/
|
||||
@Nullable
|
||||
public String getStatus() {
|
||||
return status;
|
||||
return this.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type of the storage
|
||||
*/
|
||||
@Nullable
|
||||
public String getStorageType() {
|
||||
return storageType;
|
||||
return this.storageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the percentage of the entity uploaded to the specified location
|
||||
*/
|
||||
public int getUploadPercentage() {
|
||||
return uploadPercentage;
|
||||
return this.uploadPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if mode = upload then url of the uploaded entity. if mode = download the url from which the entity can be downloaded
|
||||
*/
|
||||
@Nullable
|
||||
public String getUrl() {
|
||||
return url;
|
||||
return this.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return zone ID the object was extracted from
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return zone name the object was extracted from
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateExtraction that = (TemplateExtraction) o;
|
||||
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(accountId, that.accountId)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(extractId, that.extractId)) return false;
|
||||
if (!Objects.equal(extractMode, that.extractMode)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(state, that.state)) return false;
|
||||
if (!Objects.equal(status, that.status)) return false;
|
||||
if (!Objects.equal(storageType, that.storageType)) return false;
|
||||
if (!Objects.equal(uploadPercentage, that.uploadPercentage)) return false;
|
||||
if (!Objects.equal(url, that.url)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(zoneName, that.zoneName)) return false;
|
||||
|
||||
return true;
|
||||
return this.zoneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, accountId, created, extractId, extractMode, name, state, status, storageType, uploadPercentage, url, zoneId, zoneName);
|
||||
return Objects.hashCode(id, accountId, created, extractId, extractMode, name, state, status, storageType, uploadPercentage, url, zoneId, zoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
TemplateExtraction that = TemplateExtraction.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.accountId, that.accountId)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.extractId, that.extractId)
|
||||
&& Objects.equal(this.extractMode, that.extractMode)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.status, that.status)
|
||||
&& Objects.equal(this.storageType, that.storageType)
|
||||
&& Objects.equal(this.uploadPercentage, that.uploadPercentage)
|
||||
&& Objects.equal(this.url, that.url)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.zoneName, that.zoneName);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("accountId", accountId).add("created", created).add("extractId", extractId).add("extractMode", extractMode).add("name", name).add("state", state).add("status", status).add("storageType", storageType).add("uploadPercentage", uploadPercentage).add("url", url).add("zoneId", zoneId).add("zoneName", zoneName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TemplateExtraction{" +
|
||||
"id=" + id +
|
||||
", accountId=" + accountId +
|
||||
", created=" + created +
|
||||
", extractId=" + extractId +
|
||||
", extractMode=" + extractMode +
|
||||
", name='" + name + '\'' +
|
||||
", state='" + state + '\'' +
|
||||
", status='" + status + '\'' +
|
||||
", storageType='" + storageType + '\'' +
|
||||
", uploadPercentage=" + uploadPercentage +
|
||||
", url='" + url + '\'' +
|
||||
", zoneId=" + zoneId +
|
||||
", zoneName='" + zoneName + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,219 +18,222 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class TemplateMetadata
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
*/
|
||||
public class TemplateMetadata {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromTemplateMetadata(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String name;
|
||||
private String osTypeId;
|
||||
private String displayText;
|
||||
private String snapshotId;
|
||||
private String volumeId;
|
||||
private String virtualMachineId;
|
||||
private Boolean passwordEnabled;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name of the template
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
protected String name;
|
||||
protected String osTypeId;
|
||||
protected String displayText;
|
||||
protected String snapshotId;
|
||||
protected String volumeId;
|
||||
protected String virtualMachineId;
|
||||
protected Boolean passwordEnabled;
|
||||
|
||||
/**
|
||||
* @see TemplateMetadata#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param osTypeId
|
||||
* the ID of the OS Type that best represents the OS of this template.
|
||||
*/
|
||||
public Builder osTypeId(String osTypeId) {
|
||||
this.osTypeId = osTypeId;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @see TemplateMetadata#getOsTypeId()
|
||||
*/
|
||||
public T osTypeId(String osTypeId) {
|
||||
this.osTypeId = osTypeId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayText
|
||||
* the display text of the template. This is usually used for display purposes.
|
||||
*/
|
||||
public Builder displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @see TemplateMetadata#getDisplayText()
|
||||
*/
|
||||
public T displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param snapshotId
|
||||
* the ID of the snapshot the template is being created from.
|
||||
* Either this parameter, or volumeId has to be passed in
|
||||
*/
|
||||
public Builder snapshotId(String snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @see TemplateMetadata#getSnapshotId()
|
||||
*/
|
||||
public T snapshotId(String snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param volumeId
|
||||
* the ID of the disk volume the template is being created from.
|
||||
* Either this parameter, or snapshotId has to be passed in
|
||||
*/
|
||||
public Builder volumeId(String volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @see TemplateMetadata#getVolumeId()
|
||||
*/
|
||||
public T volumeId(String volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param virtualMachineId
|
||||
* the ID of the disk volume the template is being created from
|
||||
*/
|
||||
public Builder virtualMachineId(String virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @see TemplateMetadata#getVirtualMachineId()
|
||||
*/
|
||||
public T virtualMachineId(String virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* the template supports the password reset feature.
|
||||
*/
|
||||
public Builder passwordEnabled() {
|
||||
this.passwordEnabled = true;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @see TemplateMetadata#isPasswordEnabled()
|
||||
*/
|
||||
public T passwordEnabled(Boolean passwordEnabled) {
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
return self();
|
||||
}
|
||||
|
||||
public TemplateMetadata build() {
|
||||
TemplateMetadata template = new TemplateMetadata(name, osTypeId, displayText);
|
||||
template.setPasswordEnabled(passwordEnabled);
|
||||
template.setSnapshotId(snapshotId);
|
||||
template.setVirtualMachineId(virtualMachineId);
|
||||
template.setVolumeId(volumeId);
|
||||
return template;
|
||||
}
|
||||
}
|
||||
public TemplateMetadata build() {
|
||||
return new TemplateMetadata(name, osTypeId, displayText, snapshotId, volumeId, virtualMachineId, passwordEnabled);
|
||||
}
|
||||
|
||||
public T fromTemplateMetadata(TemplateMetadata in) {
|
||||
return this
|
||||
.name(in.getName())
|
||||
.osTypeId(in.getOsTypeId())
|
||||
.displayText(in.getDisplayText())
|
||||
.snapshotId(in.getSnapshotId())
|
||||
.volumeId(in.getVolumeId())
|
||||
.virtualMachineId(in.getVirtualMachineId())
|
||||
.passwordEnabled(in.isPasswordEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String osTypeId;
|
||||
private String displayText;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private String snapshotId;
|
||||
private String volumeId;
|
||||
private String virtualMachineId;;
|
||||
private Boolean passwordEnabled;
|
||||
private final String name;
|
||||
private final String osTypeId;
|
||||
private final String displayText;
|
||||
private final String snapshotId;
|
||||
private final String volumeId;
|
||||
private final String virtualMachineId;
|
||||
private final Boolean passwordEnabled;
|
||||
|
||||
public TemplateMetadata(String name, String osTypeId, String displayText) {
|
||||
this.name = name;
|
||||
this.osTypeId = osTypeId;
|
||||
this.displayText = displayText;
|
||||
}
|
||||
@ConstructorProperties({
|
||||
"name", "osTypeId", "displayText", "snapshotId", "volumeId", "virtualMachineId", "passwordEnabled"
|
||||
})
|
||||
protected TemplateMetadata(String name, @Nullable String osTypeId, @Nullable String displayText, @Nullable String snapshotId,
|
||||
@Nullable String volumeId, String virtualMachineId, Boolean passwordEnabled) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.osTypeId = osTypeId;
|
||||
this.displayText = displayText;
|
||||
this.snapshotId = snapshotId;
|
||||
this.volumeId = volumeId;
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
TemplateMetadata() {
|
||||
}
|
||||
/**
|
||||
* @return the name of the template
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the snapshot the template is being created from
|
||||
*/
|
||||
public String getSnapshotId() {
|
||||
return snapshotId;
|
||||
}
|
||||
/**
|
||||
* @return the ID of the OS Type that best represents the OS of this template.
|
||||
*/
|
||||
@Nullable
|
||||
public String getOsTypeId() {
|
||||
return this.osTypeId;
|
||||
}
|
||||
|
||||
public void setSnapshotId(String snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
}
|
||||
/**
|
||||
* @return the display text of the template. This is usually used for display purposes.
|
||||
*/
|
||||
@Nullable
|
||||
public String getDisplayText() {
|
||||
return this.displayText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the disk volume the template is being created from
|
||||
*/
|
||||
public String getVolumeId() {
|
||||
return volumeId;
|
||||
}
|
||||
/**
|
||||
* @return the ID of the snapshot the template is being created from
|
||||
*/
|
||||
@Nullable
|
||||
public String getSnapshotId() {
|
||||
return this.snapshotId;
|
||||
}
|
||||
|
||||
public void setVolumeId(String volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
/**
|
||||
* @return the ID of the disk volume the template is being created from
|
||||
*/
|
||||
@Nullable
|
||||
public String getVolumeId() {
|
||||
return this.volumeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Optional, VM ID
|
||||
*/
|
||||
public String getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
}
|
||||
/**
|
||||
* @return Optional, VM ID
|
||||
*/
|
||||
@Nullable
|
||||
public String getVirtualMachineId() {
|
||||
return this.virtualMachineId;
|
||||
}
|
||||
|
||||
public void setVirtualMachineId(String virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the template supports the password reset feature; default is false
|
||||
*/
|
||||
public Boolean getPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
|
||||
public void setPasswordEnabled(Boolean passwordEnabled) {
|
||||
this.passwordEnabled = passwordEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the template
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the OS Type that best represents the OS of this template.
|
||||
*/
|
||||
public String getOsTypeId() {
|
||||
return osTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the display text of the template. This is usually used for display purposes.
|
||||
*/
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplateMetadata that = (TemplateMetadata) o;
|
||||
|
||||
if (!Objects.equal(osTypeId, that.osTypeId)) return false;
|
||||
if (!Objects.equal(snapshotId, that.snapshotId)) return false;
|
||||
if (!Objects.equal(volumeId, that.volumeId)) return false;
|
||||
if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false;
|
||||
if (!Objects.equal(passwordEnabled, that.passwordEnabled)) return false;
|
||||
if (!Objects.equal(displayText, that.displayText)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, displayText, osTypeId, snapshotId, volumeId, passwordEnabled, virtualMachineId);
|
||||
}
|
||||
@Nullable
|
||||
public Boolean isPasswordEnabled() {
|
||||
return this.passwordEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, osTypeId, displayText, snapshotId, volumeId, virtualMachineId, passwordEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
TemplateMetadata that = TemplateMetadata.class.cast(obj);
|
||||
return Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.osTypeId, that.osTypeId)
|
||||
&& Objects.equal(this.displayText, that.displayText)
|
||||
&& Objects.equal(this.snapshotId, that.snapshotId)
|
||||
&& Objects.equal(this.volumeId, that.volumeId)
|
||||
&& Objects.equal(this.virtualMachineId, that.virtualMachineId)
|
||||
&& Objects.equal(this.passwordEnabled, that.passwordEnabled);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("name", name).add("osTypeId", osTypeId).add("displayText", displayText).add("snapshotId", snapshotId)
|
||||
.add("volumeId", volumeId).add("virtualMachineId", virtualMachineId).add("passwordEnabled", passwordEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TemplateMetadata{" +
|
||||
"name='" + name + '\'' +
|
||||
", osTypeId=" + osTypeId +
|
||||
", displayText='" + displayText + '\'' +
|
||||
", snapshotId=" + snapshotId +
|
||||
", volumeId=" + volumeId +
|
||||
", virtualMachineId=" + virtualMachineId +
|
||||
", passwordEnabled=" + passwordEnabled +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,139 +18,169 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class TemplatePermission implements Comparable<TemplatePermission> {
|
||||
*/
|
||||
public class TemplatePermission {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromTemplatePermission(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String account;
|
||||
private String domainId;
|
||||
private boolean isPublic;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String account;
|
||||
protected String domainId;
|
||||
protected boolean isPublic;
|
||||
|
||||
/**
|
||||
* @see TemplatePermission#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
/**
|
||||
* @see TemplatePermission#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see TemplatePermission#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder isPublic(boolean isPublic) {
|
||||
/**
|
||||
* @see TemplatePermission#isPublic()
|
||||
*/
|
||||
public T isPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public TemplatePermission build() {
|
||||
return new TemplatePermission(id, account, domainId, isPublic);
|
||||
}
|
||||
|
||||
public T fromTemplatePermission(TemplatePermission in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.account(in.getAccount())
|
||||
.domainId(in.getDomainId())
|
||||
.isPublic(in.isPublic());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
@SerializedName("domainid") private String domainId;
|
||||
@SerializedName("ispublic") private boolean isPublic;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new TemplatePermission instance.
|
||||
* @param id the template ID
|
||||
* @param account the list of accounts the template is available for
|
||||
* @param domainId the ID of the domain to which the template belongs
|
||||
* @param isPublic true if this template is a public template, false otherwise
|
||||
*/
|
||||
public TemplatePermission(String id, String account, String domainId, boolean isPublic) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String account;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("ispublic")
|
||||
private final boolean isPublic;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "account", "domainid", "ispublic"
|
||||
})
|
||||
protected TemplatePermission(String id, @Nullable String account, @Nullable String domainId, boolean isPublic) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.account = account;
|
||||
this.domainId = domainId;
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
TemplatePermission() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the template ID
|
||||
*
|
||||
* @return the template ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of accounts the template is available for
|
||||
*
|
||||
* @return the list of accounts the template is available for
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID of the domain to which the template belongs
|
||||
*
|
||||
* @return the ID of the domain to which the template belongs
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this template is a public template, false otherwise
|
||||
*
|
||||
* @return true if this template is a public template, false otherwise
|
||||
*/
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemplatePermission that = (TemplatePermission) o;
|
||||
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(isPublic, that.isPublic)) return false;
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
|
||||
return true;
|
||||
return this.isPublic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(domainId, id, isPublic, account);
|
||||
return Objects.hashCode(id, account, domainId, isPublic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
TemplatePermission that = TemplatePermission.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.isPublic, that.isPublic);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("account", account).add("domainId", domainId).add("isPublic", isPublic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TemplatePermission{" +
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", isPublic=" + isPublic +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TemplatePermission other) {
|
||||
return id.compareTo(other.getId());
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,23 +20,30 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Represents a usage record from CloudStack
|
||||
*
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class UsageRecord implements Comparable<UsageRecord> {
|
||||
*/
|
||||
public class UsageRecord {
|
||||
|
||||
public enum UsageType {
|
||||
/**
|
||||
*/
|
||||
public static enum UsageType {
|
||||
RUNNING_VM(1),
|
||||
ALLOCATED_VM(2),
|
||||
IP_ADDRESS(3),
|
||||
|
@ -52,197 +59,314 @@ public class UsageRecord implements Comparable<UsageRecord> {
|
|||
NETWORK_OFFERING(13),
|
||||
VPN_USERS(14),
|
||||
UNRECOGNIZED(0);
|
||||
|
||||
|
||||
private int code;
|
||||
|
||||
|
||||
private static final Map<Integer, UsageType> INDEX = Maps.uniqueIndex(ImmutableSet.copyOf(UsageType.values()),
|
||||
new Function<UsageType, Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer apply(UsageType input) {
|
||||
return input.code;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
UsageType(int code) {
|
||||
this.code = code;
|
||||
new Function<UsageType, Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer apply(UsageType input) {
|
||||
return input.code;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
UsageType(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "" + code;
|
||||
return "" + code;
|
||||
}
|
||||
|
||||
|
||||
public static UsageType fromValue(String usageType) {
|
||||
Integer code = new Integer(checkNotNull(usageType, "usageType"));
|
||||
return INDEX.containsKey(code) ? INDEX.get(code) : UNRECOGNIZED;
|
||||
Integer code = new Integer(checkNotNull(usageType, "usageType"));
|
||||
return INDEX.containsKey(code) ? INDEX.get(code) : UNRECOGNIZED;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromUsageRecord(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
private String accountId;
|
||||
private String accountName;
|
||||
private String domainId;
|
||||
private Date startDate;
|
||||
private Date endDate;
|
||||
private Date assignDate;
|
||||
private String releaseDate;
|
||||
private String zoneId;
|
||||
private String virtualMachineId;
|
||||
private String virtualMachineName;
|
||||
private String serviceOfferingId;
|
||||
private String templateId;
|
||||
private String ipAddress;
|
||||
private boolean isSourceNAT;
|
||||
private double rawUsageHours;
|
||||
private String usage;
|
||||
private String type;
|
||||
private UsageType usageType;
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String description;
|
||||
protected String accountId;
|
||||
protected String accountName;
|
||||
protected String domainId;
|
||||
protected Date startDate;
|
||||
protected Date endDate;
|
||||
protected Date assignDate;
|
||||
protected String releaseDate;
|
||||
protected String zoneId;
|
||||
protected String virtualMachineId;
|
||||
protected String virtualMachineName;
|
||||
protected String serviceOfferingId;
|
||||
protected String templateId;
|
||||
protected String ipAddress;
|
||||
protected boolean isSourceNAT;
|
||||
protected double rawUsageHours;
|
||||
protected String usage;
|
||||
protected String type;
|
||||
protected UsageType usageType;
|
||||
|
||||
/**
|
||||
* @see UsageRecord#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see UsageRecord#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder accountId(String accountId) {
|
||||
/**
|
||||
* @see UsageRecord#getAccountId()
|
||||
*/
|
||||
public T accountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder accountName(String accountName) {
|
||||
/**
|
||||
* @see UsageRecord#getAccountName()
|
||||
*/
|
||||
public T accountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see UsageRecord#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder startDate(Date startDate) {
|
||||
/**
|
||||
* @see UsageRecord#getStartDate()
|
||||
*/
|
||||
public T startDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder endDate(Date endDate) {
|
||||
/**
|
||||
* @see UsageRecord#getEndDate()
|
||||
*/
|
||||
public T endDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder assignDate(Date assignDate) {
|
||||
/**
|
||||
* @see UsageRecord#getAssignDate()
|
||||
*/
|
||||
public T assignDate(Date assignDate) {
|
||||
this.assignDate = assignDate;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder releaseDate(String releaseDate) {
|
||||
/**
|
||||
* @see UsageRecord#getReleaseDate()
|
||||
*/
|
||||
public T releaseDate(String releaseDate) {
|
||||
this.releaseDate = releaseDate;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneId(String zoneId) {
|
||||
/**
|
||||
* @see UsageRecord#getZoneId()
|
||||
*/
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineId(String virtualMachineId) {
|
||||
/**
|
||||
* @see UsageRecord#getVirtualMachineId()
|
||||
*/
|
||||
public T virtualMachineId(String virtualMachineId) {
|
||||
this.virtualMachineId = virtualMachineId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder virtualMachineName(String virtualMachineName) {
|
||||
/**
|
||||
* @see UsageRecord#getVirtualMachineName()
|
||||
*/
|
||||
public T virtualMachineName(String virtualMachineName) {
|
||||
this.virtualMachineName = virtualMachineName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder serviceOfferingId(String serviceOfferingId) {
|
||||
/**
|
||||
* @see UsageRecord#getServiceOfferingId()
|
||||
*/
|
||||
public T serviceOfferingId(String serviceOfferingId) {
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder templateId(String templateId) {
|
||||
/**
|
||||
* @see UsageRecord#getTemplateId()
|
||||
*/
|
||||
public T templateId(String templateId) {
|
||||
this.templateId = templateId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ipAddress(String ipAddress) {
|
||||
/**
|
||||
* @see UsageRecord#getIpAddress()
|
||||
*/
|
||||
public T ipAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder surceNAT(boolean sourceNAT) {
|
||||
isSourceNAT = sourceNAT;
|
||||
return this;
|
||||
/**
|
||||
* @see UsageRecord#isSourceNAT()
|
||||
*/
|
||||
public T isSourceNAT(boolean isSourceNAT) {
|
||||
this.isSourceNAT = isSourceNAT;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder rawUsageHours(double rawUsageHours) {
|
||||
/**
|
||||
* @see UsageRecord#getRawUsageHours()
|
||||
*/
|
||||
public T rawUsageHours(double rawUsageHours) {
|
||||
this.rawUsageHours = rawUsageHours;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder usage(String usage) {
|
||||
/**
|
||||
* @see UsageRecord#getUsage()
|
||||
*/
|
||||
public T usage(String usage) {
|
||||
this.usage = usage;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder type(String type) {
|
||||
/**
|
||||
* @see UsageRecord#getType()
|
||||
*/
|
||||
public T type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder usageType(UsageType usageType) {
|
||||
/**
|
||||
* @see UsageRecord#getUsageType()
|
||||
*/
|
||||
public T usageType(UsageType usageType) {
|
||||
this.usageType = usageType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public UsageRecord build() {
|
||||
return new UsageRecord(id, description, accountId, accountName, domainId, startDate, endDate, assignDate, releaseDate, zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours, usage, type, usageType);
|
||||
return new UsageRecord(id, description, accountId, accountName, domainId, startDate, endDate, assignDate, releaseDate,
|
||||
zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours,
|
||||
usage, type, usageType);
|
||||
}
|
||||
|
||||
public T fromUsageRecord(UsageRecord in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.description(in.getDescription())
|
||||
.accountId(in.getAccountId())
|
||||
.accountName(in.getAccountName())
|
||||
.domainId(in.getDomainId())
|
||||
.startDate(in.getStartDate())
|
||||
.endDate(in.getEndDate())
|
||||
.assignDate(in.getAssignDate())
|
||||
.releaseDate(in.getReleaseDate())
|
||||
.zoneId(in.getZoneId())
|
||||
.virtualMachineId(in.getVirtualMachineId())
|
||||
.virtualMachineName(in.getVirtualMachineName())
|
||||
.serviceOfferingId(in.getServiceOfferingId())
|
||||
.templateId(in.getTemplateId())
|
||||
.ipAddress(in.getIpAddress())
|
||||
.isSourceNAT(in.isSourceNAT())
|
||||
.rawUsageHours(in.getRawUsageHours())
|
||||
.usage(in.getUsage())
|
||||
.type(in.getType())
|
||||
.usageType(in.getUsageType());
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("usageid") private String id;
|
||||
private String description;
|
||||
@SerializedName("accountid") private String accountId;
|
||||
@SerializedName("account") private String accountName;
|
||||
@SerializedName("domainid") private String domainId;
|
||||
@SerializedName("startdate") private Date startDate;
|
||||
@SerializedName("enddate") private Date endDate;
|
||||
@SerializedName("assigndate") private Date assignDate;
|
||||
@SerializedName("releasedate") private String releaseDate;
|
||||
@SerializedName("zoneid") private String zoneId;
|
||||
@SerializedName("virtualmachineid") private String virtualMachineId;
|
||||
@SerializedName("name") private String virtualMachineName;
|
||||
@SerializedName("offeringid") private String serviceOfferingId;
|
||||
@SerializedName("templateid") private String templateId;
|
||||
@SerializedName("ipaddress") private String ipAddress;
|
||||
@SerializedName("issourcenat") private boolean isSourceNAT;
|
||||
@SerializedName("rawusage") private double rawUsageHours;
|
||||
@SerializedName("usage") private String usage;
|
||||
private String type;
|
||||
@SerializedName("usagetype") private UsageType usageType;
|
||||
|
||||
/* Exists only for the deserializer */
|
||||
UsageRecord(){
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public UsageRecord(String id, String description, String accountId, String accountName, String domainId, Date startDate, Date endDate, Date assignDate, String releaseDate, String zoneId, String virtualMachineId, String virtualMachineName, String serviceOfferingId, String templateId, String ipAddress, boolean sourceNAT, double rawUsageHours, String usage, String type, UsageType usageType) {
|
||||
this.id = id;
|
||||
@Named("usageid")
|
||||
private final String id;
|
||||
private final String description;
|
||||
@Named("accountid")
|
||||
private final String accountId;
|
||||
@Named("account")
|
||||
private final String accountName;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("startdate")
|
||||
private final Date startDate;
|
||||
@Named("enddate")
|
||||
private final Date endDate;
|
||||
@Named("assigndate")
|
||||
private final Date assignDate;
|
||||
@Named("releasedate")
|
||||
private final String releaseDate;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
@Named("virtualmachineid")
|
||||
private final String virtualMachineId;
|
||||
@Named("name")
|
||||
private final String virtualMachineName;
|
||||
@Named("offeringid")
|
||||
private final String serviceOfferingId;
|
||||
@Named("templateid")
|
||||
private final String templateId;
|
||||
@Named("ipaddress")
|
||||
private final String ipAddress;
|
||||
@Named("issourcenat")
|
||||
private final boolean isSourceNAT;
|
||||
@Named("rawusage")
|
||||
private final double rawUsageHours;
|
||||
private final String usage;
|
||||
private final String type;
|
||||
@Named("usagetype")
|
||||
private final UsageType usageType;
|
||||
|
||||
@ConstructorProperties({
|
||||
"usageid", "description", "accountid", "account", "domainid", "startdate", "enddate", "assigndate", "releasedate",
|
||||
"zoneid", "virtualmachineid", "name", "offeringid", "templateid", "ipaddress", "issourcenat", "rawusage", "usage",
|
||||
"type", "usagetype"
|
||||
})
|
||||
protected UsageRecord(String id, @Nullable String description, @Nullable String accountId, @Nullable String accountName,
|
||||
@Nullable String domainId, @Nullable Date startDate, @Nullable Date endDate, @Nullable Date assignDate,
|
||||
@Nullable String releaseDate, @Nullable String zoneId, @Nullable String virtualMachineId, @Nullable String virtualMachineName,
|
||||
@Nullable String serviceOfferingId, @Nullable String templateId, @Nullable String ipAddress,
|
||||
boolean isSourceNAT, double rawUsageHours, @Nullable String usage, @Nullable String type, @Nullable UsageType usageType) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.description = description;
|
||||
this.accountId = accountId;
|
||||
this.accountName = accountName;
|
||||
|
@ -257,7 +381,7 @@ public class UsageRecord implements Comparable<UsageRecord> {
|
|||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.templateId = templateId;
|
||||
this.ipAddress = ipAddress;
|
||||
isSourceNAT = sourceNAT;
|
||||
this.isSourceNAT = isSourceNAT;
|
||||
this.rawUsageHours = rawUsageHours;
|
||||
this.usage = usage;
|
||||
this.type = type;
|
||||
|
@ -265,152 +389,149 @@ public class UsageRecord implements Comparable<UsageRecord> {
|
|||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
return this.accountId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
return this.accountName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
return this.startDate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
return this.endDate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getAssignDate() {
|
||||
return assignDate;
|
||||
return this.assignDate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getReleaseDate() {
|
||||
return releaseDate;
|
||||
return this.releaseDate;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getVirtualMachineId() {
|
||||
return virtualMachineId;
|
||||
return this.virtualMachineId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getVirtualMachineName() {
|
||||
return virtualMachineName;
|
||||
return this.virtualMachineName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
return this.serviceOfferingId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTemplateId() {
|
||||
return templateId;
|
||||
return this.templateId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
return this.ipAddress;
|
||||
}
|
||||
|
||||
public boolean isSourceNAT() {
|
||||
return isSourceNAT;
|
||||
return this.isSourceNAT;
|
||||
}
|
||||
|
||||
public double getRawUsageHours() {
|
||||
return rawUsageHours;
|
||||
return this.rawUsageHours;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
return this.usage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UsageType getUsageType() {
|
||||
return usageType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
UsageRecord that = (UsageRecord) o;
|
||||
|
||||
if (!Objects.equal(accountId, that.accountId)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(isSourceNAT, that.isSourceNAT)) return false;
|
||||
if (!Objects.equal(rawUsageHours, that.rawUsageHours)) return false;
|
||||
if (!Objects.equal(releaseDate, that.releaseDate)) return false;
|
||||
if (!Objects.equal(serviceOfferingId, that.serviceOfferingId)) return false;
|
||||
if (!Objects.equal(templateId, that.templateId)) return false;
|
||||
if (!Objects.equal(virtualMachineId, that.virtualMachineId)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(accountName, that.accountName)) return false;
|
||||
if (!Objects.equal(assignDate, that.assignDate)) return false;
|
||||
if (!Objects.equal(description, that.description)) return false;
|
||||
if (!Objects.equal(endDate, that.endDate)) return false;
|
||||
if (!Objects.equal(ipAddress, that.ipAddress)) return false;
|
||||
if (!Objects.equal(startDate, that.startDate)) return false;
|
||||
if (!Objects.equal(type, that.type)) return false;
|
||||
if (!Objects.equal(usage, that.usage)) return false;
|
||||
if (!Objects.equal(usageType, that.usageType)) return false;
|
||||
if (!Objects.equal(virtualMachineName, that.virtualMachineName)) return false;
|
||||
|
||||
return true;
|
||||
return this.usageType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(accountId, domainId, id, isSourceNAT, rawUsageHours, releaseDate,
|
||||
serviceOfferingId, templateId, virtualMachineId, zoneId, accountName,
|
||||
assignDate, description, endDate, ipAddress, startDate, type, usage,
|
||||
usageType, virtualMachineName);
|
||||
return Objects.hashCode(id, description, accountId, accountName, domainId, startDate, endDate, assignDate, releaseDate,
|
||||
zoneId, virtualMachineId, virtualMachineName, serviceOfferingId, templateId, ipAddress, isSourceNAT, rawUsageHours,
|
||||
usage, type, usageType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
UsageRecord that = UsageRecord.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.accountId, that.accountId)
|
||||
&& Objects.equal(this.accountName, that.accountName)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.startDate, that.startDate)
|
||||
&& Objects.equal(this.endDate, that.endDate)
|
||||
&& Objects.equal(this.assignDate, that.assignDate)
|
||||
&& Objects.equal(this.releaseDate, that.releaseDate)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.virtualMachineId, that.virtualMachineId)
|
||||
&& Objects.equal(this.virtualMachineName, that.virtualMachineName)
|
||||
&& Objects.equal(this.serviceOfferingId, that.serviceOfferingId)
|
||||
&& Objects.equal(this.templateId, that.templateId)
|
||||
&& Objects.equal(this.ipAddress, that.ipAddress)
|
||||
&& Objects.equal(this.isSourceNAT, that.isSourceNAT)
|
||||
&& Objects.equal(this.rawUsageHours, that.rawUsageHours)
|
||||
&& Objects.equal(this.usage, that.usage)
|
||||
&& Objects.equal(this.type, that.type)
|
||||
&& Objects.equal(this.usageType, that.usageType);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("description", description).add("accountId", accountId).add("accountName", accountName)
|
||||
.add("domainId", domainId).add("startDate", startDate).add("endDate", endDate).add("assignDate", assignDate)
|
||||
.add("releaseDate", releaseDate).add("zoneId", zoneId).add("virtualMachineId", virtualMachineId)
|
||||
.add("virtualMachineName", virtualMachineName).add("serviceOfferingId", serviceOfferingId).add("templateId", templateId)
|
||||
.add("ipAddress", ipAddress).add("isSourceNAT", isSourceNAT).add("rawUsageHours", rawUsageHours).add("usage", usage)
|
||||
.add("type", type).add("usageType", usageType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UsageRecord{" +
|
||||
"id=" + id +
|
||||
", description='" + description + '\'' +
|
||||
", accountId=" + accountId +
|
||||
", accountName='" + accountName + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", startDate=" + startDate +
|
||||
", endDate=" + endDate +
|
||||
", assignDate=" + assignDate +
|
||||
", releaseDate=" + releaseDate +
|
||||
", zoneId=" + zoneId +
|
||||
", virtualMachineId=" + virtualMachineId +
|
||||
", virtualMachineName='" + virtualMachineName + '\'' +
|
||||
", serviceOfferingId=" + serviceOfferingId +
|
||||
", templateId=" + templateId +
|
||||
", ipAddress='" + ipAddress + '\'' +
|
||||
", isSourceNAT=" + isSourceNAT +
|
||||
", rawUsageHours=" + rawUsageHours +
|
||||
", usage='" + usage + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", usageType=" + usageType +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(UsageRecord other) {
|
||||
return this.id.compareTo(other.id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,172 +18,249 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Account.Type;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class User implements Comparable<User> {
|
||||
*/
|
||||
public class User {
|
||||
|
||||
/**
|
||||
*/
|
||||
public static enum State {
|
||||
ENABLED,
|
||||
DISABLED,
|
||||
UNKNOWN;
|
||||
|
||||
|
||||
public static State fromValue(String value) {
|
||||
try {
|
||||
return valueOf(value.toUpperCase());
|
||||
} catch(IllegalArgumentException e) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
try {
|
||||
return valueOf(value.toUpperCase());
|
||||
} catch(IllegalArgumentException e) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase();
|
||||
return name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromUser(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String name;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private Date created;
|
||||
private State state;
|
||||
private String account;
|
||||
private Account.Type accountType;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private String timeZone;
|
||||
private String apiKey;
|
||||
private String secretKey;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String firstName;
|
||||
protected String lastName;
|
||||
protected String email;
|
||||
protected Date created;
|
||||
protected User.State state;
|
||||
protected String account;
|
||||
protected Account.Type accountType;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected String timeZone;
|
||||
protected String apiKey;
|
||||
protected String secretKey;
|
||||
|
||||
/**
|
||||
* @see User#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see User#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder firstName(String firstName) {
|
||||
/**
|
||||
* @see User#getFirstName()
|
||||
*/
|
||||
public T firstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder lastName(String lastName) {
|
||||
/**
|
||||
* @see User#getLastName()
|
||||
*/
|
||||
public T lastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder email(String email) {
|
||||
/**
|
||||
* @see User#getEmail()
|
||||
*/
|
||||
public T email(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder created(Date created) {
|
||||
/**
|
||||
* @see User#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder state(State state) {
|
||||
/**
|
||||
* @see User#getState()
|
||||
*/
|
||||
public T state(User.State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
/**
|
||||
* @see User#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder accountType(Account.Type accountType) {
|
||||
/**
|
||||
* @see User#getAccountType()
|
||||
*/
|
||||
public T accountType(Account.Type accountType) {
|
||||
this.accountType = accountType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see User#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see User#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder timeZone(String timeZone) {
|
||||
/**
|
||||
* @see User#getTimeZone()
|
||||
*/
|
||||
public T timeZone(String timeZone) {
|
||||
this.timeZone = timeZone;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder apiKey(String apiKey) {
|
||||
/**
|
||||
* @see User#getApiKey()
|
||||
*/
|
||||
public T apiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder secretKey(String secretKey) {
|
||||
/**
|
||||
* @see User#getSecretKey()
|
||||
*/
|
||||
public T secretKey(String secretKey) {
|
||||
this.secretKey = secretKey;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public User build() {
|
||||
return new User(id, name, firstName, lastName, email, created, state, account, accountType, domain, domainId,
|
||||
timeZone, apiKey, secretKey);
|
||||
return new User(id, name, firstName, lastName, email, created, state, account, accountType, domain, domainId, timeZone, apiKey, secretKey);
|
||||
}
|
||||
|
||||
public T fromUser(User in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.name(in.getName())
|
||||
.firstName(in.getFirstName())
|
||||
.lastName(in.getLastName())
|
||||
.email(in.getEmail())
|
||||
.created(in.getCreated())
|
||||
.state(in.getState())
|
||||
.account(in.getAccount())
|
||||
.accountType(in.getAccountType())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.timeZone(in.getTimeZone())
|
||||
.apiKey(in.getApiKey())
|
||||
.secretKey(in.getSecretKey());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*
|
||||
*/
|
||||
User() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
@SerializedName("username")
|
||||
private String name;
|
||||
@SerializedName("firstname")
|
||||
private String firstName;
|
||||
@SerializedName("lastname")
|
||||
private String lastName;
|
||||
private String email;
|
||||
private Date created;
|
||||
private State state;
|
||||
private String account;
|
||||
@SerializedName("accounttype")
|
||||
private Account.Type accountType;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("timezone")
|
||||
private String timeZone;
|
||||
@SerializedName("apikey")
|
||||
private String apiKey;
|
||||
@SerializedName("secretkey")
|
||||
private String secretKey;
|
||||
private final String id;
|
||||
@Named("username")
|
||||
private final String name;
|
||||
@Named("firstname")
|
||||
private final String firstName;
|
||||
@Named("lastname")
|
||||
private final String lastName;
|
||||
private final String email;
|
||||
private final Date created;
|
||||
private final User.State state;
|
||||
private final String account;
|
||||
@Named("accounttype")
|
||||
private final Account.Type accountType;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("timezone")
|
||||
private final String timeZone;
|
||||
@Named("apikey")
|
||||
private final String apiKey;
|
||||
@Named("secretkey")
|
||||
private final String secretKey;
|
||||
|
||||
public User(String id, String name, String firstname, String lastname, String email, Date created, State state,
|
||||
String account, Type accountType, String domain, String domainId, String timeZone, String apiKey,
|
||||
String secretKey) {
|
||||
this.id = id;
|
||||
@ConstructorProperties({
|
||||
"id", "username", "firstname", "lastname", "email", "created", "state", "account", "accounttype", "domain",
|
||||
"domainid", "timezone", "apikey", "secretkey"
|
||||
})
|
||||
protected User(String id, @Nullable String name, @Nullable String firstName, @Nullable String lastName,
|
||||
@Nullable String email, @Nullable Date created, @Nullable User.State state, @Nullable String account,
|
||||
@Nullable Account.Type accountType, @Nullable String domain, @Nullable String domainId, @Nullable String timeZone,
|
||||
@Nullable String apiKey, @Nullable String secretKey) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = name;
|
||||
this.firstName = firstname;
|
||||
this.lastName = lastname;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.email = email;
|
||||
this.created = created;
|
||||
this.state = state;
|
||||
|
@ -197,159 +274,152 @@ public class User implements Comparable<User> {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the user ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the user name
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the user firstname
|
||||
*/
|
||||
@Nullable
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
return this.firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the user lastname
|
||||
*/
|
||||
@Nullable
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
return this.lastName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the user email address
|
||||
*/
|
||||
@Nullable
|
||||
public String getEmail() {
|
||||
return email;
|
||||
return this.email;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the date and time the user account was created
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the user state
|
||||
*/
|
||||
public State getState() {
|
||||
return state;
|
||||
@Nullable
|
||||
public User.State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the account name of the user
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the account type of the user
|
||||
*/
|
||||
@Nullable
|
||||
public Account.Type getAccountType() {
|
||||
return accountType;
|
||||
return this.accountType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the domain name of the user
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the domain ID of the user
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the timezone user was created in
|
||||
*/
|
||||
@Nullable
|
||||
public String getTimeZone() {
|
||||
return timeZone;
|
||||
return this.timeZone;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the api key of the user
|
||||
*/
|
||||
@Nullable
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
return this.apiKey;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the secret key of the user
|
||||
*/
|
||||
@Nullable
|
||||
public String getSecretKey() {
|
||||
return secretKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(User arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
User that = (User) o;
|
||||
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
|
||||
return true;
|
||||
return this.secretKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(account, domainId, id);
|
||||
return Objects.hashCode(id, name, firstName, lastName, email, created, state, account, accountType, domain, domainId, timeZone, apiKey, secretKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
User that = User.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.firstName, that.firstName)
|
||||
&& Objects.equal(this.lastName, that.lastName)
|
||||
&& Objects.equal(this.email, that.email)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.accountType, that.accountType)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.timeZone, that.timeZone)
|
||||
&& Objects.equal(this.apiKey, that.apiKey)
|
||||
&& Objects.equal(this.secretKey, that.secretKey);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("name", name).add("firstName", firstName).add("lastName", lastName).add("email", email)
|
||||
.add("created", created).add("state", state).add("account", account).add("accountType", accountType).add("domain", domain)
|
||||
.add("domainId", domainId).add("timeZone", timeZone).add("apiKey", apiKey).add("secretKey", secretKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", created=" + created +
|
||||
", state='" + state + '\'' +
|
||||
", account='" + account + '\'' +
|
||||
", accountType=" + accountType +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", timeZone='" + timeZone + '\'' +
|
||||
", apiKey='" + apiKey + '\'' +
|
||||
", secretKey='" + secretKey + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,74 +18,127 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Class VMGroup
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
public class VMGroup implements Comparable<VMGroup> {
|
||||
*/
|
||||
public class VMGroup {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromVMGroup(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private Date created;
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private String name;
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String account;
|
||||
protected Date created;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected String name;
|
||||
|
||||
/**
|
||||
* @see VMGroup#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
/**
|
||||
* @see VMGroup#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder created(Date created) {
|
||||
/**
|
||||
* @see VMGroup#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see VMGroup#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see VMGroup#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see VMGroup#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public VMGroup build() {
|
||||
return new VMGroup(id, account, created, domain, domainId, name);
|
||||
}
|
||||
|
||||
public T fromVMGroup(VMGroup in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.account(in.getAccount())
|
||||
.created(in.getCreated())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.name(in.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String account;
|
||||
private Date created;
|
||||
private String domain;
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
private String name;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public VMGroup(String id, String account, Date created, String domain, String domainId, String name) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String account;
|
||||
private final Date created;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
private final String name;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "account", "created", "domain", "domainid", "name"
|
||||
})
|
||||
protected VMGroup(String id, @Nullable String account, @Nullable Date created, @Nullable String domain,
|
||||
@Nullable String domainId, @Nullable String name) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.account = account;
|
||||
this.created = created;
|
||||
this.domain = domain;
|
||||
|
@ -93,90 +146,78 @@ public class VMGroup implements Comparable<VMGroup> {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
VMGroup() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VMGroup's ID
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the account that owns the VMGroup
|
||||
*/
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VMGroup's creation timestamp
|
||||
*/
|
||||
@Nullable
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the domain that contains the VMGroup
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ID of the domain that contains the VMGroup
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the VMGroup
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
VMGroup that = (VMGroup) o;
|
||||
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(created, that.created)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
|
||||
return true;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(domainId, id, account, created, domain, name);
|
||||
return Objects.hashCode(id, account, created, domain, domainId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
VMGroup that = VMGroup.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.created, that.created)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.name, that.name);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("account", account).add("created", created).add("domain", domain).add("domainId", domainId).add("name", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VMGroup{" +
|
||||
"id=" + id +
|
||||
", account='" + account + '\'' +
|
||||
", created=" + created +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", name='" + name + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(VMGroup vmGroup) {
|
||||
return id.compareTo(vmGroup.getId());
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,139 +18,236 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents the data object used in CloudStack's "Vlan" API.
|
||||
*
|
||||
*
|
||||
* @author Richard Downer
|
||||
*/
|
||||
*/
|
||||
public class VlanIPRange implements Comparable<VlanIPRange> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromVlanIPRange(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
private boolean forVirtualNetwork;
|
||||
private String zoneId;
|
||||
private String vlan;
|
||||
private String account;
|
||||
private String domainId;
|
||||
private String domain;
|
||||
private String podId;
|
||||
private String podName;
|
||||
private String gateway;
|
||||
private String netmask;
|
||||
private String startIP;
|
||||
private String endIP;
|
||||
private String networkId;
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String description;
|
||||
protected boolean forVirtualNetwork;
|
||||
protected String zoneId;
|
||||
protected String vlan;
|
||||
protected String account;
|
||||
protected String domainId;
|
||||
protected String domain;
|
||||
protected String podId;
|
||||
protected String podName;
|
||||
protected String gateway;
|
||||
protected String netmask;
|
||||
protected String startIP;
|
||||
protected String endIP;
|
||||
protected String networkId;
|
||||
|
||||
/**
|
||||
* @see VlanIPRange#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see VlanIPRange#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder forVirtualNetwork(boolean forVirtualNetwork) {
|
||||
/**
|
||||
* @see VlanIPRange#isForVirtualNetwork()
|
||||
*/
|
||||
public T forVirtualNetwork(boolean forVirtualNetwork) {
|
||||
this.forVirtualNetwork = forVirtualNetwork;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneId(String zoneId) {
|
||||
/**
|
||||
* @see VlanIPRange#getZoneId()
|
||||
*/
|
||||
public T zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder vlan(String vlan) {
|
||||
/**
|
||||
* @see VlanIPRange#getVlan()
|
||||
*/
|
||||
public T vlan(String vlan) {
|
||||
this.vlan = vlan;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder account(String account) {
|
||||
/**
|
||||
* @see VlanIPRange#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see VlanIPRange#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see VlanIPRange#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder podId(String podId) {
|
||||
/**
|
||||
* @see VlanIPRange#getPodId()
|
||||
*/
|
||||
public T podId(String podId) {
|
||||
this.podId = podId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder podName(String podName) {
|
||||
/**
|
||||
* @see VlanIPRange#getPodName()
|
||||
*/
|
||||
public T podName(String podName) {
|
||||
this.podName = podName;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder gateway(String gateway) {
|
||||
/**
|
||||
* @see VlanIPRange#getGateway()
|
||||
*/
|
||||
public T gateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder netmask(String netmask) {
|
||||
/**
|
||||
* @see VlanIPRange#getNetmask()
|
||||
*/
|
||||
public T netmask(String netmask) {
|
||||
this.netmask = netmask;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder startIP(String startIP) {
|
||||
/**
|
||||
* @see VlanIPRange#getStartIP()
|
||||
*/
|
||||
public T startIP(String startIP) {
|
||||
this.startIP = startIP;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder endIP(String endIP) {
|
||||
/**
|
||||
* @see VlanIPRange#getEndIP()
|
||||
*/
|
||||
public T endIP(String endIP) {
|
||||
this.endIP = endIP;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder networkId(String networkId) {
|
||||
/**
|
||||
* @see VlanIPRange#getNetworkId()
|
||||
*/
|
||||
public T networkId(String networkId) {
|
||||
this.networkId = networkId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public VlanIPRange build() {
|
||||
return new VlanIPRange(id, description, forVirtualNetwork, zoneId, vlan, account, domainId, domain, podId,
|
||||
podName, gateway, netmask, startIP, endIP, networkId);
|
||||
}
|
||||
|
||||
public VlanIPRange build() {
|
||||
return new VlanIPRange(id, description, forVirtualNetwork, zoneId, vlan, account, domainId, domain, podId, podName, gateway, netmask, startIP, endIP, networkId);
|
||||
public T fromVlanIPRange(VlanIPRange in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.description(in.getDescription())
|
||||
.forVirtualNetwork(in.isForVirtualNetwork())
|
||||
.zoneId(in.getZoneId())
|
||||
.vlan(in.getVlan())
|
||||
.account(in.getAccount())
|
||||
.domainId(in.getDomainId())
|
||||
.domain(in.getDomain())
|
||||
.podId(in.getPodId())
|
||||
.podName(in.getPodName())
|
||||
.gateway(in.getGateway())
|
||||
.netmask(in.getNetmask())
|
||||
.startIP(in.getStartIP())
|
||||
.endIP(in.getEndIP())
|
||||
.networkId(in.getNetworkId());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
@SerializedName("forvirtualnetwork") private boolean forVirtualNetwork;
|
||||
@SerializedName("zoneid") private String zoneId;
|
||||
private String vlan;
|
||||
private String account;
|
||||
@SerializedName("domainid") private String domainId;
|
||||
private String domain;
|
||||
@SerializedName("podid") private String podId;
|
||||
@SerializedName("podname") private String podName;
|
||||
private String gateway;
|
||||
private String netmask;
|
||||
@SerializedName("startip") private String startIP;
|
||||
@SerializedName("endip") private String endIP;
|
||||
@SerializedName("networkid") private String networkId;
|
||||
|
||||
/* just for the deserializer */
|
||||
VlanIPRange() {}
|
||||
|
||||
public VlanIPRange(String id, String description, boolean forVirtualNetwork, String zoneId, String vlan, String account, String domainId, String domain, String podId, String podName, String gateway, String netmask, String startIP, String endIP, String networkId) {
|
||||
this.id = id;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String id;
|
||||
private final String description;
|
||||
@Named("forvirtualnetwork")
|
||||
private final boolean forVirtualNetwork;
|
||||
@Named("zoneid")
|
||||
private final String zoneId;
|
||||
private final String vlan;
|
||||
private final String account;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
private final String domain;
|
||||
@Named("podid")
|
||||
private final String podId;
|
||||
@Named("podname")
|
||||
private final String podName;
|
||||
private final String gateway;
|
||||
private final String netmask;
|
||||
@Named("startip")
|
||||
private final String startIP;
|
||||
@Named("endip")
|
||||
private final String endIP;
|
||||
@Named("networkid")
|
||||
private final String networkId;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "description", "forvirtualnetwork", "zoneid", "vlan", "account", "domainid", "domain", "podid", "podname",
|
||||
"gateway", "netmask", "startip", "endip", "networkid"
|
||||
})
|
||||
protected VlanIPRange(String id, @Nullable String description, boolean forVirtualNetwork, @Nullable String zoneId,
|
||||
@Nullable String vlan, @Nullable String account, @Nullable String domainId, @Nullable String domain,
|
||||
@Nullable String podId, @Nullable String podName, @Nullable String gateway, @Nullable String netmask,
|
||||
@Nullable String startIP, @Nullable String endIP, @Nullable String networkId) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.description = description;
|
||||
this.forVirtualNetwork = forVirtualNetwork;
|
||||
this.zoneId = zoneId;
|
||||
|
@ -168,121 +265,121 @@ public class VlanIPRange implements Comparable<VlanIPRange> {
|
|||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public boolean isForVirtualNetwork() {
|
||||
return forVirtualNetwork;
|
||||
return this.forVirtualNetwork;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getVlan() {
|
||||
return vlan;
|
||||
return this.vlan;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPodId() {
|
||||
return podId;
|
||||
return this.podId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPodName() {
|
||||
return podName;
|
||||
return this.podName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
return this.gateway;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
return this.netmask;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getStartIP() {
|
||||
return startIP;
|
||||
return this.startIP;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getEndIP() {
|
||||
return endIP;
|
||||
return this.endIP;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
VlanIPRange that = (VlanIPRange) o;
|
||||
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(forVirtualNetwork, that.forVirtualNetwork)) return false;
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(networkId, that.networkId)) return false;
|
||||
if (!Objects.equal(podId, that.podId)) return false;
|
||||
if (!Objects.equal(zoneId, that.zoneId)) return false;
|
||||
if (!Objects.equal(account, that.account)) return false;
|
||||
if (!Objects.equal(description, that.description)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(endIP, that.endIP)) return false;
|
||||
if (!Objects.equal(gateway, that.gateway)) return false;
|
||||
if (!Objects.equal(netmask, that.netmask)) return false;
|
||||
if (!Objects.equal(podName, that.podName)) return false;
|
||||
if (!Objects.equal(startIP, that.startIP)) return false;
|
||||
if (!Objects.equal(vlan, that.vlan)) return false;
|
||||
|
||||
return true;
|
||||
return this.networkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(domainId, forVirtualNetwork, id, networkId, podId,
|
||||
zoneId, account, description, domain, endIP, gateway,
|
||||
netmask, podName, startIP, vlan);
|
||||
return Objects.hashCode(id, description, forVirtualNetwork, zoneId, vlan, account, domainId, domain, podId, podName, gateway, netmask, startIP, endIP, networkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
VlanIPRange that = VlanIPRange.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.forVirtualNetwork, that.forVirtualNetwork)
|
||||
&& Objects.equal(this.zoneId, that.zoneId)
|
||||
&& Objects.equal(this.vlan, that.vlan)
|
||||
&& Objects.equal(this.account, that.account)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.podId, that.podId)
|
||||
&& Objects.equal(this.podName, that.podName)
|
||||
&& Objects.equal(this.gateway, that.gateway)
|
||||
&& Objects.equal(this.netmask, that.netmask)
|
||||
&& Objects.equal(this.startIP, that.startIP)
|
||||
&& Objects.equal(this.endIP, that.endIP)
|
||||
&& Objects.equal(this.networkId, that.networkId);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("description", description).add("forVirtualNetwork", forVirtualNetwork).add("zoneId", zoneId)
|
||||
.add("vlan", vlan).add("account", account).add("domainId", domainId).add("domain", domain).add("podId", podId)
|
||||
.add("podName", podName).add("gateway", gateway).add("netmask", netmask).add("startIP", startIP).add("endIP", endIP)
|
||||
.add("networkId", networkId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VlanIPRange{" +
|
||||
"id=" + id +
|
||||
", description='" + description + '\'' +
|
||||
", forVirtualNetwork=" + forVirtualNetwork +
|
||||
", zoneId=" + zoneId +
|
||||
", vlan='" + vlan + '\'' +
|
||||
", account='" + account + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", domain='" + domain + '\'' +
|
||||
", podId=" + podId +
|
||||
", podName='" + podName + '\'' +
|
||||
", gateway='" + gateway + '\'' +
|
||||
", netmask='" + netmask + '\'' +
|
||||
", startIP='" + startIP + '\'' +
|
||||
", endIP='" + endIP + '\'' +
|
||||
", networkId=" + networkId +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(VlanIPRange other) {
|
||||
return this.id.compareTo(other.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,177 +20,257 @@ package org.jclouds.cloudstack.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole, Andrei Savu
|
||||
*/
|
||||
*/
|
||||
public class Zone implements Comparable<Zone> {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromZone(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String description;
|
||||
private String displayText;
|
||||
private List<String> DNS = ImmutableList.of();
|
||||
private String domain;
|
||||
private String domainId;
|
||||
private String guestCIDRAddress;
|
||||
private List<String> internalDNS = ImmutableList.of();
|
||||
private String name;
|
||||
private NetworkType networkType;
|
||||
private String VLAN;
|
||||
private boolean securityGroupsEnabled;
|
||||
private AllocationState allocationState;
|
||||
private String dhcpProvider;
|
||||
private String zoneToken;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
public Builder id(String id) {
|
||||
protected String id;
|
||||
protected String description;
|
||||
protected String displayText;
|
||||
protected String DNS1;
|
||||
protected String DNS2;
|
||||
protected String domain;
|
||||
protected String domainId;
|
||||
protected String guestCIDRAddress;
|
||||
protected String internalDNS1;
|
||||
protected String internalDNS2;
|
||||
protected String name;
|
||||
protected NetworkType networkType;
|
||||
protected String VLAN;
|
||||
protected boolean securityGroupsEnabled;
|
||||
protected AllocationState allocationState;
|
||||
protected String dhcpProvider;
|
||||
protected String zoneToken;
|
||||
|
||||
/**
|
||||
* @see Zone#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
/**
|
||||
* @see Zone#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder displayText(String displayText) {
|
||||
/**
|
||||
* @see Zone#getDisplayText()
|
||||
*/
|
||||
public T displayText(String displayText) {
|
||||
this.displayText = displayText;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder DNS(List<String> DNS) {
|
||||
this.DNS = ImmutableList.copyOf(checkNotNull(DNS, "DNS"));
|
||||
return this;
|
||||
/**
|
||||
* @see Zone#getDNS()
|
||||
*/
|
||||
public T DNS(List<String> DNS) {
|
||||
if (!DNS.isEmpty()) this.DNS1 = DNS.get(0);
|
||||
if (DNS.size() > 1) this.DNS2 = DNS.get(1);
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domain(String domain) {
|
||||
/**
|
||||
* @see Zone#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domainId(String domainId) {
|
||||
/**
|
||||
* @see Zone#getDomainId()
|
||||
*/
|
||||
public T domainId(String domainId) {
|
||||
this.domainId = domainId;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder guestCIDRAddress(String guestCIDRAddress) {
|
||||
/**
|
||||
* @see Zone#getGuestCIDRAddress()
|
||||
*/
|
||||
public T guestCIDRAddress(String guestCIDRAddress) {
|
||||
this.guestCIDRAddress = guestCIDRAddress;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder internalDNS(List<String> internalDNS) {
|
||||
this.internalDNS = ImmutableList.copyOf(checkNotNull(internalDNS, "internalDNS"));
|
||||
return this;
|
||||
/**
|
||||
* @see Zone#getInternalDNS()
|
||||
*/
|
||||
public T internalDNS(List<String> DNS) {
|
||||
if (!DNS.isEmpty()) this.internalDNS1 = DNS.get(0);
|
||||
if (DNS.size() > 1) this.internalDNS2 = DNS.get(1);
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
/**
|
||||
* @see Zone#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder networkType(NetworkType networkType) {
|
||||
/**
|
||||
* @see Zone#getNetworkType()
|
||||
*/
|
||||
public T networkType(NetworkType networkType) {
|
||||
this.networkType = networkType;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder VLAN(String VLAN) {
|
||||
/**
|
||||
* @see Zone#getVLAN()
|
||||
*/
|
||||
public T VLAN(String VLAN) {
|
||||
this.VLAN = VLAN;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder securityGroupsEnabled(boolean securityGroupsEnabled) {
|
||||
/**
|
||||
* @see Zone#isSecurityGroupsEnabled()
|
||||
*/
|
||||
public T securityGroupsEnabled(boolean securityGroupsEnabled) {
|
||||
this.securityGroupsEnabled = securityGroupsEnabled;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
|
||||
public Builder allocationState(AllocationState allocationState) {
|
||||
/**
|
||||
* @see Zone#getAllocationState()
|
||||
*/
|
||||
public T allocationState(AllocationState allocationState) {
|
||||
this.allocationState = allocationState;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder dhcpProvider(String dhcpProvider) {
|
||||
/**
|
||||
* @see Zone#getDhcpProvider()
|
||||
*/
|
||||
public T dhcpProvider(String dhcpProvider) {
|
||||
this.dhcpProvider = dhcpProvider;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder zoneToken(String zoneToken) {
|
||||
/**
|
||||
* @see Zone#getZoneToken()
|
||||
*/
|
||||
public T zoneToken(String zoneToken) {
|
||||
this.zoneToken = zoneToken;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Zone build() {
|
||||
return new Zone(id, description, displayText, DNS, domain, domainId, guestCIDRAddress, internalDNS, name,
|
||||
networkType, VLAN, securityGroupsEnabled, allocationState, dhcpProvider, zoneToken);
|
||||
return new Zone(id, description, displayText, DNS1, DNS2, domain, domainId, guestCIDRAddress, internalDNS1, internalDNS2,
|
||||
name, networkType, VLAN, securityGroupsEnabled, allocationState, dhcpProvider, zoneToken);
|
||||
}
|
||||
|
||||
public T fromZone(Zone in) {
|
||||
return this
|
||||
.id(in.getId())
|
||||
.description(in.getDescription())
|
||||
.displayText(in.getDisplayText())
|
||||
.DNS(in.getDNS())
|
||||
.domain(in.getDomain())
|
||||
.domainId(in.getDomainId())
|
||||
.guestCIDRAddress(in.getGuestCIDRAddress())
|
||||
.internalDNS(in.getInternalDNS())
|
||||
.name(in.getName())
|
||||
.networkType(in.getNetworkType())
|
||||
.VLAN(in.getVLAN())
|
||||
.securityGroupsEnabled(in.isSecurityGroupsEnabled())
|
||||
.allocationState(in.getAllocationState())
|
||||
.dhcpProvider(in.getDhcpProvider())
|
||||
.zoneToken(in.getZoneToken());
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
@SerializedName("displaytext")
|
||||
private String displayText;
|
||||
@SerializedName("dns1")
|
||||
private String DNS1;
|
||||
@SerializedName("dns2")
|
||||
private String DNS2;
|
||||
private String domain;
|
||||
@Nullable
|
||||
@SerializedName("domainid")
|
||||
private String domainId;
|
||||
@SerializedName("guestcidraddress")
|
||||
private String guestCIDRAddress;
|
||||
@SerializedName("internaldns1")
|
||||
private String internalDNS1;
|
||||
@SerializedName("internaldns2")
|
||||
private String internalDNS2;
|
||||
private String name;
|
||||
@SerializedName("networktype")
|
||||
private NetworkType networkType;
|
||||
@SerializedName("vlan")
|
||||
private String VLAN;
|
||||
@SerializedName("securitygroupsenabled")
|
||||
private boolean securityGroupsEnabled;
|
||||
@SerializedName("allocationstate")
|
||||
private AllocationState allocationState;
|
||||
@SerializedName("dhcpprovider")
|
||||
private String dhcpProvider;
|
||||
@SerializedName("zonetoken")
|
||||
private String zoneToken;
|
||||
|
||||
/**
|
||||
* present only for serializer
|
||||
*/
|
||||
Zone() {
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Zone(String id, String description, String displayText, List<String> DNS, String domain, String domainId,
|
||||
String guestCIDRAddress, List<String> internalDNS, String name, NetworkType networkType,
|
||||
String vLAN, boolean securityGroupsEnabled, AllocationState allocationState, String dhcpProvider, String zoneToken) {
|
||||
this.id = id;
|
||||
private final String id;
|
||||
private final String description;
|
||||
@Named("displaytext")
|
||||
private final String displayText;
|
||||
@Named("dns1")
|
||||
private final String DNS1;
|
||||
@Named("dns2")
|
||||
private final String DNS2;
|
||||
private final String domain;
|
||||
@Named("domainid")
|
||||
private final String domainId;
|
||||
@Named("guestcidraddress")
|
||||
private final String guestCIDRAddress;
|
||||
@Named("internaldns1")
|
||||
private final String internalDNS1;
|
||||
@Named("internaldns2")
|
||||
private final String internalDNS2;
|
||||
private final String name;
|
||||
@Named("networktype")
|
||||
private final NetworkType networkType;
|
||||
@Named("vlan")
|
||||
private final String VLAN;
|
||||
@Named("securitygroupsenabled")
|
||||
private final boolean securityGroupsEnabled;
|
||||
@Named("allocationstate")
|
||||
private final AllocationState allocationState;
|
||||
@Named("dhcpprovider")
|
||||
private final String dhcpProvider;
|
||||
@Named("zonetoken")
|
||||
private final String zoneToken;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "description", "displaytext", "dns1", "dns2", "domain", "domainid", "guestcidraddress", "internaldns1", "internaldns2", "name", "networktype", "vlan", "securitygroupsenabled", "allocationstate", "dhcpprovider", "zonetoken"
|
||||
})
|
||||
protected Zone(String id, @Nullable String description, @Nullable String displayText, @Nullable String DNS1, @Nullable String DNS2,
|
||||
@Nullable String domain, @Nullable String domainId, @Nullable String guestCIDRAddress, @Nullable String internalDNS1,
|
||||
@Nullable String internalDNS2, @Nullable String name, @Nullable NetworkType networkType, @Nullable String VLAN,
|
||||
boolean securityGroupsEnabled, @Nullable AllocationState allocationState, @Nullable String dhcpProvider,
|
||||
@Nullable String zoneToken) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.description = description;
|
||||
this.displayText = displayText;
|
||||
this.DNS1 = checkNotNull(DNS, "DNS").size() > 0 ? DNS.get(0) : null;
|
||||
this.DNS2 = DNS.size() > 1 ? DNS.get(1) : null;
|
||||
this.DNS1 = DNS1;
|
||||
this.DNS2 = DNS2;
|
||||
this.domain = domain;
|
||||
this.domainId = domainId;
|
||||
this.guestCIDRAddress = guestCIDRAddress;
|
||||
this.internalDNS1 = checkNotNull(internalDNS, "internalDNS").size() > 0 ? internalDNS.get(0) : null;
|
||||
this.internalDNS2 = internalDNS.size() > 1 ? internalDNS.get(1) : null;
|
||||
this.internalDNS1 = internalDNS1;
|
||||
this.internalDNS2 = internalDNS2;
|
||||
this.name = name;
|
||||
this.networkType = networkType;
|
||||
this.VLAN = vLAN;
|
||||
this.VLAN = VLAN;
|
||||
this.securityGroupsEnabled = securityGroupsEnabled;
|
||||
this.allocationState = allocationState;
|
||||
this.dhcpProvider = dhcpProvider;
|
||||
|
@ -201,21 +281,23 @@ public class Zone implements Comparable<Zone> {
|
|||
* @return Zone id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zone description
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the display text of the zone
|
||||
*/
|
||||
@Nullable
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return this.displayText;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,8 +315,9 @@ public class Zone implements Comparable<Zone> {
|
|||
/**
|
||||
* @return Domain name for the Vms in the zone
|
||||
*/
|
||||
@Nullable
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,14 +325,15 @@ public class Zone implements Comparable<Zone> {
|
|||
*/
|
||||
@Nullable
|
||||
public String getDomainId() {
|
||||
return domainId;
|
||||
return this.domainId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the guest CIDR address for the Zone
|
||||
*/
|
||||
@Nullable
|
||||
public String getGuestCIDRAddress() {
|
||||
return guestCIDRAddress;
|
||||
return this.guestCIDRAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,113 +351,104 @@ public class Zone implements Comparable<Zone> {
|
|||
/**
|
||||
* @return Zone name
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the network type of the zone; can be Basic or Advanced
|
||||
*/
|
||||
@Nullable
|
||||
public NetworkType getNetworkType() {
|
||||
return networkType;
|
||||
return this.networkType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vlan range of the zone
|
||||
*/
|
||||
@Nullable
|
||||
public String getVLAN() {
|
||||
return VLAN;
|
||||
return this.VLAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this zone has security groups enabled
|
||||
*/
|
||||
public boolean isSecurityGroupsEnabled() {
|
||||
return securityGroupsEnabled;
|
||||
return this.securityGroupsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the allocation state of the cluster
|
||||
*/
|
||||
@Nullable
|
||||
public AllocationState getAllocationState() {
|
||||
return allocationState;
|
||||
return this.allocationState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dhcp Provider for the Zone
|
||||
*/
|
||||
@Nullable
|
||||
public String getDhcpProvider() {
|
||||
return dhcpProvider;
|
||||
return this.dhcpProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Zone Token
|
||||
*/
|
||||
@Nullable
|
||||
public String getZoneToken() {
|
||||
return zoneToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Zone that = (Zone) o;
|
||||
|
||||
if (!Objects.equal(id, that.id)) return false;
|
||||
if (!Objects.equal(description, that.description)) return false;
|
||||
if (!Objects.equal(displayText, that.displayText)) return false;
|
||||
if (!Objects.equal(DNS1, that.DNS1)) return false;
|
||||
if (!Objects.equal(DNS2, that.DNS2)) return false;
|
||||
if (!Objects.equal(domain, that.domain)) return false;
|
||||
if (!Objects.equal(domainId, that.domainId)) return false;
|
||||
if (!Objects.equal(guestCIDRAddress, that.guestCIDRAddress)) return false;
|
||||
if (!Objects.equal(internalDNS1, that.internalDNS1)) return false;
|
||||
if (!Objects.equal(internalDNS2, that.internalDNS2)) return false;
|
||||
if (!Objects.equal(name, that.name)) return false;
|
||||
if (!Objects.equal(networkType, that.networkType)) return false;
|
||||
if (!Objects.equal(VLAN, that.VLAN)) return false;
|
||||
if (!Objects.equal(securityGroupsEnabled, that.securityGroupsEnabled)) return false;
|
||||
if (!Objects.equal(allocationState, that.allocationState)) return false;
|
||||
if (!Objects.equal(dhcpProvider, that.dhcpProvider)) return false;
|
||||
if (!Objects.equal(zoneToken, that.zoneToken)) return false;
|
||||
|
||||
return true;
|
||||
return this.zoneToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, description, displayText, DNS1, DNS2, domain, domainId,
|
||||
guestCIDRAddress, internalDNS1, internalDNS2, name, networkType, VLAN,
|
||||
securityGroupsEnabled, allocationState, dhcpProvider,
|
||||
zoneToken);
|
||||
return Objects.hashCode(id, description, displayText, DNS1, DNS2, domain, domainId, guestCIDRAddress, internalDNS1,
|
||||
internalDNS2, name, networkType, VLAN, securityGroupsEnabled, allocationState, dhcpProvider, zoneToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Zone that = Zone.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.description, that.description)
|
||||
&& Objects.equal(this.displayText, that.displayText)
|
||||
&& Objects.equal(this.DNS1, that.DNS1)
|
||||
&& Objects.equal(this.DNS2, that.DNS2)
|
||||
&& Objects.equal(this.domain, that.domain)
|
||||
&& Objects.equal(this.domainId, that.domainId)
|
||||
&& Objects.equal(this.guestCIDRAddress, that.guestCIDRAddress)
|
||||
&& Objects.equal(this.internalDNS1, that.internalDNS1)
|
||||
&& Objects.equal(this.internalDNS2, that.internalDNS2)
|
||||
&& Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.networkType, that.networkType)
|
||||
&& Objects.equal(this.VLAN, that.VLAN)
|
||||
&& Objects.equal(this.securityGroupsEnabled, that.securityGroupsEnabled)
|
||||
&& Objects.equal(this.allocationState, that.allocationState)
|
||||
&& Objects.equal(this.dhcpProvider, that.dhcpProvider)
|
||||
&& Objects.equal(this.zoneToken, that.zoneToken);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.add("id", id).add("description", description).add("displayText", displayText).add("DNS1", DNS1).add("DNS2", DNS2)
|
||||
.add("domain", domain).add("domainId", domainId).add("guestCIDRAddress", guestCIDRAddress).add("internalDNS1", internalDNS1)
|
||||
.add("internalDNS2", internalDNS2).add("name", name).add("networkType", networkType).add("VLAN", VLAN)
|
||||
.add("securityGroupsEnabled", securityGroupsEnabled).add("allocationState", allocationState).add("dhcpProvider", dhcpProvider)
|
||||
.add("zoneToken", zoneToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Zone{" +
|
||||
"id=" + id +
|
||||
", description='" + description + '\'' +
|
||||
", displayText='" + displayText + '\'' +
|
||||
", DNS1='" + DNS1 + '\'' +
|
||||
", DNS2='" + DNS2 + '\'' +
|
||||
", domain='" + domain + '\'' +
|
||||
", domainId=" + domainId +
|
||||
", guestCIDRAddress='" + guestCIDRAddress + '\'' +
|
||||
", internalDNS1='" + internalDNS1 + '\'' +
|
||||
", internalDNS2='" + internalDNS2 + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", networkType=" + networkType +
|
||||
", VLAN='" + VLAN + '\'' +
|
||||
", securityGroupsEnabled=" + securityGroupsEnabled +
|
||||
", allocationState='" + allocationState + '\'' +
|
||||
", dhcpProvider='" + dhcpProvider + '\'' +
|
||||
", zoneToken='" + zoneToken + '\'' +
|
||||
'}';
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Zone arg0) {
|
||||
return id.compareTo(arg0.getId());
|
||||
public int compareTo(Zone o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ public class ParseLoginResponseFromHttpResponse implements Function<HttpResponse
|
|||
String jSessionId = get(Splitter.on("=").split(get(Splitter.on(";").trimResults().split(
|
||||
getOnlyElement(response.getHeaders().get("Set-Cookie"))), 0)), 1);
|
||||
|
||||
return LoginResponse.builder().copyOf(login).jSessionId(jSessionId).build();
|
||||
return LoginResponse.builder().fromLoginResponse(login).jSessionId(jSessionId).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class ParseTypedAsyncJob implements Function<AsyncJob<Map<String, JsonBal
|
|||
if (toParse.getResult() != null) {
|
||||
if (toParse.getResult().size() == 1) {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
Builder<Object> builder = AsyncJob.Builder.fromAsyncJobUntyped((AsyncJob) toParse);
|
||||
Builder<?,Object> builder = AsyncJob.Builder.fromAsyncJobUntyped((AsyncJob) toParse);
|
||||
if (toParse.getResult().containsKey("success")) {
|
||||
builder.result(null);
|
||||
} else {
|
||||
|
@ -118,11 +118,11 @@ public class ParseTypedAsyncJob implements Function<AsyncJob<Map<String, JsonBal
|
|||
result = builder.build();
|
||||
} else if (toParse.getResult().containsKey("errorcode")) {
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
Builder<Object> builder = AsyncJob.Builder.fromAsyncJobUntyped((AsyncJob) toParse);
|
||||
Builder<?, Object> builder = AsyncJob.Builder.fromAsyncJobUntyped((AsyncJob) toParse);
|
||||
builder.result(null);// avoid classcastexceptions
|
||||
builder.error(new AsyncJobError(ErrorCode.fromValue(toParse.getResult().get("errorcode").toString()), toParse
|
||||
.getResult().containsKey("errortext") ? toParse.getResult().get("errortext").toString()
|
||||
.replace("\"", "") : null));
|
||||
builder.error(AsyncJobError.builder().errorCode(ErrorCode.fromValue(toParse.getResult().get("errorcode").toString()))
|
||||
.errorText(toParse.getResult().containsKey("errortext") ? toParse.getResult().get("errortext").toString().replace("\"", "") : null)
|
||||
.build());
|
||||
result = builder.build();
|
||||
} else if (toParse.getResult().size() > 1) {
|
||||
logger.warn("unexpected size of async job result; expecting a map with a single element",
|
||||
|
|
|
@ -28,18 +28,18 @@ import org.jclouds.cloudstack.domain.SnapshotPolicySchedule;
|
|||
*/
|
||||
public class SnapshotPolicySchedules {
|
||||
public static SnapshotPolicySchedule hourly(int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.HOURLY, String.format("%02d", minute));
|
||||
return SnapshotPolicySchedule.builder().interval(Snapshot.Interval.HOURLY).time(String.format("%02d", minute)).build();
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule daily(int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.DAILY, String.format("%02d:%02d", minute, hour));
|
||||
return SnapshotPolicySchedule.builder().interval(Snapshot.Interval.DAILY).time(String.format("%02d:%02d", minute, hour)).build();
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule weekly(int day, int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.WEEKLY, String.format("%02d:%02d:%02d", minute, hour, day));
|
||||
return SnapshotPolicySchedule.builder().interval(Snapshot.Interval.WEEKLY).time(String.format("%02d:%02d:%02d", minute, hour, day)).build();
|
||||
}
|
||||
|
||||
public static SnapshotPolicySchedule monthly(int day, int hour, int minute) {
|
||||
return new SnapshotPolicySchedule(Snapshot.Interval.MONTHLY, String.format("%02d:%02d:%02d", minute, hour, day));
|
||||
return SnapshotPolicySchedule.builder().interval(Snapshot.Interval.MONTHLY).time(String.format("%02d:%02d:%02d", minute, hour, day)).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.jclouds.cloudstack;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.jclouds.cloudstack.features.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.cloudstack.config.CloudStackProperties;
|
||||
import org.jclouds.cloudstack.features.AccountClient;
|
||||
import org.jclouds.cloudstack.features.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.jclouds.cloudstack.domain.ServiceOffering;
|
|||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.domain.Zone;
|
||||
import org.jclouds.cloudstack.features.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.cloudstack.functions.StaticNATVirtualMachineInNetwork;
|
||||
import org.jclouds.cloudstack.functions.ZoneIdToZone;
|
||||
import org.jclouds.cloudstack.predicates.JobComplete;
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.jclouds.cloudstack.domain.EncryptedPasswordAndPrivateKey;
|
|||
import org.jclouds.cloudstack.domain.Network;
|
||||
import org.jclouds.cloudstack.domain.SshKeyPair;
|
||||
import org.jclouds.cloudstack.domain.TrafficType;
|
||||
import org.jclouds.cloudstack.features.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.cloudstack.functions.WindowsLoginCredentialsFromEncryptedData;
|
||||
import org.jclouds.cloudstack.options.ListNetworksOptions;
|
||||
import org.jclouds.compute.RunNodesException;
|
||||
|
@ -160,8 +160,8 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
|||
WindowsLoginCredentialsFromEncryptedData passwordDecrypt = new WindowsLoginCredentialsFromEncryptedData(crypto);
|
||||
|
||||
assertEquals(passwordDecrypt.apply(
|
||||
new EncryptedPasswordAndPrivateKey(encryptedPassword, keyPair.getPrivateKey())).getPassword(),
|
||||
"bX7vvptvw");
|
||||
EncryptedPasswordAndPrivateKey.builder().encryptedPassword(encryptedPassword).privateKey(keyPair.getPrivateKey()).build())
|
||||
.getPassword(), "bX7vvptvw");
|
||||
|
||||
} finally {
|
||||
if (node != null) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class OptionsConverterTest {
|
|||
private static final Map<String,Network> EMPTY_NETWORKS_MAP = Collections.<String, Network>emptyMap();
|
||||
private static final String ZONE_ID = "2";
|
||||
private final NetworkService firewallServiceWithStaticNat
|
||||
= new NetworkService("Firewall", ImmutableMap.of("StaticNat", "true"));
|
||||
= NetworkService.builder().name("Firewall").capabilities(ImmutableMap.of("StaticNat", "true")).build();
|
||||
|
||||
@Test
|
||||
public void testBasicNetworkOptionsConverter() {
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.cloudstack.domain;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -35,17 +36,18 @@ public class VirtualMachineTest {
|
|||
@Test(groups = "unit", enabled = true)
|
||||
public void testCpuUsed() {
|
||||
// Class under test should detect if the % is missing off the end
|
||||
boolean caught = false;
|
||||
try { VirtualMachine.builder().cpuUsed("23.4").build(); } catch (Exception e) { caught = true; }
|
||||
assertTrue(caught);
|
||||
try {
|
||||
VirtualMachine.builder().id("1").cpuUsed("23.4").build();
|
||||
fail("Should have thrown an exception due to % being missing!");
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
// If CpuUsed is not specified at all, that's OK
|
||||
caught = false;
|
||||
try { VirtualMachine.builder().build(); } catch (Exception e) { caught = true; }
|
||||
assertFalse(caught);
|
||||
VirtualMachine vm = VirtualMachine.builder().id("2").build();
|
||||
assertEquals(vm.getCpuUsed(), 0.0f);
|
||||
|
||||
// Retrieving CpuUsed should just give us a straightforward float
|
||||
VirtualMachine vm = VirtualMachine.builder().cpuUsed("23.4%").build();
|
||||
vm = VirtualMachine.builder().id("3").cpuUsed("23.4%").build();
|
||||
assertEquals(vm.getCpuUsed(), 23.4, 0.01);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.cloudstack.features;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListAccountsOptions;
|
||||
import org.jclouds.functions.IdentityFunction;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.functions.ReturnVoidOnNotFoundOr404OrUnableToFindAccountOwner;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.AssociateIPAddressOptions;
|
||||
import org.jclouds.cloudstack.options.ListPublicIPAddressesOptions;
|
||||
import org.jclouds.functions.IdentityFunction;
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
|||
|
||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.cloudstack.options.ListPublicIPAddressesOptions;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.lang.reflect.Method;
|
|||
|
||||
import org.jclouds.cloudstack.functions.ParseAsyncJobFromHttpResponse;
|
||||
import org.jclouds.cloudstack.functions.ParseAsyncJobsFromHttpResponse;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListAsyncJobsOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Set;
|
|||
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob.ResultCode;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.cloudstack.features;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Capabilities;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.cloudstack.features;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
|
|
|
@ -26,6 +26,7 @@ import static org.testng.Assert.assertTrue;
|
|||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.net.URI;
|
|||
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.Domain;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -24,7 +24,7 @@ import static com.google.common.collect.Iterables.find;
|
|||
import com.google.common.collect.Sets;
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import java.util.NoSuchElementException;
|
||||
import static org.jclouds.cloudstack.options.ListDomainChildrenOptions.Builder.name;
|
||||
|
||||
import static org.jclouds.cloudstack.options.ListDomainChildrenOptions.Builder.parentDomainId;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
@ -33,13 +33,10 @@ import static org.testng.Assert.assertTrue;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Domain;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code DomainDomainClient}
|
||||
*
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.lang.reflect.Method;
|
|||
|
||||
import org.jclouds.cloudstack.domain.ResourceLimit;
|
||||
import org.jclouds.cloudstack.domain.ResourceLimit.ResourceType;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.cloudstack.features;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.jclouds.cloudstack.domain.Account;
|
|||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||
import org.jclouds.cloudstack.domain.AsyncJob;
|
||||
import org.jclouds.cloudstack.domain.User;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListEventsOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Event;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.jclouds.cloudstack.CloudStackContext;
|
|||
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
|
||||
import org.jclouds.cloudstack.domain.FirewallRule;
|
||||
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.jclouds.cloudstack.domain.Network;
|
|||
import org.jclouds.cloudstack.domain.PortForwardingRule;
|
||||
import org.jclouds.cloudstack.domain.PublicIPAddress;
|
||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.cloudstack.options.CreateFirewallRuleOptions;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.cloudstack.features;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.CreateAccountOptions;
|
||||
import org.jclouds.cloudstack.options.UpdateAccountOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.testng.Assert.assertNotNull;
|
|||
|
||||
import org.jclouds.cloudstack.CloudStackGlobalClient;
|
||||
import org.jclouds.cloudstack.domain.Account;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.crypto.CryptoStreams;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.cloudstack.features;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListAlertsOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
|
|
|
@ -25,6 +25,7 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Alert;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.cloudstack.options.ListAlertsOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Capacity;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListCapacityOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Capacity;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.net.URI;
|
|||
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.ConfigurationEntry;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.collections.Sets;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.net.URI;
|
|||
|
||||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.Domain;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -26,6 +26,7 @@ import static org.testng.Assert.assertNull;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.cloudstack.domain.Domain;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.cloudstack.features;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.ListHostsOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jclouds.cloudstack.CloudStackContext;
|
|||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Cluster;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.cloudstack.options.AddClusterOptions;
|
||||
import org.jclouds.cloudstack.options.AddHostOptions;
|
||||
import org.jclouds.cloudstack.options.AddSecondaryStorageOptions;
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Cluster;
|
||||
import org.jclouds.cloudstack.domain.Host;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.cloudstack.features;
|
|||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||
import org.jclouds.cloudstack.options.CreateDiskOfferingOptions;
|
||||
import org.jclouds.cloudstack.options.CreateServiceOfferingOptions;
|
||||
import org.jclouds.cloudstack.options.UpdateDiskOfferingOptions;
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jclouds.cloudstack.domain.NetworkOffering;
|
|||
import org.jclouds.cloudstack.domain.NetworkOfferingAvailabilityType;
|
||||
import org.jclouds.cloudstack.domain.ServiceOffering;
|
||||
import org.jclouds.cloudstack.domain.StorageType;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||
import org.jclouds.cloudstack.options.UpdateDiskOfferingOptions;
|
||||
import org.jclouds.cloudstack.options.UpdateNetworkOfferingOptions;
|
||||
import org.jclouds.cloudstack.options.UpdateServiceOfferingOptions;
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.net.URI;
|
|||
import org.jclouds.cloudstack.CloudStackContext;
|
||||
import org.jclouds.cloudstack.domain.AllocationState;
|
||||
import org.jclouds.cloudstack.domain.Pod;
|
||||
import org.jclouds.cloudstack.internal.BaseCloudStackRestClientExpectTest;
|
||||
import org.jclouds.cloudstack.options.CreatePodOptions;
|
||||
import org.jclouds.cloudstack.options.UpdatePodOptions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue