mirror of https://github.com/apache/jclouds.git
Merge pull request #703 from aplowe/master
gogrid: adjusting domain objects for issue 971 - using ConstructorProperties and added builders
This commit is contained in:
commit
2c7f15c498
|
@ -77,10 +77,16 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds.driver</groupId>
|
<groupId>org.jclouds.driver</groupId>
|
||||||
<artifactId>jclouds-log4j</artifactId>
|
<artifactId>jclouds-slf4j</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,72 +18,127 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class BillingToken
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class BillingToken implements Comparable<BillingToken> {
|
public class BillingToken implements Comparable<BillingToken> {
|
||||||
|
|
||||||
private long id;
|
public static Builder<?> builder() {
|
||||||
private String name;
|
return new ConcreteBuilder();
|
||||||
private double price;
|
}
|
||||||
|
|
||||||
/**
|
public Builder<?> toBuilder() {
|
||||||
* A no-args constructor is required for deserialization
|
return new ConcreteBuilder().fromBillingToken(this);
|
||||||
*/
|
|
||||||
public BillingToken() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BillingToken(long id, String name, double price) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected long id;
|
||||||
|
protected String name;
|
||||||
|
protected double price;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see BillingToken#getId()
|
||||||
|
*/
|
||||||
|
public T id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see BillingToken#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see BillingToken#getPrice()
|
||||||
|
*/
|
||||||
|
public T price(double price) {
|
||||||
|
this.price = price;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BillingToken build() {
|
||||||
|
return new BillingToken(id, name, price);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T fromBillingToken(BillingToken in) {
|
||||||
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.name(in.getName())
|
||||||
|
.price(in.getPrice());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final long id;
|
||||||
|
private final String name;
|
||||||
|
private final double price;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "name", "price"
|
||||||
|
})
|
||||||
|
protected BillingToken(long id, String name, double price) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = checkNotNull(name, "name");
|
||||||
this.price = price;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPrice() {
|
public double getPrice() {
|
||||||
return price;
|
return this.price;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
BillingToken other = (BillingToken) obj;
|
|
||||||
if (id != other.id)
|
|
||||||
return false;
|
|
||||||
if (name == null) {
|
|
||||||
if (other.name != null)
|
|
||||||
return false;
|
|
||||||
} else if (!name.equals(other.name))
|
|
||||||
return false;
|
|
||||||
if (Double.doubleToLongBits(price) != Double.doubleToLongBits(other.price))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id, name, price);
|
||||||
int result = 1;
|
}
|
||||||
result = prime * result + (int) (id ^ (id >>> 32));
|
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
@Override
|
||||||
long temp;
|
public boolean equals(Object obj) {
|
||||||
temp = Double.doubleToLongBits(price);
|
if (this == obj) return true;
|
||||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
return result;
|
BillingToken that = BillingToken.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id)
|
||||||
|
&& Objects.equal(this.name, that.name)
|
||||||
|
&& Objects.equal(this.price, that.price);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("name", name).add("price", price);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,8 +146,4 @@ public class BillingToken implements Comparable<BillingToken> {
|
||||||
return Longs.compare(id, o.getId());
|
return Longs.compare(id, o.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "BillingToken{" + "id=" + id + ", name='" + name + '\'' + ", price=" + price + '}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,50 +18,109 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class Customer
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class Customer {
|
public class Customer {
|
||||||
|
|
||||||
private long id;
|
public static Builder<?> builder() {
|
||||||
private String name;
|
return new ConcreteBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromCustomer(this);
|
||||||
|
}
|
||||||
|
|
||||||
public Customer(long id, String name) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
this.id = id;
|
protected abstract T self();
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getId() {
|
protected long id;
|
||||||
return id;
|
protected String name;
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @see Customer#getId()
|
||||||
|
*/
|
||||||
|
public T id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
/**
|
||||||
return name;
|
* @see Customer#getName()
|
||||||
}
|
*/
|
||||||
|
public T name(String name) {
|
||||||
/**
|
this.name = name;
|
||||||
* A no-args constructor is required for deserialization
|
return self();
|
||||||
*/
|
}
|
||||||
public Customer() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public Customer build() {
|
||||||
public boolean equals(Object o) {
|
return new Customer(id, name);
|
||||||
if (this == o) return true;
|
}
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
public T fromCustomer(Customer in) {
|
||||||
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.name(in.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Customer customer = (Customer) o;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (id != customer.id) return false;
|
private final long id;
|
||||||
if (name != null ? !name.equals(customer.name) : customer.name != null) return false;
|
private final String name;
|
||||||
|
|
||||||
return true;
|
@ConstructorProperties({
|
||||||
}
|
"id", "name"
|
||||||
|
})
|
||||||
|
protected Customer(long id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = checkNotNull(name, "name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
Customer that = Customer.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id)
|
||||||
|
&& Objects.equal(this.name, that.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("name", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = (int) (id ^ (id >>> 32));
|
|
||||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,129 +18,187 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.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;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class Ip
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class Ip implements Comparable<Ip> {
|
public class Ip implements Comparable<Ip> {
|
||||||
|
|
||||||
private long id;
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
private String ip;
|
}
|
||||||
private String subnet;
|
|
||||||
@SerializedName("public")
|
public Builder<?> toBuilder() {
|
||||||
private boolean isPublic;
|
return new ConcreteBuilder().fromIp(this);
|
||||||
private IpState state;
|
|
||||||
private Option datacenter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A no-args constructor is required for deserialization
|
|
||||||
*/
|
|
||||||
public Ip() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
* Constructs a generic IP address without any additional options.
|
protected abstract T self();
|
||||||
*
|
|
||||||
* @param ip
|
protected long id;
|
||||||
* ip address
|
protected String ip;
|
||||||
*/
|
protected String subnet;
|
||||||
public Ip(String ip) {
|
protected boolean isPublic;
|
||||||
this.ip = ip;
|
protected IpState state;
|
||||||
|
protected Option datacenter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Ip#getId()
|
||||||
|
*/
|
||||||
|
public T id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Ip#getIp()
|
||||||
|
*/
|
||||||
|
public T ip(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Ip#getSubnet()
|
||||||
|
*/
|
||||||
|
public T subnet(String subnet) {
|
||||||
|
this.subnet = subnet;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Ip#isPublic()
|
||||||
|
*/
|
||||||
|
public T isPublic(boolean isPublic) {
|
||||||
|
this.isPublic = isPublic;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Ip#getState()
|
||||||
|
*/
|
||||||
|
public T state(IpState state) {
|
||||||
|
this.state = state;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Ip#getDatacenter()
|
||||||
|
*/
|
||||||
|
public T datacenter(Option datacenter) {
|
||||||
|
this.datacenter = datacenter;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ip build() {
|
||||||
|
return new Ip(id, ip, subnet, isPublic, state, datacenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T fromIp(Ip in) {
|
||||||
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.ip(in.getIp())
|
||||||
|
.subnet(in.getSubnet())
|
||||||
|
.isPublic(in.isPublic())
|
||||||
|
.state(in.getState())
|
||||||
|
.datacenter(in.getDatacenter());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ip(long id, String ip, String subnet, boolean isPublic, IpState state, Option datacenter) {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final long id;
|
||||||
|
private final String ip;
|
||||||
|
private final String subnet;
|
||||||
|
private final boolean isPublic;
|
||||||
|
private final IpState state;
|
||||||
|
private final Option datacenter;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "ip", "subnet", "public", "state", "datacenter"
|
||||||
|
})
|
||||||
|
protected Ip(long id, String ip, @Nullable String subnet, boolean isPublic, @Nullable IpState state, @Nullable Option datacenter) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.ip = ip;
|
this.ip = checkNotNull(ip, "ip");
|
||||||
this.subnet = subnet;
|
this.subnet = subnet;
|
||||||
this.isPublic = isPublic;
|
this.isPublic = isPublic;
|
||||||
this.state = state;
|
this.state = state == null ? IpState.UNRECOGNIZED : state;
|
||||||
this.datacenter = datacenter;
|
this.datacenter = datacenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
|
||||||
|
|
||||||
public Option getDatacenter() {
|
|
||||||
return datacenter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIp() {
|
public String getIp() {
|
||||||
return ip;
|
return this.ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getSubnet() {
|
public String getSubnet() {
|
||||||
return subnet;
|
return this.subnet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return isPublic;
|
return this.isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IpState getState() {
|
public IpState getState() {
|
||||||
return state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Nullable
|
||||||
public boolean equals(Object obj) {
|
public Option getDatacenter() {
|
||||||
if (this == obj)
|
return this.datacenter;
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
Ip other = (Ip) obj;
|
|
||||||
if (datacenter == null) {
|
|
||||||
if (other.datacenter != null)
|
|
||||||
return false;
|
|
||||||
} else if (!datacenter.equals(other.datacenter))
|
|
||||||
return false;
|
|
||||||
if (id != other.id)
|
|
||||||
return false;
|
|
||||||
if (ip == null) {
|
|
||||||
if (other.ip != null)
|
|
||||||
return false;
|
|
||||||
} else if (!ip.equals(other.ip))
|
|
||||||
return false;
|
|
||||||
if (isPublic != other.isPublic)
|
|
||||||
return false;
|
|
||||||
if (state == null) {
|
|
||||||
if (other.state != null)
|
|
||||||
return false;
|
|
||||||
} else if (!state.equals(other.state))
|
|
||||||
return false;
|
|
||||||
if (subnet == null) {
|
|
||||||
if (other.subnet != null)
|
|
||||||
return false;
|
|
||||||
} else if (!subnet.equals(other.subnet))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id, ip, subnet, isPublic, state, datacenter);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((datacenter == null) ? 0 : datacenter.hashCode());
|
|
||||||
result = prime * result + (int) (id ^ (id >>> 32));
|
|
||||||
result = prime * result + ((ip == null) ? 0 : ip.hashCode());
|
|
||||||
result = prime * result + (isPublic ? 1231 : 1237);
|
|
||||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
|
||||||
result = prime * result + ((subnet == null) ? 0 : subnet.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
Ip that = Ip.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id)
|
||||||
|
&& Objects.equal(this.ip, that.ip)
|
||||||
|
&& Objects.equal(this.subnet, that.subnet)
|
||||||
|
&& Objects.equal(this.isPublic, that.isPublic)
|
||||||
|
&& Objects.equal(this.state, that.state)
|
||||||
|
&& Objects.equal(this.datacenter, that.datacenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("ip", ip).add("subnet", subnet).add("isPublic", isPublic).add("state", state).add("datacenter", datacenter);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Ip [datacenter=" + datacenter + ", id=" + id + ", ip=" + ip + ", isPublic="
|
return string().toString();
|
||||||
+ isPublic + ", state=" + state + ", subnet=" + subnet + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Ip o) {
|
public int compareTo(Ip o) {
|
||||||
return Longs.compare(id, o.getId());
|
return Longs.compare(id, o.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,64 +18,116 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class IpPortPair
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class IpPortPair implements Comparable<IpPortPair> {
|
public class IpPortPair implements Comparable<IpPortPair> {
|
||||||
|
|
||||||
private Ip ip;
|
public static Builder<?> builder() {
|
||||||
private int port;
|
return new ConcreteBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromIpPortPair(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
* A no-args constructor is required for deserialization
|
protected abstract T self();
|
||||||
*/
|
|
||||||
public IpPortPair() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public IpPortPair(Ip ip, int port) {
|
protected Ip ip;
|
||||||
this.ip = ip;
|
protected int port;
|
||||||
this.port = port;
|
|
||||||
}
|
/**
|
||||||
|
* @see IpPortPair#getIp()
|
||||||
|
*/
|
||||||
|
public T ip(Ip ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Ip getIp() {
|
/**
|
||||||
return ip;
|
* @see IpPortPair#getPort()
|
||||||
}
|
*/
|
||||||
|
public T port(int port) {
|
||||||
|
this.port = port;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public int getPort() {
|
public IpPortPair build() {
|
||||||
return port;
|
return new IpPortPair(ip, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T fromIpPortPair(IpPortPair in) {
|
||||||
|
return this
|
||||||
|
.ip(in.getIp())
|
||||||
|
.port(in.getPort());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
public boolean equals(Object o) {
|
@Override
|
||||||
if (this == o) return true;
|
protected ConcreteBuilder self() {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IpPortPair that = (IpPortPair) o;
|
private final Ip ip;
|
||||||
|
private final int port;
|
||||||
|
|
||||||
if (port != that.port) return false;
|
@ConstructorProperties({
|
||||||
if (ip != null ? !ip.equals(that.ip) : that.ip != null) return false;
|
"ip", "port"
|
||||||
|
})
|
||||||
|
protected IpPortPair(Ip ip, int port) {
|
||||||
|
this.ip = checkNotNull(ip, "ip");
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
public Ip getIp() {
|
||||||
}
|
return this.ip;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public int getPort() {
|
||||||
public int hashCode() {
|
return this.port;
|
||||||
int result = ip != null ? ip.hashCode() : 0;
|
}
|
||||||
result = 31 * result + port;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(IpPortPair o) {
|
|
||||||
if(ip != null && o.getIp() != null) return Longs.compare(ip.getId(), o.getIp().getId());
|
|
||||||
return Ints.compare(port, o.getPort());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(ip, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
IpPortPair that = IpPortPair.class.cast(obj);
|
||||||
|
return Objects.equal(this.ip, that.ip)
|
||||||
|
&& Objects.equal(this.port, that.port);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("ip", ip).add("port", port);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "IpPortPair [ip=" + ip + ", port=" + port + "]";
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(IpPortPair o) {
|
||||||
|
if(ip != null && o.getIp() != null) return Longs.compare(ip.getId(), o.getIp().getId());
|
||||||
|
return Ints.compare(port, o.getPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,160 +18,269 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents any job in GoGrid system
|
* Represents any job in GoGrid system
|
||||||
* (jobs include server creation, stopping, etc)
|
* (jobs include server creation, stopping, etc)
|
||||||
*
|
*
|
||||||
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API:Job_(Object)" />
|
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
|
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API:Job_(Object)" />
|
||||||
*/
|
*/
|
||||||
public class Job implements Comparable<Job> {
|
public class Job implements Comparable<Job> {
|
||||||
|
|
||||||
private long id;
|
public static Builder<?> builder() {
|
||||||
private Option command;
|
return new ConcreteBuilder();
|
||||||
@SerializedName("objecttype")
|
}
|
||||||
private ObjectType objectType;
|
|
||||||
@SerializedName("createdon")
|
|
||||||
private Date createdOn;
|
|
||||||
@SerializedName("lastupdatedon")
|
|
||||||
private Date lastUpdatedOn;
|
|
||||||
@SerializedName("currentstate")
|
|
||||||
private JobState currentState;
|
|
||||||
private int attempts;
|
|
||||||
private String owner;
|
|
||||||
private Set<JobProperties> history;
|
|
||||||
@SerializedName("detail") /*NOTE: as of Feb 28, 10,
|
|
||||||
there is a contradiction b/w the name in
|
|
||||||
documentation (details) and actual param
|
|
||||||
name (detail)*/
|
|
||||||
private Map<String, String> details;
|
|
||||||
|
|
||||||
/**
|
public Builder<?> toBuilder() {
|
||||||
* A no-args constructor is required for deserialization
|
return new ConcreteBuilder().fromJob(this);
|
||||||
*/
|
}
|
||||||
public Job() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Job(long id, Option command, ObjectType objectType,
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
Date createdOn, Date lastUpdatedOn, JobState currentState,
|
protected abstract T self();
|
||||||
int attempts, String owner, SortedSet<JobProperties> history,
|
|
||||||
Map<String, String> details) {
|
|
||||||
this.id = id;
|
|
||||||
this.command = command;
|
|
||||||
this.objectType = objectType;
|
|
||||||
this.createdOn = createdOn;
|
|
||||||
this.lastUpdatedOn = lastUpdatedOn;
|
|
||||||
this.currentState = currentState;
|
|
||||||
this.attempts = attempts;
|
|
||||||
this.owner = owner;
|
|
||||||
this.history = history;
|
|
||||||
this.details = details;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getId() {
|
protected long id;
|
||||||
return id;
|
protected Option command;
|
||||||
}
|
protected ObjectType objectType;
|
||||||
|
protected Date createdOn;
|
||||||
|
protected Date lastUpdatedOn;
|
||||||
|
protected JobState currentState;
|
||||||
|
protected int attempts;
|
||||||
|
protected String owner;
|
||||||
|
protected Set<JobProperties> history = ImmutableSet.of();
|
||||||
|
protected Map<String, String> details = ImmutableMap.of();
|
||||||
|
|
||||||
public Option getCommand() {
|
/**
|
||||||
return command;
|
* @see Job#getId()
|
||||||
}
|
*/
|
||||||
|
public T id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public ObjectType getObjectType() {
|
/**
|
||||||
return objectType;
|
* @see Job#getCommand()
|
||||||
}
|
*/
|
||||||
|
public T command(Option command) {
|
||||||
|
this.command = command;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Date getCreatedOn() {
|
/**
|
||||||
return createdOn;
|
* @see Job#getObjectType()
|
||||||
}
|
*/
|
||||||
|
public T objectType(ObjectType objectType) {
|
||||||
|
this.objectType = objectType;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Date getLastUpdatedOn() {
|
/**
|
||||||
return lastUpdatedOn;
|
* @see Job#getCreatedOn()
|
||||||
}
|
*/
|
||||||
|
public T createdOn(Date createdOn) {
|
||||||
|
this.createdOn = createdOn;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public JobState getCurrentState() {
|
/**
|
||||||
return currentState;
|
* @see Job#getLastUpdatedOn()
|
||||||
}
|
*/
|
||||||
|
public T lastUpdatedOn(Date lastUpdatedOn) {
|
||||||
|
this.lastUpdatedOn = lastUpdatedOn;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public int getAttempts() {
|
/**
|
||||||
return attempts;
|
* @see Job#getCurrentState()
|
||||||
}
|
*/
|
||||||
|
public T currentState(JobState currentState) {
|
||||||
|
this.currentState = currentState;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public String getOwner() {
|
/**
|
||||||
return owner;
|
* @see Job#getAttempts()
|
||||||
}
|
*/
|
||||||
|
public T attempts(int attempts) {
|
||||||
|
this.attempts = attempts;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Set<JobProperties> getHistory() {
|
/**
|
||||||
return history;
|
* @see Job#getOwner()
|
||||||
}
|
*/
|
||||||
|
public T owner(String owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getDetails() {
|
/**
|
||||||
return details;
|
* @see Job#getHistory()
|
||||||
}
|
*/
|
||||||
|
public T history(Set<JobProperties> history) {
|
||||||
|
this.history = ImmutableSet.copyOf(checkNotNull(history, "history"));
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public T history(JobProperties... in) {
|
||||||
public boolean equals(Object o) {
|
return history(ImmutableSet.copyOf(in));
|
||||||
if (this == o) return true;
|
}
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
Job job = (Job) o;
|
/**
|
||||||
|
* @see Job#getDetails()
|
||||||
|
*/
|
||||||
|
public T details(Map<String, String> details) {
|
||||||
|
this.details = ImmutableMap.copyOf(checkNotNull(details, "details"));
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
if (attempts != job.attempts) return false;
|
public Job build() {
|
||||||
if (id != job.id) return false;
|
return new Job(id, command, objectType, createdOn, lastUpdatedOn, currentState, attempts, owner, history, details);
|
||||||
if (command != null ? !command.equals(job.command) : job.command != null) return false;
|
}
|
||||||
if (createdOn != null ? !createdOn.equals(job.createdOn) : job.createdOn != null) return false;
|
|
||||||
if (currentState != null ? !currentState.equals(job.currentState) : job.currentState != null) return false;
|
|
||||||
if (details != null ? !details.equals(job.details) : job.details != null) return false;
|
|
||||||
if (history != null ? !history.equals(job.history) : job.history != null) return false;
|
|
||||||
if (lastUpdatedOn != null ? !lastUpdatedOn.equals(job.lastUpdatedOn) : job.lastUpdatedOn != null) return false;
|
|
||||||
if (objectType != null ? !objectType.equals(job.objectType) : job.objectType != null) return false;
|
|
||||||
if (owner != null ? !owner.equals(job.owner) : job.owner != null) return false;
|
|
||||||
|
|
||||||
return true;
|
public T fromJob(Job in) {
|
||||||
}
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.command(in.getCommand())
|
||||||
|
.objectType(in.getObjectType())
|
||||||
|
.createdOn(in.getCreatedOn())
|
||||||
|
.lastUpdatedOn(in.getLastUpdatedOn())
|
||||||
|
.currentState(in.getCurrentState())
|
||||||
|
.attempts(in.getAttempts())
|
||||||
|
.owner(in.getOwner())
|
||||||
|
.history(in.getHistory())
|
||||||
|
.details(in.getDetails());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
public int hashCode() {
|
@Override
|
||||||
int result = (int) (id ^ (id >>> 32));
|
protected ConcreteBuilder self() {
|
||||||
result = 31 * result + (command != null ? command.hashCode() : 0);
|
return this;
|
||||||
result = 31 * result + (objectType != null ? objectType.hashCode() : 0);
|
}
|
||||||
result = 31 * result + (createdOn != null ? createdOn.hashCode() : 0);
|
}
|
||||||
result = 31 * result + (lastUpdatedOn != null ? lastUpdatedOn.hashCode() : 0);
|
|
||||||
result = 31 * result + (currentState != null ? currentState.hashCode() : 0);
|
|
||||||
result = 31 * result + attempts;
|
|
||||||
result = 31 * result + (owner != null ? owner.hashCode() : 0);
|
|
||||||
result = 31 * result + (history != null ? history.hashCode() : 0);
|
|
||||||
result = 31 * result + (details != null ? details.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private final long id;
|
||||||
public int compareTo(Job o) {
|
private final Option command;
|
||||||
if(createdOn != null && o.getCreatedOn() != null)
|
private final ObjectType objectType;
|
||||||
return Longs.compare(createdOn.getTime(), o.getCreatedOn().getTime());
|
private final Date createdOn;
|
||||||
return Longs.compare(id, o.getId());
|
private final Date lastUpdatedOn;
|
||||||
}
|
private final JobState currentState;
|
||||||
|
private final int attempts;
|
||||||
|
private final String owner;
|
||||||
|
private final Set<JobProperties> history;
|
||||||
|
private final Map<String, String> details;
|
||||||
|
|
||||||
|
/* NOTE: as of Feb 28, 10, there is a contradiction b/w the name in documentation (details) and actual param name (detail)*/
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "command", "objecttype", "createdon", "lastupdatedon", "currentstate", "attempts", "owner", "history", "detail"
|
||||||
|
})
|
||||||
|
protected Job(long id, Option command, ObjectType objectType, Date createdOn, @Nullable Date lastUpdatedOn,
|
||||||
|
JobState currentState, int attempts, String owner, Set<JobProperties> history, Map<String, String> details) {
|
||||||
|
this.id = id;
|
||||||
|
this.command = checkNotNull(command, "command");
|
||||||
|
this.objectType = checkNotNull(objectType, "objectType");
|
||||||
|
this.createdOn = checkNotNull(createdOn, "createdOn");
|
||||||
|
this.lastUpdatedOn = lastUpdatedOn;
|
||||||
|
this.currentState = checkNotNull(currentState, "currentState");
|
||||||
|
this.attempts = attempts;
|
||||||
|
this.owner = checkNotNull(owner, "owner");
|
||||||
|
this.history = ImmutableSet.copyOf(checkNotNull(history, "history"));
|
||||||
|
this.details = ImmutableMap.copyOf(checkNotNull(details, "details"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Option getCommand() {
|
||||||
|
return this.command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectType getObjectType() {
|
||||||
|
return this.objectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedOn() {
|
||||||
|
return this.createdOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Date getLastUpdatedOn() {
|
||||||
|
return this.lastUpdatedOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JobState getCurrentState() {
|
||||||
|
return this.currentState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAttempts() {
|
||||||
|
return this.attempts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return this.owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<JobProperties> getHistory() {
|
||||||
|
return this.history;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getDetails() {
|
||||||
|
return this.details;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(id, command, objectType, createdOn, lastUpdatedOn, currentState, attempts, owner, history, details);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
Job that = Job.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id)
|
||||||
|
&& Objects.equal(this.command, that.command)
|
||||||
|
&& Objects.equal(this.objectType, that.objectType)
|
||||||
|
&& Objects.equal(this.createdOn, that.createdOn)
|
||||||
|
&& Objects.equal(this.lastUpdatedOn, that.lastUpdatedOn)
|
||||||
|
&& Objects.equal(this.currentState, that.currentState)
|
||||||
|
&& Objects.equal(this.attempts, that.attempts)
|
||||||
|
&& Objects.equal(this.owner, that.owner)
|
||||||
|
&& Objects.equal(this.history, that.history)
|
||||||
|
&& Objects.equal(this.details, that.details);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("command", command).add("objectType", objectType).add("createdOn", createdOn).add("lastUpdatedOn", lastUpdatedOn).add("currentState", currentState).add("attempts", attempts).add("owner", owner).add("history", history).add("details", details);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Job o) {
|
||||||
|
if(createdOn != null && o.getCreatedOn() != null)
|
||||||
|
return Longs.compare(createdOn.getTime(), o.getCreatedOn().getTime());
|
||||||
|
return Longs.compare(id, o.getId());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Job{" +
|
|
||||||
"id=" + id +
|
|
||||||
", command=" + command +
|
|
||||||
", objectType=" + objectType +
|
|
||||||
", createdOn=" + createdOn +
|
|
||||||
", lastUpdatedOn=" + lastUpdatedOn +
|
|
||||||
", currentState=" + currentState +
|
|
||||||
", attempts=" + attempts +
|
|
||||||
", owner='" + owner + '\'' +
|
|
||||||
", history=" + history +
|
|
||||||
", details=" + details +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,92 +18,153 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State of a job.
|
* State of a job.
|
||||||
*
|
*
|
||||||
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API:Job_State_(Object)"/>
|
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API:Job_State_(Object)"/>
|
||||||
*
|
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class JobProperties implements Comparable<JobProperties> {
|
public class JobProperties implements Comparable<JobProperties> {
|
||||||
|
|
||||||
private long id;
|
public static Builder<?> builder() {
|
||||||
@SerializedName("updatedon")
|
return new ConcreteBuilder();
|
||||||
private Date updatedOn;
|
}
|
||||||
private JobState state;
|
|
||||||
private String note;
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromJobProperties(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
* A no-args constructor is required for deserialization
|
protected abstract T self();
|
||||||
*/
|
|
||||||
public JobProperties() {
|
|
||||||
|
|
||||||
}
|
protected long id;
|
||||||
|
protected Date updatedOn;
|
||||||
|
protected JobState state;
|
||||||
|
protected String note;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see JobProperties#getId()
|
||||||
|
*/
|
||||||
|
public T id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public JobProperties(long id, Date updatedOn, JobState state, String note) {
|
/**
|
||||||
this.id = id;
|
* @see JobProperties#getUpdatedOn()
|
||||||
this.updatedOn = updatedOn;
|
*/
|
||||||
this.state = state;
|
public T updatedOn(Date updatedOn) {
|
||||||
this.note = note;
|
this.updatedOn = updatedOn;
|
||||||
}
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public long getId() {
|
/**
|
||||||
return id;
|
* @see JobProperties#getState()
|
||||||
}
|
*/
|
||||||
|
public T state(JobState state) {
|
||||||
|
this.state = state;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Date getUpdatedOn() {
|
/**
|
||||||
return updatedOn;
|
* @see JobProperties#getNote()
|
||||||
}
|
*/
|
||||||
|
public T note(String note) {
|
||||||
|
this.note = note;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public JobState getState() {
|
public JobProperties build() {
|
||||||
return state;
|
return new JobProperties(id, updatedOn, state, note);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T fromJobProperties(JobProperties in) {
|
||||||
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.updatedOn(in.getUpdatedOn())
|
||||||
|
.state(in.getState())
|
||||||
|
.note(in.getNote());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getNote() {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
return note;
|
@Override
|
||||||
}
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private final long id;
|
||||||
public boolean equals(Object o) {
|
private final Date updatedOn;
|
||||||
if (this == o) return true;
|
private final JobState state;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
private final String note;
|
||||||
|
|
||||||
JobProperties jobState = (JobProperties) o;
|
@ConstructorProperties({
|
||||||
|
"id", "updatedon", "state", "note"
|
||||||
|
})
|
||||||
|
protected JobProperties(long id, Date updatedOn, JobState state, @Nullable String note) {
|
||||||
|
this.id = id;
|
||||||
|
this.updatedOn = checkNotNull(updatedOn, "updatedOn");
|
||||||
|
this.state = checkNotNull(state, "state");
|
||||||
|
this.note = note;
|
||||||
|
}
|
||||||
|
|
||||||
if (id != jobState.id) return false;
|
public long getId() {
|
||||||
if (note != null ? !note.equals(jobState.note) : jobState.note != null) return false;
|
return this.id;
|
||||||
if (state != null ? !state.equals(jobState.state) : jobState.state != null) return false;
|
}
|
||||||
if (updatedOn != null ? !updatedOn.equals(jobState.updatedOn) : jobState.updatedOn != null) return false;
|
|
||||||
|
|
||||||
return true;
|
public Date getUpdatedOn() {
|
||||||
}
|
return this.updatedOn;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public JobState getState() {
|
||||||
public int hashCode() {
|
return this.state;
|
||||||
int result = (int) (id ^ (id >>> 32));
|
}
|
||||||
result = 31 * result + (updatedOn != null ? updatedOn.hashCode() : 0);
|
|
||||||
result = 31 * result + (state != null ? state.hashCode() : 0);
|
|
||||||
result = 31 * result + (note != null ? note.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Nullable
|
||||||
public String toString() {
|
public String getNote() {
|
||||||
return "JobState{" +
|
return this.note;
|
||||||
"id=" + id +
|
}
|
||||||
", updatedOn=" + updatedOn +
|
|
||||||
", state=" + state +
|
|
||||||
", note='" + note + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(JobProperties o) {
|
public int hashCode() {
|
||||||
return Longs.compare(id, o.getId());
|
return Objects.hashCode(id, updatedOn, state, note);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
JobProperties that = JobProperties.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id)
|
||||||
|
&& Objects.equal(this.updatedOn, that.updatedOn)
|
||||||
|
&& Objects.equal(this.state, that.state)
|
||||||
|
&& Objects.equal(this.note, that.note);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("updatedOn", updatedOn).add("state", state).add("note", note);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(JobProperties o) {
|
||||||
|
return Longs.compare(id, o.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,177 +18,259 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
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.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class LoadBalancer
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class LoadBalancer implements Comparable<LoadBalancer> {
|
public class LoadBalancer implements Comparable<LoadBalancer> {
|
||||||
|
|
||||||
private long id;
|
public static Builder<?> builder() {
|
||||||
private String name;
|
return new ConcreteBuilder();
|
||||||
private String description;
|
}
|
||||||
@SerializedName("virtualip")
|
|
||||||
private IpPortPair virtualIp;
|
public Builder<?> toBuilder() {
|
||||||
@SerializedName("realiplist")
|
return new ConcreteBuilder().fromLoadBalancer(this);
|
||||||
private Set<IpPortPair> realIpList;
|
|
||||||
private LoadBalancerType type;
|
|
||||||
private LoadBalancerPersistenceType persistence;
|
|
||||||
private LoadBalancerOs os;
|
|
||||||
private LoadBalancerState state;
|
|
||||||
private Option datacenter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A no-args constructor is required for deserialization
|
|
||||||
*/
|
|
||||||
public LoadBalancer() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadBalancer(long id, String name, String description, IpPortPair virtualIp,
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
Set<IpPortPair> realIpList, LoadBalancerType type,
|
protected abstract T self();
|
||||||
LoadBalancerPersistenceType persistence, LoadBalancerOs os, LoadBalancerState state,
|
|
||||||
Option datacenter) {
|
protected long id;
|
||||||
|
protected String name;
|
||||||
|
protected String description;
|
||||||
|
protected IpPortPair virtualIp;
|
||||||
|
protected Set<IpPortPair> realIpList = ImmutableSet.of();
|
||||||
|
protected LoadBalancerType type;
|
||||||
|
protected LoadBalancerPersistenceType persistence;
|
||||||
|
protected LoadBalancerOs os;
|
||||||
|
protected LoadBalancerState state;
|
||||||
|
protected Option datacenter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getId()
|
||||||
|
*/
|
||||||
|
public T id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getDescription()
|
||||||
|
*/
|
||||||
|
public T description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getVirtualIp()
|
||||||
|
*/
|
||||||
|
public T virtualIp(IpPortPair virtualIp) {
|
||||||
|
this.virtualIp = virtualIp;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getRealIpList()
|
||||||
|
*/
|
||||||
|
public T realIpList(Set<IpPortPair> realIpList) {
|
||||||
|
this.realIpList = ImmutableSet.copyOf(checkNotNull(realIpList, "realIpList"));
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T realIpList(IpPortPair... in) {
|
||||||
|
return realIpList(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getType()
|
||||||
|
*/
|
||||||
|
public T type(LoadBalancerType type) {
|
||||||
|
this.type = type;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getPersistence()
|
||||||
|
*/
|
||||||
|
public T persistence(LoadBalancerPersistenceType persistence) {
|
||||||
|
this.persistence = persistence;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getOs()
|
||||||
|
*/
|
||||||
|
public T os(LoadBalancerOs os) {
|
||||||
|
this.os = os;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getState()
|
||||||
|
*/
|
||||||
|
public T state(LoadBalancerState state) {
|
||||||
|
this.state = state;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see LoadBalancer#getDatacenter()
|
||||||
|
*/
|
||||||
|
public T datacenter(Option datacenter) {
|
||||||
|
this.datacenter = datacenter;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadBalancer build() {
|
||||||
|
return new LoadBalancer(id, name, description, virtualIp, realIpList, type, persistence, os, state, datacenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T fromLoadBalancer(LoadBalancer in) {
|
||||||
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.name(in.getName())
|
||||||
|
.description(in.getDescription())
|
||||||
|
.virtualIp(in.getVirtualIp())
|
||||||
|
.realIpList(in.getRealIpList())
|
||||||
|
.type(in.getType())
|
||||||
|
.persistence(in.getPersistence())
|
||||||
|
.os(in.getOs())
|
||||||
|
.state(in.getState())
|
||||||
|
.datacenter(in.getDatacenter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final long id;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
private final IpPortPair virtualIp;
|
||||||
|
private final Set<IpPortPair> realIpList;
|
||||||
|
private final LoadBalancerType type;
|
||||||
|
private final LoadBalancerPersistenceType persistence;
|
||||||
|
private final LoadBalancerOs os;
|
||||||
|
private final LoadBalancerState state;
|
||||||
|
private final Option datacenter;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "name", "description", "virtualip", "realiplist", "type", "persistence", "os", "state", "datacenter"
|
||||||
|
})
|
||||||
|
protected LoadBalancer(long id, String name, @Nullable String description, IpPortPair virtualIp, Set<IpPortPair> realIpList, LoadBalancerType type, LoadBalancerPersistenceType persistence, LoadBalancerOs os, LoadBalancerState state, Option datacenter) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = checkNotNull(name, "name");
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.virtualIp = virtualIp;
|
this.virtualIp = checkNotNull(virtualIp, "virtualIp");
|
||||||
this.realIpList = realIpList;
|
this.realIpList = ImmutableSet.copyOf(checkNotNull(realIpList, "realIpList"));
|
||||||
this.type = type;
|
this.type = checkNotNull(type, "type");
|
||||||
this.persistence = persistence;
|
this.persistence = checkNotNull(persistence, "persistence");
|
||||||
this.os = os;
|
this.os = checkNotNull(os, "os");
|
||||||
this.state = state;
|
this.state = checkNotNull(state, "state");
|
||||||
this.datacenter = datacenter;
|
this.datacenter = checkNotNull(datacenter, "datacenter");
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
|
||||||
|
|
||||||
public Option getDatacenter() {
|
|
||||||
return datacenter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IpPortPair getVirtualIp() {
|
public IpPortPair getVirtualIp() {
|
||||||
return virtualIp;
|
return this.virtualIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<IpPortPair> getRealIpList() {
|
public Set<IpPortPair> getRealIpList() {
|
||||||
return realIpList;
|
return this.realIpList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadBalancerType getType() {
|
public LoadBalancerType getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadBalancerPersistenceType getPersistence() {
|
public LoadBalancerPersistenceType getPersistence() {
|
||||||
return persistence;
|
return this.persistence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadBalancerOs getOs() {
|
public LoadBalancerOs getOs() {
|
||||||
return os;
|
return this.os;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoadBalancerState getState() {
|
public LoadBalancerState getState() {
|
||||||
return state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Option getDatacenter() {
|
||||||
public boolean equals(Object obj) {
|
return this.datacenter;
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (obj == null)
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
LoadBalancer other = (LoadBalancer) obj;
|
|
||||||
if (datacenter == null) {
|
|
||||||
if (other.datacenter != null)
|
|
||||||
return false;
|
|
||||||
} else if (!datacenter.equals(other.datacenter))
|
|
||||||
return false;
|
|
||||||
if (description == null) {
|
|
||||||
if (other.description != null)
|
|
||||||
return false;
|
|
||||||
} else if (!description.equals(other.description))
|
|
||||||
return false;
|
|
||||||
if (id != other.id)
|
|
||||||
return false;
|
|
||||||
if (name == null) {
|
|
||||||
if (other.name != null)
|
|
||||||
return false;
|
|
||||||
} else if (!name.equals(other.name))
|
|
||||||
return false;
|
|
||||||
if (os == null) {
|
|
||||||
if (other.os != null)
|
|
||||||
return false;
|
|
||||||
} else if (!os.equals(other.os))
|
|
||||||
return false;
|
|
||||||
if (persistence == null) {
|
|
||||||
if (other.persistence != null)
|
|
||||||
return false;
|
|
||||||
} else if (!persistence.equals(other.persistence))
|
|
||||||
return false;
|
|
||||||
if (realIpList == null) {
|
|
||||||
if (other.realIpList != null)
|
|
||||||
return false;
|
|
||||||
} else if (!realIpList.equals(other.realIpList))
|
|
||||||
return false;
|
|
||||||
if (state == null) {
|
|
||||||
if (other.state != null)
|
|
||||||
return false;
|
|
||||||
} else if (!state.equals(other.state))
|
|
||||||
return false;
|
|
||||||
if (type == null) {
|
|
||||||
if (other.type != null)
|
|
||||||
return false;
|
|
||||||
} else if (!type.equals(other.type))
|
|
||||||
return false;
|
|
||||||
if (virtualIp == null) {
|
|
||||||
if (other.virtualIp != null)
|
|
||||||
return false;
|
|
||||||
} else if (!virtualIp.equals(other.virtualIp))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id, name, description, virtualIp, realIpList, type, persistence, os, state, datacenter);
|
||||||
int result = 1;
|
}
|
||||||
result = prime * result + ((datacenter == null) ? 0 : datacenter.hashCode());
|
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
@Override
|
||||||
result = prime * result + (int) (id ^ (id >>> 32));
|
public boolean equals(Object obj) {
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
if (this == obj) return true;
|
||||||
result = prime * result + ((os == null) ? 0 : os.hashCode());
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
result = prime * result + ((persistence == null) ? 0 : persistence.hashCode());
|
LoadBalancer that = LoadBalancer.class.cast(obj);
|
||||||
result = prime * result + ((realIpList == null) ? 0 : realIpList.hashCode());
|
return Objects.equal(this.id, that.id)
|
||||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
&& Objects.equal(this.name, that.name)
|
||||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
&& Objects.equal(this.description, that.description)
|
||||||
result = prime * result + ((virtualIp == null) ? 0 : virtualIp.hashCode());
|
&& Objects.equal(this.virtualIp, that.virtualIp)
|
||||||
return result;
|
&& Objects.equal(this.realIpList, that.realIpList)
|
||||||
|
&& Objects.equal(this.type, that.type)
|
||||||
|
&& Objects.equal(this.persistence, that.persistence)
|
||||||
|
&& Objects.equal(this.os, that.os)
|
||||||
|
&& Objects.equal(this.state, that.state)
|
||||||
|
&& Objects.equal(this.datacenter, that.datacenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("name", name).add("description", description).add("virtualIp", virtualIp).add("realIpList", realIpList).add("type", type).add("persistence", persistence).add("os", os).add("state", state).add("datacenter", datacenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(LoadBalancer o) {
|
public int compareTo(LoadBalancer o) {
|
||||||
return Longs.compare(id, o.getId());
|
return Longs.compare(id, o.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "LoadBalancer [datacenter=" + datacenter + ", description=" + description + ", id="
|
|
||||||
+ id + ", name=" + name + ", os=" + os + ", persistence=" + persistence
|
|
||||||
+ ", realIpList=" + realIpList + ", state=" + state + ", type=" + type
|
|
||||||
+ ", virtualIp=" + virtualIp + "]";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,79 +18,138 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.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;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class Option
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class Option implements Comparable<Option> {
|
public class Option implements Comparable<Option> {
|
||||||
|
|
||||||
private Long id;
|
public static Builder<?> builder() {
|
||||||
private String name;
|
return new ConcreteBuilder();
|
||||||
private String description;
|
}
|
||||||
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
|
return new ConcreteBuilder().fromOption(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Option createWithIdNameAndDescription(Long id, String name, String description) {
|
||||||
|
return new Option(id, name, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
/**
|
protected Long id;
|
||||||
* A no-args constructor is required for deserialization
|
protected String name;
|
||||||
*/
|
protected String description;
|
||||||
public Option() {
|
|
||||||
}
|
/**
|
||||||
|
* @see Option#getId()
|
||||||
|
*/
|
||||||
|
public T id(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Option(Long id) {
|
/**
|
||||||
this(id, null, null);
|
* @see Option#getName()
|
||||||
}
|
*/
|
||||||
|
public T name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Option(String name) {
|
/**
|
||||||
this(null, name, null);
|
* @see Option#getDescription()
|
||||||
}
|
*/
|
||||||
|
public T description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public Option(Long id, String name, String description) {
|
public Option build() {
|
||||||
this.id = id;
|
return new Option(id, name, description);
|
||||||
this.name = name;
|
}
|
||||||
this.description = description;
|
|
||||||
}
|
public T fromOption(Option in) {
|
||||||
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.name(in.getName())
|
||||||
|
.description(in.getDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public long getId() {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
return id;
|
@Override
|
||||||
}
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
private final Long id;
|
||||||
return name;
|
private final String name;
|
||||||
}
|
private final String description;
|
||||||
|
|
||||||
public String getDescription() {
|
@ConstructorProperties({
|
||||||
return description;
|
"id", "name", "description"
|
||||||
}
|
})
|
||||||
|
protected Option(Long id, String name, @Nullable String description) {
|
||||||
|
this.id = checkNotNull(id, "id");
|
||||||
|
this.name = checkNotNull(name, "name");
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public Long getId() {
|
||||||
public boolean equals(Object o) {
|
return this.id;
|
||||||
if (this == o) return true;
|
}
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
Option option = (Option) o;
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
if (description != null ? !description.equals(option.description) : option.description != null) return false;
|
@Nullable
|
||||||
if (id != null ? !id.equals(option.id) : option.id != null) return false;
|
public String getDescription() {
|
||||||
if (name != null ? !name.equals(option.name) : option.name != null) return false;
|
return this.description;
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = id != null ? id.hashCode() : 0;
|
|
||||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
|
||||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(Option o) {
|
|
||||||
return Longs.compare(id, o.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(id, name, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
Option that = Option.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id)
|
||||||
|
&& Objects.equal(this.name, that.name)
|
||||||
|
&& Objects.equal(this.description, that.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("name", name).add("description", description);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + id + ", name=" + name + ", description=" + description + "]";
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Option o) {
|
||||||
|
return Longs.compare(id, o.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,127 +18,272 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Objects.toStringHelper;
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class Server
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class Server implements Comparable<Server> {
|
public class Server implements Comparable<Server> {
|
||||||
private long id;
|
|
||||||
private boolean isSandbox;
|
|
||||||
private String name;
|
|
||||||
private String description;
|
|
||||||
private ServerState state;
|
|
||||||
private Option datacenter;
|
|
||||||
|
|
||||||
private Option type;
|
public static Builder<?> builder() {
|
||||||
private Option ram;
|
return new ConcreteBuilder();
|
||||||
private Option os;
|
}
|
||||||
private Ip ip;
|
|
||||||
|
public Builder<?> toBuilder() {
|
||||||
private ServerImage image;
|
return new ConcreteBuilder().fromServer(this);
|
||||||
|
|
||||||
/**
|
|
||||||
* A no-args constructor is required for deserialization
|
|
||||||
*/
|
|
||||||
Server() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Server(long id, Option datacenter, boolean sandbox, String name, String description, ServerState state,
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
Option type, Option ram, Option os, Ip ip, ServerImage image) {
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected long id;
|
||||||
|
protected boolean isSandbox;
|
||||||
|
protected String name;
|
||||||
|
protected String description;
|
||||||
|
protected ServerState state;
|
||||||
|
protected Option datacenter;
|
||||||
|
protected Option type;
|
||||||
|
protected Option ram;
|
||||||
|
protected Option os;
|
||||||
|
protected Ip ip;
|
||||||
|
protected ServerImage image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getId()
|
||||||
|
*/
|
||||||
|
public T id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#isSandbox()
|
||||||
|
*/
|
||||||
|
public T isSandbox(boolean isSandbox) {
|
||||||
|
this.isSandbox = isSandbox;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getDescription()
|
||||||
|
*/
|
||||||
|
public T description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getState()
|
||||||
|
*/
|
||||||
|
public T state(ServerState state) {
|
||||||
|
this.state = state;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getDatacenter()
|
||||||
|
*/
|
||||||
|
public T datacenter(Option datacenter) {
|
||||||
|
this.datacenter = datacenter;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getType()
|
||||||
|
*/
|
||||||
|
public T type(Option type) {
|
||||||
|
this.type = type;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getRam()
|
||||||
|
*/
|
||||||
|
public T ram(Option ram) {
|
||||||
|
this.ram = ram;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getOs()
|
||||||
|
*/
|
||||||
|
public T os(Option os) {
|
||||||
|
this.os = os;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getIp()
|
||||||
|
*/
|
||||||
|
public T ip(Ip ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Server#getImage()
|
||||||
|
*/
|
||||||
|
public T image(ServerImage image) {
|
||||||
|
this.image = image;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Server build() {
|
||||||
|
return new Server(id, isSandbox, name, description, state, datacenter, type, ram, os, ip, image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T fromServer(Server in) {
|
||||||
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.isSandbox(in.isSandbox())
|
||||||
|
.name(in.getName())
|
||||||
|
.description(in.getDescription())
|
||||||
|
.state(in.getState())
|
||||||
|
.datacenter(in.getDatacenter())
|
||||||
|
.type(in.getType())
|
||||||
|
.ram(in.getRam())
|
||||||
|
.os(in.getOs())
|
||||||
|
.ip(in.getIp())
|
||||||
|
.image(in.getImage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final long id;
|
||||||
|
private final boolean isSandbox;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
private final ServerState state;
|
||||||
|
private final Option datacenter;
|
||||||
|
private final Option type;
|
||||||
|
private final Option ram;
|
||||||
|
private final Option os;
|
||||||
|
private final Ip ip;
|
||||||
|
private final ServerImage image;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "isSandbox", "name", "description", "state", "datacenter", "type", "ram", "os", "ip", "image"
|
||||||
|
})
|
||||||
|
protected Server(long id, boolean isSandbox, String name, @Nullable String description, ServerState state,
|
||||||
|
@Nullable Option datacenter, Option type, Option ram, Option os, Ip ip, ServerImage image) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.isSandbox = sandbox;
|
this.isSandbox = isSandbox;
|
||||||
this.name = name;
|
this.name = checkNotNull(name, "name");
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.state = state;
|
this.state = checkNotNull(state, "state");
|
||||||
this.type = type;
|
|
||||||
this.ram = ram;
|
|
||||||
this.os = os;
|
|
||||||
this.ip = ip;
|
|
||||||
this.image = image;
|
|
||||||
this.datacenter = datacenter;
|
this.datacenter = datacenter;
|
||||||
|
this.type = checkNotNull(type, "type");
|
||||||
|
this.ram = checkNotNull(ram, "ram");
|
||||||
|
this.os = checkNotNull(os, "os");
|
||||||
|
this.ip = checkNotNull(ip, "ip");
|
||||||
|
this.image = checkNotNull(image, "image");
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSandbox() {
|
public boolean isSandbox() {
|
||||||
return isSandbox;
|
return this.isSandbox;
|
||||||
}
|
|
||||||
|
|
||||||
public Option getDatacenter() {
|
|
||||||
return datacenter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerState getState() {
|
public ServerState getState() {
|
||||||
return state;
|
return this.state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Option getDatacenter() {
|
||||||
|
return this.datacenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Option getType() {
|
public Option getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Option getRam() {
|
public Option getRam() {
|
||||||
return ram;
|
return this.ram;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Option getOs() {
|
public Option getOs() {
|
||||||
return os;
|
return this.os;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ip getIp() {
|
public Ip getIp() {
|
||||||
return ip;
|
return this.ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerImage getImage() {
|
public ServerImage getImage() {
|
||||||
return image;
|
return this.image;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object) {
|
|
||||||
if (this == object) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (object instanceof Server) {
|
|
||||||
final Server other = Server.class.cast(object);
|
|
||||||
return equal(id, other.id) && equal(name, other.name);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(id, name);
|
return Objects.hashCode(id, isSandbox, name, description, state, datacenter, type, ram, os, ip, image);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
Server that = Server.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id)
|
||||||
|
&& Objects.equal(this.isSandbox, that.isSandbox)
|
||||||
|
&& Objects.equal(this.name, that.name)
|
||||||
|
&& Objects.equal(this.description, that.description)
|
||||||
|
&& Objects.equal(this.state, that.state)
|
||||||
|
&& Objects.equal(this.datacenter, that.datacenter)
|
||||||
|
&& Objects.equal(this.type, that.type)
|
||||||
|
&& Objects.equal(this.ram, that.ram)
|
||||||
|
&& Objects.equal(this.os, that.os)
|
||||||
|
&& Objects.equal(this.ip, that.ip)
|
||||||
|
&& Objects.equal(this.image, that.image);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("isSandbox", isSandbox).add("name", name).add("description", description).add("state", state).add("datacenter", datacenter).add("type", type).add("ram", ram).add("os", os).add("ip", ip).add("image", image);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Server that) {
|
public int compareTo(Server that) {
|
||||||
if (that == null)
|
|
||||||
return 1;
|
|
||||||
if (this == that)
|
|
||||||
return 0;
|
|
||||||
return Longs.compare(id, that.getId());
|
return Longs.compare(id, that.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return toStringHelper("").add("id", id).add("name", name).add("description", description).add("os", os).add(
|
|
||||||
"image", image).add("datacenter", datacenter).add("state", state).add("ip", ip).add("isSandbox",
|
|
||||||
isSandbox).add("ram", ram).add("type", type).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,148 +18,363 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Objects.toStringHelper;
|
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class ServerImage
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class ServerImage implements Comparable<ServerImage> {
|
public class ServerImage implements Comparable<ServerImage> {
|
||||||
|
|
||||||
private long id;
|
public static Builder<?> builder() {
|
||||||
private String name;
|
return new ConcreteBuilder();
|
||||||
private String friendlyName;
|
}
|
||||||
private String description;
|
|
||||||
private Option os;
|
public Builder<?> toBuilder() {
|
||||||
private Option architecture;
|
return new ConcreteBuilder().fromServerImage(this);
|
||||||
private ServerImageType type;
|
|
||||||
private ServerImageState state;
|
|
||||||
private double price;
|
|
||||||
private String location;
|
|
||||||
private boolean isActive;
|
|
||||||
private boolean isPublic;
|
|
||||||
private Date createdTime;
|
|
||||||
private Date updatedTime;
|
|
||||||
@SerializedName("billingtokens")
|
|
||||||
private Set<BillingToken> billingTokens;
|
|
||||||
private Customer owner;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A no-args constructor is required for deserialization
|
|
||||||
*/
|
|
||||||
public ServerImage() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerImage(long id, String name, String friendlyName, String description, Option os, Option architecture,
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
ServerImageType type, ServerImageState state, double price, String location, boolean active,
|
protected abstract T self();
|
||||||
boolean aPublic, Date createdTime, Date updatedTime, Set<BillingToken> billingTokens, Customer owner) {
|
|
||||||
|
protected long id;
|
||||||
|
protected String name;
|
||||||
|
protected String friendlyName;
|
||||||
|
protected String description;
|
||||||
|
protected Option os;
|
||||||
|
protected Option architecture;
|
||||||
|
protected ServerImageType type;
|
||||||
|
protected ServerImageState state;
|
||||||
|
protected double price;
|
||||||
|
protected String location;
|
||||||
|
protected boolean isActive;
|
||||||
|
protected boolean isPublic;
|
||||||
|
protected Date createdTime;
|
||||||
|
protected Date updatedTime;
|
||||||
|
protected Set<BillingToken> billingTokens = ImmutableSet.of();
|
||||||
|
protected Customer owner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getId()
|
||||||
|
*/
|
||||||
|
public T id(long id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getFriendlyName()
|
||||||
|
*/
|
||||||
|
public T friendlyName(String friendlyName) {
|
||||||
|
this.friendlyName = friendlyName;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getDescription()
|
||||||
|
*/
|
||||||
|
public T description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getOs()
|
||||||
|
*/
|
||||||
|
public T os(Option os) {
|
||||||
|
this.os = os;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getArchitecture()
|
||||||
|
*/
|
||||||
|
public T architecture(Option architecture) {
|
||||||
|
this.architecture = architecture;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getType()
|
||||||
|
*/
|
||||||
|
public T type(ServerImageType type) {
|
||||||
|
this.type = type;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getState()
|
||||||
|
*/
|
||||||
|
public T state(ServerImageState state) {
|
||||||
|
this.state = state;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getPrice()
|
||||||
|
*/
|
||||||
|
public T price(double price) {
|
||||||
|
this.price = price;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getLocation()
|
||||||
|
*/
|
||||||
|
public T location(String location) {
|
||||||
|
this.location = location;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#isActive()
|
||||||
|
*/
|
||||||
|
public T isActive(boolean isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#isPublic()
|
||||||
|
*/
|
||||||
|
public T isPublic(boolean isPublic) {
|
||||||
|
this.isPublic = isPublic;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getCreatedTime()
|
||||||
|
*/
|
||||||
|
public T createdTime(Date createdTime) {
|
||||||
|
this.createdTime = createdTime;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getUpdatedTime()
|
||||||
|
*/
|
||||||
|
public T updatedTime(Date updatedTime) {
|
||||||
|
this.updatedTime = updatedTime;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getBillingTokens()
|
||||||
|
*/
|
||||||
|
public T billingTokens(Set<BillingToken> billingTokens) {
|
||||||
|
this.billingTokens = ImmutableSet.copyOf(checkNotNull(billingTokens, "billingTokens"));
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T billingTokens(BillingToken... in) {
|
||||||
|
return billingTokens(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ServerImage#getOwner()
|
||||||
|
*/
|
||||||
|
public T owner(Customer owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerImage build() {
|
||||||
|
return new ServerImage(id, name, friendlyName, description, os, architecture, type, state, price, location, isActive, isPublic, createdTime, updatedTime, billingTokens, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T fromServerImage(ServerImage in) {
|
||||||
|
return this
|
||||||
|
.id(in.getId())
|
||||||
|
.name(in.getName())
|
||||||
|
.friendlyName(in.getFriendlyName())
|
||||||
|
.description(in.getDescription())
|
||||||
|
.os(in.getOs())
|
||||||
|
.architecture(in.getArchitecture())
|
||||||
|
.type(in.getType())
|
||||||
|
.state(in.getState())
|
||||||
|
.price(in.getPrice())
|
||||||
|
.location(in.getLocation())
|
||||||
|
.isActive(in.isActive())
|
||||||
|
.isPublic(in.isPublic())
|
||||||
|
.createdTime(in.getCreatedTime())
|
||||||
|
.updatedTime(in.getUpdatedTime())
|
||||||
|
.billingTokens(in.getBillingTokens())
|
||||||
|
.owner(in.getOwner());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final long id;
|
||||||
|
private final String name;
|
||||||
|
private final String friendlyName;
|
||||||
|
private final String description;
|
||||||
|
private final Option os;
|
||||||
|
private final Option architecture;
|
||||||
|
private final ServerImageType type;
|
||||||
|
private final ServerImageState state;
|
||||||
|
private final double price;
|
||||||
|
private final String location;
|
||||||
|
private final boolean isActive;
|
||||||
|
private final boolean isPublic;
|
||||||
|
private final Date createdTime;
|
||||||
|
private final Date updatedTime;
|
||||||
|
private final Set<BillingToken> billingTokens;
|
||||||
|
private final Customer owner;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "name", "friendlyName", "description", "os", "architecture", "type", "state", "price", "location", "isActive", "isPublic", "createdTime", "updatedTime", "billingtokens", "owner"
|
||||||
|
})
|
||||||
|
protected ServerImage(long id, String name, String friendlyName, @Nullable String description, Option os, @Nullable Option architecture,
|
||||||
|
ServerImageType type, ServerImageState state, double price, String location, boolean isActive,
|
||||||
|
boolean isPublic, @Nullable Date createdTime, @Nullable Date updatedTime, Set<BillingToken> billingTokens, Customer owner) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = checkNotNull(name, "name");
|
||||||
this.friendlyName = friendlyName;
|
this.friendlyName = checkNotNull(friendlyName, "friendlyName");
|
||||||
this.description = description;
|
this.description = Strings.nullToEmpty(description);
|
||||||
this.os = os;
|
this.os = checkNotNull(os, "os");
|
||||||
this.architecture = architecture;
|
this.architecture = architecture;
|
||||||
this.type = type;
|
this.type = checkNotNull(type, "type");
|
||||||
this.state = state;
|
this.state = checkNotNull(state, "state");
|
||||||
this.price = price;
|
this.price = price;
|
||||||
this.location = location;
|
this.location = checkNotNull(location, "location");
|
||||||
isActive = active;
|
this.isActive = isActive;
|
||||||
isPublic = aPublic;
|
this.isPublic = isPublic;
|
||||||
this.createdTime = createdTime;
|
this.createdTime = createdTime;
|
||||||
this.updatedTime = updatedTime;
|
this.updatedTime = updatedTime;
|
||||||
this.billingTokens = billingTokens;
|
this.billingTokens = ImmutableSet.copyOf(checkNotNull(billingTokens, "billingTokens"));
|
||||||
this.owner = owner;
|
this.owner = checkNotNull(owner, "owner");
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFriendlyName() {
|
public String getFriendlyName() {
|
||||||
return friendlyName;
|
return this.friendlyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
if (description == null)
|
return this.description;
|
||||||
return "";
|
|
||||||
return description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Option getOs() {
|
public Option getOs() {
|
||||||
return os;
|
return this.os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Option getArchitecture() {
|
public Option getArchitecture() {
|
||||||
return architecture;
|
return this.architecture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerImageType getType() {
|
public ServerImageType getType() {
|
||||||
return type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerImageState getState() {
|
public ServerImageState getState() {
|
||||||
return state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPrice() {
|
public double getPrice() {
|
||||||
return price;
|
return this.price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocation() {
|
public String getLocation() {
|
||||||
return location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return isActive;
|
return this.isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return isPublic;
|
return this.isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Date getCreatedTime() {
|
public Date getCreatedTime() {
|
||||||
return createdTime;
|
return this.createdTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Date getUpdatedTime() {
|
public Date getUpdatedTime() {
|
||||||
return updatedTime;
|
return this.updatedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<BillingToken> getBillingTokens() {
|
public Set<BillingToken> getBillingTokens() {
|
||||||
return billingTokens;
|
return this.billingTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Customer getOwner() {
|
public Customer getOwner() {
|
||||||
return owner;
|
return this.owner;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object) {
|
|
||||||
if (this == object) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (object instanceof ServerImage) {
|
|
||||||
final ServerImage other = ServerImage.class.cast(object);
|
|
||||||
return equal(id, other.id) && equal(name, other.name);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(id, name);
|
return Objects.hashCode(id, name, friendlyName, description, os, architecture, type, state, price, location, isActive, isPublic, createdTime, updatedTime, billingTokens, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
ServerImage that = ServerImage.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id)
|
||||||
|
&& Objects.equal(this.name, that.name)
|
||||||
|
&& Objects.equal(this.friendlyName, that.friendlyName)
|
||||||
|
&& Objects.equal(this.description, that.description)
|
||||||
|
&& Objects.equal(this.os, that.os)
|
||||||
|
&& Objects.equal(this.architecture, that.architecture)
|
||||||
|
&& Objects.equal(this.type, that.type)
|
||||||
|
&& Objects.equal(this.state, that.state)
|
||||||
|
&& Objects.equal(this.price, that.price)
|
||||||
|
&& Objects.equal(this.location, that.location)
|
||||||
|
&& Objects.equal(this.isActive, that.isActive)
|
||||||
|
&& Objects.equal(this.isPublic, that.isPublic)
|
||||||
|
&& Objects.equal(this.createdTime, that.createdTime)
|
||||||
|
&& Objects.equal(this.updatedTime, that.updatedTime)
|
||||||
|
&& Objects.equal(this.billingTokens, that.billingTokens)
|
||||||
|
&& Objects.equal(this.owner, that.owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("name", name).add("friendlyName", friendlyName).add("description", description).add("os", os).add("architecture", architecture).add("type", type).add("state", state).add("price", price).add("location", location).add("isActive", isActive).add("isPublic", isPublic).add("createdTime", createdTime).add("updatedTime", updatedTime).add("billingTokens", billingTokens).add("owner", owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,13 +385,4 @@ public class ServerImage implements Comparable<ServerImage> {
|
||||||
return 0;
|
return 0;
|
||||||
return Longs.compare(id, that.getId());
|
return Longs.compare(id, that.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return toStringHelper("").add("id", id).add("name", name).add("friendlyName", friendlyName).add("friendlyName",
|
|
||||||
friendlyName).add("description", description).add("os", os).add("architecture", architecture).add(
|
|
||||||
"type", type).add("state", state).add("price", price).add("location", location)
|
|
||||||
.add("isActive", isActive).add("isPublic", isPublic).add("createdTime", createdTime).add("updatedTime",
|
|
||||||
updatedTime).add("billingTokens", billingTokens).add("owner", owner).toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,43 +18,109 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain.internal;
|
package org.jclouds.gogrid.domain.internal;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class ErrorResponse
|
||||||
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class ErrorResponse implements Comparable<ErrorResponse> {
|
public class ErrorResponse {
|
||||||
|
|
||||||
private String message;
|
public static Builder<?> builder() {
|
||||||
@SerializedName("errorcode")
|
return new ConcreteBuilder();
|
||||||
private String errorCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A no-args constructor is required for deserialization
|
|
||||||
*/
|
|
||||||
public ErrorResponse() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ErrorResponse(String message, String errorCode) {
|
public Builder<?> toBuilder() {
|
||||||
this.message = message;
|
return new ConcreteBuilder().fromErrorResponse(this);
|
||||||
this.errorCode = errorCode;
|
}
|
||||||
|
|
||||||
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected String message;
|
||||||
|
protected String errorCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ErrorResponse#getMessage()
|
||||||
|
*/
|
||||||
|
public T message(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ErrorResponse#getErrorCode()
|
||||||
|
*/
|
||||||
|
public T errorCode(String errorCode) {
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ErrorResponse build() {
|
||||||
|
return new ErrorResponse(message, errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T fromErrorResponse(ErrorResponse in) {
|
||||||
|
return this
|
||||||
|
.message(in.getMessage())
|
||||||
|
.errorCode(in.getErrorCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
private final String errorCode;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"message", "errorcode"
|
||||||
|
})
|
||||||
|
protected ErrorResponse(String message, String errorCode) {
|
||||||
|
this.message = checkNotNull(message, "message");
|
||||||
|
this.errorCode = checkNotNull(errorCode, "errorCode");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return this.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getErrorCode() {
|
public String getErrorCode() {
|
||||||
return errorCode;
|
return this.errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ErrorResponse o) {
|
public int hashCode() {
|
||||||
return message.compareTo(o.getMessage());
|
return Objects.hashCode(message, errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
ErrorResponse that = ErrorResponse.class.cast(obj);
|
||||||
|
return Objects.equal(this.message, that.message)
|
||||||
|
&& Objects.equal(this.errorCode, that.errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("message", message).add("errorCode", errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[errorCode=" + errorCode + ", message=" + message + "]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,16 +37,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.gogrid.domain.Ip;
|
import org.jclouds.gogrid.domain.*;
|
||||||
import org.jclouds.gogrid.domain.IpPortPair;
|
|
||||||
import org.jclouds.gogrid.domain.Job;
|
|
||||||
import org.jclouds.gogrid.domain.LoadBalancer;
|
|
||||||
import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
|
|
||||||
import org.jclouds.gogrid.domain.LoadBalancerType;
|
|
||||||
import org.jclouds.gogrid.domain.PowerCommand;
|
|
||||||
import org.jclouds.gogrid.domain.Server;
|
|
||||||
import org.jclouds.gogrid.domain.ServerImage;
|
|
||||||
import org.jclouds.gogrid.domain.ServerImageType;
|
|
||||||
import org.jclouds.gogrid.options.AddLoadBalancerOptions;
|
import org.jclouds.gogrid.options.AddLoadBalancerOptions;
|
||||||
import org.jclouds.gogrid.options.AddServerOptions;
|
import org.jclouds.gogrid.options.AddServerOptions;
|
||||||
import org.jclouds.gogrid.options.GetImageListOptions;
|
import org.jclouds.gogrid.options.GetImageListOptions;
|
||||||
|
@ -117,7 +108,7 @@ public class GoGridLiveTestDisabled extends BaseComputeServiceContextLiveTest {
|
||||||
String ram = Iterables.get(client.getServerServices().getRamSizes(), 0).getName();
|
String ram = Iterables.get(client.getServerServices().getRamSizes(), 0).getName();
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < 1 * 500; i++)
|
for (int i = 0; i < 500; i++)
|
||||||
builder.append('a');
|
builder.append('a');
|
||||||
|
|
||||||
String description = builder.toString();
|
String description = builder.toString();
|
||||||
|
@ -251,7 +242,8 @@ public class GoGridLiveTestDisabled extends BaseComputeServiceContextLiveTest {
|
||||||
AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().create(LoadBalancerType.LEAST_CONNECTED,
|
AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().create(LoadBalancerType.LEAST_CONNECTED,
|
||||||
LoadBalancerPersistenceType.SOURCE_ADDRESS);
|
LoadBalancerPersistenceType.SOURCE_ADDRESS);
|
||||||
LoadBalancer createdLoadBalancer = client.getLoadBalancerServices().addLoadBalancer(nameOfLoadBalancer,
|
LoadBalancer createdLoadBalancer = client.getLoadBalancerServices().addLoadBalancer(nameOfLoadBalancer,
|
||||||
new IpPortPair(vip, 80), Arrays.asList(new IpPortPair(realIp1, 80), new IpPortPair(realIp2, 80)),
|
IpPortPair.builder().ip(vip).port(80).build(), Arrays.asList(IpPortPair.builder().ip(realIp1).port(80).build(),
|
||||||
|
IpPortPair.builder().ip(realIp2).port(80).build()),
|
||||||
options);
|
options);
|
||||||
assertNotNull(createdLoadBalancer);
|
assertNotNull(createdLoadBalancer);
|
||||||
assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
|
assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
|
||||||
|
@ -266,7 +258,7 @@ public class GoGridLiveTestDisabled extends BaseComputeServiceContextLiveTest {
|
||||||
assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
|
assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
|
||||||
|
|
||||||
LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().editLoadBalancerNamed(nameOfLoadBalancer,
|
LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().editLoadBalancerNamed(nameOfLoadBalancer,
|
||||||
Arrays.asList(new IpPortPair(realIp3, 8181)));
|
Arrays.asList(IpPortPair.builder().ip(realIp3).port(8181).build()));
|
||||||
assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
|
assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
|
||||||
assertNotNull(editedLoadBalancer.getRealIpList());
|
assertNotNull(editedLoadBalancer.getRealIpList());
|
||||||
assertEquals(editedLoadBalancer.getRealIpList().size(), 1);
|
assertEquals(editedLoadBalancer.getRealIpList().size(), 1);
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
Map<ServerState, Status> serverStateToNodeStatus = createMock(Map.class);
|
Map<ServerState, Status> serverStateToNodeStatus = createMock(Map.class);
|
||||||
org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||||
Option dc = new Option(1l, "US-West-1", "US West 1 Datacenter");
|
Option dc = Option.createWithIdNameAndDescription(1l, "US-West-1", "US West 1 Datacenter");
|
||||||
Option ram = new Option(1l, "512MB", "Server with 512MB RAM");
|
Option ram = Option.createWithIdNameAndDescription(1l, "512MB", "Server with 512MB RAM");
|
||||||
|
|
||||||
Set<? extends org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
|
Set<? extends org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
|
||||||
Server server = createMock(Server.class);
|
Server server = createMock(Server.class);
|
||||||
|
@ -77,7 +77,7 @@ public class ServerToNodeMetadataTest {
|
||||||
Location location = new LocationBuilder().scope(LocationScope.ZONE).id("1").description("US-West-1").build();
|
Location location = new LocationBuilder().scope(LocationScope.ZONE).id("1").description("US-West-1").build();
|
||||||
Set< ? extends Location> locations = ImmutableSet.< Location> of( location);
|
Set< ? extends Location> locations = ImmutableSet.< Location> of( location);
|
||||||
|
|
||||||
expect(server.getIp()).andReturn(new Ip("127.0.0.1"));
|
expect(server.getIp()).andReturn(Ip.builder().ip("127.0.0.1").build());
|
||||||
|
|
||||||
ServerImage image = createMock(ServerImage.class);
|
ServerImage image = createMock(ServerImage.class);
|
||||||
expect(server.getImage()).andReturn(image).atLeastOnce();
|
expect(server.getImage()).andReturn(image).atLeastOnce();
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -68,11 +67,12 @@ public class ParseJobsFromJsonResponseTest {
|
||||||
"name", "ServerCreated40562",
|
"name", "ServerCreated40562",
|
||||||
"type", "virtual_server");
|
"type", "virtual_server");
|
||||||
|
|
||||||
Job job = new Job(250628L, new Option(7L, "DeleteVirtualServer", "Delete Virtual Server"),
|
Job job = Job.builder().id(250628L).command(Option.createWithIdNameAndDescription(7L, "DeleteVirtualServer", "Delete Virtual Server"))
|
||||||
ObjectType.VIRTUAL_SERVER, new Date(1267404528895L), new Date(1267404538592L), JobState.SUCCEEDED, 1,
|
.objectType(ObjectType.VIRTUAL_SERVER).createdOn(new Date(1267404528895L)).lastUpdatedOn(new Date(1267404538592L))
|
||||||
"3116784158f0af2d-24076@api.gogrid.com", ImmutableSortedSet.of(new JobProperties(940263L, new Date(
|
.currentState(JobState.SUCCEEDED).attempts(1).owner("3116784158f0af2d-24076@api.gogrid.com").history(
|
||||||
1267404528897L), JobState.CREATED, null), new JobProperties(940264L, new Date(1267404528967L),
|
JobProperties.builder().id(940263L).updatedOn(new Date(1267404528897L)).state(JobState.CREATED).build(),
|
||||||
JobState.QUEUED, null)), details);
|
JobProperties.builder().id(940264L).updatedOn(new Date(1267404528967L)).state(JobState.QUEUED).build())
|
||||||
|
.details(details).build();
|
||||||
assertEquals(job, Iterables.getOnlyElement(response));
|
assertEquals(job, Iterables.getOnlyElement(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -64,14 +63,19 @@ public class ParseLoadBalancersFromJsonResponseTest {
|
||||||
ParseLoadBalancerListFromJsonResponse parser = i.getInstance(ParseLoadBalancerListFromJsonResponse.class);
|
ParseLoadBalancerListFromJsonResponse parser = i.getInstance(ParseLoadBalancerListFromJsonResponse.class);
|
||||||
SortedSet<LoadBalancer> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
SortedSet<LoadBalancer> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
|
||||||
|
|
||||||
Option dc = new Option(1l, "US-West-1", "US West 1 Datacenter");
|
Option dc = Option.createWithIdNameAndDescription(1l, "US-West-1", "US West 1 Datacenter");
|
||||||
|
|
||||||
|
LoadBalancer loadBalancer = LoadBalancer.builder().id(6372L).name("Balancer")
|
||||||
|
.virtualIp(IpPortPair.builder().ip(Ip.builder().id(1313082L)
|
||||||
|
.ip("204.51.240.181").subnet("204.51.240.176/255.255.255.240").isPublic(true).state(IpState.ASSIGNED).datacenter(dc).build()).port(80).build())
|
||||||
|
.realIpList(
|
||||||
|
IpPortPair.builder().ip(Ip.builder().id(1313086L).ip("204.51.240.185").subnet("204.51.240.176/255.255.255.240")
|
||||||
|
.isPublic(true).state(IpState.ASSIGNED).datacenter(dc).build()).port(80).build(),
|
||||||
|
IpPortPair.builder().ip(Ip.builder().id(1313089L).ip("204.51.240.188").subnet("204.51.240.176/255.255.255.240")
|
||||||
|
.isPublic(true).state(IpState.ASSIGNED).datacenter(dc).build()).port(80).build())
|
||||||
|
.type(LoadBalancerType.ROUND_ROBIN).persistence(LoadBalancerPersistenceType.NONE)
|
||||||
|
.os(LoadBalancerOs.F5).state(LoadBalancerState.ON).datacenter(dc).build();
|
||||||
|
|
||||||
LoadBalancer loadBalancer = new LoadBalancer(6372L, "Balancer", null, new IpPortPair(new Ip(1313082L,
|
|
||||||
"204.51.240.181", "204.51.240.176/255.255.255.240", true, IpState.ASSIGNED, dc), 80), ImmutableSortedSet
|
|
||||||
.of(new IpPortPair(new Ip(1313086L, "204.51.240.185", "204.51.240.176/255.255.255.240", true,
|
|
||||||
IpState.ASSIGNED, dc), 80), new IpPortPair(new Ip(1313089L, "204.51.240.188",
|
|
||||||
"204.51.240.176/255.255.255.240", true, IpState.ASSIGNED, dc), 80)), LoadBalancerType.ROUND_ROBIN,
|
|
||||||
LoadBalancerPersistenceType.NONE, LoadBalancerOs.F5, LoadBalancerState.ON, dc);
|
|
||||||
assertEquals(Iterables.getOnlyElement(response), loadBalancer);
|
assertEquals(Iterables.getOnlyElement(response), loadBalancer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +88,7 @@ public class ParseLoadBalancersFromJsonResponseTest {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@SuppressWarnings( { "unused" })
|
@SuppressWarnings({"unused"})
|
||||||
public Map<Type, Object> provideCustomAdapterBindings() {
|
public Map<Type, Object> provideCustomAdapterBindings() {
|
||||||
Map<Type, Object> bindings = Maps.newHashMap();
|
Map<Type, Object> bindings = Maps.newHashMap();
|
||||||
bindings.put(LoadBalancerOs.class, new CustomDeserializers.LoadBalancerOsAdapter());
|
bindings.put(LoadBalancerOs.class, new CustomDeserializers.LoadBalancerOsAdapter());
|
||||||
|
|
|
@ -22,28 +22,17 @@ import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.gogrid.config.GoGridParserModule;
|
import org.jclouds.gogrid.config.GoGridParserModule;
|
||||||
import org.jclouds.gogrid.domain.BillingToken;
|
import org.jclouds.gogrid.domain.*;
|
||||||
import org.jclouds.gogrid.domain.Customer;
|
|
||||||
import org.jclouds.gogrid.domain.Ip;
|
|
||||||
import org.jclouds.gogrid.domain.IpState;
|
|
||||||
import org.jclouds.gogrid.domain.Option;
|
|
||||||
import org.jclouds.gogrid.domain.Server;
|
|
||||||
import org.jclouds.gogrid.domain.ServerImage;
|
|
||||||
import org.jclouds.gogrid.domain.ServerImageState;
|
|
||||||
import org.jclouds.gogrid.domain.ServerImageType;
|
|
||||||
import org.jclouds.gogrid.domain.ServerState;
|
|
||||||
import org.jclouds.json.BaseSetParserTest;
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ParseServerListTest")
|
@Test(groups = "unit", testName = "ParseServerListTest")
|
||||||
|
@ -57,18 +46,19 @@ public class ParseServerListTest extends BaseSetParserTest<Server> {
|
||||||
@Override
|
@Override
|
||||||
@SelectJson("list")
|
@SelectJson("list")
|
||||||
public Set<Server> expected() {
|
public Set<Server> expected() {
|
||||||
Option dc = new Option(1l, "US-West-1", "US West 1 Datacenter");
|
Option dc = Option.createWithIdNameAndDescription(1l, "US-West-1", "US West 1 Datacenter");
|
||||||
Option centOs = new Option(13L, "CentOS 5.2 (32-bit)", "CentOS 5.2 (32-bit)");
|
Option centOs = Option.createWithIdNameAndDescription(13L, "CentOS 5.2 (32-bit)", "CentOS 5.2 (32-bit)");
|
||||||
Option webServer = new Option(1L, "Web Server", "Web or Application Server");
|
Option webServer = Option.createWithIdNameAndDescription(1L, "Web Server", "Web or Application Server");
|
||||||
return ImmutableSet.of(new Server(75245L, dc, false, "PowerServer", "server to test the api. created by Alex",
|
return ImmutableSet.of(Server.builder().id(75245L).datacenter(dc).name("PowerServer").description("server to test the api. created by Alex")
|
||||||
ServerState.ON, webServer, new Option(1L, "512MB", "Server with 512MB RAM"), centOs, new Ip(1313079L,
|
.state(ServerState.ON).type(webServer).ram(Option.createWithIdNameAndDescription(1L, "512MB", "Server with 512MB RAM")).os(centOs)
|
||||||
"204.51.240.178", "204.51.240.176/255.255.255.240", true, IpState.ASSIGNED, dc),
|
.ip(Ip.builder().id(1313079L).ip("204.51.240.178").subnet("204.51.240.176/255.255.255.240").isPublic(true).state(IpState.ASSIGNED).datacenter(dc).build())
|
||||||
new ServerImage(1946L, "GSI-f8979644-e646-4711-ad58-d98a5fa3612c", "BitNami Gallery 2.3.1-0",
|
.image(ServerImage.builder().id(1946L).name("GSI-f8979644-e646-4711-ad58-d98a5fa3612c").friendlyName("BitNami Gallery 2.3.1-0")
|
||||||
"http://bitnami.org/stack/gallery", centOs, null, ServerImageType.WEB_APPLICATION_SERVER,
|
.description("http://bitnami.org/stack/gallery").os(centOs).type(ServerImageType.WEB_APPLICATION_SERVER)
|
||||||
ServerImageState.AVAILABLE, 0.0, "24732/GSI-f8979644-e646-4711-ad58-d98a5fa3612c.img", true,
|
.state(ServerImageState.AVAILABLE).location("24732/GSI-f8979644-e646-4711-ad58-d98a5fa3612c.img").isActive(true).isPublic(true)
|
||||||
true, new Date(1261504577971L), new Date(1262649582180L), ImmutableSortedSet.of(
|
.createdTime(new Date(1261504577971L)).updatedTime(new Date(1262649582180L)).billingTokens(
|
||||||
new BillingToken(38L, "CentOS 5.2 32bit", 0.0), new BillingToken(56L,
|
BillingToken.builder().id(38L).name("CentOS 5.2 32bit").build(),
|
||||||
"BitNami: Gallery", 0.0)), new Customer(24732L, "BitRock"))));
|
BillingToken.builder().id(56L).name("BitNami: Gallery").build())
|
||||||
|
.owner(Customer.builder().id(24732L).name("BitRock").build()).build()).build());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.jclouds.rest.annotations.OnlyElement;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
@ -56,18 +57,19 @@ public class ParseServerTest extends BaseItemParserTest<Server> {
|
||||||
@SelectJson("list")
|
@SelectJson("list")
|
||||||
@OnlyElement
|
@OnlyElement
|
||||||
public Server expected() {
|
public Server expected() {
|
||||||
Option dc = new Option(1l, "US-West-1", "US West 1 Datacenter");
|
Option dc = Option.createWithIdNameAndDescription(1l, "US-West-1", "US West 1 Datacenter");
|
||||||
Option centOs = new Option(13L, "CentOS 5.2 (32-bit)", "CentOS 5.2 (32-bit)");
|
Option centOs = Option.createWithIdNameAndDescription(13L, "CentOS 5.2 (32-bit)", "CentOS 5.2 (32-bit)");
|
||||||
Option webServer = new Option(1L, "Web Server", "Web or Application Server");
|
Option webServer = Option.createWithIdNameAndDescription(1L, "Web Server", "Web or Application Server");
|
||||||
return new Server(75245L, dc, false, "PowerServer", "server to test the api. created by Alex",
|
return Server.builder().id(75245L).datacenter(dc).isSandbox(false).name("PowerServer").description("server to test the api. created by Alex")
|
||||||
ServerState.ON, webServer, new Option(1L, "512MB", "Server with 512MB RAM"), centOs, new Ip(1313079L,
|
.state(ServerState.ON).type(webServer).ram(Option.createWithIdNameAndDescription(1L, "512MB", "Server with 512MB RAM"))
|
||||||
"204.51.240.178", "204.51.240.176/255.255.255.240", true, IpState.ASSIGNED, dc), new ServerImage(
|
.os(centOs).ip(Ip.builder().id(1313079L).ip("204.51.240.178").subnet("204.51.240.176/255.255.255.240").isPublic(true).state(IpState.ASSIGNED).datacenter(dc).build())
|
||||||
1946L, "GSI-f8979644-e646-4711-ad58-d98a5fa3612c", "BitNami Gallery 2.3.1-0",
|
.image(ServerImage.builder().id(1946L).name("GSI-f8979644-e646-4711-ad58-d98a5fa3612c").friendlyName("BitNami Gallery 2.3.1-0")
|
||||||
"http://bitnami.org/stack/gallery", centOs, null, ServerImageType.WEB_APPLICATION_SERVER,
|
.description("http://bitnami.org/stack/gallery").os(centOs).type(ServerImageType.WEB_APPLICATION_SERVER)
|
||||||
ServerImageState.AVAILABLE, 0.0, "24732/GSI-f8979644-e646-4711-ad58-d98a5fa3612c.img", true, true,
|
.state(ServerImageState.AVAILABLE).location("24732/GSI-f8979644-e646-4711-ad58-d98a5fa3612c.img").isPublic(true)
|
||||||
new Date(1261504577971L), new Date(1262649582180L), ImmutableSortedSet.of(new BillingToken(38L,
|
.isActive(true).createdTime(new Date(1261504577971L)).updatedTime(new Date(1262649582180L)).billingTokens(
|
||||||
"CentOS 5.2 32bit", 0.0), new BillingToken(56L, "BitNami: Gallery", 0.0)), new Customer(24732L,
|
BillingToken.builder().id(38L).name("CentOS 5.2 32bit").build(),
|
||||||
"BitRock")));
|
BillingToken.builder().id(56L).name("BitNami: Gallery").build()).owner(
|
||||||
|
Customer.builder().id(24732L).name("BitRock").build()).build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Injector injector() {
|
protected Injector injector() {
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
|
||||||
assert image.getArchitecture() != null : image;
|
assert image.getArchitecture() != null : image;
|
||||||
assert image.getBillingTokens() != null : image;
|
assert image.getBillingTokens() != null : image;
|
||||||
if (image.getCreatedTime() == null)
|
if (image.getCreatedTime() == null)
|
||||||
Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the createdon field");
|
Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the createdTime field");
|
||||||
assert image.getDescription() != null : image;
|
assert image.getDescription() != null : image;
|
||||||
assert image.getFriendlyName() != null : image;
|
assert image.getFriendlyName() != null : image;
|
||||||
assert image.getId() >= 0 : image;
|
assert image.getId() >= 0 : image;
|
||||||
|
@ -81,7 +81,7 @@ public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
|
||||||
assert image.getState() != null : image;
|
assert image.getState() != null : image;
|
||||||
assert image.getType() != null : image;
|
assert image.getType() != null : image;
|
||||||
if (image.getUpdatedTime() == null)
|
if (image.getUpdatedTime() == null)
|
||||||
Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the updatedon field");
|
Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the updatedTime field");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -92,7 +92,7 @@ public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
|
||||||
final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
|
final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
|
||||||
ServerImage image = null;
|
ServerImage image = null;
|
||||||
try {
|
try {
|
||||||
Set<Ip> availableIps = restContext.getApi().getIpServices().getUnassignedIpList();
|
Set<Ip> availableIps = restContext.getApi().getIpServices().getUnassignedPublicIpList();
|
||||||
Ip availableIp = Iterables.getLast(availableIps);
|
Ip availableIp = Iterables.getLast(availableIps);
|
||||||
|
|
||||||
Server createdServer = restContext.getApi().getServerServices()
|
Server createdServer = restContext.getApi().getServerServices()
|
||||||
|
@ -112,9 +112,10 @@ public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
|
||||||
assertEventuallyImageStateEquals(image, ServerImageState.AVAILABLE);
|
assertEventuallyImageStateEquals(image, ServerImageState.AVAILABLE);
|
||||||
|
|
||||||
restContext.getApi().getImageServices().deleteById(image.getId());
|
restContext.getApi().getImageServices().deleteById(image.getId());
|
||||||
|
|
||||||
assertEventuallyImageStateEquals(image, ServerImageState.TRASH);
|
assertEventuallyImageStateEquals(image, ServerImageState.TRASH);
|
||||||
|
|
||||||
|
image = null;
|
||||||
} finally {
|
} finally {
|
||||||
if (image != null)
|
if (image != null)
|
||||||
try {
|
try {
|
||||||
|
@ -138,6 +139,6 @@ public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
|
||||||
.getApi()
|
.getApi()
|
||||||
.getImageServices().getImagesById(input.getId())).getState() == state;
|
.getImageServices().getImagesById(input.getId())).getState() == state;
|
||||||
}
|
}
|
||||||
}, 300, 1, TimeUnit.SECONDS).apply(image));
|
}, 600, 1, TimeUnit.SECONDS).apply(image));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.gogrid.services;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.gogrid.domain.Ip;
|
import org.jclouds.gogrid.domain.Ip;
|
||||||
|
@ -34,12 +33,13 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GridLoadBalancerAsyncClient}
|
* Tests behavior of {@code GridLoadBalancerAsyncClient}
|
||||||
*
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@ -73,8 +73,10 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
|
||||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("addLoadBalancer", String.class, IpPortPair.class,
|
Method method = GridLoadBalancerAsyncClient.class.getMethod("addLoadBalancer", String.class, IpPortPair.class,
|
||||||
List.class, AddLoadBalancerOptions[].class);
|
List.class, AddLoadBalancerOptions[].class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, "BalanceIt",
|
HttpRequest httpRequest = processor.createRequest(method, "BalanceIt",
|
||||||
new IpPortPair(new Ip("127.0.0.1"), 80), Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080),
|
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(80).build(),
|
||||||
new IpPortPair(new Ip("127.0.0.1"), 9090)), new AddLoadBalancerOptions.Builder().create(
|
ImmutableList.of(IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
|
||||||
|
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()),
|
||||||
|
new AddLoadBalancerOptions.Builder().create(
|
||||||
LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SSL_STICKY));
|
LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SSL_STICKY));
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||||
|
@ -105,8 +107,9 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
|
||||||
@Test
|
@Test
|
||||||
public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
|
public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
|
||||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", long.class, List.class);
|
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", long.class, List.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, 1l, Arrays
|
HttpRequest httpRequest = processor.createRequest(method, 1l, ImmutableList.of(
|
||||||
.asList(new IpPortPair(new Ip("127.0.0.1"), 8080), new IpPortPair(new Ip("127.0.0.1"), 9090)));
|
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
|
||||||
|
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()));
|
||||||
|
|
||||||
assertRequestLineEquals(
|
assertRequestLineEquals(
|
||||||
httpRequest,
|
httpRequest,
|
||||||
|
@ -131,8 +134,9 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
|
||||||
@Test
|
@Test
|
||||||
public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException {
|
public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException {
|
||||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancerNamed", String.class, List.class);
|
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancerNamed", String.class, List.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, "BalanceIt",
|
HttpRequest httpRequest = processor.createRequest(method, "BalanceIt", ImmutableList.of(
|
||||||
Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080), new IpPortPair(new Ip("127.0.0.1"), 9090)));
|
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
|
||||||
|
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()));
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||||
+ "edit?v=1.5&name=BalanceIt&realiplist.0.ip=127.0.0.1&"
|
+ "edit?v=1.5&name=BalanceIt&realiplist.0.ip=127.0.0.1&"
|
||||||
|
|
Loading…
Reference in New Issue