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