mirror of https://github.com/apache/jclouds.git
softlayer: issue 971 adjusting builders and applying ConstructorProperties to domain objects
This commit is contained in:
parent
ed8a1d640f
commit
ec74987054
|
@ -56,7 +56,7 @@ public class ProductItems {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function to get the ProductItemPrice for the ProductItem. Currently returns the
|
* Creates a function to get the ProductItemPrice for the ProductItem. Currently returns the
|
||||||
* first price. This will need to be changed if more than one price is returned.
|
* first prices. This will need to be changed if more than one prices is returned.
|
||||||
*/
|
*/
|
||||||
public static Function<ProductItem, ProductItemPrice> price() {
|
public static Function<ProductItem, ProductItemPrice> price() {
|
||||||
return new Function<ProductItem, ProductItemPrice>() {
|
return new Function<ProductItem, ProductItemPrice>() {
|
||||||
|
@ -71,7 +71,7 @@ public class ProductItems {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function to get the ProductItem for the ProductItemPrice. Copies the category
|
* Creates a function to get the ProductItem for the ProductItemPrice. Copies the category
|
||||||
* information from the price to the item if necessary The ProductItemPrices must have
|
* information from the prices to the item if necessary The ProductItemPrices must have
|
||||||
* ProductItems.
|
* ProductItems.
|
||||||
*/
|
*/
|
||||||
public static Function<ProductItemPrice, ProductItem> item() {
|
public static Function<ProductItemPrice, ProductItem> item() {
|
||||||
|
@ -80,7 +80,7 @@ public class ProductItems {
|
||||||
public ProductItem apply(ProductItemPrice productItemPrice) {
|
public ProductItem apply(ProductItemPrice productItemPrice) {
|
||||||
Set<ProductItemCategory> categories = productItemPrice.getCategories();
|
Set<ProductItemCategory> categories = productItemPrice.getCategories();
|
||||||
ProductItem item = productItemPrice.getItem();
|
ProductItem item = productItemPrice.getItem();
|
||||||
ProductItem.Builder builder = ProductItem.Builder.fromProductItem(productItemPrice.getItem());
|
ProductItem.Builder builder = productItemPrice.getItem().toBuilder();
|
||||||
if (item.getCategories().size() == 0 && categories.size() != 0) {
|
if (item.getCategories().size() == 0 && categories.size() != 0) {
|
||||||
builder.categories(categories);
|
builder.categories(categories);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a set of ProductItems to Hardware. All cores have a speed of 2.0Ghz The Hardware Id will
|
* Converts a set of ProductItems to Hardware. All cores have a speed of 2.0Ghz The Hardware Id will
|
||||||
* be a comma separated list containing the price ids: cpus,ram,volume
|
* be a comma separated list containing the prices ids: cpus,ram,volume
|
||||||
*
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class SoftLayerComputeServiceAdapter implements
|
||||||
|
|
||||||
ProductOrder order = ProductOrder.builder().packageId(productPackageSupplier.get().getId())
|
ProductOrder order = ProductOrder.builder().packageId(productPackageSupplier.get().getId())
|
||||||
.location(template.getLocation().getId()).quantity(1).useHourlyPricing(true).prices(getPrices(template))
|
.location(template.getLocation().getId()).quantity(1).useHourlyPricing(true).prices(getPrices(template))
|
||||||
.virtualGuest(newGuest).build();
|
.virtualGuests(newGuest).build();
|
||||||
|
|
||||||
logger.debug(">> ordering new virtualGuest domain(%s) hostname(%s)", domainName, name);
|
logger.debug(">> ordering new virtualGuest domain(%s) hostname(%s)", domainName, name);
|
||||||
ProductOrderReceipt productOrderReceipt = client.getVirtualGuestClient().orderVirtualGuest(order);
|
ProductOrderReceipt productOrderReceipt = client.getVirtualGuestClient().orderVirtualGuest(order);
|
||||||
|
|
|
@ -18,28 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.softlayer.config;
|
package org.jclouds.softlayer.config;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.json.config.GsonModule.DateAdapter;
|
import org.jclouds.json.config.GsonModule.DateAdapter;
|
||||||
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
|
||||||
import org.jclouds.softlayer.domain.Datacenter;
|
|
||||||
import org.jclouds.softlayer.domain.OperatingSystem;
|
|
||||||
import org.jclouds.softlayer.domain.PowerState;
|
|
||||||
import org.jclouds.softlayer.domain.VirtualGuest;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonSerializationContext;
|
|
||||||
import com.google.gson.JsonSerializer;
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -47,72 +29,6 @@ import com.google.inject.Provides;
|
||||||
*/
|
*/
|
||||||
public class SoftLayerParserModule extends AbstractModule {
|
public class SoftLayerParserModule extends AbstractModule {
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public static class VirtualGuestAdapter implements JsonSerializer<VirtualGuest>, JsonDeserializer<VirtualGuest> {
|
|
||||||
|
|
||||||
public JsonElement serialize(VirtualGuest src, Type typeOfSrc, JsonSerializationContext context) {
|
|
||||||
return context.serialize(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualGuest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
|
||||||
throws JsonParseException {
|
|
||||||
return apply(context.<VirtualGuestInternal> deserialize(json, VirtualGuestInternal.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualGuest apply(VirtualGuestInternal in) {
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal class that flattens billingItem into billingItemId
|
|
||||||
*/
|
|
||||||
public static class VirtualGuestInternal extends VirtualGuest {
|
|
||||||
private BillingItem billingItem;
|
|
||||||
|
|
||||||
public VirtualGuestInternal(int accountId, Date createDate, boolean dedicatedAccountHostOnly, String domain,
|
|
||||||
String fullyQualifiedDomainName, String hostname, int id, Date lastVerifiedDate, int maxCpu,
|
|
||||||
String maxCpuUnits, int maxMemory, Date metricPollDate, Date modifyDate, String notes,
|
|
||||||
boolean privateNetworkOnly, int startCpus, int statusId, String uuid, String primaryBackendIpAddress,
|
|
||||||
String primaryIpAddress, int billingItemId, OperatingSystem operatingSystem, Datacenter datacenter,
|
|
||||||
PowerState powerState) {
|
|
||||||
super(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, hostname, id,
|
|
||||||
lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes,
|
|
||||||
privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress,
|
|
||||||
billingItemId, operatingSystem, datacenter, powerState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBillingItemId() {
|
|
||||||
return billingItem != null ? billingItem.id : -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class BillingItem {
|
|
||||||
|
|
||||||
private int id = -1;
|
|
||||||
|
|
||||||
// for deserializer
|
|
||||||
BillingItem() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public BillingItem(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[id=" + id + "]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
public Map<Type, Object> provideCustomAdapterBindings() {
|
|
||||||
return ImmutableMap.<Type, Object> of(VirtualGuest.class, new VirtualGuestAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -21,135 +21,156 @@ package org.jclouds.softlayer.domain;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Strings.emptyToNull;
|
import static com.google.common.base.Strings.emptyToNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class Address
|
||||||
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Account_Address"
|
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Account_Address"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class Address implements Comparable<Address> {
|
public class Address {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int id = -1;
|
return new ConcreteBuilder().fromAddress(this);
|
||||||
private String country;
|
}
|
||||||
private String state;
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
public Builder id(int id) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int id;
|
||||||
|
protected String country;
|
||||||
|
protected String state;
|
||||||
|
protected String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Address#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder country(String country) {
|
/**
|
||||||
|
* @see Address#getCountry()
|
||||||
|
*/
|
||||||
|
public T country(String country) {
|
||||||
this.country = country;
|
this.country = country;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder state(String state) {
|
/**
|
||||||
|
* @see Address#getState()
|
||||||
|
*/
|
||||||
|
public T state(String state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder description(String description) {
|
/**
|
||||||
|
* @see Address#getDescription()
|
||||||
|
*/
|
||||||
|
public T description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address build() {
|
public Address build() {
|
||||||
return new Address(id, country, state, description);
|
return new Address(id, country, state, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromAddress(Address in) {
|
public T fromAddress(Address in) {
|
||||||
return Address.builder().id(in.getId())
|
return this
|
||||||
.country(in.getCountry())
|
.id(in.getId())
|
||||||
.state(in.getState())
|
.country(in.getCountry())
|
||||||
.description(in.getDescription());
|
.state(in.getState())
|
||||||
|
.description(in.getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private String country;
|
@Override
|
||||||
private String state;
|
protected ConcreteBuilder self() {
|
||||||
private String description;
|
return this;
|
||||||
|
}
|
||||||
// for deserializer
|
|
||||||
Address() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address(int id, String country, String state, String description) {
|
private final int id;
|
||||||
|
private final String country;
|
||||||
|
private final String state;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "country", "state", "description"
|
||||||
|
})
|
||||||
|
protected Address(int id, String country, @Nullable String state, @Nullable String description) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.country = checkNotNull(emptyToNull(country),"country cannot be null or empty:"+country);
|
this.country = checkNotNull(emptyToNull(country),"country cannot be null or empty:"+country);
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(Address arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unique id of the address.
|
* @return The unique id of the address.
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The country of the address.
|
* @return The country of the address.
|
||||||
*/
|
*/
|
||||||
public String getCountry() {
|
public String getCountry() {
|
||||||
return country;
|
return this.country;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The state of the address.
|
* @return The state of the address.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getState() {
|
public String getState() {
|
||||||
return state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The description of the address.
|
* @return The description of the address.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return this.description;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromAddress(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (id ^ (id >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
Address that = Address.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.id, that.id);
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
Address other = (Address) obj;
|
protected ToStringHelper string() {
|
||||||
if (id != other.id)
|
return Objects.toStringHelper(this)
|
||||||
return false;
|
.add("id", id).add("country", country).add("state", state).add("description", description);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + id + ", country=" + country + ", state=" + state + ", description=" + description + "]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,161 +20,186 @@ package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class Datacenter
|
||||||
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Location_Datacenter"
|
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Location_Datacenter"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class Datacenter implements Comparable<Datacenter> {
|
public class Datacenter {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int id = -1;
|
return new ConcreteBuilder().fromDatacenter(this);
|
||||||
private String name;
|
}
|
||||||
private String longName;
|
|
||||||
private Address locationAddress;
|
|
||||||
private Set<Region> regions = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
public Builder id(int id) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int id;
|
||||||
|
protected String name;
|
||||||
|
protected String longName;
|
||||||
|
protected Address locationAddress;
|
||||||
|
protected Set<Region> regions = ImmutableSet.of();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Datacenter#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(String name) {
|
/**
|
||||||
|
* @see Datacenter#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder longName(String longName) {
|
/**
|
||||||
|
* @see Datacenter#getLongName()
|
||||||
|
*/
|
||||||
|
public T longName(String longName) {
|
||||||
this.longName = longName;
|
this.longName = longName;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder locationAddress(Address locationAddress) {
|
/**
|
||||||
|
* @see Datacenter#getLocationAddress()
|
||||||
|
*/
|
||||||
|
public T locationAddress(Address locationAddress) {
|
||||||
this.locationAddress = locationAddress;
|
this.locationAddress = locationAddress;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder region(Region regions) {
|
/**
|
||||||
this.regions.add(checkNotNull(regions, "regions"));
|
* @see Datacenter#getRegions()
|
||||||
return this;
|
*/
|
||||||
|
public T regions(Set<Region> regions) {
|
||||||
|
this.regions = ImmutableSet.copyOf(checkNotNull(regions, "regions"));
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder regions(Iterable<Region> regions) {
|
public T regions(Region... in) {
|
||||||
this.regions = ImmutableSet.<Region> copyOf(checkNotNull(regions, "regions"));
|
return regions(ImmutableSet.copyOf(in));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Datacenter build() {
|
public Datacenter build() {
|
||||||
return new Datacenter(id, name, longName, locationAddress, regions);
|
return new Datacenter(id, name, longName, locationAddress, regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromDatacenter(Datacenter in) {
|
public T fromDatacenter(Datacenter in) {
|
||||||
return Datacenter.builder().id(in.getId()).name(in.getName())
|
return this
|
||||||
.longName(in.getLongName()).locationAddress(in.getLocationAddress())
|
.id(in.getId())
|
||||||
|
.name(in.getName())
|
||||||
|
.longName(in.getLongName())
|
||||||
|
.locationAddress(in.getLocationAddress())
|
||||||
.regions(in.getRegions());
|
.regions(in.getRegions());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private String name;
|
@Override
|
||||||
private String longName;
|
protected ConcreteBuilder self() {
|
||||||
private Address locationAddress;
|
return this;
|
||||||
private Set<Region> regions = Sets.newLinkedHashSet();
|
}
|
||||||
// for deserializer
|
|
||||||
Datacenter() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Datacenter(int id, String name, String longName, Address locationAddress, Iterable<Region> regions) {
|
private final int id;
|
||||||
|
private final String name;
|
||||||
|
private final String longName;
|
||||||
|
private final Address locationAddress;
|
||||||
|
private final Set<Region> regions;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "name", "longName", "locationAddress", "regions"
|
||||||
|
})
|
||||||
|
protected Datacenter(int id, @Nullable String name, @Nullable String longName, @Nullable Address locationAddress, @Nullable Set<Region> regions) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.longName = longName;
|
this.longName = longName;
|
||||||
this.locationAddress = locationAddress;
|
this.locationAddress = locationAddress;
|
||||||
this.regions = ImmutableSet.<Region> copyOf(checkNotNull(regions, "regions"));
|
this.regions = regions == null ? ImmutableSet.<Region>of() : ImmutableSet.copyOf(regions);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(Datacenter arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unique identifier of a specific location.
|
* @return The unique identifier of a specific location.
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A short location description.
|
* @return A short location description.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A longer location description.
|
* @return A longer location description.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getLongName() {
|
public String getLongName() {
|
||||||
return longName;
|
return this.longName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A location's physical address (optional).
|
* @return A location's physical address (optional).
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Address getLocationAddress() {
|
public Address getLocationAddress() {
|
||||||
return locationAddress;
|
return this.locationAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A location can be a member of 1 or more regions.
|
* A location can be a member of 1 or more regions.
|
||||||
* Sometimes the list of regions is empty, for example as a new Datacenter is being added.
|
* Sometimes the list of regions is empty, for example as a new Datacenter is being added.
|
||||||
* The list of regions usually contains one with keyName=FIRST_AVAILABLE which should be ignored.
|
* The list of regions usually contains one with keyName=FIRST_AVAILABLE which should be ignored.
|
||||||
|
*
|
||||||
* @return The regions to which a location belongs.
|
* @return The regions to which a location belongs.
|
||||||
*/
|
*/
|
||||||
public Set<Region> getRegions() {
|
public Set<Region> getRegions() {
|
||||||
return regions;
|
return this.regions;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromDatacenter(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (id ^ (id >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
Datacenter that = Datacenter.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.id, that.id);
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
Datacenter other = (Datacenter) obj;
|
protected ToStringHelper string() {
|
||||||
if (id != other.id)
|
return Objects.toStringHelper(this)
|
||||||
return false;
|
.add("id", id).add("name", name).add("longName", longName).add("locationAddress", locationAddress).add("regions", regions);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + id + ", country=" + name + ", state=" + longName + "], locationAddress=" + locationAddress + ", regions="+regions+"]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,118 +20,123 @@ package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends the SoftLayer_Software_Component data type to include operating system specific properties.
|
* Extends the SoftLayer_Software_Component data type to include operating system specific properties.
|
||||||
*
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Software_Component_OperatingSystem"
|
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Software_Component_OperatingSystem"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class OperatingSystem implements Comparable<OperatingSystem> {
|
public class OperatingSystem {
|
||||||
|
|
||||||
// There are other properties
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int id = -1;
|
return new ConcreteBuilder().fromOperatingSystem(this);
|
||||||
private Set<Password> passwords = Sets.newLinkedHashSet();
|
}
|
||||||
|
|
||||||
public Builder id(int id) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int id;
|
||||||
|
protected Set<Password> passwords = ImmutableSet.of();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see OperatingSystem#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder password(Password password) {
|
/**
|
||||||
this.passwords.add(checkNotNull(password, "password"));
|
* @see OperatingSystem#getPasswords()
|
||||||
return this;
|
*/
|
||||||
|
public T passwords(Set<Password> passwords) {
|
||||||
|
this.passwords = ImmutableSet.copyOf(checkNotNull(passwords, "passwords"));
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder passwords(Iterable<Password> passwords) {
|
public T passwords(Password... in) {
|
||||||
this.passwords = ImmutableSet.<Password> copyOf(checkNotNull(passwords, "passwords"));
|
return passwords(ImmutableSet.copyOf(in));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperatingSystem build() {
|
public OperatingSystem build() {
|
||||||
return new OperatingSystem(id, passwords);
|
return new OperatingSystem(id, passwords);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromOperatingSystem(OperatingSystem in) {
|
public T fromOperatingSystem(OperatingSystem in) {
|
||||||
return OperatingSystem.builder()
|
return this
|
||||||
.id(in.getId())
|
.id(in.getId())
|
||||||
.passwords(in.getPasswords());
|
.passwords(in.getPasswords());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private Set<Password> passwords = Sets.newLinkedHashSet();
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
// for deserializer
|
return this;
|
||||||
OperatingSystem() {
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperatingSystem(int id,Iterable<Password> passwords) {
|
private final int id;
|
||||||
|
private final Set<Password> passwords;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "passwords"
|
||||||
|
})
|
||||||
|
protected OperatingSystem(int id, @Nullable Set<Password> passwords) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.passwords = ImmutableSet.<Password> copyOf(checkNotNull(passwords, "passwords"));
|
this.passwords = passwords == null ? ImmutableSet.<Password>of() : ImmutableSet.copyOf(passwords);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(OperatingSystem arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return An ID number identifying this Software Component (Software Installation)
|
* @return An ID number identifying this Software Component (Software Installation)
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return Username/Password pairs used for access to this Software Installation.
|
* @return Username/Password pairs used for access to this Software Installation.
|
||||||
*/
|
*/
|
||||||
public Set<Password> getPasswords() {
|
public Set<Password> getPasswords() {
|
||||||
return passwords;
|
return this.passwords;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromOperatingSystem(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (id ^ (id >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
OperatingSystem that = OperatingSystem.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.id, that.id);
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
OperatingSystem other = (OperatingSystem) obj;
|
protected ToStringHelper string() {
|
||||||
if (id != other.id)
|
return Objects.toStringHelper(this)
|
||||||
return false;
|
.add("id", id).add("passwords", passwords);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + id + ", passwords=" + passwords + "]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -21,121 +21,134 @@ package org.jclouds.softlayer.domain;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Strings.emptyToNull;
|
import static com.google.common.base.Strings.emptyToNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Contains a password for a specific software component instance
|
* Contains a password for a specific software component instance
|
||||||
*
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Software_Component_Password"
|
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Software_Component_Password"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class Password implements Comparable<Password> {
|
public class Password {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int id = -1;
|
return new ConcreteBuilder().fromPassword(this);
|
||||||
private String username;
|
}
|
||||||
private String password;
|
|
||||||
|
|
||||||
public Builder id(int id) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int id;
|
||||||
|
protected String username;
|
||||||
|
protected String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Password#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder username(String username) {
|
/**
|
||||||
|
* @see Password#getUsername()
|
||||||
|
*/
|
||||||
|
public T username(String username) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder password(String password) {
|
/**
|
||||||
|
* @see Password#getPassword()
|
||||||
|
*/
|
||||||
|
public T password(String password) {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Password build() {
|
public Password build() {
|
||||||
return new Password(id, username, password);
|
return new Password(id, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromPassword(Password in) {
|
public T fromPassword(Password in) {
|
||||||
return Password.builder().id(in.getId())
|
return this
|
||||||
.username(in.getUsername())
|
.id(in.getId())
|
||||||
.password(in.getPassword());
|
.username(in.getUsername())
|
||||||
|
.password(in.getPassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private String username;
|
@Override
|
||||||
private String password;
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
// for deserializer
|
}
|
||||||
Password() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Password(int id, String username, String password) {
|
private final int id;
|
||||||
|
private final String username;
|
||||||
|
private final String password;
|
||||||
|
|
||||||
|
@ConstructorProperties({"id", "username", "password"})
|
||||||
|
public Password(int id, String username, @Nullable String password) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = checkNotNull(emptyToNull(username),"username cannot be null or empty:"+username);
|
this.username = checkNotNull(emptyToNull(username),"username cannot be null or empty:"+username);
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(Password arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return An id number for this specific username/password pair.
|
* @return An id number for this specific username/password pair.
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The username part of the username/password pair.
|
* @return The username part of the username/password pair.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return this.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The password part of the username/password pair.
|
* @return The password part of the username/password pair.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return this.password;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromPassword(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (id ^ (id >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
Password that = Password.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.id, that.id);
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
Password other = (Password) obj;
|
protected ToStringHelper string() {
|
||||||
if (id != other.id)
|
return Objects.toStringHelper(this)
|
||||||
return false;
|
.add("id", id).add("username", username).add("password", password);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Password [id=" + id + ", username=" + username + ", password=**********]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,83 +20,98 @@ package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The power state class provides a common set of values for which a guest's power state will be presented in the SoftLayer API.
|
* The power state class provides a common set of values for which a guest's power state will be presented in the SoftLayer API.
|
||||||
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Power_State"
|
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Power_State"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class PowerState implements Comparable<PowerState> {
|
public class PowerState {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private VirtualGuest.State keyName;
|
return new ConcreteBuilder().fromPowerState(this);
|
||||||
|
}
|
||||||
|
|
||||||
public Builder keyName(VirtualGuest.State keyName) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected VirtualGuest.State keyName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see PowerState#getKeyName()
|
||||||
|
*/
|
||||||
|
public T keyName(VirtualGuest.State keyName) {
|
||||||
this.keyName = keyName;
|
this.keyName = keyName;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PowerState build() {
|
public PowerState build() {
|
||||||
return new PowerState(keyName);
|
return new PowerState(keyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromAddress(PowerState in) {
|
public T fromPowerState(PowerState in) {
|
||||||
return PowerState.builder().keyName(in.getKeyName());
|
return this
|
||||||
|
.keyName(in.getKeyName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private VirtualGuest.State keyName;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
// for deserializer
|
protected ConcreteBuilder self() {
|
||||||
PowerState() {
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final VirtualGuest.State keyName;
|
||||||
|
|
||||||
|
@ConstructorProperties("keyName")
|
||||||
public PowerState(VirtualGuest.State keyName) {
|
public PowerState(VirtualGuest.State keyName) {
|
||||||
this.keyName = checkNotNull(keyName,"keyName cannot be null or empty:"+keyName);
|
this.keyName = checkNotNull(keyName,"keyName cannot be null or empty:"+keyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(PowerState arg0) {
|
|
||||||
return keyName.compareTo(arg0.keyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps onto {@code VirtualGuest.State}
|
* Maps onto {@code VirtualGuest.State}
|
||||||
* @return The key name of a power state.
|
|
||||||
*
|
*
|
||||||
|
* @return The key name of a power state.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public VirtualGuest.State getKeyName() {
|
public VirtualGuest.State getKeyName() {
|
||||||
return keyName;
|
return this.keyName;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromAddress(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
PowerState that = (PowerState) o;
|
|
||||||
if (keyName != null ? !keyName.equals(that.keyName) : that.keyName != null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return keyName != null ? keyName.hashCode() : 0;
|
return Objects.hashCode(keyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
PowerState that = PowerState.class.cast(obj);
|
||||||
|
return Objects.equal(this.keyName, that.keyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("keyName", keyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[keyName=" + keyName + "]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,131 +20,154 @@ package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SoftLayer_Product_Item data type contains general information relating to
|
* The SoftLayer_Product_Item data type contains general information relating to
|
||||||
* a single SoftLayer product.
|
* a single SoftLayer product.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item"
|
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class ProductItem implements Comparable<ProductItem> {
|
public class ProductItem {
|
||||||
|
|
||||||
// TODO there are more elements than this.
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int id = -1;
|
return new ConcreteBuilder().fromProductItem(this);
|
||||||
private String description;
|
}
|
||||||
private String units;
|
|
||||||
private Float capacity;
|
|
||||||
private Set<ProductItemPrice> prices = Sets.newLinkedHashSet();
|
|
||||||
private Set<ProductItemCategory> categories = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
public Builder id(int id) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int id;
|
||||||
|
protected String description;
|
||||||
|
protected String units;
|
||||||
|
protected Float capacity;
|
||||||
|
protected Set<ProductItemPrice> prices = ImmutableSet.of();
|
||||||
|
protected Set<ProductItemCategory> categories = ImmutableSet.of();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductItem#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder description(String description) {
|
/**
|
||||||
|
* @see ProductItem#getDescription()
|
||||||
|
*/
|
||||||
|
public T description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder units(String units) {
|
/**
|
||||||
|
* @see ProductItem#getUnits()
|
||||||
|
*/
|
||||||
|
public T units(String units) {
|
||||||
this.units = units;
|
this.units = units;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder capacity(Float capacity) {
|
/**
|
||||||
|
* @see ProductItem#getCapacity()
|
||||||
|
*/
|
||||||
|
public T capacity(Float capacity) {
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder price(ProductItemPrice prices) {
|
/**
|
||||||
this.prices.add(checkNotNull(prices, "prices"));
|
* @see ProductItem#getPrices()
|
||||||
return this;
|
*/
|
||||||
|
public T prices(Set<ProductItemPrice> prices) {
|
||||||
|
this.prices = ImmutableSet.copyOf(checkNotNull(prices, "prices"));
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder prices(Iterable<ProductItemPrice> prices) {
|
public T prices(ProductItemPrice... in) {
|
||||||
this.prices = ImmutableSet.<ProductItemPrice> copyOf(checkNotNull(prices, "prices"));
|
return prices(ImmutableSet.copyOf(in));
|
||||||
return this;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductItem#getCategories()
|
||||||
|
*/
|
||||||
|
public T categories(Set<ProductItemCategory> categories) {
|
||||||
|
this.categories = ImmutableSet.copyOf(checkNotNull(categories, "categories"));
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder category(ProductItemCategory categories) {
|
public T categories(ProductItemCategory... in) {
|
||||||
this.categories.add(checkNotNull(categories, "categories"));
|
return categories(ImmutableSet.copyOf(in));
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder categories(Iterable<ProductItemCategory> categories) {
|
|
||||||
this.categories = ImmutableSet.<ProductItemCategory> copyOf(checkNotNull(categories, "categories"));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductItem build() {
|
public ProductItem build() {
|
||||||
return new ProductItem(id, description, units, capacity, prices, categories);
|
return new ProductItem(id, description, units, capacity, prices, categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromProductItem(ProductItem in) {
|
public T fromProductItem(ProductItem in) {
|
||||||
return ProductItem.builder().id(in.getId())
|
return this
|
||||||
.description(in.getDescription())
|
.id(in.getId())
|
||||||
.units(in.getUnits())
|
.description(in.getDescription())
|
||||||
.capacity(in.getCapacity())
|
.units(in.getUnits())
|
||||||
.prices(in.getPrices())
|
.capacity(in.getCapacity())
|
||||||
.categories(in.getCategories());
|
.prices(in.getPrices())
|
||||||
|
.categories(in.getCategories());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private String description;
|
@Override
|
||||||
private String units;
|
protected ConcreteBuilder self() {
|
||||||
private Float capacity;
|
return this;
|
||||||
private Set<ProductItemPrice> prices = Sets.newLinkedHashSet();
|
}
|
||||||
private Set<ProductItemCategory> categories = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
// for deserializer
|
|
||||||
ProductItem() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductItem(int id, String description, String units, Float capacity,
|
private final int id;
|
||||||
Iterable<ProductItemPrice> prices, Iterable<ProductItemCategory> categories) {
|
private final String description;
|
||||||
|
private final String units;
|
||||||
|
private final Float capacity;
|
||||||
|
private final Set<ProductItemPrice> prices;
|
||||||
|
private final Set<ProductItemCategory> categories;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "description", "units", "capacity", "prices", "categories"
|
||||||
|
})
|
||||||
|
protected ProductItem(int id, @Nullable String description, @Nullable String units, @Nullable Float capacity, @Nullable Set<ProductItemPrice> prices, @Nullable Set<ProductItemCategory> categories) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.units = units;
|
this.units = units;
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
this.prices = ImmutableSet.<ProductItemPrice> copyOf(checkNotNull(prices, "prices"));
|
this.prices = prices == null ? ImmutableSet.<ProductItemPrice>of() : ImmutableSet.copyOf(prices);
|
||||||
this.categories = ImmutableSet.<ProductItemCategory> copyOf(checkNotNull(categories, "categories"));
|
this.categories = categories == null ? ImmutableSet.<ProductItemCategory>of() : ImmutableSet.copyOf(categories);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ProductItem arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unique identifier of a specific location.
|
* @return The unique identifier of a specific location.
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A product's description
|
* @return A product's description
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,64 +175,54 @@ public class ProductItem implements Comparable<ProductItem> {
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getUnits() {
|
public String getUnits() {
|
||||||
return units;
|
return this.units;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Some Product Items have capacity information such as RAM and
|
* @return Some Product Items have capacity information such as RAM and
|
||||||
* bandwidth, and others. This provides the numerical representation
|
bandwidth, and others. This provides the numerical representation
|
||||||
* of the capacity given in the description of this product item.
|
of the capacity given in the description of this product item.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Float getCapacity() {
|
public Float getCapacity() {
|
||||||
return capacity;
|
return this.capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return A product item's prices.
|
* @return A product item's prices.
|
||||||
*/
|
*/
|
||||||
public Set<ProductItemPrice> getPrices() {
|
public Set<ProductItemPrice> getPrices() {
|
||||||
return prices;
|
return this.prices;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return An item's associated item categories.
|
* @return An item's associated item categories.
|
||||||
*/
|
*/
|
||||||
public Set<ProductItemCategory> getCategories() {
|
public Set<ProductItemCategory> getCategories() {
|
||||||
return categories;
|
return this.categories;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromProductItem(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (id ^ (id >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
ProductItem that = ProductItem.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.id, that.id);
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
ProductItem other = (ProductItem) obj;
|
protected ToStringHelper string() {
|
||||||
if (id != other.id)
|
return Objects.toStringHelper(this)
|
||||||
return false;
|
.add("id", id).add("description", description).add("units", units).add("capacity", capacity).add("prices", prices).add("categories", categories);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ProductItem [id=" + id + ", description=" + description + ", units=" + units + ", capacity=" + capacity
|
return string().toString();
|
||||||
+ ", prices=" + prices + ", categories=" + categories + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,123 +18,139 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.softlayer.domain;
|
package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SoftLayer_Product_Item_Category data type contains
|
* The SoftLayer_Product_Item_Category data type contains
|
||||||
* general category information for prices.
|
* general category information for prices.
|
||||||
*
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Category"
|
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Category"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class ProductItemCategory implements Comparable<ProductItemCategory> {
|
public class ProductItemCategory {
|
||||||
|
|
||||||
// TODO there are more elements than this.
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int id = -1;
|
return new ConcreteBuilder().fromProductItemCategory(this);
|
||||||
private String name;
|
}
|
||||||
private String categoryCode;
|
|
||||||
|
|
||||||
public Builder id(int id) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int id;
|
||||||
|
protected String name;
|
||||||
|
protected String categoryCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductItemCategory#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(String name) {
|
/**
|
||||||
|
* @see ProductItemCategory#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder categoryCode(String categoryCode) {
|
/**
|
||||||
|
* @see ProductItemCategory#getCategoryCode()
|
||||||
|
*/
|
||||||
|
public T categoryCode(String categoryCode) {
|
||||||
this.categoryCode = categoryCode;
|
this.categoryCode = categoryCode;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductItemCategory build() {
|
public ProductItemCategory build() {
|
||||||
return new ProductItemCategory(id, name, categoryCode);
|
return new ProductItemCategory(id, name, categoryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromProductItemCategory(ProductItemCategory in) {
|
public T fromProductItemCategory(ProductItemCategory in) {
|
||||||
return ProductItemCategory.builder().id(in.getId())
|
return this
|
||||||
.name(in.getName())
|
.id(in.getId())
|
||||||
.categoryCode(in.getCategoryCode());
|
.name(in.getName())
|
||||||
|
.categoryCode(in.getCategoryCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private String name;
|
@Override
|
||||||
private String categoryCode;
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
// for deserializer
|
}
|
||||||
ProductItemCategory() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductItemCategory(int id, String name, String categoryCode) {
|
private final int id;
|
||||||
|
private final String name;
|
||||||
|
private final String categoryCode;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "name", "categoryCode"
|
||||||
|
})
|
||||||
|
protected ProductItemCategory(int id, @Nullable String name, @Nullable String categoryCode) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.categoryCode = categoryCode;
|
this.categoryCode = categoryCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ProductItemCategory arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unique identifier of a specific location.
|
* @return The unique identifier of a specific location.
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The friendly, descriptive name of the category as seen on the order forms and on invoices.
|
* @return The friendly, descriptive name of the category as seen on the order forms and on invoices.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The code used to identify this category.
|
* @return The code used to identify this category.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getCategoryCode() {
|
public String getCategoryCode() {
|
||||||
return categoryCode;
|
return this.categoryCode;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromProductItemCategory(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (id ^ (id >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
ProductItemCategory that = ProductItemCategory.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.id, that.id);
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
ProductItemCategory other = (ProductItemCategory) obj;
|
protected ToStringHelper string() {
|
||||||
if (id != other.id)
|
return Objects.toStringHelper(this)
|
||||||
return false;
|
.add("id", id).add("name", name).add("categoryCode", categoryCode);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ProductItemCategory [id=" + id + ", name=" + name + ", categoryCode=" + categoryCode + "]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,183 +20,209 @@ package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SoftLayer_Product_Item_Price data type contains general information
|
* The SoftLayer_Product_Item_Price data type contains general information
|
||||||
* relating to a single SoftLayer product item price. You can find out what
|
* relating to a single SoftLayer product item prices. You can find out what
|
||||||
* packages each price is in as well as which category under which this price is
|
* packages each prices is in as well as which category under which this prices is
|
||||||
* sold. All prices are returned in Floating point values measured in US Dollars
|
* sold. All prices are returned in Floating point values measured in US Dollars
|
||||||
* ($USD).
|
* ($USD).
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price"
|
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class ProductItemPrice implements Comparable<ProductItemPrice> {
|
public class ProductItemPrice {
|
||||||
// TODO there are more elements than this.
|
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder<?> builder() {
|
||||||
return new Builder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int id = -1;
|
return new ConcreteBuilder().fromProductItemPrice(this);
|
||||||
private long itemId = -1;
|
}
|
||||||
private Float recurringFee;
|
|
||||||
private Float hourlyRecurringFee;
|
|
||||||
private ProductItem item;
|
|
||||||
private Set<ProductItemCategory> categories = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
public Builder id(int id) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int id;
|
||||||
|
protected long itemId;
|
||||||
|
protected Float recurringFee;
|
||||||
|
protected Float hourlyRecurringFee;
|
||||||
|
protected ProductItem item;
|
||||||
|
protected Set<ProductItemCategory> categories = ImmutableSet.of();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductItemPrice#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder itemId(long itemId) {
|
/**
|
||||||
|
* @see ProductItemPrice#getItemId()
|
||||||
|
*/
|
||||||
|
public T itemId(long itemId) {
|
||||||
this.itemId = itemId;
|
this.itemId = itemId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder recurringFee(Float recurringFee) {
|
/**
|
||||||
|
* @see ProductItemPrice#getRecurringFee()
|
||||||
|
*/
|
||||||
|
public T recurringFee(Float recurringFee) {
|
||||||
this.recurringFee = recurringFee;
|
this.recurringFee = recurringFee;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder hourlyRecurringFee(Float hourlyRecurringFee) {
|
/**
|
||||||
|
* @see ProductItemPrice#getHourlyRecurringFee()
|
||||||
|
*/
|
||||||
|
public T hourlyRecurringFee(Float hourlyRecurringFee) {
|
||||||
this.hourlyRecurringFee = hourlyRecurringFee;
|
this.hourlyRecurringFee = hourlyRecurringFee;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder item(ProductItem item) {
|
/**
|
||||||
|
* @see ProductItemPrice#getItem()
|
||||||
|
*/
|
||||||
|
public T item(ProductItem item) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder category(ProductItemCategory categories) {
|
/**
|
||||||
this.categories.add(checkNotNull(categories, "categories"));
|
* @see ProductItemPrice#getCategories()
|
||||||
return this;
|
*/
|
||||||
|
public T categories(Set<ProductItemCategory> categories) {
|
||||||
|
this.categories = ImmutableSet.copyOf(checkNotNull(categories, "categories"));
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder categories(Iterable<ProductItemCategory> categories) {
|
public T categories(ProductItemCategory... in) {
|
||||||
this.categories = ImmutableSet.<ProductItemCategory> copyOf(checkNotNull(categories, "categories"));
|
return categories(ImmutableSet.copyOf(in));
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductItemPrice build() {
|
public ProductItemPrice build() {
|
||||||
return new ProductItemPrice(id, itemId, recurringFee, hourlyRecurringFee, item, categories);
|
return new ProductItemPrice(id, itemId, recurringFee, hourlyRecurringFee, item, categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromPrice(ProductItemPrice in) {
|
public T fromProductItemPrice(ProductItemPrice in) {
|
||||||
return ProductItemPrice.builder().id(in.getId()).itemId(in.getItemId())
|
return this
|
||||||
.hourlyRecurringFee(in.getHourlyRecurringFee()).recurringFee(in.getRecurringFee());
|
.id(in.getId())
|
||||||
|
.itemId(in.getItemId())
|
||||||
|
.recurringFee(in.getRecurringFee())
|
||||||
|
.hourlyRecurringFee(in.getHourlyRecurringFee())
|
||||||
|
.item(in.getItem())
|
||||||
|
.categories(in.getCategories());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private long itemId = -1;
|
@Override
|
||||||
private Float recurringFee;
|
protected ConcreteBuilder self() {
|
||||||
private Float hourlyRecurringFee;
|
return this;
|
||||||
private ProductItem item;
|
}
|
||||||
private Set<ProductItemCategory> categories = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
// for deserializer
|
|
||||||
ProductItemPrice() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductItemPrice(int id, long itemId, Float recurringFee, Float hourlyRecurringFee, ProductItem item, Iterable<ProductItemCategory> categories) {
|
private final int id;
|
||||||
|
private final long itemId;
|
||||||
|
private final Float recurringFee;
|
||||||
|
private final Float hourlyRecurringFee;
|
||||||
|
private final ProductItem item;
|
||||||
|
private final Set<ProductItemCategory> categories;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "itemId", "recurringFee", "hourlyRecurringFee", "item", "categories"
|
||||||
|
})
|
||||||
|
protected ProductItemPrice(int id, long itemId, @Nullable Float recurringFee, @Nullable Float hourlyRecurringFee, @Nullable ProductItem item, @Nullable Set<ProductItemCategory> categories) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.itemId = itemId;
|
this.itemId = itemId;
|
||||||
this.recurringFee = recurringFee;
|
this.recurringFee = recurringFee;
|
||||||
this.hourlyRecurringFee = hourlyRecurringFee;
|
this.hourlyRecurringFee = hourlyRecurringFee;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.categories = ImmutableSet.<ProductItemCategory> copyOf(checkNotNull(categories, "categories"));
|
this.categories = categories == null ? ImmutableSet.<ProductItemCategory>of() : ImmutableSet.copyOf(categories);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ProductItemPrice arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unique identifier of a Product Item Price.
|
* @return The unique identifier of a Product Item Price.
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unique identifier for a product Item
|
* @return The unique identifier for a product Item
|
||||||
*/
|
*/
|
||||||
public long getItemId() {
|
public long getItemId() {
|
||||||
return itemId;
|
return this.itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A recurring fee is a fee that happens every billing period. This
|
* @return A recurring fee is a fee that happens every billing period. This
|
||||||
* fee is represented as a Floating point decimal in US dollars
|
fee is represented as a Floating point decimal in US dollars
|
||||||
* ($USD).
|
($USD).
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Float getRecurringFee() {
|
public Float getRecurringFee() {
|
||||||
return recurringFee;
|
return this.recurringFee;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The hourly price for this item, should this item be part of an
|
* @return The hourly prices for this item, should this item be part of an
|
||||||
* hourly pricing package.
|
hourly pricing package.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Float getHourlyRecurringFee() {
|
public Float getHourlyRecurringFee() {
|
||||||
return hourlyRecurringFee;
|
return this.hourlyRecurringFee;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The product item a prices is tied to.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public ProductItem getItem() {
|
||||||
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return An item's associated item categories.
|
* @return An item's associated item categories.
|
||||||
*/
|
*/
|
||||||
public Set<ProductItemCategory> getCategories() {
|
public Set<ProductItemCategory> getCategories() {
|
||||||
return categories;
|
return this.categories;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The product item a price is tied to.
|
|
||||||
*/
|
|
||||||
public ProductItem getItem() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromPrice(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[id=" + id + ", itemId=" + itemId + ", recurringFee=" + recurringFee + ", hourlyRecurringFee="
|
|
||||||
+ hourlyRecurringFee + ", item="+item+", categories="+categories+"]";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
ProductItemPrice that = (ProductItemPrice) o;
|
|
||||||
|
|
||||||
if (id != that.id) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return (id ^ (id >>> 32));
|
return Objects.hashCode(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
ProductItemPrice that = ProductItemPrice.class.cast(obj);
|
||||||
|
return Objects.equal(this.id, that.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id).add("itemId", itemId).add("recurringFee", recurringFee).add("hourlyRecurringFee", hourlyRecurringFee).add("item", item).add("categories", categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return string().toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,118 +20,135 @@ package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class ProductOrder
|
||||||
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest"
|
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class ProductOrder {
|
public class ProductOrder {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int packageId = -1;
|
return new ConcreteBuilder().fromProductOrder(this);
|
||||||
private Set<ProductItemPrice> prices = Sets.newLinkedHashSet();
|
}
|
||||||
private Set<VirtualGuest> virtualGuests = Sets.newLinkedHashSet();
|
|
||||||
private String location;
|
|
||||||
private int quantity;
|
|
||||||
private boolean useHourlyPricing;
|
|
||||||
|
|
||||||
public Builder packageId(int packageId) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int packageId;
|
||||||
|
protected String location;
|
||||||
|
protected Set<ProductItemPrice> prices = ImmutableSet.of();
|
||||||
|
protected Set<VirtualGuest> virtualGuests = ImmutableSet.of();
|
||||||
|
protected int quantity;
|
||||||
|
protected boolean useHourlyPricing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductOrder#getPackageId()
|
||||||
|
*/
|
||||||
|
public T packageId(int packageId) {
|
||||||
this.packageId = packageId;
|
this.packageId = packageId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a price to the order
|
* @see ProductOrder#getLocation()
|
||||||
* All that is required to send in is the price ID of each item desired to be ordered.
|
|
||||||
* @param prices
|
|
||||||
* The Prices of the item desired to be ordered
|
|
||||||
*/
|
*/
|
||||||
public Builder price(ProductItemPrice prices) {
|
public T location(String location) {
|
||||||
this.prices.add(checkNotNull(prices, "prices"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds multiple prices to the order, overwriting any existing ones
|
|
||||||
* All that is required to send in is the price ID of each item desired to be ordered.
|
|
||||||
* @param prices
|
|
||||||
* The Prices of the items desired to be ordered
|
|
||||||
*/
|
|
||||||
public Builder prices(Iterable<ProductItemPrice> prices) {
|
|
||||||
this.prices = ImmutableSet.<ProductItemPrice> copyOf(checkNotNull(prices, "prices"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a virtualGuest to the order
|
|
||||||
* @param virtualGuest
|
|
||||||
* The virtualGuest to add. Needs domain and hostname.
|
|
||||||
*/
|
|
||||||
public Builder virtualGuest(VirtualGuest virtualGuest) {
|
|
||||||
this.virtualGuests.add(checkNotNull(virtualGuest, "virtualGuest"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder virtualGuests(Iterable<VirtualGuest> virtualGuests) {
|
|
||||||
this.virtualGuests = ImmutableSet.<VirtualGuest> copyOf(checkNotNull(virtualGuests, "virtualGuests"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder location(String location) {
|
|
||||||
this.location = location;
|
this.location = location;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder quantity(int quantity) {
|
/**
|
||||||
|
* @see ProductOrder#getPrices()
|
||||||
|
*/
|
||||||
|
public T prices(Iterable<ProductItemPrice> prices) {
|
||||||
|
this.prices = ImmutableSet.copyOf(checkNotNull(prices, "prices"));
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T prices(ProductItemPrice... in) {
|
||||||
|
return prices(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductOrder#getVirtualGuests()
|
||||||
|
*/
|
||||||
|
public T virtualGuests(Set<VirtualGuest> virtualGuests) {
|
||||||
|
this.virtualGuests = ImmutableSet.copyOf(checkNotNull(virtualGuests, "virtualGuests"));
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T virtualGuests(VirtualGuest... in) {
|
||||||
|
return virtualGuests(ImmutableSet.copyOf(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductOrder#getQuantity()
|
||||||
|
*/
|
||||||
|
public T quantity(int quantity) {
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder useHourlyPricing(Boolean useHourlyPricing) {
|
/**
|
||||||
|
* @see ProductOrder#getUseHourlyPricing()
|
||||||
|
*/
|
||||||
|
public T useHourlyPricing(boolean useHourlyPricing) {
|
||||||
this.useHourlyPricing = useHourlyPricing;
|
this.useHourlyPricing = useHourlyPricing;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductOrder build() {
|
public ProductOrder build() {
|
||||||
return new ProductOrder(packageId, location,prices, virtualGuests, quantity, useHourlyPricing);
|
return new ProductOrder(packageId, location, prices, virtualGuests, quantity, useHourlyPricing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromProductOrder(ProductOrder in) {
|
public T fromProductOrder(ProductOrder in) {
|
||||||
return ProductOrder.builder().packageId(in.getPackageId())
|
return this
|
||||||
.location(in.getLocation())
|
.packageId(in.getPackageId())
|
||||||
.prices(in.getPrices())
|
.location(in.getLocation())
|
||||||
.virtualGuests(in.getVirtualGuests())
|
.prices(in.getPrices())
|
||||||
.quantity(in.getQuantity())
|
.virtualGuests(in.getVirtualGuests())
|
||||||
.useHourlyPricing(in.getUseHourlyPricing());
|
.quantity(in.getQuantity())
|
||||||
|
.useHourlyPricing(in.getUseHourlyPricing());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int packageId = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private String location;
|
@Override
|
||||||
private Set<ProductItemPrice> prices = Sets.newLinkedHashSet();
|
protected ConcreteBuilder self() {
|
||||||
private Set<VirtualGuest> virtualGuests = Sets.newLinkedHashSet();
|
return this;
|
||||||
private int quantity;
|
}
|
||||||
private boolean useHourlyPricing;
|
|
||||||
|
|
||||||
// for deserializer
|
|
||||||
ProductOrder() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductOrder(int packageId, String location, Iterable<ProductItemPrice> prices, Iterable<VirtualGuest> virtualGuest, int quantity, boolean useHourlyPricing) {
|
private final int packageId;
|
||||||
|
private final String location;
|
||||||
|
private final Set<ProductItemPrice> prices;
|
||||||
|
private final Set<VirtualGuest> virtualGuests;
|
||||||
|
private final int quantity;
|
||||||
|
private final boolean useHourlyPricing;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"packageId", "location", "prices", "virtualGuest", "quantity", "useHourlyPricing"
|
||||||
|
})
|
||||||
|
protected ProductOrder(int packageId, @Nullable String location, @Nullable Set<ProductItemPrice> prices, @Nullable Set<VirtualGuest> virtualGuests, int quantity, boolean useHourlyPricing) {
|
||||||
this.packageId = packageId;
|
this.packageId = packageId;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.prices = ImmutableSet.<ProductItemPrice> copyOf(checkNotNull(prices, "prices"));
|
this.prices = prices == null ? ImmutableSet.<ProductItemPrice>of() : ImmutableSet.copyOf(prices);
|
||||||
this.virtualGuests = ImmutableSet.<VirtualGuest> copyOf(checkNotNull(virtualGuest, "virtualGuest"));
|
this.virtualGuests = virtualGuests == null ? ImmutableSet.<VirtualGuest>of() : ImmutableSet.copyOf(virtualGuests);
|
||||||
this.quantity = quantity;
|
this.quantity = quantity;
|
||||||
this.useHourlyPricing = useHourlyPricing;
|
this.useHourlyPricing = useHourlyPricing;
|
||||||
}
|
}
|
||||||
|
@ -140,79 +157,70 @@ public class ProductOrder {
|
||||||
* @return The package id of an order. This is required.
|
* @return The package id of an order. This is required.
|
||||||
*/
|
*/
|
||||||
public int getPackageId() {
|
public int getPackageId() {
|
||||||
return packageId;
|
return this.packageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The region keyname or specific location keyname where the order should be provisioned.
|
* @return The region keyname or specific location keyname where the order should be provisioned.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getLocation() {
|
public String getLocation() {
|
||||||
return location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item prices in this order.
|
* Gets the item prices in this order.
|
||||||
* All that is required to be present is the price ID
|
* All that is required to be present is the prices ID
|
||||||
|
*
|
||||||
* @return the prices.
|
* @return the prices.
|
||||||
*/
|
*/
|
||||||
public Set<ProductItemPrice> getPrices() {
|
public Set<ProductItemPrice> getPrices() {
|
||||||
return prices;
|
return this.prices;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the virtual guests in this order.
|
* Gets the virtual guests in this order.
|
||||||
|
*
|
||||||
* @return the the virtual guests.
|
* @return the the virtual guests.
|
||||||
*/
|
*/
|
||||||
public Set<VirtualGuest> getVirtualGuests() {
|
public Set<VirtualGuest> getVirtualGuests() {
|
||||||
return virtualGuests;
|
return this.virtualGuests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getQuantity() {
|
public int getQuantity() {
|
||||||
return quantity;
|
return this.quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getUseHourlyPricing() {
|
public boolean getUseHourlyPricing() {
|
||||||
return useHourlyPricing;
|
return this.useHourlyPricing;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromProductOrder(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
ProductOrder that = (ProductOrder) o;
|
|
||||||
|
|
||||||
if (packageId != that.packageId) return false;
|
|
||||||
if (quantity != that.quantity) return false;
|
|
||||||
if (useHourlyPricing != that.useHourlyPricing) return false;
|
|
||||||
if (location != null ? !location.equals(that.location) : that.location != null)
|
|
||||||
return false;
|
|
||||||
if (prices != null ? !prices.equals(that.prices) : that.prices != null)
|
|
||||||
return false;
|
|
||||||
if (virtualGuests != null ? !virtualGuests.equals(that.virtualGuests) : that.virtualGuests != null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = (packageId ^ (packageId >>> 32));
|
return Objects.hashCode(packageId, location, prices, virtualGuests, quantity, useHourlyPricing);
|
||||||
result = 31 * result + (location != null ? location.hashCode() : 0);
|
|
||||||
result = 31 * result + (prices != null ? prices.hashCode() : 0);
|
|
||||||
result = 31 * result + (virtualGuests != null ? virtualGuests.hashCode() : 0);
|
|
||||||
result = 31 * result + (quantity ^ (quantity >>> 32));
|
|
||||||
result = 31 * result + (useHourlyPricing ? 1 : 0);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
ProductOrder that = ProductOrder.class.cast(obj);
|
||||||
|
return Objects.equal(this.packageId, that.packageId)
|
||||||
|
&& Objects.equal(this.location, that.location)
|
||||||
|
&& Objects.equal(this.prices, that.prices)
|
||||||
|
&& Objects.equal(this.virtualGuests, that.virtualGuests)
|
||||||
|
&& Objects.equal(this.quantity, that.quantity)
|
||||||
|
&& Objects.equal(this.useHourlyPricing, that.useHourlyPricing);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return Objects.toStringHelper(this)
|
||||||
|
.add("packageId", packageId).add("location", location).add("prices", prices).add("virtualGuests", virtualGuests).add("quantity", quantity).add("useHourlyPricing", useHourlyPricing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[packageId=" + packageId + ", location=" + location + ", prices=" + prices
|
return string().toString();
|
||||||
+ ", virtualGuests=" + virtualGuests +", quantity=" + quantity + ", useHourlyPricing=" + useHourlyPricing + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,63 +18,86 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.softlayer.domain;
|
package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class ProductOrderReceipt
|
||||||
|
*
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Receipt"
|
* @see <a href= "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Receipt"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class ProductOrderReceipt implements Comparable<ProductOrderReceipt> {
|
public class ProductOrderReceipt {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int orderId = -1;
|
return new ConcreteBuilder().fromProductOrderReceipt(this);
|
||||||
private ProductOrder orderDetails;
|
}
|
||||||
|
|
||||||
public Builder orderId(int orderId) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int orderId;
|
||||||
|
protected ProductOrder orderDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductOrderReceipt#getOrderId()
|
||||||
|
*/
|
||||||
|
public T orderId(int orderId) {
|
||||||
this.orderId = orderId;
|
this.orderId = orderId;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder orderDetails(ProductOrder orderDetails) {
|
/**
|
||||||
|
* @see ProductOrderReceipt#getOrderDetails()
|
||||||
|
*/
|
||||||
|
public T orderDetails(ProductOrder orderDetails) {
|
||||||
this.orderDetails = orderDetails;
|
this.orderDetails = orderDetails;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductOrderReceipt build() {
|
public ProductOrderReceipt build() {
|
||||||
return new ProductOrderReceipt(orderId,orderDetails);
|
return new ProductOrderReceipt(orderId, orderDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromAddress(ProductOrderReceipt in) {
|
public T fromProductOrderReceipt(ProductOrderReceipt in) {
|
||||||
return ProductOrderReceipt.builder().orderId(in.getOrderId()).orderDetails(in.getOrderDetails());
|
return this
|
||||||
|
.orderId(in.getOrderId())
|
||||||
|
.orderDetails(in.getOrderDetails());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int orderId = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private ProductOrder orderDetails;
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
// for deserializer
|
return this;
|
||||||
ProductOrderReceipt() {
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductOrderReceipt(int orderId,ProductOrder orderDetails) {
|
private final int orderId;
|
||||||
|
private final ProductOrder orderDetails;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"orderId", "orderDetails"
|
||||||
|
})
|
||||||
|
protected ProductOrderReceipt(int orderId, @Nullable ProductOrder orderDetails) {
|
||||||
this.orderId = orderId;
|
this.orderId = orderId;
|
||||||
this.orderDetails = orderDetails;
|
this.orderDetails = orderDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ProductOrderReceipt arg0) {
|
|
||||||
return Integer.valueOf(orderId).compareTo(arg0.getOrderId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return unique identifier for the order.
|
* @return unique identifier for the order.
|
||||||
*/
|
*/
|
||||||
public int getOrderId() {
|
public int getOrderId() {
|
||||||
return orderId;
|
return this.orderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,40 +106,33 @@ public class ProductOrderReceipt implements Comparable<ProductOrderReceipt> {
|
||||||
* This will only return when an order is processed successfully.
|
* This will only return when an order is processed successfully.
|
||||||
* It will contain all the items in an order as well as the order totals.
|
* It will contain all the items in an order as well as the order totals.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public ProductOrder getOrderDetails() {
|
public ProductOrder getOrderDetails() {
|
||||||
return orderDetails;
|
return this.orderDetails;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromAddress(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(orderId, orderDetails);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (orderId ^ (orderId >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
ProductOrderReceipt that = ProductOrderReceipt.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.orderId, that.orderId)
|
||||||
if (getClass() != obj.getClass())
|
&& Objects.equal(this.orderDetails, that.orderDetails);
|
||||||
return false;
|
}
|
||||||
ProductOrderReceipt other = (ProductOrderReceipt) obj;
|
|
||||||
if (orderId != other.orderId)
|
protected ToStringHelper string() {
|
||||||
return false;
|
return Objects.toStringHelper(this)
|
||||||
return true;
|
.add("orderId", orderId).add("orderDetails", orderDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[orderId=" + orderId + ", orderDetails="+orderDetails+"]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,10 +20,14 @@ package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SoftLayer_Product_Package data type contains information about packages
|
* The SoftLayer_Product_Package data type contains information about packages
|
||||||
|
@ -33,156 +37,174 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Package"
|
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Package"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class ProductPackage implements Comparable<ProductPackage> {
|
public class ProductPackage {
|
||||||
|
|
||||||
// TODO there are more elements than this.
|
public static Builder<?> builder() {
|
||||||
|
return new ConcreteBuilder();
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public Builder<?> toBuilder() {
|
||||||
private int id = -1;
|
return new ConcreteBuilder().fromProductPackage(this);
|
||||||
private String name;
|
}
|
||||||
private String description;
|
|
||||||
private Set<ProductItem> items = Sets.newLinkedHashSet();
|
|
||||||
private Set<Datacenter> datacenters = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
public Builder id(int id) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int id;
|
||||||
|
protected String name;
|
||||||
|
protected String description;
|
||||||
|
protected Set<ProductItem> items = ImmutableSet.of();
|
||||||
|
protected Set<Datacenter> locations = ImmutableSet.of();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductPackage#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder name(String name) {
|
/**
|
||||||
|
* @see ProductPackage#getName()
|
||||||
|
*/
|
||||||
|
public T name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder description(String description) {
|
/**
|
||||||
|
* @see ProductPackage#getDescription()
|
||||||
|
*/
|
||||||
|
public T description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder items(Iterable<ProductItem> items) {
|
/**
|
||||||
this.items = ImmutableSet.<ProductItem> copyOf(checkNotNull(items, "items"));
|
* @see ProductPackage#getItems()
|
||||||
return this;
|
*/
|
||||||
|
public T items(Set<ProductItem> items) {
|
||||||
|
this.items = ImmutableSet.copyOf(checkNotNull(items, "items"));
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder datacenters(Iterable<Datacenter> datacenters) {
|
public T items(ProductItem... in) {
|
||||||
this.datacenters = ImmutableSet.<Datacenter> copyOf(checkNotNull(datacenters, "datacenters"));
|
return items(ImmutableSet.copyOf(in));
|
||||||
return this;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ProductPackage#getDatacenters()
|
||||||
|
*/
|
||||||
|
public T datacenters(Set<Datacenter> locations) {
|
||||||
|
this.locations = ImmutableSet.copyOf(checkNotNull(locations, "locations"));
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T datacenters(Datacenter... in) {
|
||||||
|
return datacenters(ImmutableSet.copyOf(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductPackage build() {
|
public ProductPackage build() {
|
||||||
return new ProductPackage(id, name, description, items, datacenters);
|
return new ProductPackage(id, name, description, items, locations);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromProductPackage(ProductPackage in) {
|
public T fromProductPackage(ProductPackage in) {
|
||||||
return ProductPackage.builder().id(in.getId())
|
return this
|
||||||
.name(in.getName())
|
.id(in.getId())
|
||||||
.description(in.getDescription())
|
.name(in.getName())
|
||||||
.items(in.getItems())
|
.description(in.getDescription())
|
||||||
.datacenters(in.getDatacenters());
|
.items(in.getItems())
|
||||||
|
.datacenters(in.getDatacenters());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int id = -1;
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
private String name;
|
@Override
|
||||||
private String description;
|
protected ConcreteBuilder self() {
|
||||||
private Set<ProductItem> items = Sets.newLinkedHashSet();
|
return this;
|
||||||
private Set<Datacenter> locations = Sets.newLinkedHashSet();
|
}
|
||||||
|
|
||||||
// for deserializer
|
|
||||||
ProductPackage() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductPackage(int id, String name, String description, Iterable<ProductItem> items, Iterable<Datacenter> datacenters) {
|
private final int id;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
private final Set<ProductItem> items;
|
||||||
|
private final Set<Datacenter> locations;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"id", "name", "description", "items", "locations"
|
||||||
|
})
|
||||||
|
protected ProductPackage(int id, @Nullable String name, @Nullable String description, @Nullable Set<ProductItem> items, Set<Datacenter> locations) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.items = ImmutableSet.<ProductItem> copyOf(checkNotNull(items, "items"));
|
this.items = items == null ? ImmutableSet.<ProductItem>of() : ImmutableSet.copyOf(items);
|
||||||
this.locations = ImmutableSet.<Datacenter> copyOf(checkNotNull(datacenters, "datacenters"));
|
this.locations = locations == null ? ImmutableSet.<Datacenter>of() : ImmutableSet.copyOf(locations);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ProductPackage arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A package's internal identifier. Everything regarding a
|
* @return A package's internal identifier. Everything regarding a
|
||||||
* SoftLayer_Product_Package is tied back to this id.
|
SoftLayer_Product_Package is tied back to this id.
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The description of the package. For server packages, this is
|
* @return The description of the package. For server packages, this is
|
||||||
* usually a detailed description of processor type and count.
|
usually a detailed description of processor type and count.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A generic description of the processor type and count. This
|
* @return A generic description of the processor type and count. This
|
||||||
* includes HTML, so you may want to strip these tags if you plan to
|
includes HTML, so you may want to strip these tags if you plan to
|
||||||
* use it.
|
use it.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return this.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return A collection of valid items available for purchase in this
|
* @return A collection of valid items available for purchase in this
|
||||||
* package.
|
package.
|
||||||
*/
|
*/
|
||||||
public Set<ProductItem> getItems() {
|
public Set<ProductItem> getItems() {
|
||||||
return items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return A collection of valid locations for this package.
|
|
||||||
*/
|
|
||||||
public Set<Datacenter> getDatacenters() {
|
public Set<Datacenter> getDatacenters() {
|
||||||
return locations;
|
return this.locations;
|
||||||
}
|
|
||||||
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return Builder.fromProductPackage(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(id);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (id ^ (id >>> 32));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
ProductPackage that = ProductPackage.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.id, that.id);
|
||||||
if (getClass() != obj.getClass())
|
}
|
||||||
return false;
|
|
||||||
ProductPackage other = (ProductPackage) obj;
|
protected ToStringHelper string() {
|
||||||
if (id != other.id)
|
return Objects.toStringHelper(this)
|
||||||
return false;
|
.add("id", id).add("name", name).add("description", description).add("items", items).add("locations", locations);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ProductPackage [id=" + id + ", name=" + name + ", description=" + description + ", items=" + items + ", datacenters=" + locations + "]";
|
return string().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,12 @@ package org.jclouds.softlayer.domain;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Strings.emptyToNull;
|
import static com.google.common.base.Strings.emptyToNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A region is made up of a keyname and a description of that region.
|
* A region is made up of a keyname and a description of that region.
|
||||||
* A region keyname can be used as part of an order.
|
* A region keyname can be used as part of an order.
|
||||||
|
@ -50,28 +56,25 @@ public class Region implements Comparable<Region> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Region build() {
|
public Region build() {
|
||||||
return new Region(keyname, description);
|
return new Region(0, keyname, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromAddress(Region in) {
|
public static Builder fromAddress(Region in) {
|
||||||
return Region.builder().keyname(in.getKeyname())
|
return Region.builder().keyname(in.getKeyname())
|
||||||
.description(in.getDescription());
|
.description(in.getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An integer representing the order in which this element is displayed */
|
/* An integer representing the order in which this element is displayed */
|
||||||
private int sortOrder = 0;
|
private final int sortOrder;
|
||||||
private String keyname;
|
private final String keyname;
|
||||||
private String description;
|
private final String description;
|
||||||
|
|
||||||
// for deserializer
|
@ConstructorProperties({"sortOrder", "keyname", "description"})
|
||||||
Region() {
|
public Region(int sortOrder, String keyname, String description) {
|
||||||
|
this.sortOrder = sortOrder;
|
||||||
}
|
this.keyname = checkNotNull(emptyToNull(keyname), "keyname cannot be null or empty:" + keyname);
|
||||||
|
this.description = description;
|
||||||
public Region(String keyname, String description) {
|
|
||||||
this.keyname = checkNotNull(emptyToNull(keyname),"keyname cannot be null or empty:"+keyname);
|
|
||||||
this.description = checkNotNull(emptyToNull(description),"country cannot be null or empty:"+description);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,6 +92,7 @@ public class Region implements Comparable<Region> {
|
||||||
/**
|
/**
|
||||||
* @return A short description of a region's name. This description is seen on the order forms.
|
* @return A short description of a region's name. This description is seen on the order forms.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
@ -103,26 +107,19 @@ public class Region implements Comparable<Region> {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
Region region = (Region) o;
|
Region region = (Region) o;
|
||||||
|
return Objects.equal(keyname, region.keyname)
|
||||||
if (sortOrder != region.sortOrder) return false;
|
&& Objects.equal(description, region.description);
|
||||||
if (!description.equals(region.description)) return false;
|
|
||||||
if (!keyname.equals(region.keyname)) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = sortOrder;
|
return Objects.hashCode(keyname, description);
|
||||||
result = 31 * result + keyname.hashCode();
|
|
||||||
result = 31 * result + description.hashCode();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[keyname=" + keyname + ", description=" + description + "]";
|
return "[keyname=" + keyname + ", description=" + description + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,10 +20,14 @@ package org.jclouds.softlayer.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The virtual guest data type presents the structure in which all virtual guests will be presented.
|
* The virtual guest data type presents the structure in which all virtual guests will be presented.
|
||||||
|
@ -42,199 +46,13 @@ import com.google.gson.annotations.SerializedName;
|
||||||
* The domain portion must consist of least one label followed by a period '.' then ending with the TLD label.
|
* The domain portion must consist of least one label followed by a period '.' then ending with the TLD label.
|
||||||
* Combining the hostname, followed by a period '.', followed by the domain gives the FQDN (fully qualified domain name),
|
* Combining the hostname, followed by a period '.', followed by the domain gives the FQDN (fully qualified domain name),
|
||||||
* which may not exceed 253 characters in total length.
|
* which may not exceed 253 characters in total length.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @see <a href=
|
* @see <a href=
|
||||||
* "http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest"
|
"http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest"
|
||||||
* />
|
/>
|
||||||
*/
|
*/
|
||||||
public class VirtualGuest implements Comparable<VirtualGuest> {
|
public class VirtualGuest {
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
private int id = -1;
|
|
||||||
private int accountId = -1;
|
|
||||||
private Date createDate;
|
|
||||||
private boolean dedicatedAccountHostOnly;
|
|
||||||
private String hostname;
|
|
||||||
private String domain;
|
|
||||||
private String fullyQualifiedDomainName;
|
|
||||||
private Date lastVerifiedDate;
|
|
||||||
private int maxCpu = -1;
|
|
||||||
private String maxCpuUnits;
|
|
||||||
private int maxMemory = -1;
|
|
||||||
private Date metricPollDate;
|
|
||||||
private Date modifyDate;
|
|
||||||
private String notes;
|
|
||||||
private boolean privateNetworkOnly;
|
|
||||||
private int startCpus = -1;
|
|
||||||
private int statusId = -1;
|
|
||||||
private String uuid;
|
|
||||||
private String primaryBackendIpAddress;
|
|
||||||
private String primaryIpAddress;
|
|
||||||
private int billingItemId;
|
|
||||||
private OperatingSystem operatingSystem;
|
|
||||||
private Datacenter datacenter;
|
|
||||||
private PowerState powerState;
|
|
||||||
|
|
||||||
public Builder id(int id) {
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder accountId(int accountId) {
|
|
||||||
this.accountId = accountId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder createDate(Date createDate) {
|
|
||||||
this.createDate = createDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder dedicatedAccountHostOnly(boolean dedicatedAccountHostOnly) {
|
|
||||||
this.dedicatedAccountHostOnly = dedicatedAccountHostOnly;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder hostname(String hostname) {
|
|
||||||
this.hostname = hostname;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder domain(String domain) {
|
|
||||||
this.domain = domain;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder fullyQualifiedDomainName(String fullyQualifiedDomainName) {
|
|
||||||
this.fullyQualifiedDomainName = fullyQualifiedDomainName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder lastVerifiedDate(Date lastVerifiedDate) {
|
|
||||||
this.lastVerifiedDate = lastVerifiedDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder maxCpu(int maxCpu) {
|
|
||||||
this.maxCpu = maxCpu;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder maxCpuUnits(String maxCpuUnits) {
|
|
||||||
this.maxCpuUnits = maxCpuUnits;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder maxMemory(int maxMemory) {
|
|
||||||
this.maxMemory = maxMemory;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder metricPollDate(Date metricPollDate) {
|
|
||||||
this.metricPollDate = metricPollDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder modifyDate(Date modifyDate) {
|
|
||||||
this.modifyDate = modifyDate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder notes(String notes) {
|
|
||||||
this.notes = notes;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder privateNetworkOnly(boolean privateNetworkOnly) {
|
|
||||||
this.privateNetworkOnly = privateNetworkOnly;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder startCpus(int startCpus) {
|
|
||||||
this.startCpus = startCpus;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder statusId(int statusId) {
|
|
||||||
this.statusId = statusId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder uuid(String uuid) {
|
|
||||||
this.uuid = uuid;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder primaryBackendIpAddress(String primaryBackendIpAddress) {
|
|
||||||
this.primaryBackendIpAddress = primaryBackendIpAddress;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder primaryIpAddress(String primaryIpAddress) {
|
|
||||||
this.primaryIpAddress = primaryIpAddress;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder billingItemId(int billingItemId) {
|
|
||||||
this.billingItemId = billingItemId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder operatingSystem(OperatingSystem operatingSystem) {
|
|
||||||
this.operatingSystem = operatingSystem;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder datacenter(Datacenter datacenter) {
|
|
||||||
this.datacenter = datacenter;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder powerState(PowerState powerState) {
|
|
||||||
this.powerState = powerState;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualGuest build() {
|
|
||||||
return new VirtualGuest(accountId, createDate, dedicatedAccountHostOnly, domain,
|
|
||||||
fullyQualifiedDomainName, hostname, id, lastVerifiedDate, maxCpu,
|
|
||||||
maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes,
|
|
||||||
privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress,
|
|
||||||
primaryIpAddress, billingItemId,operatingSystem,datacenter,powerState);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Builder fromVirtualGuest(VirtualGuest in) {
|
|
||||||
return VirtualGuest.builder()
|
|
||||||
.accountId(in.getAccountId())
|
|
||||||
.createDate(in.getCreateDate())
|
|
||||||
.dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly())
|
|
||||||
.domain(in.getDomain())
|
|
||||||
.fullyQualifiedDomainName(in.getFullyQualifiedDomainName())
|
|
||||||
.hostname(in.getHostname())
|
|
||||||
.id(in.getId())
|
|
||||||
.lastVerifiedDate(in.getLastVerifiedDate())
|
|
||||||
.maxCpu(in.getMaxCpu())
|
|
||||||
.maxCpuUnits(in.getMaxCpuUnits())
|
|
||||||
.maxMemory(in.getMaxMemory())
|
|
||||||
.metricPollDate(in.getMetricPollDate())
|
|
||||||
.modifyDate(in.getModifyDate())
|
|
||||||
.notes(in.getNotes())
|
|
||||||
.privateNetworkOnly(in.isPrivateNetworkOnly())
|
|
||||||
.startCpus(in.getStartCpus())
|
|
||||||
.statusId(in.getStatusId())
|
|
||||||
.uuid(in.getUuid())
|
|
||||||
.primaryBackendIpAddress(in.getPrimaryBackendIpAddress())
|
|
||||||
.primaryIpAddress(in.getPrimaryIpAddress())
|
|
||||||
.billingItemId(in.getBillingItemId())
|
|
||||||
.operatingSystem(in.getOperatingSystem())
|
|
||||||
.datacenter(in.getDatacenter())
|
|
||||||
.powerState(in.getPowerState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These states come from the powerState field. i.e.
|
* These states come from the powerState field. i.e.
|
||||||
|
@ -260,44 +78,325 @@ public class VirtualGuest implements Comparable<VirtualGuest> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int accountId = -1;
|
public static class BillingItem {
|
||||||
private Date createDate;
|
private final int id;
|
||||||
@SerializedName("dedicatedAccountHostOnlyFlag")
|
|
||||||
private boolean dedicatedAccountHostOnly;
|
|
||||||
private String domain;
|
|
||||||
private String fullyQualifiedDomainName;
|
|
||||||
private String hostname;
|
|
||||||
private int id = -1;
|
|
||||||
private Date lastVerifiedDate;
|
|
||||||
private int maxCpu = -1;
|
|
||||||
private String maxCpuUnits;
|
|
||||||
private int maxMemory = -1;
|
|
||||||
private Date metricPollDate;
|
|
||||||
private Date modifyDate;
|
|
||||||
private String notes;
|
|
||||||
@SerializedName("privateNetworkOnlyFlag")
|
|
||||||
private boolean privateNetworkOnly;
|
|
||||||
private int startCpus = -1;
|
|
||||||
private int statusId = -1;
|
|
||||||
private String uuid;
|
|
||||||
private String primaryBackendIpAddress;
|
|
||||||
private String primaryIpAddress;
|
|
||||||
|
|
||||||
private int billingItemId = -1;
|
@ConstructorProperties("id")
|
||||||
private OperatingSystem operatingSystem;
|
public BillingItem(int id) {
|
||||||
private Datacenter datacenter;
|
this.id = id;
|
||||||
private PowerState powerState;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// for deserializer
|
public static Builder<?> builder() {
|
||||||
VirtualGuest() {
|
return new ConcreteBuilder();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualGuest(int accountId, Date createDate, boolean dedicatedAccountHostOnly, String domain,
|
public Builder<?> toBuilder() {
|
||||||
String fullyQualifiedDomainName, String hostname, int id, Date lastVerifiedDate, int maxCpu,
|
return new ConcreteBuilder().fromVirtualGuest(this);
|
||||||
String maxCpuUnits, int maxMemory, Date metricPollDate, Date modifyDate, String notes,
|
}
|
||||||
boolean privateNetworkOnly, int startCpus, int statusId, String uuid, String primaryBackendIpAddress,
|
|
||||||
String primaryIpAddress,int billingItemId, OperatingSystem operatingSystem, Datacenter datacenter, PowerState powerState) {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
|
protected abstract T self();
|
||||||
|
|
||||||
|
protected int accountId;
|
||||||
|
protected Date createDate;
|
||||||
|
protected boolean dedicatedAccountHostOnly;
|
||||||
|
protected String domain;
|
||||||
|
protected String fullyQualifiedDomainName;
|
||||||
|
protected String hostname;
|
||||||
|
protected int id;
|
||||||
|
protected Date lastVerifiedDate;
|
||||||
|
protected int maxCpu;
|
||||||
|
protected String maxCpuUnits;
|
||||||
|
protected int maxMemory;
|
||||||
|
protected Date metricPollDate;
|
||||||
|
protected Date modifyDate;
|
||||||
|
protected String notes;
|
||||||
|
protected boolean privateNetworkOnly;
|
||||||
|
protected int startCpus;
|
||||||
|
protected int statusId;
|
||||||
|
protected String uuid;
|
||||||
|
protected String primaryBackendIpAddress;
|
||||||
|
protected String primaryIpAddress;
|
||||||
|
protected int billingItemId;
|
||||||
|
protected OperatingSystem operatingSystem;
|
||||||
|
protected Datacenter datacenter;
|
||||||
|
protected PowerState powerState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getAccountId()
|
||||||
|
*/
|
||||||
|
public T accountId(int accountId) {
|
||||||
|
this.accountId = accountId;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getCreateDate()
|
||||||
|
*/
|
||||||
|
public T createDate(Date createDate) {
|
||||||
|
this.createDate = createDate;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#isDedicatedAccountHostOnly()
|
||||||
|
*/
|
||||||
|
public T dedicatedAccountHostOnly(boolean dedicatedAccountHostOnly) {
|
||||||
|
this.dedicatedAccountHostOnly = dedicatedAccountHostOnly;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getDomain()
|
||||||
|
*/
|
||||||
|
public T domain(String domain) {
|
||||||
|
this.domain = domain;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getFullyQualifiedDomainName()
|
||||||
|
*/
|
||||||
|
public T fullyQualifiedDomainName(String fullyQualifiedDomainName) {
|
||||||
|
this.fullyQualifiedDomainName = fullyQualifiedDomainName;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getHostname()
|
||||||
|
*/
|
||||||
|
public T hostname(String hostname) {
|
||||||
|
this.hostname = hostname;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getId()
|
||||||
|
*/
|
||||||
|
public T id(int id) {
|
||||||
|
this.id = id;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getLastVerifiedDate()
|
||||||
|
*/
|
||||||
|
public T lastVerifiedDate(Date lastVerifiedDate) {
|
||||||
|
this.lastVerifiedDate = lastVerifiedDate;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getMaxCpu()
|
||||||
|
*/
|
||||||
|
public T maxCpu(int maxCpu) {
|
||||||
|
this.maxCpu = maxCpu;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getMaxCpuUnits()
|
||||||
|
*/
|
||||||
|
public T maxCpuUnits(String maxCpuUnits) {
|
||||||
|
this.maxCpuUnits = maxCpuUnits;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getMaxMemory()
|
||||||
|
*/
|
||||||
|
public T maxMemory(int maxMemory) {
|
||||||
|
this.maxMemory = maxMemory;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getMetricPollDate()
|
||||||
|
*/
|
||||||
|
public T metricPollDate(Date metricPollDate) {
|
||||||
|
this.metricPollDate = metricPollDate;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getModifyDate()
|
||||||
|
*/
|
||||||
|
public T modifyDate(Date modifyDate) {
|
||||||
|
this.modifyDate = modifyDate;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getNotes()
|
||||||
|
*/
|
||||||
|
public T notes(String notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#isPrivateNetworkOnly()
|
||||||
|
*/
|
||||||
|
public T privateNetworkOnly(boolean privateNetworkOnly) {
|
||||||
|
this.privateNetworkOnly = privateNetworkOnly;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getStartCpus()
|
||||||
|
*/
|
||||||
|
public T startCpus(int startCpus) {
|
||||||
|
this.startCpus = startCpus;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getStatusId()
|
||||||
|
*/
|
||||||
|
public T statusId(int statusId) {
|
||||||
|
this.statusId = statusId;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getUuid()
|
||||||
|
*/
|
||||||
|
public T uuid(String uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getPrimaryBackendIpAddress()
|
||||||
|
*/
|
||||||
|
public T primaryBackendIpAddress(String primaryBackendIpAddress) {
|
||||||
|
this.primaryBackendIpAddress = primaryBackendIpAddress;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getPrimaryIpAddress()
|
||||||
|
*/
|
||||||
|
public T primaryIpAddress(String primaryIpAddress) {
|
||||||
|
this.primaryIpAddress = primaryIpAddress;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getBillingItemId()
|
||||||
|
*/
|
||||||
|
public T billingItemId(int billingItemId) {
|
||||||
|
this.billingItemId = billingItemId;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getOperatingSystem()
|
||||||
|
*/
|
||||||
|
public T operatingSystem(OperatingSystem operatingSystem) {
|
||||||
|
this.operatingSystem = operatingSystem;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getDatacenter()
|
||||||
|
*/
|
||||||
|
public T datacenter(Datacenter datacenter) {
|
||||||
|
this.datacenter = datacenter;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see VirtualGuest#getPowerState()
|
||||||
|
*/
|
||||||
|
public T powerState(PowerState powerState) {
|
||||||
|
this.powerState = powerState;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VirtualGuest build() {
|
||||||
|
return new VirtualGuest(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, hostname,
|
||||||
|
id, lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes, privateNetworkOnly,
|
||||||
|
startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress, new BillingItem(billingItemId),
|
||||||
|
operatingSystem, datacenter, powerState);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T fromVirtualGuest(VirtualGuest in) {
|
||||||
|
return this
|
||||||
|
.accountId(in.getAccountId())
|
||||||
|
.createDate(in.getCreateDate())
|
||||||
|
.dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly())
|
||||||
|
.domain(in.getDomain())
|
||||||
|
.fullyQualifiedDomainName(in.getFullyQualifiedDomainName())
|
||||||
|
.hostname(in.getHostname())
|
||||||
|
.id(in.getId())
|
||||||
|
.lastVerifiedDate(in.getLastVerifiedDate())
|
||||||
|
.maxCpu(in.getMaxCpu())
|
||||||
|
.maxCpuUnits(in.getMaxCpuUnits())
|
||||||
|
.maxMemory(in.getMaxMemory())
|
||||||
|
.metricPollDate(in.getMetricPollDate())
|
||||||
|
.modifyDate(in.getModifyDate())
|
||||||
|
.notes(in.getNotes())
|
||||||
|
.privateNetworkOnly(in.isPrivateNetworkOnly())
|
||||||
|
.startCpus(in.getStartCpus())
|
||||||
|
.statusId(in.getStatusId())
|
||||||
|
.uuid(in.getUuid())
|
||||||
|
.primaryBackendIpAddress(in.getPrimaryBackendIpAddress())
|
||||||
|
.primaryIpAddress(in.getPrimaryIpAddress())
|
||||||
|
.billingItemId(in.getBillingItemId())
|
||||||
|
.operatingSystem(in.getOperatingSystem())
|
||||||
|
.datacenter(in.getDatacenter())
|
||||||
|
.powerState(in.getPowerState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@Override
|
||||||
|
protected ConcreteBuilder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int accountId;
|
||||||
|
private final Date createDate;
|
||||||
|
private final boolean dedicatedAccountHostOnly;
|
||||||
|
private final String domain;
|
||||||
|
private final String fullyQualifiedDomainName;
|
||||||
|
private final String hostname;
|
||||||
|
private final int id;
|
||||||
|
private final Date lastVerifiedDate;
|
||||||
|
private final int maxCpu;
|
||||||
|
private final String maxCpuUnits;
|
||||||
|
private final int maxMemory;
|
||||||
|
private final Date metricPollDate;
|
||||||
|
private final Date modifyDate;
|
||||||
|
private final String notes;
|
||||||
|
private final boolean privateNetworkOnly;
|
||||||
|
private final int startCpus;
|
||||||
|
private final int statusId;
|
||||||
|
private final String uuid;
|
||||||
|
private final String primaryBackendIpAddress;
|
||||||
|
private final String primaryIpAddress;
|
||||||
|
private final int billingItemId;
|
||||||
|
private final OperatingSystem operatingSystem;
|
||||||
|
private final Datacenter datacenter;
|
||||||
|
private final PowerState powerState;
|
||||||
|
|
||||||
|
@ConstructorProperties({
|
||||||
|
"accountId", "createDate", "dedicatedAccountHostOnlyFlag", "domain", "fullyQualifiedDomainName", "hostname", "id", "lastVerifiedDate", "maxCpu", "maxCpuUnits", "maxMemory", "metricPollDate", "modifyDate", "notes", "privateNetworkOnlyFlag", "startCpus", "statusId", "uuid", "primaryBackendIpAddress", "primaryIpAddress", "billingItem", "operatingSystem", "datacenter", "powerState"
|
||||||
|
})
|
||||||
|
protected VirtualGuest(int accountId, @Nullable Date createDate, boolean dedicatedAccountHostOnly, @Nullable String domain,
|
||||||
|
@Nullable String fullyQualifiedDomainName, @Nullable String hostname, int id, @Nullable Date lastVerifiedDate,
|
||||||
|
int maxCpu, @Nullable String maxCpuUnits, int maxMemory, @Nullable Date metricPollDate, @Nullable Date modifyDate,
|
||||||
|
@Nullable String notes, boolean privateNetworkOnly, int startCpus, int statusId, @Nullable String uuid,
|
||||||
|
@Nullable String primaryBackendIpAddress, @Nullable String primaryIpAddress, @Nullable BillingItem billingItem,
|
||||||
|
@Nullable OperatingSystem operatingSystem, @Nullable Datacenter datacenter, @Nullable PowerState powerState) {
|
||||||
this.accountId = accountId;
|
this.accountId = accountId;
|
||||||
this.createDate = createDate;
|
this.createDate = createDate;
|
||||||
this.dedicatedAccountHostOnly = dedicatedAccountHostOnly;
|
this.dedicatedAccountHostOnly = dedicatedAccountHostOnly;
|
||||||
|
@ -318,336 +417,241 @@ public class VirtualGuest implements Comparable<VirtualGuest> {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.primaryBackendIpAddress = primaryBackendIpAddress;
|
this.primaryBackendIpAddress = primaryBackendIpAddress;
|
||||||
this.primaryIpAddress = primaryIpAddress;
|
this.primaryIpAddress = primaryIpAddress;
|
||||||
this.billingItemId = billingItemId;
|
this.billingItemId = billingItem == null ? -1 : billingItem.id;
|
||||||
this.operatingSystem = operatingSystem;
|
this.operatingSystem = operatingSystem;
|
||||||
this.datacenter = datacenter;
|
this.datacenter = datacenter;
|
||||||
this.powerState = powerState;
|
this.powerState = powerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(VirtualGuest arg0) {
|
|
||||||
return Integer.valueOf(id).compareTo(arg0.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A computing instance's associated account id
|
* @return A computing instance's associated account id
|
||||||
*/
|
*/
|
||||||
public int getAccountId() {
|
public int getAccountId() {
|
||||||
return accountId;
|
return this.accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The date a virtual computing instance was created.
|
* @return The date a virtual computing instance was created.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Date getCreateDate() {
|
public Date getCreateDate() {
|
||||||
return createDate;
|
return this.createDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return When true this flag specifies that a compute instance is to run on hosts that only
|
* @return When true this flag specifies that a compute instance is to run on hosts that only
|
||||||
* have guests from the same account.
|
have guests from the same account.
|
||||||
*/
|
*/
|
||||||
public boolean isDedicatedAccountHostOnly() {
|
public boolean isDedicatedAccountHostOnly() {
|
||||||
return dedicatedAccountHostOnly;
|
return this.dedicatedAccountHostOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A computing instance's domain name
|
* @return A computing instance's domain name
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getDomain() {
|
public String getDomain() {
|
||||||
return domain;
|
return this.domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A name reflecting the hostname and domain of the computing instance.
|
* @return A name reflecting the hostname and domain of the computing instance.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getFullyQualifiedDomainName() {
|
public String getFullyQualifiedDomainName() {
|
||||||
return fullyQualifiedDomainName;
|
return this.fullyQualifiedDomainName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A virtual computing instance's hostname
|
* @return A virtual computing instance's hostname
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getHostname() {
|
public String getHostname() {
|
||||||
return hostname;
|
return this.hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Unique ID for a computing instance.
|
* @return Unique ID for a computing instance.
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The last timestamp of when the guest was verified as a resident virtual machine on the
|
* @return The last timestamp of when the guest was verified as a resident virtual machine on the
|
||||||
* host's hypervisor platform.
|
host's hypervisor platform.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Date getLastVerifiedDate() {
|
public Date getLastVerifiedDate() {
|
||||||
return lastVerifiedDate;
|
return this.lastVerifiedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The maximum amount of CPU resources a computing instance may utilize.
|
* @return The maximum amount of CPU resources a computing instance may utilize.
|
||||||
*/
|
*/
|
||||||
public int getMaxCpu() {
|
public int getMaxCpu() {
|
||||||
return maxCpu;
|
return this.maxCpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The unit of the maximum amount of CPU resources a computing instance may utilize.
|
* @return The unit of the maximum amount of CPU resources a computing instance may utilize.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getMaxCpuUnits() {
|
public String getMaxCpuUnits() {
|
||||||
return maxCpuUnits;
|
return this.maxCpuUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The maximum amount of memory a computing instance may utilize.
|
* @return The maximum amount of memory a computing instance may utilize.
|
||||||
*/
|
*/
|
||||||
public int getMaxMemory() {
|
public int getMaxMemory() {
|
||||||
return maxMemory;
|
return this.maxMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The date of the most recent metric tracking poll performed.
|
* @return The date of the most recent metric tracking poll performed.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Date getMetricPollDate() {
|
public Date getMetricPollDate() {
|
||||||
return metricPollDate;
|
return this.metricPollDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The date a virtual computing instance was last modified.
|
* @return The date a virtual computing instance was last modified.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Date getModifyDate() {
|
public Date getModifyDate() {
|
||||||
return modifyDate;
|
return this.modifyDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A small note about a cloud instance to use at your discretion.
|
* @return A small note about a cloud instance to use at your discretion.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getNotes() {
|
public String getNotes() {
|
||||||
return notes;
|
return this.notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Whether the computing instance only has access to the private network.
|
* @return Whether the computing instance only has access to the private network.
|
||||||
*/
|
*/
|
||||||
public boolean isPrivateNetworkOnly() {
|
public boolean isPrivateNetworkOnly() {
|
||||||
return privateNetworkOnly;
|
return this.privateNetworkOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The number of CPUs available to a computing instance upon startup.
|
* @return The number of CPUs available to a computing instance upon startup.
|
||||||
*/
|
*/
|
||||||
public int getStartCpus() {
|
public int getStartCpus() {
|
||||||
return startCpus;
|
return this.startCpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A computing instances status ID
|
* @return A computing instances status ID
|
||||||
*/
|
*/
|
||||||
public int getStatusId() {
|
public int getStatusId() {
|
||||||
return statusId;
|
return this.statusId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Unique ID for a computing instance's record on a virtualization platform.
|
* @return Unique ID for a computing instance's record on a virtualization platform.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return uuid;
|
return this.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return private ip address
|
* @return private ip address
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getPrimaryBackendIpAddress() {
|
public String getPrimaryBackendIpAddress() {
|
||||||
return primaryBackendIpAddress;
|
return this.primaryBackendIpAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return public ip address
|
* @return public ip address
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public String getPrimaryIpAddress() {
|
public String getPrimaryIpAddress() {
|
||||||
return primaryIpAddress;
|
return this.primaryIpAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The billing item for a CloudLayer Compute Instance.
|
* @return The billing item for a CloudLayer Compute Instance.
|
||||||
*/
|
*/
|
||||||
public int getBillingItemId() {
|
public int getBillingItemId() {
|
||||||
return billingItemId;
|
return this.billingItemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A guest's operating system.
|
* @return A guest's operating system.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public OperatingSystem getOperatingSystem() {
|
public OperatingSystem getOperatingSystem() {
|
||||||
return operatingSystem;
|
return this.operatingSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The guest's datacenter
|
* @return The guest's datacenter
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Datacenter getDatacenter() {
|
public Datacenter getDatacenter() {
|
||||||
return datacenter;
|
return this.datacenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The current power state of a virtual guest.
|
* @return The current power state of a virtual guest.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public PowerState getPowerState() {
|
public PowerState getPowerState() {
|
||||||
return powerState;
|
return this.powerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return Objects.hashCode(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, hostname, id, lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes, privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress, billingItemId, operatingSystem, datacenter, powerState);
|
||||||
int result = 1;
|
|
||||||
result = prime * result + (accountId ^ (accountId >>> 32));
|
|
||||||
result = prime * result + ((createDate == null) ? 0 : createDate.hashCode());
|
|
||||||
result = prime * result + (dedicatedAccountHostOnly ? 1231 : 1237);
|
|
||||||
result = prime * result + ((domain == null) ? 0 : domain.hashCode());
|
|
||||||
result = prime * result + ((fullyQualifiedDomainName == null) ? 0 : fullyQualifiedDomainName.hashCode());
|
|
||||||
result = prime * result + ((hostname == null) ? 0 : hostname.hashCode());
|
|
||||||
result = prime * result + (id ^ (id >>> 32));
|
|
||||||
result = prime * result + ((lastVerifiedDate == null) ? 0 : lastVerifiedDate.hashCode());
|
|
||||||
result = prime * result + maxCpu;
|
|
||||||
result = prime * result + ((maxCpuUnits == null) ? 0 : maxCpuUnits.hashCode());
|
|
||||||
result = prime * result + maxMemory;
|
|
||||||
result = prime * result + ((metricPollDate == null) ? 0 : metricPollDate.hashCode());
|
|
||||||
result = prime * result + ((modifyDate == null) ? 0 : modifyDate.hashCode());
|
|
||||||
result = prime * result + ((notes == null) ? 0 : notes.hashCode());
|
|
||||||
result = prime * result + ((primaryBackendIpAddress == null) ? 0 : primaryBackendIpAddress.hashCode());
|
|
||||||
result = prime * result + ((primaryIpAddress == null) ? 0 : primaryIpAddress.hashCode());
|
|
||||||
result = prime * result + (privateNetworkOnly ? 1231 : 1237);
|
|
||||||
result = prime * result + startCpus;
|
|
||||||
result = prime * result + statusId;
|
|
||||||
result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
|
|
||||||
result = prime * result + (getBillingItemId() ^ (getBillingItemId() >>> 32));
|
|
||||||
result = prime * result + ((operatingSystem == null) ? 0 : operatingSystem.hashCode());
|
|
||||||
result = prime * result + ((datacenter == null) ? 0 : datacenter.hashCode());
|
|
||||||
result = prime * result + ((powerState == null) ? 0 : powerState.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj)
|
if (this == obj) return true;
|
||||||
return true;
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
if (obj == null)
|
VirtualGuest that = VirtualGuest.class.cast(obj);
|
||||||
return false;
|
return Objects.equal(this.accountId, that.accountId)
|
||||||
if (getClass() != obj.getClass())
|
&& Objects.equal(this.createDate, that.createDate)
|
||||||
return false;
|
&& Objects.equal(this.dedicatedAccountHostOnly, that.dedicatedAccountHostOnly)
|
||||||
VirtualGuest other = (VirtualGuest) obj;
|
&& Objects.equal(this.domain, that.domain)
|
||||||
if (accountId != other.accountId)
|
&& Objects.equal(this.fullyQualifiedDomainName, that.fullyQualifiedDomainName)
|
||||||
return false;
|
&& Objects.equal(this.hostname, that.hostname)
|
||||||
if (createDate == null) {
|
&& Objects.equal(this.id, that.id)
|
||||||
if (other.createDate != null)
|
&& Objects.equal(this.lastVerifiedDate, that.lastVerifiedDate)
|
||||||
return false;
|
&& Objects.equal(this.maxCpu, that.maxCpu)
|
||||||
} else if (!createDate.equals(other.createDate))
|
&& Objects.equal(this.maxCpuUnits, that.maxCpuUnits)
|
||||||
return false;
|
&& Objects.equal(this.maxMemory, that.maxMemory)
|
||||||
if (dedicatedAccountHostOnly != other.dedicatedAccountHostOnly)
|
&& Objects.equal(this.metricPollDate, that.metricPollDate)
|
||||||
return false;
|
&& Objects.equal(this.modifyDate, that.modifyDate)
|
||||||
if (domain == null) {
|
&& Objects.equal(this.notes, that.notes)
|
||||||
if (other.domain != null)
|
&& Objects.equal(this.privateNetworkOnly, that.privateNetworkOnly)
|
||||||
return false;
|
&& Objects.equal(this.startCpus, that.startCpus)
|
||||||
} else if (!domain.equals(other.domain))
|
&& Objects.equal(this.statusId, that.statusId)
|
||||||
return false;
|
&& Objects.equal(this.uuid, that.uuid)
|
||||||
if (fullyQualifiedDomainName == null) {
|
&& Objects.equal(this.primaryBackendIpAddress, that.primaryBackendIpAddress)
|
||||||
if (other.fullyQualifiedDomainName != null)
|
&& Objects.equal(this.primaryIpAddress, that.primaryIpAddress)
|
||||||
return false;
|
&& Objects.equal(this.billingItemId, that.billingItemId)
|
||||||
} else if (!fullyQualifiedDomainName.equals(other.fullyQualifiedDomainName))
|
&& Objects.equal(this.operatingSystem, that.operatingSystem)
|
||||||
return false;
|
&& Objects.equal(this.datacenter, that.datacenter)
|
||||||
if (hostname == null) {
|
&& Objects.equal(this.powerState, that.powerState);
|
||||||
if (other.hostname != null)
|
}
|
||||||
return false;
|
|
||||||
} else if (!hostname.equals(other.hostname))
|
protected ToStringHelper string() {
|
||||||
return false;
|
return Objects.toStringHelper(this)
|
||||||
if (id != other.id)
|
.add("accountId", accountId).add("createDate", createDate).add("dedicatedAccountHostOnly", dedicatedAccountHostOnly).add("domain", domain).add("fullyQualifiedDomainName", fullyQualifiedDomainName).add("hostname", hostname).add("id", id).add("lastVerifiedDate", lastVerifiedDate).add("maxCpu", maxCpu).add("maxCpuUnits", maxCpuUnits).add("maxMemory", maxMemory).add("metricPollDate", metricPollDate).add("modifyDate", modifyDate).add("notes", notes).add("privateNetworkOnly", privateNetworkOnly).add("startCpus", startCpus).add("statusId", statusId).add("uuid", uuid).add("primaryBackendIpAddress", primaryBackendIpAddress).add("primaryIpAddress", primaryIpAddress).add("billingItemId", billingItemId).add("operatingSystem", operatingSystem).add("datacenter", datacenter).add("powerState", powerState);
|
||||||
return false;
|
|
||||||
if (lastVerifiedDate == null) {
|
|
||||||
if (other.lastVerifiedDate != null)
|
|
||||||
return false;
|
|
||||||
} else if (!lastVerifiedDate.equals(other.lastVerifiedDate))
|
|
||||||
return false;
|
|
||||||
if (maxCpu != other.maxCpu)
|
|
||||||
return false;
|
|
||||||
if (maxCpuUnits == null) {
|
|
||||||
if (other.maxCpuUnits != null)
|
|
||||||
return false;
|
|
||||||
} else if (!maxCpuUnits.equals(other.maxCpuUnits))
|
|
||||||
return false;
|
|
||||||
if (maxMemory != other.maxMemory)
|
|
||||||
return false;
|
|
||||||
if (metricPollDate == null) {
|
|
||||||
if (other.metricPollDate != null)
|
|
||||||
return false;
|
|
||||||
} else if (!metricPollDate.equals(other.metricPollDate))
|
|
||||||
return false;
|
|
||||||
if (modifyDate == null) {
|
|
||||||
if (other.modifyDate != null)
|
|
||||||
return false;
|
|
||||||
} else if (!modifyDate.equals(other.modifyDate))
|
|
||||||
return false;
|
|
||||||
if (notes == null) {
|
|
||||||
if (other.notes != null)
|
|
||||||
return false;
|
|
||||||
} else if (!notes.equals(other.notes))
|
|
||||||
return false;
|
|
||||||
if (primaryBackendIpAddress == null) {
|
|
||||||
if (other.primaryBackendIpAddress != null)
|
|
||||||
return false;
|
|
||||||
} else if (!primaryBackendIpAddress.equals(other.primaryBackendIpAddress))
|
|
||||||
return false;
|
|
||||||
if (primaryIpAddress == null) {
|
|
||||||
if (other.primaryIpAddress != null)
|
|
||||||
return false;
|
|
||||||
} else if (!primaryIpAddress.equals(other.primaryIpAddress))
|
|
||||||
return false;
|
|
||||||
if (privateNetworkOnly != other.privateNetworkOnly)
|
|
||||||
return false;
|
|
||||||
if (startCpus != other.startCpus)
|
|
||||||
return false;
|
|
||||||
if (statusId != other.statusId)
|
|
||||||
return false;
|
|
||||||
if (uuid == null) {
|
|
||||||
if (other.uuid != null)
|
|
||||||
return false;
|
|
||||||
} else if (!uuid.equals(other.uuid))
|
|
||||||
return false;
|
|
||||||
if (getBillingItemId() != other.getBillingItemId())
|
|
||||||
return false;
|
|
||||||
if (operatingSystem == null) {
|
|
||||||
if (other.operatingSystem != null)
|
|
||||||
return false;
|
|
||||||
} else if (!operatingSystem.equals(other.operatingSystem))
|
|
||||||
return false;
|
|
||||||
if (datacenter == null) {
|
|
||||||
if (other.datacenter != null)
|
|
||||||
return false;
|
|
||||||
} else if (!datacenter.equals(other.datacenter))
|
|
||||||
return false;
|
|
||||||
if (powerState == null) {
|
|
||||||
if (other.powerState != null)
|
|
||||||
return false;
|
|
||||||
} else if (!powerState.equals(other.powerState))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[accountId=" + accountId + ", createDate=" + createDate + ", dedicatedAccountHostOnly="
|
return string().toString();
|
||||||
+ dedicatedAccountHostOnly + ", domain=" + domain + ", fullyQualifiedDomainName="
|
|
||||||
+ fullyQualifiedDomainName + ", hostname=" + hostname + ", id=" + id + ", lastVerifiedDate="
|
|
||||||
+ lastVerifiedDate + ", maxCpu=" + maxCpu + ", maxCpuUnits=" + maxCpuUnits + ", maxMemory=" + maxMemory
|
|
||||||
+ ", metricPollDate=" + metricPollDate + ", modifyDate=" + modifyDate + ", notes=" + notes
|
|
||||||
+ ", primaryBackendIpAddress=" + primaryBackendIpAddress + ", primaryIpAddress=" + primaryIpAddress
|
|
||||||
+ ", privateNetworkOnly=" + privateNetworkOnly + ", startCpus=" + startCpus + ", statusId=" + statusId
|
|
||||||
+ ", uuid=" + uuid + ", billingItemId="+getBillingItemId()+", operatingSystem="+operatingSystem+", datacenter="+datacenter
|
|
||||||
+ ", powerState="+powerState+"]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class ProductOrderToJsonTest {
|
||||||
.quantity(99)
|
.quantity(99)
|
||||||
.useHourlyPricing(true)
|
.useHourlyPricing(true)
|
||||||
.prices(ImmutableSet.of(price1,price2))
|
.prices(ImmutableSet.of(price1,price2))
|
||||||
.virtualGuest(guest)
|
.virtualGuests(guest)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String expected = String.format(FORMAT.replaceAll("'","\""),
|
String expected = String.format(FORMAT.replaceAll("'","\""),
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class ProductItemToImageTest {
|
||||||
{
|
{
|
||||||
ProductItem item = ProductItem.builder()
|
ProductItem item = ProductItem.builder()
|
||||||
.description(description)
|
.description(description)
|
||||||
.price(ProductItemPrice.builder().id(1234).build())
|
.prices(ProductItemPrice.builder().id(1234).build())
|
||||||
.build();
|
.build();
|
||||||
Image i = new ProductItemToImage().apply(item);
|
Image i = new ProductItemToImage().apply(item);
|
||||||
OperatingSystem os = i.getOperatingSystem();
|
OperatingSystem os = i.getOperatingSystem();
|
||||||
|
@ -122,7 +122,7 @@ public class ProductItemToImageTest {
|
||||||
public void testUbuntu() {
|
public void testUbuntu() {
|
||||||
ProductItem item = ProductItem.builder()
|
ProductItem item = ProductItem.builder()
|
||||||
.description("Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install (64 bit)")
|
.description("Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install (64 bit)")
|
||||||
.price(ProductItemPrice.builder().id(1234).build())
|
.prices(ProductItemPrice.builder().id(1234).build())
|
||||||
.build();
|
.build();
|
||||||
Image i = new ProductItemToImage().apply(item);
|
Image i = new ProductItemToImage().apply(item);
|
||||||
OperatingSystem os = i.getOperatingSystem();
|
OperatingSystem os = i.getOperatingSystem();
|
||||||
|
@ -136,7 +136,7 @@ public class ProductItemToImageTest {
|
||||||
public void testUbuntuNoBitCount() {
|
public void testUbuntuNoBitCount() {
|
||||||
ProductItem item = ProductItem.builder()
|
ProductItem item = ProductItem.builder()
|
||||||
.description("Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install")
|
.description("Ubuntu Linux 10.04 LTS Lucid Lynx - Minimal Install")
|
||||||
.price(ProductItemPrice.builder().id(1234).build())
|
.prices(ProductItemPrice.builder().id(1234).build())
|
||||||
.build();
|
.build();
|
||||||
Image i = new ProductItemToImage().apply(item);
|
Image i = new ProductItemToImage().apply(item);
|
||||||
OperatingSystem os = i.getOperatingSystem();
|
OperatingSystem os = i.getOperatingSystem();
|
||||||
|
@ -151,7 +151,7 @@ public class ProductItemToImageTest {
|
||||||
public void testCompletelyUnknown() {
|
public void testCompletelyUnknown() {
|
||||||
ProductItem item = ProductItem.builder()
|
ProductItem item = ProductItem.builder()
|
||||||
.description("This fails to match anything!!!")
|
.description("This fails to match anything!!!")
|
||||||
.price(ProductItemPrice.builder().id(1234).build())
|
.prices(ProductItemPrice.builder().id(1234).build())
|
||||||
.build();
|
.build();
|
||||||
Image i = new ProductItemToImage().apply(item);
|
Image i = new ProductItemToImage().apply(item);
|
||||||
OperatingSystem os = i.getOperatingSystem();
|
OperatingSystem os = i.getOperatingSystem();
|
||||||
|
@ -165,7 +165,7 @@ public class ProductItemToImageTest {
|
||||||
public void test64BitUnknown() {
|
public void test64BitUnknown() {
|
||||||
ProductItem item = ProductItem.builder()
|
ProductItem item = ProductItem.builder()
|
||||||
.description("This only has the bit-count (64 bit)")
|
.description("This only has the bit-count (64 bit)")
|
||||||
.price(ProductItemPrice.builder().id(1234).build())
|
.prices(ProductItemPrice.builder().id(1234).build())
|
||||||
.build();
|
.build();
|
||||||
Image i = new ProductItemToImage().apply(item);
|
Image i = new ProductItemToImage().apply(item);
|
||||||
OperatingSystem os = i.getOperatingSystem();
|
OperatingSystem os = i.getOperatingSystem();
|
||||||
|
@ -183,7 +183,7 @@ public class ProductItemToImageTest {
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
public void testNoDescription() {
|
public void testNoDescription() {
|
||||||
ProductItem item = ProductItem.builder()
|
ProductItem item = ProductItem.builder()
|
||||||
.price(ProductItemPrice.builder().id(1234).build())
|
.prices(ProductItemPrice.builder().id(1234).build())
|
||||||
.build();
|
.build();
|
||||||
new ProductItemToImage().apply(item);
|
new ProductItemToImage().apply(item);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public class ProductItemToImageTest {
|
||||||
@Test
|
@Test
|
||||||
public void testId() {
|
public void testId() {
|
||||||
ProductItemPrice price = ProductItemPrice.builder().id(1234).build();
|
ProductItemPrice price = ProductItemPrice.builder().id(1234).build();
|
||||||
ProductItem item = ProductItem.builder().price(price).build();
|
ProductItem item = ProductItem.builder().prices(price).build();
|
||||||
assertEquals("1234",imageId().apply(item));
|
assertEquals("1234",imageId().apply(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class ProductItemsTest {
|
||||||
item = ProductItem.builder().id(1)
|
item = ProductItem.builder().id(1)
|
||||||
.capacity(2.0f)
|
.capacity(2.0f)
|
||||||
.description("an item")
|
.description("an item")
|
||||||
.price(price)
|
.prices(price)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class ProductItemsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testItemCallGetsCategory() {
|
public void testItemCallGetsCategory() {
|
||||||
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||||
.category(category)
|
.categories(category)
|
||||||
.item(item)
|
.item(item)
|
||||||
.build();
|
.build();
|
||||||
ProductItem newItem = item().apply(price);
|
ProductItem newItem = item().apply(price);
|
||||||
|
@ -114,8 +114,7 @@ public class ProductItemsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testItemCallNoCategoryOnPrice() {
|
public void testItemCallNoCategoryOnPrice() {
|
||||||
|
|
||||||
ProductItem item1 = ProductItem.Builder.fromProductItem(item)
|
ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category)).build();
|
||||||
.categories(ImmutableSet.of(category)).build();
|
|
||||||
|
|
||||||
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||||
.item(item1)
|
.item(item1)
|
||||||
|
@ -132,11 +131,10 @@ public class ProductItemsTest {
|
||||||
.categoryCode("new category")
|
.categoryCode("new category")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ProductItem item1 = ProductItem.Builder.fromProductItem(item)
|
ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category2)).build();
|
||||||
.categories(ImmutableSet.of(category2)).build();
|
|
||||||
|
|
||||||
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||||
.category(category)
|
.categories(category)
|
||||||
.item(item1)
|
.item(item1)
|
||||||
.build();
|
.build();
|
||||||
ProductItem newItem = item().apply(price);
|
ProductItem newItem = item().apply(price);
|
||||||
|
|
|
@ -67,26 +67,26 @@ public class ProductItemsToHardwareTest {
|
||||||
.id(1)
|
.id(1)
|
||||||
.description("2 x 2.0 GHz Cores")
|
.description("2 x 2.0 GHz Cores")
|
||||||
.capacity(2F)
|
.capacity(2F)
|
||||||
.category(ProductItemCategory.builder().categoryCode("guest_core").build())
|
.categories(ProductItemCategory.builder().categoryCode("guest_core").build())
|
||||||
.price(ProductItemPrice.builder().id(123).build())
|
.prices(ProductItemPrice.builder().id(123).build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ramItem = ProductItem.builder().id(2).description("2GB ram").capacity(2F).category(
|
ramItem = ProductItem.builder().id(2).description("2GB ram").capacity(2F).categories(
|
||||||
ProductItemCategory.builder().categoryCode("ram").build()).price(
|
ProductItemCategory.builder().categoryCode("ram").build()).prices(
|
||||||
ProductItemPrice.builder().id(456).build()).build();
|
ProductItemPrice.builder().id(456).build()).build();
|
||||||
|
|
||||||
volumeItem = ProductItem.builder().id(3).description("100 GB (SAN)").capacity(100F).price(
|
volumeItem = ProductItem.builder().id(3).description("100 GB (SAN)").capacity(100F).prices(
|
||||||
ProductItemPrice.builder().id(789).build()).category(
|
ProductItemPrice.builder().id(789).build()).categories(
|
||||||
ProductItemCategory.builder().categoryCode("guest_disk0").build()).build();
|
ProductItemCategory.builder().categoryCode("guest_disk0").build()).build();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHardwareId() {
|
public void testHardwareId() {
|
||||||
ProductItem item1 = ProductItem.builder().price(ProductItemPrice.builder().id(123).build()).build();
|
ProductItem item1 = ProductItem.builder().prices(ProductItemPrice.builder().id(123).build()).build();
|
||||||
ProductItem item2 = ProductItem.builder().price(ProductItemPrice.builder().id(456).build()).build();
|
ProductItem item2 = ProductItem.builder().prices(ProductItemPrice.builder().id(456).build()).build();
|
||||||
ProductItem item3 = ProductItem.builder().price(ProductItemPrice.builder().id(789).build()).build();
|
ProductItem item3 = ProductItem.builder().prices(ProductItemPrice.builder().id(789).build()).build();
|
||||||
|
|
||||||
String id = hardwareId().apply(ImmutableList.of(item1, item2, item3));
|
String id = hardwareId().apply(ImmutableList.of(item1, item2, item3));
|
||||||
assertEquals("123,456,789", id);
|
assertEquals("123,456,789", id);
|
||||||
|
@ -138,9 +138,9 @@ public class ProductItemsToHardwareTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHardwareWithTwoDisks() {
|
public void testHardwareWithTwoDisks() {
|
||||||
ProductItem localVolumeItem = ProductItem.builder().id(4).description("25 GB").capacity(25F).price(
|
ProductItem localVolumeItem = ProductItem.builder().id(4).description("25 GB").capacity(25F).prices(
|
||||||
ProductItemPrice.builder().id(987).build()).category(
|
ProductItemPrice.builder().id(987).build()).categories(
|
||||||
ProductItemCategory.builder().categoryCode("guest_disk1").build()).build();
|
ProductItemCategory.builder().categoryCode("guest_disk1").build()).build();
|
||||||
|
|
||||||
Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem,localVolumeItem));
|
Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem,localVolumeItem));
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest {
|
||||||
|
|
||||||
for (ProductItemPrice price : item.getPrices()) {
|
for (ProductItemPrice price : item.getPrices()) {
|
||||||
// ProductItemPrice newDetails =
|
// ProductItemPrice newDetails =
|
||||||
// client.getProductItemPrice(price.getId());
|
// client.getProductItemPrice(prices.getId());
|
||||||
// assertEquals(item.getId(), newDetails.getId());
|
// assertEquals(item.getId(), newDetails.getId());
|
||||||
checkPrice(price);
|
checkPrice(price);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class VirtualGuestClientLiveTest extends BaseSoftLayerClientLiveTest {
|
||||||
TEST_HOSTNAME_PREFIX + new Random().nextInt()).build();
|
TEST_HOSTNAME_PREFIX + new Random().nextInt()).build();
|
||||||
|
|
||||||
ProductOrder order = ProductOrder.builder().packageId(pkgId).quantity(1).useHourlyPricing(true).prices(
|
ProductOrder order = ProductOrder.builder().packageId(pkgId).quantity(1).useHourlyPricing(true).prices(
|
||||||
prices.build()).virtualGuest(guest).build();
|
prices.build()).virtualGuests(guest).build();
|
||||||
|
|
||||||
ProductOrderReceipt receipt = socontext.getApi().getVirtualGuestClient().orderVirtualGuest(order);
|
ProductOrderReceipt receipt = socontext.getApi().getVirtualGuestClient().orderVirtualGuest(order);
|
||||||
ProductOrder order2 = receipt.getOrderDetails();
|
ProductOrder order2 = receipt.getOrderDetails();
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class ParseVirtualGuestHaltedTest extends BaseItemParserTest<VirtualGuest
|
||||||
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
||||||
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
||||||
.operatingSystem(OperatingSystem.builder().id(913824)
|
.operatingSystem(OperatingSystem.builder().id(913824)
|
||||||
.password(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
.passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||||
.build())
|
.build())
|
||||||
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
||||||
//TODO: maybe powerState can be flattened like billingItemId
|
//TODO: maybe powerState can be flattened like billingItemId
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class ParseVirtualGuestPausedTest extends BaseItemParserTest<VirtualGuest
|
||||||
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
||||||
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
||||||
.operatingSystem(OperatingSystem.builder().id(913824)
|
.operatingSystem(OperatingSystem.builder().id(913824)
|
||||||
.password(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
.passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||||
.build())
|
.build())
|
||||||
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
||||||
//TODO: maybe powerState can be flattened like billingItemId
|
//TODO: maybe powerState can be flattened like billingItemId
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class ParseVirtualGuestRunningTest extends BaseItemParserTest<VirtualGues
|
||||||
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
.primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001)
|
||||||
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
.uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8")
|
||||||
.operatingSystem(OperatingSystem.builder().id(913824)
|
.operatingSystem(OperatingSystem.builder().id(913824)
|
||||||
.password(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
.passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build())
|
||||||
.build())
|
.build())
|
||||||
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
.datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build())
|
||||||
//TODO: maybe powerState can be flattened like billingItemId
|
//TODO: maybe powerState can be flattened like billingItemId
|
||||||
|
|
Loading…
Reference in New Issue