mirror of https://github.com/apache/jclouds.git
JCLOUDS-951: Remove inheritance in ProfitBrick's AutoValue classes
This commit is contained in:
parent
ed247e7dea
commit
5e82bbfa46
|
@ -33,7 +33,7 @@ public class AddFirewallRuleToNicRequestBinder extends BaseProfitBricksRequestBi
|
|||
protected String createPayload(Firewall.Request.AddRulePayload payload) {
|
||||
requestBuilder.append("<ws:addFirewallRulesToNic>")
|
||||
.append(format("<nicId>%s</nicId>", payload.nicId()));
|
||||
for (Firewall.RuleWithIcmp rule : payload.rules())
|
||||
for (Firewall.Rule rule : payload.rules())
|
||||
requestBuilder
|
||||
.append("<request>")
|
||||
.append(formatIfNotEmpty("<icmpCode>%s</icmpCode>", rule.icmpCode()))
|
||||
|
|
|
@ -35,8 +35,8 @@ public class CreateLoadBalancerRequestBinder extends BaseProfitBricksRequestBind
|
|||
requestBuilder.append("<ws:createLoadBalancer>")
|
||||
.append("<request>")
|
||||
.append(format("<dataCenterId>%s</dataCenterId>", payload.dataCenterId()))
|
||||
.append(format("<loadBalancerName>%s</loadBalancerName>", payload.loadBalancerName()))
|
||||
.append(format("<loadBalancerAlgorithm>%s</loadBalancerAlgorithm>", payload.loadBalancerAlgorithm()))
|
||||
.append(format("<loadBalancerName>%s</loadBalancerName>", payload.name()))
|
||||
.append(format("<loadBalancerAlgorithm>%s</loadBalancerAlgorithm>", payload.algorithm()))
|
||||
.append(format("<ip>%s</ip>", payload.ip()))
|
||||
.append(format("<lanId>%s</lanId>", payload.lanId()));
|
||||
for (String serverId : payload.serverIds())
|
||||
|
|
|
@ -36,7 +36,7 @@ public class UpdateLoadBalancerRequestBinder extends BaseProfitBricksRequestBind
|
|||
.append("<request>")
|
||||
.append(format("<loadBalancerId>%s</loadBalancerId>", payload.id()))
|
||||
.append(formatIfNotEmpty("<loadBalancerName>%s</loadBalancerName>", payload.name()))
|
||||
.append(formatIfNotEmpty("<loadBalancerAlgorithm>%s</loadBalancerAlgorithm>", payload.loadBalancerAlgorithm()))
|
||||
.append(formatIfNotEmpty("<loadBalancerAlgorithm>%s</loadBalancerAlgorithm>", payload.algorithm()))
|
||||
.append(formatIfNotEmpty("<ip>%s</ip>", payload.ip()))
|
||||
.append("</request>")
|
||||
.append("</ws:updateLoadBalancer>").toString();
|
||||
|
|
|
@ -33,7 +33,7 @@ public class UpdateSnapshotRequestBinder extends BaseProfitBricksRequestBinder<S
|
|||
protected String createPayload(Snapshot.Request.UpdatePayload payload) {
|
||||
requestBuilder.append("<ws:updateSnapshot>")
|
||||
.append("<request>")
|
||||
.append(format("<snapshotId>%s</snapshotId>", payload.snapshotId()))
|
||||
.append(format("<snapshotId>%s</snapshotId>", payload.id()))
|
||||
.append(format("<description>%s</description>", payload.description()))
|
||||
.append(format("<snapshotName>%s</snapshotName>", payload.name()))
|
||||
.append(formatIfNotEmpty("<bootable>%s</bootable>", payload.bootable()))
|
||||
|
|
|
@ -37,7 +37,7 @@ public class CreateStorageRequestBinder extends BaseProfitBricksRequestBinder<St
|
|||
.append(formatIfNotEmpty("<storageName>%s</storageName>", payload.name()))
|
||||
.append(format("<size>%.0f</size>", payload.size()))
|
||||
.append(formatIfNotEmpty("<mountImageId>%s</mountImageId>", payload.mountImageId()))
|
||||
.append(formatIfNotEmpty("<profitBricksImagePassword>%s</profitBricksImagePassword>", payload.profitBricksImagePassword()))
|
||||
.append(formatIfNotEmpty("<profitBricksImagePassword>%s</profitBricksImagePassword>", payload.imagePassword()))
|
||||
.append("</request>")
|
||||
.append("</ws:createStorage>");
|
||||
return requestBuilder.toString();
|
||||
|
|
|
@ -54,7 +54,7 @@ import org.jclouds.profitbricks.features.ServerApi;
|
|||
import org.jclouds.profitbricks.compute.concurrent.ProvisioningJob;
|
||||
import org.jclouds.profitbricks.compute.concurrent.ProvisioningManager;
|
||||
import org.jclouds.profitbricks.domain.Snapshot;
|
||||
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||
import org.jclouds.profitbricks.domain.Provisionable;
|
||||
import org.jclouds.profitbricks.util.Passwords;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ import org.jclouds.profitbricks.compute.function.StorageToVolume;
|
|||
import org.jclouds.profitbricks.compute.internal.ProvisioningStatusAware;
|
||||
import org.jclouds.profitbricks.compute.internal.ProvisioningStatusPollingPredicate;
|
||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||
import org.jclouds.profitbricks.domain.Provisionable;
|
||||
import org.jclouds.util.Predicates2;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jclouds.domain.Location;
|
|||
import org.jclouds.profitbricks.domain.OsType;
|
||||
import org.jclouds.profitbricks.domain.ProvisioningState;
|
||||
import org.jclouds.profitbricks.domain.Snapshot;
|
||||
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||
import org.jclouds.profitbricks.domain.Provisionable;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Strings;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
|
||||
public enum AvailabilityZone {
|
||||
|
||||
AUTO, ZONE_1, ZONE_2, UNRECOGNIZED;
|
||||
|
@ -25,11 +27,6 @@ public enum AvailabilityZone {
|
|||
}
|
||||
|
||||
public static AvailabilityZone fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (Exception ex) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(AvailabilityZone.class, v).or(UNRECOGNIZED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,17 +16,14 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkInvalidChars;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@AutoValue
|
||||
public abstract class DataCenter {
|
||||
|
@ -49,81 +46,60 @@ public abstract class DataCenter {
|
|||
|
||||
@Nullable
|
||||
public abstract List<Storage> storages();
|
||||
// @Nullable public abstract List<LoadBalancer> loadBalancers();
|
||||
|
||||
public static DataCenter create(String id, String name, int version, ProvisioningState state, Location location, List<Server> servers,
|
||||
List<Storage> storages) {
|
||||
return new AutoValue_DataCenter(id, name, version, state, location,
|
||||
servers != null ? ImmutableList.copyOf(servers) : Lists.<Server>newArrayList(),
|
||||
storages != null ? ImmutableList.copyOf(storages) : Lists.<Storage>newArrayList());
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_DataCenter.Builder()
|
||||
.servers(ImmutableList.<Server>of())
|
||||
.storages(ImmutableList.<Storage>of());
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromDataCenter(this);
|
||||
}
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
public static final class Builder {
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private ProvisioningState state;
|
||||
private Location location;
|
||||
private int version;
|
||||
private List<Server> servers;
|
||||
private List<Storage> storages;
|
||||
// private List<LoadBalancer> loadBalancer;
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public abstract Builder version(int version);
|
||||
|
||||
public abstract Builder state(ProvisioningState state);
|
||||
|
||||
public abstract Builder location(Location location);
|
||||
|
||||
public abstract Builder servers(List<Server> servers);
|
||||
|
||||
public abstract Builder storages(List<Storage> storages);
|
||||
|
||||
abstract DataCenter autoBuild();
|
||||
|
||||
public DataCenter build(){
|
||||
DataCenter built = autoBuild();
|
||||
return built.toBuilder()
|
||||
.servers(ImmutableList.copyOf(built.servers()))
|
||||
.storages(ImmutableList.copyOf(built.storages()))
|
||||
.autoBuild();
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder state(ProvisioningState state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder location(Location location) {
|
||||
this.location = location;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder version(int version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder servers(List<Server> servers) {
|
||||
this.servers = servers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder storages(List<Storage> storages) {
|
||||
this.storages = storages;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataCenter build() {
|
||||
return DataCenter.create(id, name, version, state, location, servers, storages);
|
||||
}
|
||||
|
||||
public Builder fromDataCenter(DataCenter in) {
|
||||
return this.id(in.id()).name(in.name()).version(in.version()).state(in.state()).location(in.location()).servers(in.servers())
|
||||
.storages(in.storages());
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Request {
|
||||
|
||||
public static CreatePayload creatingPayload(String name, Location location) {
|
||||
CreatePayload payload = new AutoValue_DataCenter_Request_CreatePayload(name, location);
|
||||
checkInvalidChars(payload.name());
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
public static UpdatePayload updatingPayload(String id, String name) {
|
||||
UpdatePayload payload = new AutoValue_DataCenter_Request_UpdatePayload(id, name);
|
||||
checkInvalidChars(payload.name());
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class CreatePayload {
|
||||
|
||||
|
@ -131,11 +107,6 @@ public abstract class DataCenter {
|
|||
|
||||
public abstract Location location();
|
||||
|
||||
public static CreatePayload create(String name, Location location) {
|
||||
checkInvalidChars(name);
|
||||
return new AutoValue_DataCenter_Request_CreatePayload(name, location);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -145,17 +116,6 @@ public abstract class DataCenter {
|
|||
|
||||
public abstract String name();
|
||||
|
||||
public static UpdatePayload create(String id, String name) {
|
||||
checkInvalidChars(name);
|
||||
return new AutoValue_DataCenter_Request_UpdatePayload(id, name);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Pattern INVALID_CHARS = Pattern.compile("^.*[@/\\|'`’^].*$");
|
||||
|
||||
private static void checkInvalidChars(String name) {
|
||||
checkArgument(!isNullOrEmpty(name), "Name is required.");
|
||||
checkArgument(!INVALID_CHARS.matcher(name).matches(), "Name must not contain any of: @ / \\ | ' ` ’ ^");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,12 @@ package org.jclouds.profitbricks.domain;
|
|||
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
@AutoValue
|
||||
public abstract class Drive {
|
||||
|
||||
public static final class Request {
|
||||
public abstract static class Request {
|
||||
|
||||
@AutoValue
|
||||
public abstract static class AddRomDriveToServerPayload {
|
||||
|
@ -30,40 +32,23 @@ public abstract class Drive {
|
|||
|
||||
public abstract String imageId();
|
||||
|
||||
@Nullable
|
||||
public abstract String deviceNumber();
|
||||
|
||||
public static AddRomDriveToServerPayload create(String serverId, String storageId, String deviceNumber) {
|
||||
return new AutoValue_Drive_Request_AddRomDriveToServerPayload(serverId, storageId, deviceNumber);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_Drive_Request_AddRomDriveToServerPayload.Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private String serverId;
|
||||
private String imageId;
|
||||
private String deviceNumber;
|
||||
public abstract Builder serverId(String serverId);
|
||||
|
||||
public Builder serverId(String serverId) {
|
||||
this.serverId = serverId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder imageId(String imageId);
|
||||
|
||||
public Builder storageId(String storageId) {
|
||||
this.imageId = storageId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder deviceNumber(String deviceNumber);
|
||||
|
||||
public Builder deviceNumber(String deviceNumber) {
|
||||
this.deviceNumber = deviceNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AddRomDriveToServerPayload build() {
|
||||
return AddRomDriveToServerPayload.create(serverId, imageId, deviceNumber);
|
||||
}
|
||||
public abstract AddRomDriveToServerPayload build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,18 +16,18 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.net.InetAddresses.isInetAddress;
|
||||
import static org.jclouds.profitbricks.util.MacAddresses.isMacAddress;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkIcmp;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkIp;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkMacAddress;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkPortRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.profitbricks.domain.internal.FirewallRuleCommonProperties;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@AutoValue
|
||||
public abstract class Firewall {
|
||||
|
@ -37,11 +37,7 @@ public abstract class Firewall {
|
|||
TCP, UDP, ICMP, ANY, UNRECOGNIZED;
|
||||
|
||||
public static Protocol fromValue(String value) {
|
||||
try {
|
||||
return valueOf(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(Protocol.class, value).or(UNRECOGNIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +47,8 @@ public abstract class Firewall {
|
|||
@Nullable
|
||||
public abstract String nicId();
|
||||
|
||||
public abstract boolean active();
|
||||
@Nullable
|
||||
public abstract Boolean active();
|
||||
|
||||
@Nullable
|
||||
public abstract ProvisioningState state();
|
||||
|
@ -59,20 +56,41 @@ public abstract class Firewall {
|
|||
@Nullable
|
||||
public abstract List<Rule> rules();
|
||||
|
||||
public static Firewall create(String id, String nicId, boolean active, ProvisioningState provisioningState,
|
||||
List<Rule> rules) {
|
||||
return new AutoValue_Firewall(id, nicId, active, provisioningState,
|
||||
rules != null ? ImmutableList.copyOf(rules) : ImmutableList.<Rule>of());
|
||||
public static Builder builder() {
|
||||
return new AutoValue_Firewall.Builder()
|
||||
.rules(ImmutableList.<Rule>of());
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public abstract Builder nicId(String nicId);
|
||||
|
||||
public abstract Builder active(Boolean active);
|
||||
|
||||
public abstract Builder state(ProvisioningState state);
|
||||
|
||||
public abstract Builder rules(List<Rule> rules);
|
||||
|
||||
abstract Firewall autoBuild();
|
||||
|
||||
public Firewall build(){
|
||||
Firewall built = autoBuild();
|
||||
|
||||
return built.toBuilder()
|
||||
.rules(ImmutableList.copyOf(built.rules()))
|
||||
.autoBuild();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Request {
|
||||
|
||||
public static AddRulePayload.Builder ruleAddingBuilder() {
|
||||
return new AddRulePayload.Builder();
|
||||
public static AddRulePayload createAddRulePayload(String nicId, List<Rule> rules) {
|
||||
return new AutoValue_Firewall_Request_AddRulePayload(nicId, ImmutableList.copyOf(rules));
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -80,207 +98,37 @@ public abstract class Firewall {
|
|||
|
||||
public abstract String nicId();
|
||||
|
||||
public abstract List<RuleWithIcmp> rules();
|
||||
public abstract List<Rule> rules();
|
||||
|
||||
public static AddRulePayload create(String nicId, List<RuleWithIcmp> rules) {
|
||||
return new AutoValue_Firewall_Request_AddRulePayload(nicId, rules);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String nicId;
|
||||
private List<RuleWithIcmp> rules = Lists.newArrayList();
|
||||
|
||||
public Builder nicId(String nicId) {
|
||||
this.nicId = nicId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder rules(List<RuleWithIcmp> rules) {
|
||||
this.rules = rules;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RuleWithIcmp.Builder newRule() {
|
||||
return new RuleWithIcmp.Builder(this);
|
||||
}
|
||||
|
||||
public Builder addRule(RuleWithIcmp rule) {
|
||||
this.rules.add(rule);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AddRulePayload build() {
|
||||
return AddRulePayload.create(nicId, rules);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String id;
|
||||
private String nicId;
|
||||
private boolean active;
|
||||
|
||||
private ProvisioningState state;
|
||||
private List<Rule> rules;
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder nicId(String nicId) {
|
||||
this.nicId = nicId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder active(boolean active) {
|
||||
this.active = active;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder state(ProvisioningState state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder rules(List<Rule> firewallRules) {
|
||||
this.rules = firewallRules;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder fromFirewall(Firewall in) {
|
||||
return this.id(in.id()).nicId(in.nicId()).active(in.active()).state(in.state())
|
||||
.rules(in.rules());
|
||||
}
|
||||
|
||||
public Firewall build() {
|
||||
return Firewall.create(id, nicId, active, state, rules);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class RuleBuilder<B extends RuleBuilder, D extends FirewallRuleCommonProperties> {
|
||||
|
||||
protected String name;
|
||||
protected Integer portRangeEnd;
|
||||
protected Integer portRangeStart;
|
||||
protected Protocol protocol;
|
||||
protected String sourceIp;
|
||||
protected String sourceMac;
|
||||
protected String targetIp;
|
||||
|
||||
public B name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
public B portRangeEnd(Integer portRangeEnd) {
|
||||
this.portRangeEnd = portRangeEnd;
|
||||
return self();
|
||||
}
|
||||
|
||||
public B portRangeStart(Integer portRangeStart) {
|
||||
this.portRangeStart = portRangeStart;
|
||||
return self();
|
||||
}
|
||||
|
||||
public B protocol(Protocol protocol) {
|
||||
this.protocol = protocol;
|
||||
return self();
|
||||
}
|
||||
|
||||
public B sourceIp(String sourceIp) {
|
||||
this.sourceIp = sourceIp;
|
||||
return self();
|
||||
}
|
||||
|
||||
public B sourceMac(String sourceMac) {
|
||||
this.sourceMac = sourceMac;
|
||||
return self();
|
||||
}
|
||||
|
||||
public B targetIp(String targetIp) {
|
||||
this.targetIp = targetIp;
|
||||
return self();
|
||||
}
|
||||
|
||||
public abstract B self();
|
||||
|
||||
public abstract D build();
|
||||
|
||||
protected void checkPortRange() {
|
||||
checkArgument(!(portRangeEnd == null ^ portRangeStart == null), "Port range must be both present or null");
|
||||
if (portRangeEnd != null) {
|
||||
checkArgument(protocol == Protocol.TCP || protocol == Protocol.UDP, "Port range can only be set for TCP or UDP");
|
||||
checkArgument(portRangeEnd > portRangeStart, "portRangeEnd must be greater than portRangeStart");
|
||||
checkArgument(portRangeEnd >= 1 && portRangeEnd <= 65534, "Port range end must be 1 to 65534");
|
||||
checkArgument(portRangeStart >= 1 && portRangeStart <= 65534, "Port range start must be 1 to 65534");
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkMac() {
|
||||
if (sourceMac != null)
|
||||
checkArgument(isMacAddress(sourceMac), "Source MAC must match pattern 'aa:bb:cc:dd:ee:ff'");
|
||||
}
|
||||
|
||||
protected void checkIp() {
|
||||
if (sourceIp != null)
|
||||
checkArgument(isInetAddress(sourceIp), "Source IP is invalid");
|
||||
if (targetIp != null)
|
||||
checkArgument(isInetAddress(targetIp), "Target IP is invalid");
|
||||
}
|
||||
|
||||
protected void checkFields() {
|
||||
checkMac();
|
||||
checkPortRange();
|
||||
checkIp();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class Rule implements FirewallRuleCommonProperties {
|
||||
public abstract static class Rule {
|
||||
|
||||
@Nullable
|
||||
public abstract String id();
|
||||
|
||||
public static Rule create(String id, String name, Integer portRangeEnd, Integer portRangeStart,
|
||||
Protocol protocol, String sourceIp, String sourceMac, String targetIp) {
|
||||
return new AutoValue_Firewall_Rule(name, portRangeEnd, portRangeStart, protocol, sourceIp, sourceMac,
|
||||
targetIp, id);
|
||||
}
|
||||
@Nullable
|
||||
public abstract String name();
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
@Nullable
|
||||
public abstract Integer portRangeEnd();
|
||||
|
||||
public static class Builder extends RuleBuilder<Builder, Rule> {
|
||||
@Nullable
|
||||
public abstract Integer portRangeStart();
|
||||
|
||||
private String id;
|
||||
@Nullable
|
||||
public abstract Protocol protocol();
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
@Nullable
|
||||
public abstract String sourceIp();
|
||||
|
||||
@Override
|
||||
public Builder self() {
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract String sourceMac();
|
||||
|
||||
@Override
|
||||
public Rule build() {
|
||||
checkFields();
|
||||
return Rule.create(id, name, portRangeEnd, portRangeStart, protocol, sourceIp, sourceMac, targetIp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class RuleWithIcmp implements FirewallRuleCommonProperties {
|
||||
@Nullable
|
||||
public abstract String targetIp();
|
||||
|
||||
@Nullable
|
||||
public abstract Integer icmpCode();
|
||||
|
@ -288,76 +136,52 @@ public abstract class Firewall {
|
|||
@Nullable
|
||||
public abstract Integer icmpType();
|
||||
|
||||
public static RuleWithIcmp create(Integer icmpCode, Integer icmpType, String name, Integer portRangeEnd,
|
||||
Integer portRangeStart, Protocol protocol, String sourceIp, String sourceMac, String targetIp) {
|
||||
return new AutoValue_Firewall_RuleWithIcmp(name, portRangeEnd, portRangeStart, protocol, sourceIp, sourceMac,
|
||||
targetIp, icmpCode, icmpType);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_Firewall_Rule.Builder()
|
||||
.protocol(Protocol.ANY);
|
||||
}
|
||||
|
||||
public static class Builder extends RuleBuilder<Builder, RuleWithIcmp> {
|
||||
public Builder toBuilder() {
|
||||
return new AutoValue_Firewall_Rule.Builder(this);
|
||||
}
|
||||
|
||||
private Request.AddRulePayload.Builder parentBuilder;
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private Integer icmpCode;
|
||||
private Integer icmpType;
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public Builder() {
|
||||
public abstract Builder name(String name);
|
||||
|
||||
}
|
||||
public abstract Builder portRangeEnd(Integer portRangeEnd);
|
||||
|
||||
private Builder(Request.AddRulePayload.Builder parentBuilder) {
|
||||
this.parentBuilder = parentBuilder;
|
||||
}
|
||||
public abstract Builder portRangeStart(Integer portRangeStart);
|
||||
|
||||
public Builder nextRule() {
|
||||
this.parentBuilder.addRule(build());
|
||||
return new Builder(parentBuilder);
|
||||
}
|
||||
public abstract Builder protocol(Protocol protocol);
|
||||
|
||||
public Request.AddRulePayload.Builder endRule() {
|
||||
this.parentBuilder.addRule(build());
|
||||
return parentBuilder;
|
||||
}
|
||||
public abstract Builder sourceIp(String sourceIp);
|
||||
|
||||
public Builder icmpCode(Integer icmpCode) {
|
||||
this.icmpCode = icmpCode;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder sourceMac(String sourceMac);
|
||||
|
||||
public Builder icmpType(Integer icmpType) {
|
||||
this.icmpType = icmpType;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder targetIp(String targetIp);
|
||||
|
||||
@Override
|
||||
public Builder self() {
|
||||
return this;
|
||||
}
|
||||
public abstract Builder icmpCode(Integer icmpCode);
|
||||
|
||||
@Override
|
||||
public RuleWithIcmp build() {
|
||||
checkFields();
|
||||
return RuleWithIcmp.create(icmpCode, icmpType, name, portRangeEnd, portRangeStart, protocol,
|
||||
sourceIp, sourceMac, targetIp);
|
||||
}
|
||||
public abstract Builder icmpType(Integer icmpType);
|
||||
|
||||
@Override
|
||||
protected void checkFields() {
|
||||
super.checkFields();
|
||||
checkIcmp();
|
||||
}
|
||||
abstract Rule autoBuild();
|
||||
|
||||
private void checkIcmp() {
|
||||
if (icmpCode != null)
|
||||
checkArgument(icmpCode >= 1 && icmpCode <= 254, "ICMP code must be 1 to 254");
|
||||
if (icmpType != null)
|
||||
checkArgument(icmpType >= 1 && icmpType <= 254, "ICMP type must be 1 to 254");
|
||||
if (icmpCode != null || icmpType != null)
|
||||
checkArgument(protocol == Protocol.ICMP, "ICMP code and types can only be set for ICMP protocol");
|
||||
public Rule build() {
|
||||
Rule rule = autoBuild();
|
||||
if (rule.sourceIp() != null)
|
||||
checkIp(rule.sourceIp());
|
||||
if (rule.targetIp() != null)
|
||||
checkIp(rule.targetIp());
|
||||
if (rule.sourceMac() != null)
|
||||
checkMacAddress(rule.sourceMac());
|
||||
checkPortRange(rule.portRangeStart(), rule.portRangeEnd(), rule.protocol());
|
||||
checkIcmp(rule.icmpType(), rule.icmpCode(), rule.protocol());
|
||||
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Enums;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
@AutoValue
|
||||
public abstract class Image implements Provisionable {
|
||||
|
@ -28,84 +29,99 @@ public abstract class Image implements Provisionable {
|
|||
HDD, CDROM, UNRECOGNIZED;
|
||||
|
||||
public static Type fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(Type.class, v).or(UNRECOGNIZED);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String id();
|
||||
|
||||
public abstract String name();
|
||||
|
||||
public abstract float size(); // MB
|
||||
|
||||
public abstract Location location();
|
||||
|
||||
public abstract OsType osType();
|
||||
|
||||
public abstract Type type();
|
||||
|
||||
public abstract boolean isPublic();
|
||||
@Nullable
|
||||
public abstract Boolean isPublic();
|
||||
|
||||
public abstract boolean isWriteable();
|
||||
@Nullable
|
||||
public abstract Boolean isWriteable();
|
||||
|
||||
public abstract boolean isBootable();
|
||||
@Nullable
|
||||
public abstract Boolean isBootable();
|
||||
|
||||
public static Image create(String id, String name, float size, Type type, Location location, OsType osType,
|
||||
boolean isPublic, Boolean isWriteable, Boolean isBootable, Boolean cpuHotPlug, Boolean cpuHotUnPlug,
|
||||
Boolean ramHotPlug, Boolean ramHotUnPlug, Boolean nicHotPlug, Boolean nicHotUnPlug,
|
||||
Boolean discVirtioHotPlug, Boolean discVirtioHotUnPlug) {
|
||||
return new AutoValue_Image(cpuHotPlug, cpuHotUnPlug, ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug,
|
||||
discVirtioHotPlug, discVirtioHotUnPlug, id, name, size, location, osType, type, isPublic, isWriteable,
|
||||
isBootable);
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotUnPlug();
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_Image.Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromImage(this);
|
||||
}
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
public static class Builder extends Provisionable.Builder<Builder, Image> {
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private Type type;
|
||||
private boolean isPublic;
|
||||
private boolean isWriteable;
|
||||
private boolean isBootable;
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public Builder type(Type type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder isPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder size(float size);
|
||||
|
||||
public Builder isWriteable(boolean isWriteable) {
|
||||
this.isWriteable = isWriteable;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder location(Location location);
|
||||
|
||||
public Builder isBootable(boolean isBootable) {
|
||||
this.isBootable = isBootable;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder osType(OsType osType);
|
||||
|
||||
@Override
|
||||
public Image build() {
|
||||
return Image.create(id, name, size, type, location, osType, isPublic, isWriteable, isBootable, cpuHotPlug, cpuHotUnPlug,
|
||||
ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug);
|
||||
}
|
||||
public abstract Builder type(Type type);
|
||||
|
||||
public Builder fromImage(Image in) {
|
||||
return this.id(in.id()).isBootable(in.isBootable()).isCpuHotPlug(in.isCpuHotPlug()).isCpuHotUnPlug(in.isCpuHotUnPlug())
|
||||
.isDiscVirtioHotPlug(in.isDiscVirtioHotPlug()).isDiscVirtioHotUnPlug(in.isDiscVirtioHotUnPlug())
|
||||
.isNicHotPlug(in.isNicHotPlug()).isNicHotUnPlug(in.isNicHotUnPlug()).isPublic(in.isPublic())
|
||||
.isRamHotPlug(in.isRamHotPlug()).isRamHotUnPlug(in.isRamHotUnPlug()).isWriteable(in.isWriteable())
|
||||
.location(in.location()).name(in.name()).osType(in.osType()).size(in.size()).type(in.type());
|
||||
}
|
||||
public abstract Builder isPublic(Boolean isPublic);
|
||||
|
||||
@Override
|
||||
public Builder self() {
|
||||
return this;
|
||||
}
|
||||
public abstract Builder isWriteable(Boolean isWriteable);
|
||||
|
||||
public abstract Builder isBootable(Boolean isBootable);
|
||||
|
||||
public abstract Builder isCpuHotPlug(Boolean isCpuHotPlug);
|
||||
|
||||
public abstract Builder isCpuHotUnPlug(Boolean isCpuHotUnPlug);
|
||||
|
||||
public abstract Builder isRamHotPlug(Boolean isRamHotPlug);
|
||||
|
||||
public abstract Builder isRamHotUnPlug(Boolean isRamHotUnPlug);
|
||||
|
||||
public abstract Builder isNicHotPlug(Boolean isNicHotPlug);
|
||||
|
||||
public abstract Builder isNicHotUnPlug(Boolean isNicHotUnPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotPlug(Boolean isDiscVirtioHotPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotUnPlug(Boolean isDiscVirtioHotUnPlug);
|
||||
|
||||
public abstract Image build();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,14 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkIp;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkIps;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
@AutoValue
|
||||
|
@ -30,51 +35,39 @@ public abstract class IpBlock {
|
|||
|
||||
public abstract List<PublicIp> publicIps();
|
||||
|
||||
@Nullable
|
||||
public abstract List<String> ips();
|
||||
|
||||
public static IpBlock create(String id, Location location, List<PublicIp> publicIps, List<String> ips) {
|
||||
return new AutoValue_IpBlock(id, location, publicIps, ips != null ? ImmutableList.copyOf(ips) : ImmutableList.<String>of());
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_IpBlock.Builder()
|
||||
.publicIps(ImmutableList.<PublicIp>of())
|
||||
.ips(ImmutableList.<String>of());
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
private String id;
|
||||
private Location location;
|
||||
private List<PublicIp> publicIps;
|
||||
private List<String> ips;
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public Builder location(Location location) {
|
||||
this.location = location;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder location(Location location);
|
||||
|
||||
public Builder publicIps(List<PublicIp> publicIps) {
|
||||
this.publicIps = publicIps;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder publicIps(List<PublicIp> publicIps);
|
||||
|
||||
public Builder ips(List<String> ips) {
|
||||
this.ips = ips;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder ips(List<String> ips);
|
||||
|
||||
abstract IpBlock autoBuild();
|
||||
|
||||
public IpBlock build() {
|
||||
return IpBlock.create(id, location, publicIps, ips);
|
||||
}
|
||||
IpBlock ipBlock = autoBuild();
|
||||
checkIps(ipBlock.ips());
|
||||
|
||||
public Builder fromIpBlock(IpBlock in) {
|
||||
return this.id(in.id()).location(in.location()).publicIps(in.publicIps()).ips(in.ips());
|
||||
return ipBlock.toBuilder()
|
||||
.publicIps(ImmutableList.copyOf(ipBlock.publicIps()))
|
||||
.ips(ImmutableList.copyOf(ipBlock.ips()))
|
||||
.autoBuild();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -85,41 +78,26 @@ public abstract class IpBlock {
|
|||
@Nullable
|
||||
public abstract String nicId();
|
||||
|
||||
public static PublicIp create(String ip, String nicId) {
|
||||
return new AutoValue_IpBlock_PublicIp(ip, nicId);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_IpBlock_PublicIp.Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromPublicIp(this);
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public static final class Builder {
|
||||
public abstract Builder ip(String ip);
|
||||
|
||||
private String ip;
|
||||
private String nicId;
|
||||
public abstract Builder nicId(String nicId);
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder nicId(String nicId) {
|
||||
this.nicId = nicId;
|
||||
return this;
|
||||
}
|
||||
abstract PublicIp autoBuild();
|
||||
|
||||
public PublicIp build() {
|
||||
return PublicIp.create(ip, nicId);
|
||||
}
|
||||
PublicIp publicIp = autoBuild();
|
||||
checkIp(publicIp.ip());
|
||||
|
||||
public Builder fromPublicIp(PublicIp in) {
|
||||
return this.ip(in.ip()).nicId(in.nicId());
|
||||
return publicIp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,17 +16,18 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Enums;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import static com.google.common.net.InetAddresses.isInetAddress;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkIp;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkLanId;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
@AutoValue
|
||||
public abstract class LoadBalancer {
|
||||
|
||||
|
@ -59,7 +60,7 @@ public abstract class LoadBalancer {
|
|||
public abstract String ip();
|
||||
|
||||
@Nullable
|
||||
public abstract String lanId();
|
||||
public abstract Integer lanId();
|
||||
|
||||
@Nullable
|
||||
public abstract ProvisioningState state();
|
||||
|
@ -76,141 +77,76 @@ public abstract class LoadBalancer {
|
|||
@Nullable
|
||||
public abstract List<Firewall> firewalls();
|
||||
|
||||
public static LoadBalancer create(String id, String name, Algorithm algorithm, DataCenter dataCenter,
|
||||
boolean internetAccess, String ip, String lanId, ProvisioningState state, Date creationTime,
|
||||
Date lastModificationTime, List<Server> balancedServers, List<Firewall> firewalls) {
|
||||
return new AutoValue_LoadBalancer(id, name, algorithm, dataCenter,
|
||||
internetAccess, ip, lanId, state, creationTime, lastModificationTime,
|
||||
balancedServers != null ? ImmutableList.copyOf(balancedServers) : ImmutableList.<Server>of(),
|
||||
firewalls != null ? ImmutableList.copyOf(firewalls) : ImmutableList.<Firewall>of());
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_LoadBalancer.Builder()
|
||||
.balancedServers(ImmutableList.<Server>of())
|
||||
.firewalls(ImmutableList.<Firewall>of());
|
||||
}
|
||||
|
||||
private static void checkIp(String ip) {
|
||||
if (ip != null)
|
||||
checkArgument(isInetAddress(ip), "Invalid IP");
|
||||
}
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
public static class Builder {
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private String id;
|
||||
public abstract Builder id(String id);
|
||||
|
||||
private String name;
|
||||
public abstract Builder name(String name);
|
||||
|
||||
private Algorithm algorithm;
|
||||
public abstract Builder algorithm(Algorithm algorithm);
|
||||
|
||||
private DataCenter dataCenter;
|
||||
public abstract Builder dataCenter(DataCenter dataCenter);
|
||||
|
||||
private boolean internetAccess;
|
||||
public abstract Builder internetAccess(Boolean internetAccess);
|
||||
|
||||
private String ip;
|
||||
public abstract Builder ip(String ip);
|
||||
|
||||
private String lanId;
|
||||
public abstract Builder lanId(Integer lanId);
|
||||
|
||||
private ProvisioningState state;
|
||||
public abstract Builder creationTime(Date creationTime);
|
||||
|
||||
private Date creationTime;
|
||||
public abstract Builder state(ProvisioningState state);
|
||||
|
||||
private Date lastModificationTime;
|
||||
public abstract Builder lastModificationTime(Date lastModificationTime);
|
||||
|
||||
public List<Server> balancedServers;
|
||||
public abstract Builder balancedServers(List<Server> balancedServers);
|
||||
|
||||
private List<Firewall> firewalls;
|
||||
public abstract Builder firewalls(List<Firewall> firewalls);
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder algorithm(Algorithm algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder dataCenter(DataCenter dataCenter) {
|
||||
this.dataCenter = dataCenter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder internetAccess(boolean internetAccess) {
|
||||
this.internetAccess = internetAccess;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder lanId(String lanId) {
|
||||
this.lanId = lanId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder creationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder state(ProvisioningState state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder lastModificationTime(Date lastModificationTime) {
|
||||
this.lastModificationTime = lastModificationTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder balancedServers(List<Server> balancedServers) {
|
||||
this.balancedServers = balancedServers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder firewalls(List<Firewall> firewalls) {
|
||||
this.firewalls = firewalls;
|
||||
return this;
|
||||
}
|
||||
abstract LoadBalancer autoBuild();
|
||||
|
||||
public LoadBalancer build() {
|
||||
checkIp(ip);
|
||||
return LoadBalancer.create(id, name, algorithm, dataCenter, internetAccess,
|
||||
ip, lanId, state, creationTime, lastModificationTime, balancedServers, firewalls);
|
||||
}
|
||||
LoadBalancer loadBalancer = autoBuild();
|
||||
if (loadBalancer.ip() != null)
|
||||
checkIp(loadBalancer.ip());
|
||||
if (loadBalancer.lanId() != null)
|
||||
checkLanId(loadBalancer.lanId());
|
||||
|
||||
public Builder fromLoadBalancer(LoadBalancer in) {
|
||||
return this.id(in.id()).name(in.name()).algorithm(in.algorithm())
|
||||
.dataCenter(in.dataCenter()).internetAccess(in.internetAccess())
|
||||
.ip(in.ip()).lanId(in.lanId()).state(in.state()).creationTime(in.creationTime())
|
||||
.lastModificationTime(in.lastModificationTime()).balancedServers(in.balancedServers())
|
||||
.firewalls(in.firewalls());
|
||||
return loadBalancer.toBuilder()
|
||||
.balancedServers(ImmutableList.copyOf(loadBalancer.balancedServers()))
|
||||
.firewalls(ImmutableList.copyOf(loadBalancer.firewalls()))
|
||||
.autoBuild();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Request {
|
||||
|
||||
public static CreatePayload.Builder creatingBuilder() {
|
||||
return new CreatePayload.Builder();
|
||||
return new AutoValue_LoadBalancer_Request_CreatePayload.Builder()
|
||||
.serverIds(ImmutableList.<String>of())
|
||||
.algorithm(Algorithm.ROUND_ROBIN);
|
||||
}
|
||||
|
||||
public static UpdatePayload.Builder updatingBuilder() {
|
||||
return new UpdatePayload.Builder();
|
||||
return new AutoValue_LoadBalancer_Request_UpdatePayload.Builder()
|
||||
.algorithm(Algorithm.ROUND_ROBIN);
|
||||
}
|
||||
|
||||
public static RegisterPayload.Builder registerBuilder() {
|
||||
return new RegisterPayload.Builder();
|
||||
public static RegisterPayload createRegisteringPaylod(String loadBalancerId, List<String> serverIds) {
|
||||
return new AutoValue_LoadBalancer_Request_RegisterPayload(loadBalancerId, ImmutableList.copyOf(serverIds));
|
||||
}
|
||||
|
||||
public static DeregisterPayload.Builder deregisterBuilder() {
|
||||
return new DeregisterPayload.Builder();
|
||||
public static DeregisterPayload createDeregisteringPayload(String loadBalancerId, List<String> serverIds) {
|
||||
return new AutoValue_LoadBalancer_Request_DeregisterPayload(loadBalancerId, ImmutableList.copyOf(serverIds));
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -218,63 +154,48 @@ public abstract class LoadBalancer {
|
|||
|
||||
public abstract String dataCenterId();
|
||||
|
||||
public abstract String loadBalancerName();
|
||||
@Nullable
|
||||
public abstract String name();
|
||||
|
||||
public abstract Algorithm loadBalancerAlgorithm();
|
||||
public abstract Algorithm algorithm();
|
||||
|
||||
@Nullable
|
||||
public abstract String ip();
|
||||
|
||||
public abstract String lanId();
|
||||
@Nullable
|
||||
public abstract Integer lanId();
|
||||
|
||||
public abstract List<String> serverIds();
|
||||
|
||||
public static CreatePayload create(String dataCenterId, String loadBalancerName, Algorithm loadBalancerAlgorithm, String ip, String lanId, List<String> serverIds) {
|
||||
return new AutoValue_LoadBalancer_Request_CreatePayload(dataCenterId, loadBalancerName, loadBalancerAlgorithm, ip, lanId,
|
||||
serverIds != null ? ImmutableList.copyOf(serverIds) : Lists.<String>newArrayList());
|
||||
}
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
public static class Builder {
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public String dataCenterId;
|
||||
public String loadBalancerName;
|
||||
public Algorithm loadBalancerAlgorithm;
|
||||
public String ip;
|
||||
public String lanId;
|
||||
public List<String> serverIds;
|
||||
public abstract Builder dataCenterId(String dataCenterId);
|
||||
|
||||
public Builder dataCenterId(String dataCenterId) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder loadBalancerName(String loadBalancerName) {
|
||||
this.loadBalancerName = loadBalancerName;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder algorithm(Algorithm algorithm);
|
||||
|
||||
public Builder loadBalancerAlgorithm(Algorithm loadBalancerAlgorithm) {
|
||||
this.loadBalancerAlgorithm = loadBalancerAlgorithm;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder ip(String ip);
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder lanId(Integer lanId);
|
||||
|
||||
public Builder lanId(String lanId) {
|
||||
this.lanId = lanId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder serverIds(List<String> serverIds);
|
||||
|
||||
public Builder serverIds(List<String> serverIds) {
|
||||
this.serverIds = serverIds;
|
||||
return this;
|
||||
}
|
||||
abstract CreatePayload autoBuild();
|
||||
|
||||
public CreatePayload build() {
|
||||
checkIp(ip);
|
||||
return CreatePayload.create(dataCenterId, loadBalancerName, loadBalancerAlgorithm, ip, lanId, serverIds);
|
||||
CreatePayload payload = autoBuild();
|
||||
if (payload.ip() != null)
|
||||
checkIp(payload.ip());
|
||||
if (payload.lanId() != null)
|
||||
checkLanId(payload.lanId());
|
||||
|
||||
return payload.toBuilder()
|
||||
.serverIds(ImmutableList.copyOf(payload.serverIds()))
|
||||
.autoBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,67 +203,19 @@ public abstract class LoadBalancer {
|
|||
@AutoValue
|
||||
public abstract static class RegisterPayload {
|
||||
|
||||
public abstract List<String> serverIds();
|
||||
|
||||
public abstract String id();
|
||||
|
||||
public static RegisterPayload create(List<String> serverIds, String id) {
|
||||
return new AutoValue_LoadBalancer_Request_RegisterPayload(
|
||||
serverIds != null ? ImmutableList.copyOf(serverIds) : Lists.<String>newArrayList(), id);
|
||||
}
|
||||
public abstract List<String> serverIds();
|
||||
|
||||
public static class Builder {
|
||||
|
||||
public List<String> serverIds;
|
||||
public String id;
|
||||
|
||||
public Builder serverIds(List<String> serverIds) {
|
||||
this.serverIds = serverIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RegisterPayload build() {
|
||||
return RegisterPayload.create(serverIds, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class DeregisterPayload {
|
||||
|
||||
public abstract List<String> serverIds();
|
||||
|
||||
public abstract String id();
|
||||
|
||||
public static DeregisterPayload create(List<String> serverIds, String id) {
|
||||
return new AutoValue_LoadBalancer_Request_DeregisterPayload(
|
||||
serverIds != null ? ImmutableList.copyOf(serverIds) : Lists.<String>newArrayList(), id);
|
||||
}
|
||||
public abstract List<String> serverIds();
|
||||
|
||||
public static class Builder {
|
||||
|
||||
public List<String> serverIds;
|
||||
public String id;
|
||||
|
||||
public Builder serverIds(List<String> serverIds) {
|
||||
this.serverIds = serverIds;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeregisterPayload build() {
|
||||
return DeregisterPayload.create(serverIds, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -350,49 +223,33 @@ public abstract class LoadBalancer {
|
|||
|
||||
public abstract String id();
|
||||
|
||||
@Nullable
|
||||
public abstract String name();
|
||||
|
||||
public abstract Algorithm loadBalancerAlgorithm();
|
||||
public abstract Algorithm algorithm();
|
||||
|
||||
@Nullable
|
||||
public abstract String ip();
|
||||
|
||||
public static UpdatePayload create(String id, String name, Algorithm loadBalancerAlgorithm, String ip) {
|
||||
return new AutoValue_LoadBalancer_Request_UpdatePayload(id, name, loadBalancerAlgorithm, ip);
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public static class Builder {
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public String id;
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public String name;
|
||||
public abstract Builder algorithm(Algorithm algorithm);
|
||||
|
||||
public Algorithm loadBalancerAlgorithm;
|
||||
public abstract Builder ip(String ip);
|
||||
|
||||
public String ip;
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder loadBalancerName(String loadBalancerName) {
|
||||
this.name = loadBalancerName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder loadBalancerAlgorithm(Algorithm loadBalancerAlgorithm) {
|
||||
this.loadBalancerAlgorithm = loadBalancerAlgorithm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
}
|
||||
abstract UpdatePayload autoBuild();
|
||||
|
||||
public UpdatePayload build() {
|
||||
checkIp(ip);
|
||||
return UpdatePayload.create(id, name, loadBalancerAlgorithm, ip);
|
||||
UpdatePayload payload = autoBuild();
|
||||
if (payload.ip() != null)
|
||||
checkIp(payload.ip());
|
||||
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
|
||||
public enum Location {
|
||||
|
||||
DE_FKB("de/fkb", "Germany, Karlsruhe"),
|
||||
|
@ -41,11 +43,7 @@ public enum Location {
|
|||
}
|
||||
|
||||
public static Location fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(Location.class, v).or(UNRECOGNIZED);
|
||||
}
|
||||
|
||||
public static Location fromId(String id) {
|
||||
|
|
|
@ -16,14 +16,15 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.net.InetAddresses.isInetAddress;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkIp;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkIps;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkLanId;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkMacAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
|
@ -39,9 +40,11 @@ public abstract class Nic {
|
|||
@Nullable
|
||||
public abstract String dataCenterId();
|
||||
|
||||
public abstract int lanId();
|
||||
@Nullable
|
||||
public abstract Integer lanId();
|
||||
|
||||
public abstract boolean internetAccess();
|
||||
@Nullable
|
||||
public abstract Boolean internetAccess();
|
||||
|
||||
@Nullable
|
||||
public abstract String serverId();
|
||||
|
@ -53,9 +56,10 @@ public abstract class Nic {
|
|||
public abstract String macAddress();
|
||||
|
||||
@Nullable
|
||||
public abstract Firewall firewalls();
|
||||
public abstract Firewall firewall();
|
||||
|
||||
public abstract boolean dhcpActive();
|
||||
@Nullable
|
||||
public abstract Boolean dhcpActive();
|
||||
|
||||
@Nullable
|
||||
public abstract String gatewayIp();
|
||||
|
@ -63,158 +67,81 @@ public abstract class Nic {
|
|||
@Nullable
|
||||
public abstract ProvisioningState state();
|
||||
|
||||
public static Nic create(String id, String name, String dataCenterId, int lanId, boolean internetAccess,
|
||||
String serverId, List<String> ips, String macAddress, Firewall firewall, boolean dhcpActive,
|
||||
String gatewayIp, ProvisioningState state) {
|
||||
return new AutoValue_Nic(id, name, dataCenterId, lanId, internetAccess, serverId,
|
||||
ips != null ? ImmutableList.copyOf(ips) : ImmutableList.<String>of(), macAddress,
|
||||
firewall, dhcpActive, gatewayIp, state);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_Nic.Builder()
|
||||
.ips(ImmutableList.<String>of());
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromNic(this);
|
||||
}
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
private static void checkIp(String ip) {
|
||||
if (ip != null)
|
||||
checkArgument(isInetAddress(ip), "Invalid IP");
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private static void checkIps(List<String> ips) {
|
||||
for (String ip : ips)
|
||||
checkIp(ip);
|
||||
}
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public static class Builder {
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public String id;
|
||||
public abstract Builder dataCenterId(String dataCenterId);
|
||||
|
||||
public String name;
|
||||
public abstract Builder lanId(Integer lanId);
|
||||
|
||||
public String dataCenterId;
|
||||
public abstract Builder internetAccess(Boolean internetAccess);
|
||||
|
||||
public int lanId;
|
||||
public abstract Builder serverId(String serverId);
|
||||
|
||||
public boolean internetAccess;
|
||||
public abstract Builder ips(List<String> ips);
|
||||
|
||||
public String serverId;
|
||||
public abstract Builder macAddress(String macAddress);
|
||||
|
||||
@Nullable
|
||||
public List<String> ips;
|
||||
public abstract Builder firewall(Firewall firewall);
|
||||
|
||||
public String macAddress;
|
||||
public abstract Builder dhcpActive(Boolean dhcpActive);
|
||||
|
||||
public Firewall firewall;
|
||||
public abstract Builder gatewayIp(String gatewayIp);
|
||||
|
||||
public boolean dhcpActive;
|
||||
public abstract Builder state(ProvisioningState state);
|
||||
|
||||
public String gatewayIp;
|
||||
|
||||
public ProvisioningState state;
|
||||
|
||||
public Builder() {
|
||||
this.ips = Lists.newArrayList();
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder dataCenterId(String dataCenterId) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder lanId(int lanId) {
|
||||
this.lanId = lanId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder internetAccess(boolean internetAccess) {
|
||||
this.internetAccess = internetAccess;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder serverId(String serverId) {
|
||||
this.serverId = serverId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ips(List<String> ips) {
|
||||
this.ips = ips;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ips.add(ip);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder macAddress(String macAddress) {
|
||||
this.macAddress = macAddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder dhcpActive(boolean dhcpActive) {
|
||||
this.dhcpActive = dhcpActive;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder gatewayIp(String gatewayIp) {
|
||||
this.gatewayIp = gatewayIp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder state(ProvisioningState state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder firewall(Firewall firewall) {
|
||||
this.firewall = firewall;
|
||||
return this;
|
||||
}
|
||||
abstract Nic autoBuild();
|
||||
|
||||
public Nic build() {
|
||||
checkIps(ips);
|
||||
return Nic.create(id, name, dataCenterId, lanId, internetAccess, serverId, ips,
|
||||
macAddress, firewall, dhcpActive, gatewayIp, state);
|
||||
Nic nic = autoBuild();
|
||||
if (nic.ips() != null)
|
||||
checkIps(nic.ips());
|
||||
if (nic.gatewayIp() != null)
|
||||
checkIp(nic.gatewayIp());
|
||||
if (nic.lanId() != null)
|
||||
checkLanId(nic.lanId());
|
||||
if (nic.macAddress() != null)
|
||||
checkMacAddress(nic.macAddress());
|
||||
|
||||
return nic.toBuilder()
|
||||
.ips(ImmutableList.copyOf(nic.ips()))
|
||||
.autoBuild();
|
||||
}
|
||||
|
||||
private Builder fromNic(Nic in) {
|
||||
return this.id(in.id()).name(in.name()).lanId(in.lanId()).internetAccess(in.internetAccess())
|
||||
.serverId(in.serverId()).ips(in.ips()).macAddress(in.macAddress()).dhcpActive(in.dhcpActive())
|
||||
.gatewayIp(in.gatewayIp()).dataCenterId(dataCenterId);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Request {
|
||||
|
||||
public static CreatePayload.Builder creatingBuilder() {
|
||||
return new CreatePayload.Builder();
|
||||
return new AutoValue_Nic_Request_CreatePayload.Builder();
|
||||
}
|
||||
|
||||
public static UpdatePayload.Builder updatingBuilder() {
|
||||
return new UpdatePayload.Builder();
|
||||
return new AutoValue_Nic_Request_UpdatePayload.Builder();
|
||||
}
|
||||
|
||||
public static SetInternetAccessPayload.Builder setInternetAccessBuilder() {
|
||||
return new SetInternetAccessPayload.Builder();
|
||||
return new AutoValue_Nic_Request_SetInternetAccessPayload.Builder();
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class CreatePayload {
|
||||
|
||||
public abstract String serverId();
|
||||
|
||||
public abstract int lanId();
|
||||
|
||||
@Nullable
|
||||
public abstract String ip();
|
||||
|
||||
|
@ -224,54 +151,30 @@ public abstract class Nic {
|
|||
@Nullable
|
||||
public abstract Boolean dhcpActive();
|
||||
|
||||
public abstract String serverId();
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public abstract int lanId();
|
||||
public abstract Builder serverId(String serverId);
|
||||
|
||||
public static CreatePayload create(String ip, String name, Boolean dhcpActive, String serverId, int lanId) {
|
||||
return new AutoValue_Nic_Request_CreatePayload(ip, name, dhcpActive, serverId, lanId);
|
||||
}
|
||||
public abstract Builder lanId(int lanId);
|
||||
|
||||
public static class Builder {
|
||||
public abstract Builder ip(String ip);
|
||||
|
||||
private String ip;
|
||||
private String name;
|
||||
private Boolean dhcpActive;
|
||||
private String serverId;
|
||||
private int lanId;
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder dhcpActive(Boolean dhcpActive);
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder dhcpActive(Boolean dhcpActive) {
|
||||
this.dhcpActive = dhcpActive;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder serverId(String serverId) {
|
||||
this.serverId = serverId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder lanId(int lanId) {
|
||||
this.lanId = lanId;
|
||||
return this;
|
||||
}
|
||||
abstract CreatePayload autoBuild();
|
||||
|
||||
public CreatePayload build() {
|
||||
checkIp(ip);
|
||||
return CreatePayload.create(ip, name, dhcpActive, serverId, lanId);
|
||||
CreatePayload payload = autoBuild();
|
||||
if (payload.ip() != null)
|
||||
checkIp(payload.ip());
|
||||
checkLanId(payload.lanId());
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -288,48 +191,32 @@ public abstract class Nic {
|
|||
@Nullable
|
||||
public abstract Boolean dhcpActive();
|
||||
|
||||
public abstract int lanId();
|
||||
@Nullable
|
||||
public abstract Integer lanId();
|
||||
|
||||
public static UpdatePayload create(String id, String ip, String name, Boolean dhcpActive, int lanId) {
|
||||
return new AutoValue_Nic_Request_UpdatePayload(id, ip, name, dhcpActive, lanId);
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public static class Builder {
|
||||
public abstract Builder id(String id);
|
||||
|
||||
private String id;
|
||||
private String ip;
|
||||
private String name;
|
||||
private Boolean dhcpActive;
|
||||
private int lanId;
|
||||
public abstract Builder ip(String ip);
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder dhcpActive(Boolean dhcpActive);
|
||||
|
||||
public Builder dhcpActive(Boolean dhcpActive) {
|
||||
this.dhcpActive = dhcpActive;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder lanId(Integer lanId);
|
||||
|
||||
public Builder lanId(int lanId) {
|
||||
this.lanId = lanId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
abstract UpdatePayload autoBuild();
|
||||
|
||||
public UpdatePayload build() {
|
||||
checkIp(ip);
|
||||
return UpdatePayload.create(id, ip, name, dhcpActive, lanId);
|
||||
UpdatePayload payload = autoBuild();
|
||||
if (payload.ip() != null)
|
||||
checkIp(payload.ip());
|
||||
if (payload.lanId() != null)
|
||||
checkLanId(payload.lanId());
|
||||
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -343,35 +230,19 @@ public abstract class Nic {
|
|||
|
||||
public abstract boolean internetAccess();
|
||||
|
||||
public static SetInternetAccessPayload create(String dataCenterId, int lanId, boolean internetAccess) {
|
||||
return new AutoValue_Nic_Request_SetInternetAccessPayload(dataCenterId, lanId, internetAccess);
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public static class Builder {
|
||||
public abstract Builder dataCenterId(String dataCenterId);
|
||||
|
||||
public String dataCenterId;
|
||||
public int lanId;
|
||||
public boolean internetAccess;
|
||||
public abstract Builder lanId(int lanId);
|
||||
|
||||
public Builder dataCenterId(String dataCenterId) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder internetAccess(boolean internetAccess);
|
||||
|
||||
public Builder lanId(int lanId) {
|
||||
this.lanId = lanId;
|
||||
return this;
|
||||
}
|
||||
public abstract SetInternetAccessPayload build();
|
||||
|
||||
public Builder internetAccess(boolean internetAccess) {
|
||||
this.internetAccess = internetAccess;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SetInternetAccessPayload build() {
|
||||
return SetInternetAccessPayload.create(dataCenterId, lanId, internetAccess);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,15 +16,13 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
|
||||
public enum OsType {
|
||||
|
||||
WINDOWS, LINUX, OTHER, UNRECOGNIZED;
|
||||
|
||||
public static OsType fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(OsType.class, v).or(UNRECOGNIZED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
/**
|
||||
* Marker interface for {@link org.jclouds.profitbricks.domain.Image} and
|
||||
* {@link org.jclouds.profitbricks.domain.Snapshot}
|
||||
*/
|
||||
public interface Provisionable {
|
||||
|
||||
}
|
|
@ -16,15 +16,13 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
|
||||
public enum ProvisioningState {
|
||||
|
||||
INACTIVE, INPROCESS, AVAILABLE, DELETED, ERROR, UNRECOGNIZED;
|
||||
|
||||
public static ProvisioningState fromValue(String value) {
|
||||
try {
|
||||
return valueOf(value);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(ProvisioningState.class, value).or(UNRECOGNIZED);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,24 +16,20 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import org.jclouds.profitbricks.domain.internal.ServerCommonProperties;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkCores;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkRam;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.profitbricks.domain.internal.HotPluggable;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
@AutoValue
|
||||
public abstract class Server implements ServerCommonProperties {
|
||||
public abstract class Server {
|
||||
|
||||
public enum Status {
|
||||
|
||||
|
@ -44,11 +40,7 @@ public abstract class Server implements ServerCommonProperties {
|
|||
}
|
||||
|
||||
public static Status fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(Status.class, v).or(UNRECOGNIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,9 +51,14 @@ public abstract class Server implements ServerCommonProperties {
|
|||
public abstract String id();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public abstract String name();
|
||||
|
||||
@Nullable
|
||||
public abstract Integer cores();
|
||||
|
||||
@Nullable
|
||||
public abstract Integer ram();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean hasInternetAccess();
|
||||
|
||||
|
@ -95,179 +92,130 @@ public abstract class Server implements ServerCommonProperties {
|
|||
@Nullable
|
||||
public abstract Boolean loadBalanced();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract String hostname(); // Non-profitbricks property; Added to hold hostname parsed from image temporarily
|
||||
|
||||
public static Server create(DataCenter dataCenter, String id, String name, int cores, int ram,
|
||||
Boolean hasInternetAccess, ProvisioningState state, Status status, OsType osType,
|
||||
AvailabilityZone availabilityZone, Date creationTime, Date lastModificationTime, List<Storage> storages,
|
||||
List<Nic> nics, Boolean isCpuHotPlug, Boolean isRamHotPlug, Boolean isNicHotPlug, Boolean isNicHotUnPlug,
|
||||
Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug, String balancedNicId, Boolean loadBalanced,
|
||||
String hostname) {
|
||||
return new AutoValue_Server(isCpuHotPlug, null, isRamHotPlug, null, isNicHotPlug, isNicHotUnPlug, isDiscVirtioHotPlug,
|
||||
isDiscVirtioHotUnPlug, cores, ram, dataCenter, id, name, hasInternetAccess, state, status, osType,
|
||||
availabilityZone, creationTime, lastModificationTime,
|
||||
storages != null ? ImmutableList.copyOf(storages) : Lists.<Storage>newArrayList(),
|
||||
nics != null ? ImmutableList.copyOf(nics) : Lists.<Nic>newArrayList(),
|
||||
balancedNicId, loadBalanced, hostname);
|
||||
public static Builder builder() {
|
||||
return new AutoValue_Server.Builder()
|
||||
.storages(ImmutableList.<Storage>of())
|
||||
.nics(ImmutableList.<Nic>of());
|
||||
}
|
||||
|
||||
public static DescribingBuilder builder() {
|
||||
return new DescribingBuilder();
|
||||
}
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
public DescribingBuilder toBuilder() {
|
||||
return builder().fromServer(this);
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public abstract static class Builder<B extends Builder, D extends ServerCommonProperties> extends HotPluggable.Builder<B, D> {
|
||||
public abstract Builder dataCenter(DataCenter dataCenter);
|
||||
|
||||
protected String name;
|
||||
protected int cores;
|
||||
protected int ram;
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public B name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public B cores(int cores) {
|
||||
this.cores = cores;
|
||||
return self();
|
||||
}
|
||||
public abstract Builder cores(Integer cores);
|
||||
|
||||
public B ram(int ram) {
|
||||
this.ram = ram;
|
||||
return self();
|
||||
}
|
||||
}
|
||||
public abstract Builder ram(Integer ram);
|
||||
|
||||
public static class DescribingBuilder extends Builder<DescribingBuilder, Server> {
|
||||
public abstract Builder hasInternetAccess(Boolean internetAccess);
|
||||
|
||||
private DataCenter dataCenter;
|
||||
private String id;
|
||||
private ProvisioningState state;
|
||||
private Status status;
|
||||
private OsType osType;
|
||||
private AvailabilityZone zone;
|
||||
private Date creationTime;
|
||||
private Date lastModificationTime;
|
||||
private Boolean hasInternetAccess;
|
||||
private List<Storage> storages;
|
||||
private List<Nic> nics;
|
||||
private Boolean loadBalanced;
|
||||
private String balancedNicId;
|
||||
private String hostname;
|
||||
public abstract Builder state(ProvisioningState state);
|
||||
|
||||
public DescribingBuilder dataCenter(DataCenter dataCenter) {
|
||||
this.dataCenter = dataCenter;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder status(Status status);
|
||||
|
||||
public DescribingBuilder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder osType(OsType osType);
|
||||
|
||||
public DescribingBuilder state(ProvisioningState state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder availabilityZone(AvailabilityZone availabilityZone);
|
||||
|
||||
public DescribingBuilder status(Status status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder creationTime(Date creationTime);
|
||||
|
||||
public DescribingBuilder osType(OsType osType) {
|
||||
this.osType = osType;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder lastModificationTime(Date lastModificationTime);
|
||||
|
||||
public DescribingBuilder availabilityZone(AvailabilityZone zone) {
|
||||
this.zone = zone;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder storages(List<Storage> storages);
|
||||
|
||||
public DescribingBuilder creationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder nics(List<Nic> nics);
|
||||
|
||||
public DescribingBuilder lastModificationTime(Date lastModificationTime) {
|
||||
this.lastModificationTime = lastModificationTime;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder balancedNicId(String balancedNicIds);
|
||||
|
||||
public DescribingBuilder hasInternetAccess(Boolean hasInternetAccess) {
|
||||
this.hasInternetAccess = hasInternetAccess;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder loadBalanced(Boolean isLoadBalanced);
|
||||
|
||||
public DescribingBuilder storages(List<Storage> storages) {
|
||||
this.storages = storages;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder isCpuHotPlug(Boolean isCpuHotPlug);
|
||||
|
||||
public DescribingBuilder nics(List<Nic> nics) {
|
||||
this.nics = nics;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder isCpuHotUnPlug(Boolean isCpuHotUnPlug);
|
||||
|
||||
public DescribingBuilder balancedNicId(String balancedNicId) {
|
||||
this.balancedNicId = balancedNicId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder isRamHotPlug(Boolean isRamHotPlug);
|
||||
|
||||
public DescribingBuilder loadBalanced(Boolean loadBalanced) {
|
||||
this.loadBalanced = loadBalanced;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder isRamHotUnPlug(Boolean isRamHotUnPlug);
|
||||
|
||||
public DescribingBuilder hostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder isNicHotPlug(Boolean isNicHotPlug);
|
||||
|
||||
public abstract Builder isNicHotUnPlug(Boolean isNicHotUnPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotPlug(Boolean isDiscVirtioHotPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotUnPlug(Boolean isDiscVirtioHotUnPlug);
|
||||
|
||||
public abstract Builder hostname(String hostname);
|
||||
|
||||
abstract Server autoBuild();
|
||||
|
||||
@Override
|
||||
public Server build() {
|
||||
return Server.create(dataCenter, id, name, cores, ram, hasInternetAccess, state, status, osType, zone, creationTime,
|
||||
lastModificationTime, storages, nics, cpuHotPlug, ramHotPlug, nicHotPlug, nicHotUnPlug,
|
||||
discVirtioHotPlug, discVirtioHotUnPlug, balancedNicId, loadBalanced, hostname);
|
||||
Server server = autoBuild();
|
||||
if (server.cores() != null)
|
||||
checkCores(server.cores());
|
||||
if (server.ram() != null)
|
||||
checkRam(server.ram(), server.isRamHotUnPlug());
|
||||
return server.toBuilder()
|
||||
.storages(ImmutableList.copyOf(server.storages()))
|
||||
.nics(ImmutableList.copyOf(server.nics()))
|
||||
.autoBuild();
|
||||
}
|
||||
|
||||
private DescribingBuilder fromServer(Server in) {
|
||||
return this.id(in.id()).cores(in.cores()).creationTime(in.creationTime()).hasInternetAccess(in.hasInternetAccess())
|
||||
.isCpuHotPlug(in.isCpuHotPlug()).isDiscVirtioHotPlug(in.isDiscVirtioHotPlug())
|
||||
.isDiscVirtioHotUnPlug(in.isDiscVirtioHotUnPlug()).isNicHotPlug(in.isNicHotPlug())
|
||||
.isNicHotUnPlug(in.isNicHotUnPlug()).isRamHotPlug(in.isRamHotPlug())
|
||||
.lastModificationTime(in.lastModificationTime()).name(in.name()).osType(in.osType()).ram(in.ram())
|
||||
.state(in.state()).status(in.status()).storages(in.storages()).nics(in.nics()).dataCenter(in.dataCenter())
|
||||
.balancedNicId(balancedNicId).loadBalanced(loadBalanced).hostname(hostname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescribingBuilder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final class Request {
|
||||
|
||||
public static CreatePayload.Builder creatingBuilder() {
|
||||
return new CreatePayload.Builder();
|
||||
return new AutoValue_Server_Request_CreatePayload.Builder();
|
||||
}
|
||||
|
||||
public static UpdatePayload.Builder updatingBuilder() {
|
||||
return new UpdatePayload.Builder();
|
||||
return new AutoValue_Server_Request_UpdatePayload.Builder();
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class CreatePayload implements ServerCommonProperties {
|
||||
public abstract static class CreatePayload {
|
||||
|
||||
public abstract int cores();
|
||||
|
||||
public abstract int ram();
|
||||
|
||||
public abstract String dataCenterId();
|
||||
|
||||
public abstract String name();
|
||||
|
||||
@Nullable
|
||||
public abstract String bootFromStorageId();
|
||||
|
||||
|
@ -286,94 +234,95 @@ public abstract class Server implements ServerCommonProperties {
|
|||
@Nullable
|
||||
public abstract OsType osType();
|
||||
|
||||
public static CreatePayload create(String dataCenterId, String name, int core, int ram) {
|
||||
return create(dataCenterId, name, core, ram, "", "", null, false, null, null, null, null, null, null, null, null);
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotPlug();
|
||||
|
||||
public static CreatePayload create(String dataCenterId, String name, int cores, int ram, String bootFromStorageId,
|
||||
String bootFromImageId, Integer lanId, Boolean hasInternetAccess, AvailabilityZone availabilityZone,
|
||||
OsType osType, Boolean isCpuHotPlug, Boolean isRamHotPlug, Boolean isNicHotPlug, Boolean isNicHotUnPlug,
|
||||
Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug) {
|
||||
validateCores(cores);
|
||||
validateRam(ram, isRamHotPlug);
|
||||
return new AutoValue_Server_Request_CreatePayload(isCpuHotPlug, null, isRamHotPlug, null, isNicHotPlug,
|
||||
isNicHotUnPlug, isDiscVirtioHotPlug, isDiscVirtioHotUnPlug, name, cores, ram, dataCenterId,
|
||||
bootFromStorageId, bootFromImageId, lanId, hasInternetAccess, availabilityZone, osType);
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotUnPlug();
|
||||
|
||||
public static class Builder extends Server.Builder<Builder, CreatePayload> {
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotPlug();
|
||||
|
||||
private String dataCenterId;
|
||||
private String bootFromStorageId;
|
||||
private String bootFromImageId;
|
||||
private Integer lanId;
|
||||
private Boolean hasInternetAccess;
|
||||
private AvailabilityZone availabilityZone;
|
||||
private OsType osType;
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotUnPlug();
|
||||
|
||||
public Builder dataCenterId(String dataCenterId) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotPlug();
|
||||
|
||||
public Builder dataCenterId(DataCenter dataCenter) {
|
||||
this.dataCenterId = checkNotNull(dataCenter, "Cannot pass null datacenter").id();
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotUnPlug();
|
||||
|
||||
public Builder bootFromStorageId(String storageId) {
|
||||
this.bootFromStorageId = storageId;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotPlug();
|
||||
|
||||
public Builder bootFromImageId(String image) {
|
||||
this.bootFromImageId = image;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotUnPlug();
|
||||
|
||||
public Builder lanId(Integer lanId) {
|
||||
this.lanId = lanId;
|
||||
return this;
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public Builder availabilityZone(AvailabilityZone zone) {
|
||||
this.availabilityZone = zone;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder cores(int cores);
|
||||
|
||||
public Builder osType(OsType osType) {
|
||||
this.osType = osType;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder ram(int ram);
|
||||
|
||||
public Builder hasInternetAccess(Boolean hasInternetAccess) {
|
||||
this.hasInternetAccess = hasInternetAccess;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder dataCenterId(String dataCenterId);
|
||||
|
||||
@Override
|
||||
public Builder self() {
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public abstract Builder bootFromStorageId(String bootFromStorageId);
|
||||
|
||||
public abstract Builder bootFromImageId(String bootFromImageId);
|
||||
|
||||
public abstract Builder lanId(Integer lanId);
|
||||
|
||||
public abstract Builder hasInternetAccess(Boolean hasInternetAccess);
|
||||
|
||||
public abstract Builder availabilityZone(AvailabilityZone availabilityZone);
|
||||
|
||||
public abstract Builder osType(OsType osType);
|
||||
|
||||
public abstract Builder isCpuHotPlug(Boolean isCpuHotPlug);
|
||||
|
||||
public abstract Builder isCpuHotUnPlug(Boolean isCpuHotUnPlug);
|
||||
|
||||
public abstract Builder isRamHotPlug(Boolean isRamHotPlug);
|
||||
|
||||
public abstract Builder isRamHotUnPlug(Boolean isRamHotUnPlug);
|
||||
|
||||
public abstract Builder isNicHotPlug(Boolean isNicHotPlug);
|
||||
|
||||
public abstract Builder isNicHotUnPlug(Boolean isNicHotUnPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotPlug(Boolean isDiscVirtioHotPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotUnPlug(Boolean isDiscVirtioHotUnPlug);
|
||||
|
||||
abstract CreatePayload autoBuild();
|
||||
|
||||
@Override
|
||||
public CreatePayload build() {
|
||||
return CreatePayload.create(dataCenterId, name, cores, ram, bootFromStorageId, bootFromImageId, lanId, hasInternetAccess,
|
||||
availabilityZone, osType, cpuHotPlug, ramHotPlug, nicHotPlug, nicHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug);
|
||||
CreatePayload payload = autoBuild();
|
||||
checkCores(payload.cores());
|
||||
checkRam(payload.ram(), payload.isRamHotUnPlug());
|
||||
return payload;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class UpdatePayload implements ServerCommonProperties {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public abstract String name();
|
||||
public abstract static class UpdatePayload {
|
||||
|
||||
public abstract String id();
|
||||
|
||||
@Nullable
|
||||
public abstract Integer cores();
|
||||
|
||||
@Nullable
|
||||
public abstract Integer ram();
|
||||
|
||||
@Nullable
|
||||
public abstract String name();
|
||||
|
||||
@Nullable
|
||||
public abstract String bootFromStorageId();
|
||||
|
||||
|
@ -386,71 +335,76 @@ public abstract class Server implements ServerCommonProperties {
|
|||
@Nullable
|
||||
public abstract OsType osType();
|
||||
|
||||
public static UpdatePayload create(String id, String name, int cores, int ram, String bootFromStorageId, String bootFromImageId,
|
||||
AvailabilityZone availabilityZone, OsType osType, Boolean isCpuHotPlug, Boolean isRamHotPlug, Boolean isNicHotPlug,
|
||||
Boolean isNicHotUnPlug, Boolean isDiscVirtioHotPlug, Boolean isDiscVirtioHotUnPlug) {
|
||||
return new AutoValue_Server_Request_UpdatePayload(isCpuHotPlug, null, isRamHotPlug, null, isNicHotPlug,
|
||||
isNicHotUnPlug, isDiscVirtioHotPlug, isDiscVirtioHotUnPlug, cores, ram, name, id, bootFromStorageId,
|
||||
bootFromImageId, availabilityZone, osType);
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotPlug();
|
||||
|
||||
public static class Builder extends Server.Builder<Builder, UpdatePayload> {
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotUnPlug();
|
||||
|
||||
private String id;
|
||||
private String bootFromStorageId;
|
||||
private String bootFromImageId;
|
||||
private AvailabilityZone availabilityZone;
|
||||
private OsType osType;
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotPlug();
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotUnPlug();
|
||||
|
||||
public Builder bootFromStorageId(String storageId) {
|
||||
this.bootFromStorageId = storageId;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotPlug();
|
||||
|
||||
public Builder bootFromImageId(String image) {
|
||||
this.bootFromImageId = image;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotUnPlug();
|
||||
|
||||
public Builder availabilityZone(AvailabilityZone zone) {
|
||||
this.availabilityZone = zone;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotPlug();
|
||||
|
||||
public Builder osType(OsType osType) {
|
||||
this.osType = osType;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotUnPlug();
|
||||
|
||||
@Override
|
||||
public Builder self() {
|
||||
return this;
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public abstract Builder cores(Integer cores);
|
||||
|
||||
public abstract Builder ram(Integer ram);
|
||||
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public abstract Builder bootFromStorageId(String bootFromStorageId);
|
||||
|
||||
public abstract Builder bootFromImageId(String bootFromImageId);
|
||||
|
||||
public abstract Builder availabilityZone(AvailabilityZone availabilityZone);
|
||||
|
||||
public abstract Builder osType(OsType osType);
|
||||
|
||||
public abstract Builder isCpuHotPlug(Boolean isCpuHotPlug);
|
||||
|
||||
public abstract Builder isCpuHotUnPlug(Boolean isCpuHotUnPlug);
|
||||
|
||||
public abstract Builder isRamHotPlug(Boolean isRamHotPlug);
|
||||
|
||||
public abstract Builder isRamHotUnPlug(Boolean isRamHotUnPlug);
|
||||
|
||||
public abstract Builder isNicHotPlug(Boolean isNicHotPlug);
|
||||
|
||||
public abstract Builder isNicHotUnPlug(Boolean isNicHotUnPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotPlug(Boolean isDiscVirtioHotPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotUnPlug(Boolean isDiscVirtioHotUnPlug);
|
||||
|
||||
abstract UpdatePayload autoBuild();
|
||||
|
||||
@Override
|
||||
public UpdatePayload build() {
|
||||
return UpdatePayload.create(id, name, cores, ram, bootFromStorageId, bootFromImageId, availabilityZone, osType,
|
||||
cpuHotPlug, ramHotPlug, nicHotPlug, nicHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug);
|
||||
|
||||
UpdatePayload payload = autoBuild();
|
||||
if (payload.cores() != null)
|
||||
checkCores(payload.cores());
|
||||
if (payload.ram() != null)
|
||||
checkRam(payload.ram(), payload.isRamHotUnPlug());
|
||||
return payload;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void validateCores(int cores) {
|
||||
checkArgument(cores > 0, "Core must be atleast 1.");
|
||||
}
|
||||
|
||||
private static void validateRam(int ram, Boolean isRamHotPlug) {
|
||||
int minRam = (isRamHotPlug == null || !isRamHotPlug) ? 256 : 1024;
|
||||
checkArgument(ram >= minRam && ram % 256 == 0, "RAM must be multiples of 256 with minimum of 256 MB (1024 MB if ramHotPlug is enabled)");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Enums;
|
||||
|
||||
@AutoValue
|
||||
public abstract class ServiceFault {
|
||||
|
@ -36,11 +37,7 @@ public abstract class ServiceFault {
|
|||
UNRECOGNIZED;
|
||||
|
||||
public static FaultCode fromValue(String v) {
|
||||
try {
|
||||
return valueOf(v);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(FaultCode.class, v).or(UNRECOGNIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,44 +49,22 @@ public abstract class ServiceFault {
|
|||
|
||||
public abstract int requestId();
|
||||
|
||||
public static ServiceFault create(FaultCode faultCode, int httpCode, String message, int requestId) {
|
||||
return new AutoValue_ServiceFault(faultCode, httpCode, message, requestId);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_ServiceFault.Builder();
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private FaultCode faultCode;
|
||||
private int httpCode;
|
||||
private String message;
|
||||
private int requestId;
|
||||
public abstract Builder faultCode(FaultCode faultCode);
|
||||
|
||||
public Builder faultCode(FaultCode code) {
|
||||
this.faultCode = code;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder httpCode(int httpCode);
|
||||
|
||||
public Builder httpCode(int httpCode) {
|
||||
this.httpCode = httpCode;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder message(String message);
|
||||
|
||||
public Builder message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder requestId(int requestId);
|
||||
|
||||
public Builder requestId(int requestId) {
|
||||
this.requestId = requestId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServiceFault build() {
|
||||
return create(faultCode, httpCode, message, requestId);
|
||||
}
|
||||
public abstract ServiceFault build();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,35 +16,36 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.profitbricks.domain.internal.HotPluggable;
|
||||
import org.jclouds.profitbricks.domain.internal.Provisionable;
|
||||
|
||||
@AutoValue
|
||||
public abstract class Snapshot implements Provisionable {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public abstract String id();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public abstract String name();
|
||||
|
||||
public abstract boolean bootable();
|
||||
@Nullable
|
||||
public abstract Float size();
|
||||
|
||||
@Nullable
|
||||
public abstract Location location();
|
||||
|
||||
@Nullable
|
||||
public abstract OsType osType();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isBootable();
|
||||
|
||||
@Nullable
|
||||
public abstract String description();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public abstract OsType osType();
|
||||
|
||||
@Nullable
|
||||
public abstract Date creationTime();
|
||||
|
||||
|
@ -55,89 +56,89 @@ public abstract class Snapshot implements Provisionable {
|
|||
public abstract ProvisioningState state();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public abstract Location location();
|
||||
public abstract Boolean isCpuHotPlug();
|
||||
|
||||
public static Snapshot create(String id, String name, float size, boolean bootable, String description, OsType osType,
|
||||
Boolean cpuHotPlug, Boolean cpuHotUnPlug, Boolean discVirtioHotPlug, Boolean discVirtioHotUnPlug,
|
||||
Boolean ramHotPlug, Boolean ramHotUnPlug, Boolean nicHotPlug, Boolean nicHotUnPlug, Date creationTime,
|
||||
Date lastModificationTime, ProvisioningState state, Location location) {
|
||||
return new AutoValue_Snapshot(cpuHotPlug, cpuHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug, ramHotPlug,
|
||||
ramHotUnPlug, nicHotPlug, nicHotUnPlug, size, id, name, bootable, description, osType, creationTime,
|
||||
lastModificationTime, state, location);
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotPlug();
|
||||
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotUnPlug();
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_Snapshot.Builder();
|
||||
}
|
||||
|
||||
public static class Builder extends Provisionable.Builder<Builder, Snapshot> {
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
private Date creationTime;
|
||||
private Date lastModificationTime;
|
||||
private ProvisioningState state;
|
||||
private boolean bootable;
|
||||
private String description;
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public Builder creationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public Builder lastModificationTime(Date lastModificationTime) {
|
||||
this.lastModificationTime = lastModificationTime;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder state(ProvisioningState state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder size(Float size);
|
||||
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder location(Location location);
|
||||
|
||||
public Builder isBootable(boolean bootable) {
|
||||
this.bootable = bootable;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder osType(OsType osType);
|
||||
|
||||
private Builder fromSnapshot(Snapshot in) {
|
||||
return this.id(in.id()).name(in.name()).size(in.size()).creationTime(in.creationTime())
|
||||
.lastModificationTime(in.lastModificationTime()).state(in.state()).isBootable(in.bootable())
|
||||
.description(in.description()).isCpuHotPlug(in.isCpuHotPlug()).isCpuHotUnPlug(in.isCpuHotUnPlug())
|
||||
.isDiscVirtioHotPlug(in.isDiscVirtioHotPlug()).isDiscVirtioHotUnPlug(in.isDiscVirtioHotUnPlug())
|
||||
.isRamHotPlug(in.isRamHotPlug()).isRamHotUnPlug(in.isRamHotUnPlug())
|
||||
.isNicHotPlug(in.isNicHotPlug()).isNicHotUnPlug(in.isNicHotUnPlug());
|
||||
}
|
||||
public abstract Builder isBootable(Boolean bootable);
|
||||
|
||||
@Override
|
||||
public Snapshot build() {
|
||||
return Snapshot.create(id, name, size, bootable, description, osType, cpuHotPlug, cpuHotUnPlug,
|
||||
discVirtioHotPlug, discVirtioHotUnPlug, ramHotPlug, ramHotUnPlug, nicHotPlug, nicHotUnPlug,
|
||||
creationTime, lastModificationTime, state, location);
|
||||
}
|
||||
public abstract Builder description(String description);
|
||||
|
||||
@Override
|
||||
public Builder self() {
|
||||
return this;
|
||||
}
|
||||
public abstract Builder creationTime(Date creationTime);
|
||||
|
||||
public abstract Builder lastModificationTime(Date lastModificationTime);
|
||||
|
||||
public abstract Builder state(ProvisioningState state);
|
||||
|
||||
public abstract Builder isCpuHotPlug(Boolean isCpuHotPlug);
|
||||
|
||||
public abstract Builder isCpuHotUnPlug(Boolean isCpuHotUnPlug);
|
||||
|
||||
public abstract Builder isRamHotPlug(Boolean isRamHotPlug);
|
||||
|
||||
public abstract Builder isRamHotUnPlug(Boolean isRamHotUnPlug);
|
||||
|
||||
public abstract Builder isNicHotPlug(Boolean isNicHotPlug);
|
||||
|
||||
public abstract Builder isNicHotUnPlug(Boolean isNicHotUnPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotPlug(Boolean isDiscVirtioHotPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotUnPlug(Boolean isDiscVirtioHotUnPlug);
|
||||
|
||||
public abstract Snapshot build();
|
||||
}
|
||||
|
||||
public static final class Request {
|
||||
|
||||
public static CreatePayload.Builder creatingBuilder() {
|
||||
return new CreatePayload.Builder();
|
||||
return new AutoValue_Snapshot_Request_CreatePayload.Builder();
|
||||
}
|
||||
|
||||
public static UpdatePayload.Builder updatingBuilder() {
|
||||
return new UpdatePayload.Builder();
|
||||
return new AutoValue_Snapshot_Request_UpdatePayload.Builder();
|
||||
}
|
||||
|
||||
public static RollbackPayload.Builder rollbackBuilder() {
|
||||
return new RollbackPayload.Builder();
|
||||
public static RollbackPayload createRollbackPayload(String snapshotId, String storageId) {
|
||||
return new AutoValue_Snapshot_Request_RollbackPayload(snapshotId, storageId);
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -145,112 +146,95 @@ public abstract class Snapshot implements Provisionable {
|
|||
|
||||
public abstract String storageId();
|
||||
|
||||
public abstract String description();
|
||||
|
||||
public abstract String name();
|
||||
|
||||
public static CreatePayload create(String storageId, String description, String name) {
|
||||
return new AutoValue_Snapshot_Request_CreatePayload(storageId, description, name);
|
||||
}
|
||||
@Nullable
|
||||
public abstract String description();
|
||||
|
||||
public static class Builder {
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private String storageId;
|
||||
private String description;
|
||||
private String name;
|
||||
public abstract Builder storageId(String storageId);
|
||||
|
||||
public Builder storageId(String storageId) {
|
||||
this.storageId = storageId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder description(String description);
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreatePayload build() {
|
||||
return CreatePayload.create(storageId, description, name);
|
||||
}
|
||||
public abstract CreatePayload build();
|
||||
}
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class UpdatePayload implements HotPluggable {
|
||||
public abstract static class UpdatePayload {
|
||||
|
||||
public abstract String snapshotId();
|
||||
public abstract String id();
|
||||
|
||||
@Nullable
|
||||
public abstract String description();
|
||||
|
||||
@Nullable
|
||||
public abstract String name();
|
||||
|
||||
public abstract boolean bootable();
|
||||
@Nullable
|
||||
public abstract Boolean bootable();
|
||||
|
||||
@Nullable
|
||||
public abstract OsType osType();
|
||||
|
||||
public static UpdatePayload create(String snapshotId, String description, String name, boolean bootable,
|
||||
OsType osType, Boolean cpuHotplug, Boolean cpuHotunplug, Boolean ramHotplug, Boolean ramHotunplug,
|
||||
Boolean nicHotplug, Boolean nicHotunplug, Boolean discVirtioHotplug, Boolean discVirtioHotunplug) {
|
||||
return new AutoValue_Snapshot_Request_UpdatePayload(
|
||||
cpuHotplug, cpuHotunplug, ramHotplug, ramHotunplug, nicHotplug, nicHotunplug, discVirtioHotplug,
|
||||
discVirtioHotunplug, snapshotId, description, name, bootable, osType);
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotPlug();
|
||||
|
||||
public static class Builder extends HotPluggable.Builder<Builder, UpdatePayload> {
|
||||
@Nullable
|
||||
public abstract Boolean isCpuHotUnPlug();
|
||||
|
||||
private String snapshotId;
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotPlug();
|
||||
|
||||
@Nullable
|
||||
private String description;
|
||||
@Nullable
|
||||
public abstract Boolean isRamHotUnPlug();
|
||||
|
||||
@Nullable
|
||||
private String name;
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotPlug();
|
||||
|
||||
private boolean bootable;
|
||||
@Nullable
|
||||
public abstract Boolean isNicHotUnPlug();
|
||||
|
||||
private OsType osType;
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotPlug();
|
||||
|
||||
public Builder snapshotId(String snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
return this;
|
||||
}
|
||||
@Nullable
|
||||
public abstract Boolean isDiscVirtioHotUnPlug();
|
||||
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder id(String snapshotId);
|
||||
|
||||
public Builder bootable(boolean bootable) {
|
||||
this.bootable = bootable;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder description(String description);
|
||||
|
||||
public Builder osType(OsType osType) {
|
||||
this.osType = osType;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
@Override
|
||||
public UpdatePayload build() {
|
||||
return UpdatePayload.create(snapshotId, description, name, bootable, osType, cpuHotPlug, cpuHotUnPlug,
|
||||
ramHotPlug, ramHotUnPlug, nicHotUnPlug, nicHotUnPlug, discVirtioHotPlug, discVirtioHotUnPlug);
|
||||
}
|
||||
public abstract Builder bootable(Boolean bootable);
|
||||
|
||||
@Override
|
||||
public Builder self() {
|
||||
return this;
|
||||
}
|
||||
public abstract Builder osType(OsType osType);
|
||||
|
||||
public abstract Builder isCpuHotPlug(Boolean isCpuHotPlug);
|
||||
|
||||
public abstract Builder isCpuHotUnPlug(Boolean isCpuHotUnPlug);
|
||||
|
||||
public abstract Builder isRamHotPlug(Boolean isRamHotPlug);
|
||||
|
||||
public abstract Builder isRamHotUnPlug(Boolean isRamHotUnPlug);
|
||||
|
||||
public abstract Builder isNicHotPlug(Boolean isNicHotPlug);
|
||||
|
||||
public abstract Builder isNicHotUnPlug(Boolean isNicHotUnPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotPlug(Boolean isDiscVirtioHotPlug);
|
||||
|
||||
public abstract Builder isDiscVirtioHotUnPlug(Boolean isDiscVirtioHotUnPlug);
|
||||
|
||||
public abstract UpdatePayload build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -262,30 +246,6 @@ public abstract class Snapshot implements Provisionable {
|
|||
|
||||
public abstract String storageId();
|
||||
|
||||
public static RollbackPayload create(String snapshotId, String storageId) {
|
||||
return new AutoValue_Snapshot_Request_RollbackPayload(snapshotId, storageId);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String snapshotId;
|
||||
|
||||
private String storageId;
|
||||
|
||||
public Builder snapshotId(String snapshotId) {
|
||||
this.snapshotId = snapshotId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder storageId(String storageId) {
|
||||
this.storageId = storageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RollbackPayload build() {
|
||||
return RollbackPayload.create(snapshotId, storageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,19 +16,17 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.domain;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkPassword;
|
||||
import static org.jclouds.profitbricks.util.Preconditions.checkSize;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import static org.jclouds.profitbricks.util.Passwords.isValidPassword;
|
||||
|
||||
@AutoValue
|
||||
public abstract class Storage {
|
||||
|
@ -38,11 +36,7 @@ public abstract class Storage {
|
|||
IDE, SCSI, VIRTIO, UNRECOGNIZED;
|
||||
|
||||
public static BusType fromValue(String value) {
|
||||
try {
|
||||
return valueOf(value);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
return Enums.getIfPresent(BusType.class, value).or(UNRECOGNIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,92 +68,43 @@ public abstract class Storage {
|
|||
@Nullable
|
||||
public abstract Integer deviceNumber();
|
||||
|
||||
public static Storage create(String id, String name, float size, Date creationTime, Date lastModificationTime,
|
||||
ProvisioningState state, List<String> serverIds, Boolean bootDevice, BusType busType, Integer deviceNumber) {
|
||||
return new AutoValue_Storage(id, name, size, creationTime, lastModificationTime, state,
|
||||
serverIds != null ? ImmutableList.copyOf(serverIds) : Lists.<String>newArrayList(),
|
||||
bootDevice, busType, deviceNumber);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
return new AutoValue_Storage.Builder()
|
||||
.serverIds(ImmutableList.<String>of());
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromStorage(this);
|
||||
}
|
||||
public abstract Builder toBuilder();
|
||||
|
||||
public static class Builder {
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private float size;
|
||||
private Date creationTime;
|
||||
private Date lastModificationTime;
|
||||
private ProvisioningState state;
|
||||
private List<String> serverIds;
|
||||
private Boolean bootDevice;
|
||||
private BusType busType;
|
||||
private Integer deviceNumber;
|
||||
public abstract Builder id(String id);
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder size(float size);
|
||||
|
||||
public Builder size(float size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder creationTime(Date creationTime);
|
||||
|
||||
public Builder creationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder lastModificationTime(Date lastModificationTime);
|
||||
|
||||
public Builder lastModificationTime(Date lastModificationTime) {
|
||||
this.lastModificationTime = lastModificationTime;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder state(ProvisioningState state);
|
||||
|
||||
public Builder state(ProvisioningState state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder serverIds(List<String> serverIds);
|
||||
|
||||
public Builder serverIds(List<String> serverIds) {
|
||||
this.serverIds = serverIds;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder bootDevice(Boolean bootDevice);
|
||||
|
||||
public Builder bootDevice(Boolean bootDevice) {
|
||||
this.bootDevice = bootDevice;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder busType(BusType busType);
|
||||
|
||||
public Builder busType(BusType busType) {
|
||||
this.busType = busType;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder deviceNumber(Integer deviceNumber);
|
||||
|
||||
public Builder deviceNumber(Integer deviceNumber) {
|
||||
this.deviceNumber = deviceNumber;
|
||||
return this;
|
||||
}
|
||||
abstract Storage autoBuild();
|
||||
|
||||
private Builder fromStorage(Storage in) {
|
||||
return this.id(in.id()).name(in.name()).size(in.size()).creationTime(in.creationTime())
|
||||
.lastModificationTime(in.lastModificationTime()).state(in.state()).serverIds(in.serverIds())
|
||||
.bootDevice(in.bootDevice()).busType(in.busType()).deviceNumber(in.deviceNumber());
|
||||
}
|
||||
|
||||
public Storage build() {
|
||||
return Storage.create(id, name, size, creationTime, lastModificationTime, state, serverIds, bootDevice, busType, deviceNumber);
|
||||
public Storage build(){
|
||||
Storage built = autoBuild();
|
||||
return built.toBuilder()
|
||||
.serverIds(ImmutableList.copyOf(built.serverIds()))
|
||||
.autoBuild();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -167,15 +112,15 @@ public abstract class Storage {
|
|||
public static final class Request {
|
||||
|
||||
public static CreatePayload.Builder creatingBuilder() {
|
||||
return new CreatePayload.Builder();
|
||||
return new AutoValue_Storage_Request_CreatePayload.Builder();
|
||||
}
|
||||
|
||||
public static UpdatePayload.Builder updatingBuilder() {
|
||||
return new UpdatePayload.Builder();
|
||||
return new AutoValue_Storage_Request_UpdatePayload.Builder();
|
||||
}
|
||||
|
||||
public static ConnectPayload.Builder connectingBuilder() {
|
||||
return new ConnectPayload.Builder();
|
||||
return new AutoValue_Storage_Request_ConnectPayload.Builder();
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -192,57 +137,32 @@ public abstract class Storage {
|
|||
public abstract String mountImageId();
|
||||
|
||||
@Nullable
|
||||
public abstract String profitBricksImagePassword();
|
||||
public abstract String imagePassword();
|
||||
|
||||
public static CreatePayload create(String dataCenterId, float size, String name, String mountImageId, String imagePassword) {
|
||||
checkSize(size);
|
||||
checkPassword(imagePassword);
|
||||
return new AutoValue_Storage_Request_CreatePayload(dataCenterId, size, name, mountImageId, imagePassword);
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public static class Builder {
|
||||
public abstract Builder dataCenterId(String dataCenterId);
|
||||
|
||||
private String dataCenterId;
|
||||
private float size;
|
||||
private String name;
|
||||
private String mountImageId;
|
||||
private String profitBricksImagePassword;
|
||||
public abstract Builder size(float size);
|
||||
|
||||
public Builder dataCenterId(String dataCenterId) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder dataCenterId(DataCenter dataCenter) {
|
||||
this.dataCenterId = checkNotNull(dataCenter, "Cannot pass null datacenter").id();
|
||||
return this;
|
||||
}
|
||||
public abstract Builder mountImageId(String mountImageId);
|
||||
|
||||
public Builder size(float size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder imagePassword(String profitBricksImagePassword);
|
||||
|
||||
public Builder mountImageId(String mountImageId) {
|
||||
this.mountImageId = mountImageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder imagePassword(String password) {
|
||||
this.profitBricksImagePassword = password;
|
||||
return this;
|
||||
}
|
||||
abstract CreatePayload autoBuild();
|
||||
|
||||
public CreatePayload build() {
|
||||
return CreatePayload.create(dataCenterId, size, name, mountImageId, profitBricksImagePassword);
|
||||
CreatePayload payload = autoBuild();
|
||||
if (payload.imagePassword() != null)
|
||||
checkPassword(payload.imagePassword());
|
||||
checkSize(payload.size());
|
||||
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
|
@ -259,40 +179,25 @@ public abstract class Storage {
|
|||
@Nullable
|
||||
public abstract String mountImageId();
|
||||
|
||||
public static UpdatePayload create(String id, Float size, String name, String mountImageId) {
|
||||
checkSize(size);
|
||||
return new AutoValue_Storage_Request_UpdatePayload(id, size, name, mountImageId);
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public static class Builder {
|
||||
public abstract Builder id(String id);
|
||||
|
||||
private String id;
|
||||
private Float size;
|
||||
private String name;
|
||||
private String mountImageId;
|
||||
public abstract Builder size(Float size);
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder name(String name);
|
||||
|
||||
public Builder size(float size) {
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder mountImageId(String mountImageId);
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder mountImageId(String mountImageId) {
|
||||
this.mountImageId = mountImageId;
|
||||
return this;
|
||||
}
|
||||
abstract UpdatePayload autoBuild();
|
||||
|
||||
public UpdatePayload build() {
|
||||
return UpdatePayload.create(id, size, name, mountImageId);
|
||||
UpdatePayload payload = autoBuild();
|
||||
if (payload.size() != null)
|
||||
checkSize(payload.size());
|
||||
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -310,54 +215,20 @@ public abstract class Storage {
|
|||
@Nullable
|
||||
public abstract Integer deviceNumber();
|
||||
|
||||
public static ConnectPayload create(String storageId, String serverId, BusType busType, Integer deviceNumber) {
|
||||
return new AutoValue_Storage_Request_ConnectPayload(storageId, serverId, busType, deviceNumber);
|
||||
}
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
|
||||
public static class Builder {
|
||||
public abstract Builder storageId(String storageId);
|
||||
|
||||
private String storageId;
|
||||
private String serverId;
|
||||
private BusType busType;
|
||||
private Integer deviceNumber;
|
||||
public abstract Builder serverId(String serverId);
|
||||
|
||||
public Builder storageId(String storageId) {
|
||||
this.storageId = storageId;
|
||||
return this;
|
||||
}
|
||||
public abstract Builder busType(BusType busType);
|
||||
|
||||
public Builder serverId(String serverId) {
|
||||
this.serverId = serverId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder busType(BusType busType) {
|
||||
this.busType = busType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder deviceNumber(Integer deviceNumber) {
|
||||
this.deviceNumber = deviceNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ConnectPayload build() {
|
||||
return ConnectPayload.create(storageId, serverId, busType, deviceNumber);
|
||||
}
|
||||
public abstract Builder deviceNumber(Integer deviceNumber);
|
||||
|
||||
public abstract ConnectPayload build();
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkSize(Float size) {
|
||||
if (size != null)
|
||||
checkArgument(size > 1, "Storage size must be > 1GB");
|
||||
}
|
||||
|
||||
private static void checkPassword(String password) {
|
||||
if (password != null)
|
||||
checkArgument(isValidPassword(password), "Password must be between 8 and 50 characters, "
|
||||
+ "only a-z, A-Z, 0-9 without characters i, I, l, o, O, w, W, y, Y, z, Z and 1, 0");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.http.parser.ipblock;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.jclouds.profitbricks.domain.IpBlock;
|
||||
import org.jclouds.profitbricks.domain.Location;
|
||||
import org.jclouds.profitbricks.http.parser.BaseProfitBricksResponseHandler;
|
||||
|
@ -28,7 +30,6 @@ import org.xml.sax.SAXException;
|
|||
public abstract class BaseIpBlockResponseHandler<T> extends BaseProfitBricksResponseHandler<T> {
|
||||
|
||||
protected final PublicIpListResponseHandler publicIpListResponseHandler;
|
||||
protected final List<IpBlock.PublicIp> publicIps = Lists.newArrayList();
|
||||
protected List<String> ips;
|
||||
|
||||
protected IpBlock.Builder builder;
|
||||
|
@ -37,7 +38,7 @@ public abstract class BaseIpBlockResponseHandler<T> extends BaseProfitBricksResp
|
|||
BaseIpBlockResponseHandler(PublicIpListResponseHandler publicIpListResponseHandler) {
|
||||
this.builder = IpBlock.builder();
|
||||
this.publicIpListResponseHandler = publicIpListResponseHandler;
|
||||
ips = Lists.newArrayList();
|
||||
this.ips = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,8 +41,8 @@ public class IpBlockResponseHandler extends BaseIpBlockResponseHandler<IpBlock>
|
|||
setPropertyOnEndTag(qName);
|
||||
if ("return".equals(qName)) {
|
||||
done = true;
|
||||
builder.publicIps(publicIpListResponseHandler.getResult());
|
||||
builder.ips(ips);
|
||||
builder.publicIps(publicIpListResponseHandler.getResult())
|
||||
.ips(ips);
|
||||
}
|
||||
clearTextBuffer();
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public abstract class BaseLoadBalancerResponseHandler<T> extends BaseProfitBrick
|
|||
else if ("ip".equals(qName))
|
||||
builder.ip(textToStringValue());
|
||||
else if ("lanId".equals(qName))
|
||||
builder.lanId(textToStringValue());
|
||||
builder.lanId(textToIntValue());
|
||||
else if ("provisioningState".equals(qName))
|
||||
builder.state(ProvisioningState.fromValue(textToStringValue()));
|
||||
else if ("creationTime".equals(qName))
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.http.parser.nic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.jclouds.profitbricks.domain.Nic;
|
||||
|
@ -31,11 +34,13 @@ public abstract class BaseNicResponseHandler<T> extends BaseProfitBricksResponse
|
|||
|
||||
protected boolean useFirewallParser = false;
|
||||
protected Nic.Builder builder;
|
||||
protected List<String> ips;
|
||||
|
||||
@Inject
|
||||
BaseNicResponseHandler(FirewallResponseHandler firewallResponseHandler) {
|
||||
this.builder = Nic.builder();
|
||||
this.firewallResponseHandler = firewallResponseHandler;
|
||||
this.ips = new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +74,7 @@ public abstract class BaseNicResponseHandler<T> extends BaseProfitBricksResponse
|
|||
else if ("serverId".equals(qName))
|
||||
builder.serverId(textToStringValue());
|
||||
else if ("ips".equals(qName))
|
||||
builder.ip(textToStringValue());
|
||||
ips.add(textToStringValue());
|
||||
else if ("macAddress".equals(qName))
|
||||
builder.macAddress(textToStringValue());
|
||||
else if ("dhcpActive".equals(qName))
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.http.parser.nic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
|
@ -44,9 +46,12 @@ public class NicListResponseHandler extends BaseNicResponseHandler<List<Nic>> {
|
|||
setPropertyOnEndTag(qName);
|
||||
if ("return".equals(qName) || "nics".equals(qName)) {
|
||||
nics.add(builder
|
||||
.ips(ips)
|
||||
.firewall(firewallResponseHandler.getResult())
|
||||
.build());
|
||||
builder = Nic.builder();
|
||||
ips = new ArrayList<String>();
|
||||
firewallResponseHandler.reset();
|
||||
}
|
||||
clearTextBuffer();
|
||||
}
|
||||
|
@ -57,6 +62,7 @@ public class NicListResponseHandler extends BaseNicResponseHandler<List<Nic>> {
|
|||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.ips = new ArrayList<String>();
|
||||
this.nics = Lists.newArrayList();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.http.parser.nic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.jclouds.profitbricks.domain.Nic;
|
||||
import org.jclouds.profitbricks.http.parser.firewall.FirewallResponseHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
@ -41,7 +44,9 @@ public class NicResponseHandler extends BaseNicResponseHandler<Nic> {
|
|||
setPropertyOnEndTag(qName);
|
||||
if ("return".equals(qName)) {
|
||||
done = true;
|
||||
builder.firewall(firewallResponseHandler.getResult());
|
||||
builder.ips(ips)
|
||||
.firewall(firewallResponseHandler.getResult());
|
||||
ips = new ArrayList<String>();
|
||||
firewallResponseHandler.reset();
|
||||
}
|
||||
clearTextBuffer();
|
||||
|
|
|
@ -33,8 +33,10 @@ public class PublicIpListResponseHandler extends BasePublicIpResponseHandler<Lis
|
|||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
setPropertyOnEndTag(qName);
|
||||
|
||||
if ("publicIps".equals(qName))
|
||||
if ("publicIps".equals(qName)){
|
||||
publicIps.add(builder.build());
|
||||
this.builder = PublicIp.builder();
|
||||
}
|
||||
clearTextBuffer();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class BaseServerResponseHandler<T> extends BaseProfitBricksRespo
|
|||
protected final NicListResponseHandler nicListResponseHandler;
|
||||
|
||||
protected DataCenter.Builder dataCenterBuilder;
|
||||
protected Server.DescribingBuilder builder;
|
||||
protected Server.Builder builder;
|
||||
|
||||
protected final DateService dateService;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ServerListResponseHandler extends BaseServerResponseHandler<List<Se
|
|||
else {
|
||||
setPropertyOnEndTag(qName);
|
||||
if ("return".equals(qName) || "servers".equals(qName) || "balancedServers".equals(qName)) {
|
||||
Server.DescribingBuilder sdb = null;
|
||||
Server.Builder sdb = null;
|
||||
try {
|
||||
sdb = builder
|
||||
.storages(storageListResponseHandler.getResult())
|
||||
|
@ -58,7 +58,7 @@ public class ServerListResponseHandler extends BaseServerResponseHandler<List<Se
|
|||
// For LoadBalancer's case, there's no DataCenter (may throw NPE on #build()).
|
||||
.dataCenter(dataCenterBuilder.build())
|
||||
.build());
|
||||
} catch (NullPointerException ex) {
|
||||
} catch (Exception ex) {
|
||||
servers.add(sdb.build());
|
||||
}
|
||||
storageListResponseHandler.reset();
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.profitbricks.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static com.google.common.net.InetAddresses.isInetAddress;
|
||||
import static org.jclouds.profitbricks.util.MacAddresses.isMacAddress;
|
||||
import static org.jclouds.profitbricks.util.Passwords.isValidPassword;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jclouds.profitbricks.domain.Firewall;
|
||||
import org.jclouds.profitbricks.domain.Firewall.Protocol;
|
||||
|
||||
/**
|
||||
* Static convenience methods for validating various ProfitBricks domain preconditions
|
||||
*/
|
||||
public final class Preconditions {
|
||||
|
||||
private static final Pattern INVALID_CHARS = Pattern.compile("^.*[@/\\|'`’^].*$");
|
||||
|
||||
public static void checkInvalidChars(String name) {
|
||||
checkArgument(!isNullOrEmpty(name), "Name is required.");
|
||||
checkArgument(!INVALID_CHARS.matcher(name).matches(), "Name must not contain any of: @ / \\ | ' ` ’ ^");
|
||||
}
|
||||
|
||||
public static void checkIp(String ip) {
|
||||
checkArgument(isInetAddress(ip), "IP '%s' is invalid", ip);
|
||||
}
|
||||
|
||||
public static void checkIps(List<String> ips) {
|
||||
checkNotNull(ips, "Null ip list");
|
||||
for (String ip : ips)
|
||||
checkIp(ip);
|
||||
}
|
||||
|
||||
public static void checkPortRange(Integer portRangeStart, Integer portRangeEnd, Firewall.Protocol protocol) {
|
||||
checkArgument(!(portRangeEnd == null ^ portRangeStart == null), "Port range must be both present or null");
|
||||
if (portRangeEnd != null) {
|
||||
checkArgument(protocol == Firewall.Protocol.TCP || protocol == Firewall.Protocol.UDP, "Port range can only be set for TCP or UDP");
|
||||
checkArgument(portRangeEnd > portRangeStart, "portRangeEnd must be greater than portRangeStart");
|
||||
checkArgument(portRangeEnd >= 1 && portRangeEnd <= 65534, "Port range end must be 1 to 65534");
|
||||
checkArgument(portRangeStart >= 1 && portRangeStart <= 65534, "Port range start must be 1 to 65534");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkMacAddress(String macAddress) {
|
||||
checkArgument(isMacAddress(macAddress), "MAC must match pattern 'aa:bb:cc:dd:ee:ff'");
|
||||
}
|
||||
|
||||
public static void checkIcmp(Integer icmpType, Integer icmpCode, Protocol protocol) {
|
||||
checkNotNull(protocol, "Protocol can't be null");
|
||||
if (protocol == Protocol.ICMP) {
|
||||
if (icmpType != null)
|
||||
checkArgument(icmpType >= 1 && icmpType <= 254, "ICMP type must be 1 to 254");
|
||||
if (icmpCode != null)
|
||||
checkArgument(icmpCode >= 1 && icmpCode <= 254, "ICMP code must be 1 to 254");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkLanId(Integer id) {
|
||||
checkArgument(id >= 0, "LAN ID must be non-negative");
|
||||
}
|
||||
|
||||
public static void checkCores(Integer cores) {
|
||||
checkArgument(cores > 0, "Number of cores must be atleast 1.");
|
||||
}
|
||||
|
||||
public static void checkRam(Integer ram, Boolean isRamHotPlug) {
|
||||
int minRam = (isRamHotPlug == null || !isRamHotPlug) ? 256 : 1024;
|
||||
checkArgument(ram >= minRam && ram % 256 == 0, "RAM must be multiples of 256 with minimum of 256 MB "
|
||||
+ "(1024 MB if ramHotPlug is enabled)");
|
||||
}
|
||||
|
||||
public static void checkSize(Float size) {
|
||||
checkArgument(size > 1, "Storage size must be > 1GB");
|
||||
}
|
||||
|
||||
public static void checkPassword(String password) {
|
||||
checkArgument(isValidPassword(password), "Password must be between 8 and 50 characters, "
|
||||
+ "only a-z, A-Z, 0-9 without characters i, I, l, o, O, w, W, y, Y, z, Z and 1, 0");
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ public class CreateDataCenterRequestBinderTest {
|
|||
public void testCreatePayload() {
|
||||
CreateDataCenterRequestBinder binder = new CreateDataCenterRequestBinder();
|
||||
|
||||
DataCenter.Request.CreatePayload payload = DataCenter.Request.CreatePayload.create("JClouds-DC", Location.DE_FKB);
|
||||
DataCenter.Request.CreatePayload payload = DataCenter.Request.creatingPayload("JClouds-DC", Location.DE_FKB);
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
assertNotNull(actual, "Binder returned null payload");
|
||||
|
|
|
@ -29,7 +29,7 @@ public class UpdateDataCenterRequestBinderTest {
|
|||
public void testCreatePayload() {
|
||||
UpdateDataCenterRequestBinder binder = new UpdateDataCenterRequestBinder();
|
||||
|
||||
DataCenter.Request.UpdatePayload payload = DataCenter.Request.UpdatePayload.create("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Apache-DC");
|
||||
DataCenter.Request.UpdatePayload payload = DataCenter.Request.updatingPayload("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Apache-DC");
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
assertNotNull(actual, "Binder returned null payload");
|
||||
|
|
|
@ -29,7 +29,7 @@ public class AddRomDriveToServerRequestBinderTest {
|
|||
|
||||
Drive.Request.AddRomDriveToServerPayload payload = Drive.Request.AddRomDriveToServerPayload.builder()
|
||||
.serverId("server-id")
|
||||
.storageId("image-id")
|
||||
.imageId("image-id")
|
||||
.deviceNumber("device-number")
|
||||
.build();
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ import org.jclouds.profitbricks.domain.Firewall;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import org.jclouds.profitbricks.domain.Firewall.Protocol;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = "unit", testName = "AddFirewallRuleToNicRequestBinderTest")
|
||||
|
@ -31,18 +32,18 @@ public class AddFirewallRuleToNicRequestBinderTest {
|
|||
public void testCreatePayload() {
|
||||
AddFirewallRuleToNicRequestBinder binder = new AddFirewallRuleToNicRequestBinder();
|
||||
|
||||
Firewall.Request.AddRulePayload payload = Firewall.Request.ruleAddingBuilder()
|
||||
.nicId("nic-id")
|
||||
.newRule()
|
||||
.name("name")
|
||||
.portRangeEnd(45678)
|
||||
.portRangeStart(12345)
|
||||
.protocol(Protocol.TCP)
|
||||
.sourceIp("192.168.0.1")
|
||||
.sourceMac("aa:bb:cc:dd:ee:ff")
|
||||
.targetIp("192.168.0.2")
|
||||
.endRule()
|
||||
.build();
|
||||
Firewall.Request.AddRulePayload payload = Firewall.Request.createAddRulePayload(
|
||||
"nic-id", ImmutableList.of(
|
||||
Firewall.Rule.builder()
|
||||
.name("name")
|
||||
.portRangeEnd(45678)
|
||||
.portRangeStart(12345)
|
||||
.protocol(Firewall.Protocol.TCP)
|
||||
.sourceIp("192.168.0.1")
|
||||
.sourceMac("aa:bb:cc:dd:ee:ff")
|
||||
.targetIp("192.168.0.2")
|
||||
.build()
|
||||
));
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
assertNotNull(actual, "Binder returned null payload");
|
||||
|
|
|
@ -16,13 +16,17 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.binder.loadbalancer;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||
import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
@Test(groups = "unit", testName = "CreateLoadBalancerRequestBinderTest")
|
||||
public class CreateLoadBalancerRequestBinderTest {
|
||||
|
@ -34,7 +38,16 @@ public class CreateLoadBalancerRequestBinderTest {
|
|||
List<String> serverIds = Lists.newArrayList();
|
||||
serverIds.add("server-ids");
|
||||
|
||||
String actual = binder.createPayload(LoadBalancer.Request.CreatePayload.create("datacenter-id", "load-balancer-name", Algorithm.ROUND_ROBIN, "-ip", "lan-id", serverIds));
|
||||
String actual = binder.createPayload(
|
||||
LoadBalancer.Request.creatingBuilder()
|
||||
.dataCenterId("datacenter-id")
|
||||
.name("load-balancer-name")
|
||||
.algorithm(Algorithm.ROUND_ROBIN)
|
||||
.ip("10.0.0.1")
|
||||
.lanId(2)
|
||||
.serverIds(ImmutableList.<String>of(
|
||||
"server-id-1", "server-id-2"))
|
||||
.build());
|
||||
|
||||
assertNotNull(actual, "Binder returned null payload");
|
||||
assertEquals(expectedPayload, actual);
|
||||
|
@ -46,9 +59,10 @@ public class CreateLoadBalancerRequestBinderTest {
|
|||
+ " <dataCenterId>datacenter-id</dataCenterId>\n"
|
||||
+ " <loadBalancerName>load-balancer-name</loadBalancerName>\n"
|
||||
+ " <loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>\n"
|
||||
+ " <ip>-ip</ip>\n"
|
||||
+ " <lanId>lan-id</lanId>\n"
|
||||
+ " <serverIds>server-ids</serverIds>\n"
|
||||
+ " <ip>10.0.0.1</ip>\n"
|
||||
+ " <lanId>2</lanId>\n"
|
||||
+ " <serverIds>server-id-1</serverIds>\n"
|
||||
+ " <serverIds>server-id-2</serverIds>\n"
|
||||
+ " </request>\n"
|
||||
+ " </ws:createLoadBalancer>").replaceAll("\\s+", "");
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class DeregisterLoadBalancerRequestBinderTest {
|
|||
serverIds.add("1");
|
||||
serverIds.add("2");
|
||||
|
||||
LoadBalancer.Request.DeregisterPayload payload = LoadBalancer.Request.DeregisterPayload.create(serverIds, "load-balancer-id");
|
||||
LoadBalancer.Request.DeregisterPayload payload = LoadBalancer.Request.createDeregisteringPayload("load-balancer-id", serverIds);
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class RegisterLoadBalancerRequestBinderTest {
|
|||
serverIds.add("1");
|
||||
serverIds.add("2");
|
||||
|
||||
LoadBalancer.Request.RegisterPayload payload = LoadBalancer.Request.RegisterPayload.create(serverIds, "load-balancer-id");
|
||||
LoadBalancer.Request.RegisterPayload payload = LoadBalancer.Request.createRegisteringPaylod("load-balancer-id", serverIds);
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
|
||||
|
|
|
@ -16,11 +16,14 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.binder.loadbalancer;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = "unit", testName = "UpdateLoadBalancerRequestBinderTest")
|
||||
|
@ -33,8 +36,12 @@ public class UpdateLoadBalancerRequestBinderTest {
|
|||
serverIds.add("1");
|
||||
serverIds.add("2");
|
||||
|
||||
LoadBalancer.Request.UpdatePayload payload = LoadBalancer.Request.UpdatePayload.create("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "load-balancer-name",
|
||||
LoadBalancer.Algorithm.ROUND_ROBIN, "ip");
|
||||
LoadBalancer.Request.UpdatePayload payload = LoadBalancer.Request.updatingBuilder()
|
||||
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||
.name("load-balancer-name")
|
||||
.algorithm(LoadBalancer.Algorithm.ROUND_ROBIN)
|
||||
.ip("10.0.0.2")
|
||||
.build();
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
|
||||
|
@ -48,7 +55,7 @@ public class UpdateLoadBalancerRequestBinderTest {
|
|||
+ " <loadBalancerId>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</loadBalancerId>\n"
|
||||
+ " <loadBalancerName>load-balancer-name</loadBalancerName>\n"
|
||||
+ " <loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>\n"
|
||||
+ " <ip>ip</ip> \n"
|
||||
+ " <ip>10.0.0.2</ip> \n"
|
||||
+ " </request>\n"
|
||||
+ " </ws:updateLoadBalancer>").replaceAll("\\s+", "");
|
||||
}
|
||||
|
|
|
@ -29,7 +29,11 @@ public class CreateSnapshotRequestBinderTest {
|
|||
public void testCreatePayload() {
|
||||
CreateSnapshotRequestBinder binder = new CreateSnapshotRequestBinder();
|
||||
|
||||
Snapshot.Request.CreatePayload payload = Snapshot.Request.CreatePayload.create("123-1233-1324", "describingthesnapshot", "snapshotname");
|
||||
Snapshot.Request.CreatePayload payload = Snapshot.Request.creatingBuilder()
|
||||
.storageId("123-1233-1324")
|
||||
.name("snapshot-name")
|
||||
.description("describing-the-snapshot")
|
||||
.build();
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
assertNotNull(actual, "Binder returned null payload");
|
||||
|
@ -40,8 +44,8 @@ public class CreateSnapshotRequestBinderTest {
|
|||
= (" <ws:createSnapshot>\n"
|
||||
+ "<request>\n"
|
||||
+ "<storageId>123-1233-1324</storageId>\n"
|
||||
+ "<description>describing the snapshot</description>\n"
|
||||
+ "<snapshotName>snapshot name</snapshotName>\n"
|
||||
+ "<description>describing-the-snapshot</description>\n"
|
||||
+ "<snapshotName>snapshot-name</snapshotName>\n"
|
||||
+ "</request>\n"
|
||||
+ "</ws:createSnapshot>").replaceAll("\\s+", "");
|
||||
}
|
||||
|
|
|
@ -28,10 +28,7 @@ public class RollbackSnapshotRequestBinderTest {
|
|||
public void testRollbackPayload() {
|
||||
RollbackSnapshotRequestBinder binder = new RollbackSnapshotRequestBinder();
|
||||
|
||||
Snapshot.Request.RollbackPayload payload = Snapshot.Request.rollbackBuilder()
|
||||
.snapshotId("snapshot-id")
|
||||
.storageId("storage-id")
|
||||
.build();
|
||||
Snapshot.Request.RollbackPayload payload = Snapshot.Request.createRollbackPayload("snapshot-id", "storage-id");
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
assertNotNull(actual, "Binder returned null payload");
|
||||
|
|
|
@ -30,7 +30,21 @@ public class UpdateSnapshotRequestBinderTest {
|
|||
public void testUpdatePayload() {
|
||||
UpdateSnapshotRequestBinder binder = new UpdateSnapshotRequestBinder();
|
||||
|
||||
Snapshot.Request.UpdatePayload payload = Snapshot.Request.UpdatePayload.create("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh", "description", "snapshot-name", true, OsType.LINUX, true, true, true, true, true, true, true, true);
|
||||
Snapshot.Request.UpdatePayload payload = Snapshot.Request.updatingBuilder()
|
||||
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||
.description("description")
|
||||
.name("snapshot-name")
|
||||
.bootable(true)
|
||||
.osType(OsType.LINUX)
|
||||
.isCpuHotPlug(true)
|
||||
.isCpuHotUnPlug(true)
|
||||
.isRamHotPlug(true)
|
||||
.isRamHotUnPlug(true)
|
||||
.isNicHotPlug(true)
|
||||
.isNicHotUnPlug(true)
|
||||
.isDiscVirtioHotPlug(true)
|
||||
.isDiscVirtioHotUnPlug(true)
|
||||
.build();
|
||||
|
||||
String actual = binder.createPayload(payload);
|
||||
assertNotNull(actual, "Binder returned null payload");
|
||||
|
|
|
@ -130,7 +130,7 @@ public class ServerToNodeMetadataTest {
|
|||
.internetAccess(true)
|
||||
.serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
||||
.macAddress("02:01:09:cd:f0:b0")
|
||||
.ip("173.252.120.6")
|
||||
.ips( ImmutableList.<String>of("173.252.120.6"))
|
||||
.build()
|
||||
)
|
||||
)
|
||||
|
|
|
@ -58,7 +58,7 @@ public class FirewallRuleBuilderTest {
|
|||
|
||||
@Test
|
||||
public void testAutoValueFirewallRuleWithIcmpPropertiesSettingCorrectly() {
|
||||
Firewall.RuleWithIcmp actual = Firewall.RuleWithIcmp.builder()
|
||||
Firewall.Rule actual = Firewall.Rule.builder()
|
||||
.name(_name)
|
||||
.icmpCode(_icmpCode)
|
||||
.icmpType(_icmpType)
|
||||
|
|
|
@ -29,8 +29,8 @@ public class ServerBuilderTest {
|
|||
private final Boolean _isNicHotUnPlug = false;
|
||||
private final Boolean _isDiscVirtioHotPlug = true;
|
||||
private final Boolean _isDiscVirtioHotUnPlug = false;
|
||||
private final int _cores = 8;
|
||||
private final int _ram = 8 * 1024;
|
||||
private final Integer _cores = 8;
|
||||
private final Integer _ram = 8 * 1024;
|
||||
private final String _id = "some-random-server-id";
|
||||
private final String _name = "jclouds-node";
|
||||
private final Boolean _hasInternetAccess = true;
|
||||
|
@ -110,7 +110,7 @@ public class ServerBuilderTest {
|
|||
assertEquals(actual.availabilityZone(), _availabilityZone);
|
||||
assertEquals(actual.bootFromImageId(), _bootFromImageId);
|
||||
assertEquals(actual.bootFromStorageId(), _bootFromStorageId);
|
||||
assertEquals(actual.cores(), _cores);
|
||||
assertEquals(actual.cores(), _cores.intValue());
|
||||
assertEquals(actual.dataCenterId(), _dataCenterId);
|
||||
assertEquals(actual.hasInternetAccess(), _hasInternetAccess);
|
||||
assertEquals(actual.name(), _name);
|
||||
|
@ -121,7 +121,7 @@ public class ServerBuilderTest {
|
|||
assertEquals(actual.isNicHotUnPlug(), _isNicHotUnPlug);
|
||||
assertEquals(actual.isRamHotPlug(), _isRamHotPlug);
|
||||
assertEquals(actual.lanId(), _lanId);
|
||||
assertEquals(actual.ram(), _ram);
|
||||
assertEquals(actual.ram(), _ram.intValue());
|
||||
assertEquals(actual.osType(), _osType);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class DataCenterApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
@Test
|
||||
public void testCreateDataCenter() {
|
||||
DataCenter dc = api.dataCenterApi().createDataCenter(
|
||||
DataCenter.Request.CreatePayload.create("JClouds", Location.DE_FKB)
|
||||
DataCenter.Request.creatingPayload("JClouds", Location.DE_FKB)
|
||||
);
|
||||
|
||||
assertNotNull(dc);
|
||||
|
@ -83,7 +83,7 @@ public class DataCenterApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
|
||||
final String newName = "Apache";
|
||||
DataCenter dataCenter = api.dataCenterApi().updateDataCenter(
|
||||
DataCenter.Request.UpdatePayload.create(dcId, newName)
|
||||
DataCenter.Request.updatingPayload(dcId, newName)
|
||||
);
|
||||
|
||||
assertNotNull(dataCenter);
|
||||
|
|
|
@ -153,7 +153,7 @@ public class DataCenterApiMockTest extends BaseProfitBricksMockTest {
|
|||
+ "</request></ws:createDataCenter>";
|
||||
try {
|
||||
DataCenter dataCenter = api.createDataCenter(
|
||||
DataCenter.Request.CreatePayload.create("JClouds-DC", Location.DE_FRA)
|
||||
DataCenter.Request.creatingPayload("JClouds-DC", Location.DE_FRA)
|
||||
);
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
assertNotNull(dataCenter);
|
||||
|
@ -170,7 +170,7 @@ public class DataCenterApiMockTest extends BaseProfitBricksMockTest {
|
|||
String[] names = {"JCl@ouds", "JC|ouds", "^clouds", ""};
|
||||
for (String name : names)
|
||||
try {
|
||||
DataCenter.Request.CreatePayload.create(name, Location.US_LAS);
|
||||
DataCenter.Request.creatingPayload(name, Location.US_LAS);
|
||||
fail("Should have failed for name: ".concat(name));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// expected exception
|
||||
|
@ -194,7 +194,7 @@ public class DataCenterApiMockTest extends BaseProfitBricksMockTest {
|
|||
+ "</request></ws:updateDataCenter>";
|
||||
try {
|
||||
DataCenter dataCenter = api.updateDataCenter(
|
||||
DataCenter.Request.UpdatePayload.create(id, newName)
|
||||
DataCenter.Request.updatingPayload(id, newName)
|
||||
);
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
assertNotNull(dataCenter);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class DrivesApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
public void addRomDriveToServerTest() {
|
||||
String requestId = api.drivesApi().addRomDriveToServer(Drive.Request.AddRomDriveToServerPayload.builder()
|
||||
.serverId(serverId)
|
||||
.storageId("05cadf29-6c12-11e4-beeb-52540066fee9")
|
||||
.imageId("05cadf29-6c12-11e4-beeb-52540066fee9")
|
||||
.deviceNumber("0")
|
||||
.build());
|
||||
assertNotNull(requestId);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DrivesApiMockTest extends BaseProfitBricksMockTest {
|
|||
try {
|
||||
String requestId = api.addRomDriveToServer(Drive.Request.AddRomDriveToServerPayload.builder()
|
||||
.serverId("server-id")
|
||||
.storageId("image-id")
|
||||
.imageId("image-id")
|
||||
.deviceNumber("device-number")
|
||||
.build());
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
|
|
|
@ -75,13 +75,13 @@ public class FirewallApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
@Test
|
||||
public void testAddFirewallRuleToNic() {
|
||||
Firewall firewall = api.firewallApi().addFirewallRuleToNic(
|
||||
Firewall.Request.ruleAddingBuilder()
|
||||
.nicId(nic.id())
|
||||
.newRule()
|
||||
.name("test-rule-tcp")
|
||||
.protocol(Protocol.TCP)
|
||||
.endRule()
|
||||
.build());
|
||||
Firewall.Request.createAddRulePayload(nic.id(), ImmutableList.of(
|
||||
Firewall.Rule.builder()
|
||||
.name("test-rule-tcp")
|
||||
.protocol(Protocol.TCP)
|
||||
.build()
|
||||
))
|
||||
);
|
||||
|
||||
assertNotNull(firewall);
|
||||
assertNotNull(firewall.rules());
|
||||
|
|
|
@ -128,18 +128,18 @@ public class FirewallApiMockTest extends BaseProfitBricksMockTest {
|
|||
+ "</request>"
|
||||
+ "</ws:addFirewallRulesToNic>";
|
||||
try {
|
||||
Firewall.Request.AddRulePayload payload = Firewall.Request.ruleAddingBuilder()
|
||||
.nicId("nic-id")
|
||||
.newRule()
|
||||
.name("name")
|
||||
.portRangeEnd(45678)
|
||||
.portRangeStart(12345)
|
||||
.protocol(Protocol.TCP)
|
||||
.sourceIp("192.168.0.1")
|
||||
.sourceMac("aa:bb:cc:dd:ee:ff")
|
||||
.targetIp("192.168.0.2")
|
||||
.endRule()
|
||||
.build();
|
||||
Firewall.Request.AddRulePayload payload = Firewall.Request.createAddRulePayload(
|
||||
"nic-id", ImmutableList.of(
|
||||
Firewall.Rule.builder()
|
||||
.name("name")
|
||||
.portRangeEnd(45678)
|
||||
.portRangeStart(12345)
|
||||
.protocol(Protocol.TCP)
|
||||
.sourceIp("192.168.0.1")
|
||||
.sourceMac("aa:bb:cc:dd:ee:ff")
|
||||
.targetIp("192.168.0.2")
|
||||
.build()
|
||||
));
|
||||
Firewall response = api.addFirewallRuleToNic(payload);
|
||||
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
|
|
|
@ -16,8 +16,13 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.features;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.jclouds.profitbricks.BaseProfitBricksLiveTest;
|
||||
import org.jclouds.profitbricks.domain.DataCenter;
|
||||
|
@ -25,16 +30,14 @@ import org.jclouds.profitbricks.domain.LoadBalancer;
|
|||
import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm;
|
||||
import org.jclouds.profitbricks.domain.Server;
|
||||
import org.testng.Assert;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = "unit", testName = "LoadbalancerApiLiveTest")
|
||||
public class LoadbalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
||||
@Test(groups = "unit", testName = "LoadBalancerApiLiveTest")
|
||||
public class LoadBalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
||||
|
||||
private String dataCenterId;
|
||||
private String loadBalancerID;
|
||||
private String loadBalancerId;
|
||||
private String serverId;
|
||||
|
||||
@Override
|
||||
|
@ -58,10 +61,10 @@ public class LoadbalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
|
||||
LoadBalancer.Request.CreatePayload payload = LoadBalancer.Request.creatingBuilder()
|
||||
.dataCenterId(dataCenterId)
|
||||
.loadBalancerName("testName")
|
||||
.loadBalancerAlgorithm(Algorithm.ROUND_ROBIN)
|
||||
.name("testName")
|
||||
.algorithm(Algorithm.ROUND_ROBIN)
|
||||
.ip("0.0.0.1")
|
||||
.lanId("1")
|
||||
.lanId(1)
|
||||
.serverIds(serverIds)
|
||||
.build();
|
||||
|
||||
|
@ -79,7 +82,7 @@ public class LoadbalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
|
||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||
public void testGetLoadBalancer() {
|
||||
LoadBalancer loadBalancer = api.loadBalancerApi().getLoadBalancer(loadBalancerID);
|
||||
LoadBalancer loadBalancer = api.loadBalancerApi().getLoadBalancer(loadBalancerId);
|
||||
|
||||
assertNotNull(loadBalancer);
|
||||
}
|
||||
|
@ -89,10 +92,8 @@ public class LoadbalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
List<String> serverIds = Lists.newArrayList();
|
||||
serverIds.add(serverId);
|
||||
|
||||
LoadBalancer.Request.RegisterPayload payload = LoadBalancer.Request.registerBuilder()
|
||||
.id(loadBalancerID)
|
||||
.serverIds(serverIds)
|
||||
.build();
|
||||
LoadBalancer.Request.RegisterPayload payload = LoadBalancer.Request
|
||||
.createRegisteringPaylod(loadBalancerId, serverIds);
|
||||
|
||||
LoadBalancer loadBalancer = api.loadBalancerApi().registerLoadBalancer(payload);
|
||||
|
||||
|
@ -104,10 +105,8 @@ public class LoadbalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
List<String> serverIds = Lists.newArrayList();
|
||||
serverIds.add(serverId);
|
||||
|
||||
LoadBalancer.Request.DeregisterPayload payload = LoadBalancer.Request.deregisterBuilder()
|
||||
.id(loadBalancerID)
|
||||
.serverIds(serverIds)
|
||||
.build();
|
||||
LoadBalancer.Request.DeregisterPayload payload = LoadBalancer.Request
|
||||
.createDeregisteringPayload(loadBalancerId, serverIds);
|
||||
|
||||
LoadBalancer loadBalancer = api.loadBalancerApi().deregisterLoadBalancer(payload);
|
||||
|
||||
|
@ -117,8 +116,8 @@ public class LoadbalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||
public void testUpdateLoadBalancer() {
|
||||
LoadBalancer.Request.UpdatePayload payload = LoadBalancer.Request.updatingBuilder()
|
||||
.id(loadBalancerID)
|
||||
.loadBalancerName("whatever")
|
||||
.id(loadBalancerId)
|
||||
.name("whatever")
|
||||
.build();
|
||||
|
||||
LoadBalancer loadBalancer = api.loadBalancerApi().updateLoadBalancer(payload);
|
||||
|
@ -128,7 +127,7 @@ public class LoadbalancerApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void testDeleteLoadBalancer() {
|
||||
boolean result = api.loadBalancerApi().deleteLoadBalancer(loadBalancerID);
|
||||
boolean result = api.loadBalancerApi().deleteLoadBalancer(loadBalancerId);
|
||||
|
||||
Assert.assertTrue(result);
|
||||
}
|
|
@ -16,22 +16,24 @@
|
|||
*/
|
||||
package org.jclouds.profitbricks.features;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
import com.squareup.okhttp.mockwebserver.MockWebServer;
|
||||
import java.util.List;
|
||||
import org.jclouds.profitbricks.ProfitBricksApi;
|
||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||
import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm;
|
||||
import org.jclouds.profitbricks.internal.BaseProfitBricksMockTest;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.AssertJUnit.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.squareup.okhttp.mockwebserver.MockResponse;
|
||||
import com.squareup.okhttp.mockwebserver.MockWebServer;
|
||||
import org.jclouds.profitbricks.ProfitBricksApi;
|
||||
import org.jclouds.profitbricks.domain.LoadBalancer;
|
||||
import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm;
|
||||
import org.jclouds.profitbricks.internal.BaseProfitBricksMockTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = "unit", testName = "LoadbalancerApiMockTest")
|
||||
public class LoadbalancerApiMockTest extends BaseProfitBricksMockTest {
|
||||
@Test(groups = "unit", testName = "LoadBalancerApiMockTest")
|
||||
public class LoadBalancerApiMockTest extends BaseProfitBricksMockTest {
|
||||
|
||||
@Test
|
||||
public void testGetAllLoadBalancers() throws Exception {
|
||||
|
@ -132,7 +134,7 @@ public class LoadbalancerApiMockTest extends BaseProfitBricksMockTest {
|
|||
+ "<loadBalancerName>load-balancer-name</loadBalancerName>"
|
||||
+ "<loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>"
|
||||
+ "<ip>192.168.0.1</ip>"
|
||||
+ "<lanId>lan-id</lanId>"
|
||||
+ "<lanId>3</lanId>"
|
||||
+ "<serverIds>server-ids</serverIds>"
|
||||
+ "</request>"
|
||||
+ "</ws:createLoadBalancer>";
|
||||
|
@ -142,10 +144,10 @@ public class LoadbalancerApiMockTest extends BaseProfitBricksMockTest {
|
|||
serverIds.add("server-ids");
|
||||
String requestId = api.createLoadBalancer(LoadBalancer.Request.creatingBuilder()
|
||||
.dataCenterId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeeee")
|
||||
.loadBalancerName("load-balancer-name")
|
||||
.loadBalancerAlgorithm(Algorithm.ROUND_ROBIN)
|
||||
.name("load-balancer-name")
|
||||
.algorithm(Algorithm.ROUND_ROBIN)
|
||||
.ip("192.168.0.1")
|
||||
.lanId("lan-id")
|
||||
.lanId(3)
|
||||
.serverIds(serverIds)
|
||||
.build());
|
||||
|
||||
|
@ -180,8 +182,8 @@ public class LoadbalancerApiMockTest extends BaseProfitBricksMockTest {
|
|||
try {
|
||||
LoadBalancer.Request.UpdatePayload toUpdate = LoadBalancer.Request.updatingBuilder()
|
||||
.id(id)
|
||||
.loadBalancerName("load-balancer-name")
|
||||
.loadBalancerAlgorithm(Algorithm.ROUND_ROBIN)
|
||||
.name("load-balancer-name")
|
||||
.algorithm(Algorithm.ROUND_ROBIN)
|
||||
.ip("192.168.0.1")
|
||||
.build();
|
||||
|
||||
|
@ -216,14 +218,13 @@ public class LoadbalancerApiMockTest extends BaseProfitBricksMockTest {
|
|||
List<String> serverIds = Lists.newArrayList();
|
||||
serverIds.add("1");
|
||||
serverIds.add("2");
|
||||
LoadBalancer.Request.RegisterPayload payload = LoadBalancer.Request.registerBuilder()
|
||||
.id("1234")
|
||||
.serverIds(serverIds)
|
||||
.build();
|
||||
LoadBalancer.Request.RegisterPayload payload = LoadBalancer.Request
|
||||
.createRegisteringPaylod("1234", serverIds);
|
||||
|
||||
LoadBalancer loadbalancer = api.registerLoadBalancer(payload);
|
||||
LoadBalancer loadBalancer = api.registerLoadBalancer(payload);
|
||||
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
assertNotNull(loadBalancer);
|
||||
} finally {
|
||||
pbApi.close();
|
||||
server.shutdown();
|
||||
|
@ -250,10 +251,14 @@ public class LoadbalancerApiMockTest extends BaseProfitBricksMockTest {
|
|||
List<String> serverIds = Lists.newArrayList();
|
||||
serverIds.add("1");
|
||||
serverIds.add("2");
|
||||
LoadBalancer loadbalancer = api.deregisterLoadBalancer(LoadBalancer.Request.DeregisterPayload.create(serverIds, "load-balancer-id"));
|
||||
|
||||
LoadBalancer.Request.DeregisterPayload payload = LoadBalancer.Request
|
||||
.createDeregisteringPayload("load-balancer-id", serverIds);
|
||||
|
||||
LoadBalancer loadBalancer = api.deregisterLoadBalancer(payload);
|
||||
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
assertNotNull(loadbalancer);
|
||||
assertNotNull(loadBalancer);
|
||||
} finally {
|
||||
pbApi.close();
|
||||
server.shutdown();
|
|
@ -140,15 +140,22 @@ public class NicApiMockTest extends BaseProfitBricksMockTest {
|
|||
String content = "<ws:updateNic>"
|
||||
+ "<request>"
|
||||
+ "<nicId>nic-id</nicId>"
|
||||
+ "<ip>ip</ip>"
|
||||
+ "<ip>10.0.0.1</ip>"
|
||||
+ "<nicName>nic-name</nicName>"
|
||||
+ "<dhcpActive>true</dhcpActive>"
|
||||
+ "<lanId>1</lanId>"
|
||||
+ "</request>"
|
||||
+ "</ws:updateNic>";
|
||||
try {
|
||||
Nic nic = api.updateNic(Nic.Request.UpdatePayload.create("nic-id", "ip", "nic-name", true, 1));
|
||||
Nic nic = api.updateNic(Nic.Request.updatingBuilder()
|
||||
.id("nic-id")
|
||||
.ip("10.0.0.1")
|
||||
.name("nic-name")
|
||||
.dhcpActive(true)
|
||||
.lanId(1)
|
||||
.build());
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
assertNotNull(nic);
|
||||
} finally {
|
||||
pbApi.close();
|
||||
server.shutdown();
|
||||
|
@ -169,8 +176,13 @@ public class NicApiMockTest extends BaseProfitBricksMockTest {
|
|||
+ "<internetAccess>true</internetAccess>"
|
||||
+ "</ws:setInternetAccess>";
|
||||
try {
|
||||
Nic nic = api.setInternetAccess(Nic.Request.SetInternetAccessPayload.create("datacenter-id", 1, true));
|
||||
Nic nic = api.setInternetAccess(Nic.Request.setInternetAccessBuilder()
|
||||
.dataCenterId("datacenter-id")
|
||||
.lanId(1)
|
||||
.internetAccess(true)
|
||||
.build());
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
assertNotNull(nic);
|
||||
} finally {
|
||||
pbApi.close();
|
||||
server.shutdown();
|
||||
|
|
|
@ -57,7 +57,12 @@ public class ServerApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
@Test
|
||||
public void testCreateServer() {
|
||||
String serverId = api.serverApi().createServer(
|
||||
Server.Request.CreatePayload.create(dataCenter.id(), "jclouds-node", 1, 1024));
|
||||
Server.Request.creatingBuilder()
|
||||
.dataCenterId(dataCenter.id())
|
||||
.name("jclouds-node")
|
||||
.cores(1)
|
||||
.ram(1024)
|
||||
.build());
|
||||
|
||||
assertNotNull(serverId);
|
||||
this.createdServerId = serverId;
|
||||
|
|
|
@ -58,7 +58,11 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
|
||||
@Test
|
||||
public void testCreateSnapshot() {
|
||||
Snapshot snapshot = api.snapshotApi().createSnapshot(Snapshot.Request.CreatePayload.create(storageId, "my description", "test snapshot"));
|
||||
Snapshot snapshot = api.snapshotApi().createSnapshot(Snapshot.Request.creatingBuilder()
|
||||
.storageId(storageId)
|
||||
.description("my description")
|
||||
.name("test snapshot")
|
||||
.build());
|
||||
|
||||
assertNotNull(snapshot);
|
||||
|
||||
|
@ -89,7 +93,7 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
String newName = "new name";
|
||||
|
||||
api.snapshotApi().updateSnapshot(Snapshot.Request.updatingBuilder()
|
||||
.snapshotId(snapshotId)
|
||||
.id(snapshotId)
|
||||
.description("new description")
|
||||
.name(newName)
|
||||
.bootable(true)
|
||||
|
@ -112,7 +116,7 @@ public class SnapshotApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
|
||||
@Test(dependsOnMethods = "testCreateSnapshot")
|
||||
public void testRollbackSnapshot() {
|
||||
String result = api.snapshotApi().rollbackSnapshot(Snapshot.Request.RollbackPayload.create(snapshotId, storageId));
|
||||
String result = api.snapshotApi().rollbackSnapshot(Snapshot.Request.createRollbackPayload(snapshotId, storageId));
|
||||
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
|
|
@ -182,9 +182,10 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
|||
|
||||
try {
|
||||
String requestId = api.updateSnapshot(Snapshot.Request.updatingBuilder()
|
||||
.snapshotId(snapshotId)
|
||||
.name("snapshot-name")
|
||||
.id(snapshotId)
|
||||
.description("description")
|
||||
.name("snapshot-name")
|
||||
.bootable(false)
|
||||
.osType(OsType.LINUX)
|
||||
.isCpuHotPlug(false)
|
||||
.isCpuHotUnPlug(false)
|
||||
|
@ -256,10 +257,7 @@ public class SnapshotApiMockTest extends BaseProfitBricksMockTest {
|
|||
|
||||
String content = "<ws:rollbackSnapshot><request><snapshotId>" + snapshotId + "</snapshotId><storageId>" + storageId + "</storageId></request></ws:rollbackSnapshot>";
|
||||
try {
|
||||
String result = api.rollbackSnapshot(Snapshot.Request.rollbackBuilder()
|
||||
.snapshotId(snapshotId)
|
||||
.storageId(storageId)
|
||||
.build());
|
||||
String result = api.rollbackSnapshot(Snapshot.Request.createRollbackPayload(snapshotId, storageId));
|
||||
assertRequestHasCommonProperties(server.takeRequest(), content);
|
||||
assertNotNull(result);
|
||||
} finally {
|
||||
|
|
|
@ -66,7 +66,7 @@ public class StorageApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
public void testUberStorage() {
|
||||
api.storageApi().createStorage(
|
||||
Storage.Request.creatingBuilder()
|
||||
.dataCenterId(dataCenter)
|
||||
.dataCenterId(dataCenter.id())
|
||||
.name("Uber Storage")
|
||||
.size(9999999f)
|
||||
.build());
|
||||
|
@ -76,7 +76,7 @@ public class StorageApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
public void testCreateStorage() {
|
||||
String storageId = api.storageApi().createStorage(
|
||||
Storage.Request.creatingBuilder()
|
||||
.dataCenterId(dataCenter)
|
||||
.dataCenterId(dataCenter.id())
|
||||
.name("hdd-1")
|
||||
.size(2f)
|
||||
.build());
|
||||
|
@ -114,7 +114,7 @@ public class StorageApiLiveTest extends BaseProfitBricksLiveTest {
|
|||
Storage.Request.updatingBuilder()
|
||||
.id(createdStorageId)
|
||||
.name("hdd-2")
|
||||
.size(5l)
|
||||
.size(5f)
|
||||
.build());
|
||||
|
||||
assertNotNull(requestId);
|
||||
|
|
|
@ -73,7 +73,7 @@ public class ResponseStatusFromPayloadHttpCommandExecutorServiceTest extends Bas
|
|||
DataCenterApi api = pbApi.dataCenterApi();
|
||||
|
||||
try {
|
||||
api.createDataCenter(DataCenter.Request.CreatePayload.create("D@tacenter", Location.DE_FKB));
|
||||
api.createDataCenter(DataCenter.Request.creatingPayload("D@tacenter", Location.DE_FKB));
|
||||
fail("Request should have failed");
|
||||
} catch (Exception ex) {
|
||||
assertTrue(ex instanceof IllegalArgumentException, "Exception should be an IllegalArgumentException");
|
||||
|
@ -111,7 +111,13 @@ public class ResponseStatusFromPayloadHttpCommandExecutorServiceTest extends Bas
|
|||
ServerApi api = pbApi.serverApi();
|
||||
|
||||
try {
|
||||
api.createServer(Server.Request.CreatePayload.create("some-datacenter-id", "node1", 99, 12800));
|
||||
api.createServer(
|
||||
Server.Request.creatingBuilder()
|
||||
.dataCenterId("some-datacenter-id")
|
||||
.name("node1")
|
||||
.cores(99)
|
||||
.ram(12800)
|
||||
.build());
|
||||
fail("Request should have failed.");
|
||||
} catch (Exception ex) {
|
||||
assertTrue(ex instanceof InsufficientResourcesException, "Exception should be InsufficientResourcesException");
|
||||
|
|
|
@ -104,7 +104,7 @@ public class DataCenterInfoResponseHandlerTest extends BaseResponseHandlerTest<D
|
|||
.lanId(1)
|
||||
.internetAccess(true)
|
||||
.serverId("qqqqqqqq-wwww-eeee-rrrr-tttttttttttt")
|
||||
.ip("202.94.38.12")
|
||||
.ips(ImmutableList.of("202.94.38.12"))
|
||||
.macAddress("02:01:09:cd:f0:b0")
|
||||
.firewall(
|
||||
Firewall.builder()
|
||||
|
|
|
@ -44,29 +44,28 @@ public class IpBlockListResponseHandlerTest extends BaseResponseHandlerTest<List
|
|||
|
||||
List<IpBlock> expected = ImmutableList.<IpBlock>of(
|
||||
IpBlock.builder()
|
||||
.id("block-id")
|
||||
.id("block-id-1")
|
||||
.location(Location.US_LAS)
|
||||
.publicIps(ImmutableList.<PublicIp>of(
|
||||
PublicIp.builder()
|
||||
.ip("1.1")
|
||||
.nicId("nic-id")
|
||||
.ip("10.0.0.2")
|
||||
.nicId("nic-id-1")
|
||||
.build(),
|
||||
PublicIp.builder()
|
||||
.ip("1.2")
|
||||
.nicId("nic-id")
|
||||
.ip("10.0.0.3")
|
||||
.nicId("nic-id-2")
|
||||
.build()))
|
||||
.build(),
|
||||
IpBlock.builder()
|
||||
.id("block-id")
|
||||
.id("block-id-2")
|
||||
.location(Location.US_LAS)
|
||||
.publicIps(ImmutableList.<PublicIp>of(
|
||||
PublicIp.builder()
|
||||
.ip("2.1")
|
||||
.nicId("nic-id")
|
||||
.ip("10.0.0.4")
|
||||
.build(),
|
||||
PublicIp.builder()
|
||||
.ip("2.2")
|
||||
.nicId("nic-id")
|
||||
.ip("10.0.0.5")
|
||||
.nicId("nic-id-4")
|
||||
.build()))
|
||||
.build()
|
||||
);
|
||||
|
|
|
@ -49,12 +49,11 @@ public class IpBlockResponseHandlerTest extends BaseResponseHandlerTest<IpBlock>
|
|||
.location(Location.US_LAS)
|
||||
.publicIps(ImmutableList.<PublicIp>of(
|
||||
PublicIp.builder()
|
||||
.ip("ip")
|
||||
.ip("10.0.0.2")
|
||||
.nicId("nic-id")
|
||||
.build(),
|
||||
PublicIp.builder()
|
||||
.ip("ip")
|
||||
.nicId("nic-id")
|
||||
.ip("10.0.0.3")
|
||||
.build()))
|
||||
.ips(emptyIpList)
|
||||
.build();
|
||||
|
|
|
@ -67,7 +67,7 @@ public class LoadBalancerListResponseHandlerTest extends BaseResponseHandlerTest
|
|||
.build())
|
||||
.internetAccess(true)
|
||||
.ip("192.168.0.1")
|
||||
.lanId("lan-id")
|
||||
.lanId(1)
|
||||
.state(ProvisioningState.AVAILABLE)
|
||||
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||
|
@ -97,7 +97,7 @@ public class LoadBalancerListResponseHandlerTest extends BaseResponseHandlerTest
|
|||
.build())
|
||||
.internetAccess(false)
|
||||
.ip("192.168.0.1")
|
||||
.lanId("lan-id")
|
||||
.lanId(2)
|
||||
.state(ProvisioningState.AVAILABLE)
|
||||
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z"))
|
||||
|
|
|
@ -85,7 +85,7 @@ public class LoadBalancerResponseHandlerTest extends BaseResponseHandlerTest<Loa
|
|||
.build())
|
||||
.internetAccess(true)
|
||||
.ip("192.168.0.1")
|
||||
.lanId("lan-id")
|
||||
.lanId(2)
|
||||
.state(ProvisioningState.AVAILABLE)
|
||||
.creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z"))
|
||||
.lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z"))
|
||||
|
|
|
@ -49,8 +49,8 @@ public class NicListResponseHandlerTest extends BaseResponseHandlerTest<List<Nic
|
|||
.lanId(1)
|
||||
.internetAccess(true)
|
||||
.serverId("server-id")
|
||||
.ip("192.168.0.1")
|
||||
.macAddress("mac-address")
|
||||
.ips(ImmutableList.of("192.168.0.1"))
|
||||
.macAddress("aa:bb:cc:dd:ee:f1")
|
||||
.firewall(
|
||||
Firewall.builder()
|
||||
.active(true)
|
||||
|
@ -75,7 +75,7 @@ public class NicListResponseHandlerTest extends BaseResponseHandlerTest<List<Nic
|
|||
"192.168.0.3",
|
||||
"192.168.0.4"
|
||||
))
|
||||
.macAddress("mac-address")
|
||||
.macAddress("aa:bb:cc:dd:ee:f2")
|
||||
.firewall(
|
||||
Firewall.builder()
|
||||
.active(false)
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jclouds.profitbricks.http.parser.nic;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.profitbricks.domain.Firewall;
|
||||
import org.jclouds.profitbricks.domain.Nic;
|
||||
|
@ -47,10 +49,10 @@ public class NicResponseHandlerTest extends BaseResponseHandlerTest<Nic> {
|
|||
.lanId(1)
|
||||
.internetAccess(true)
|
||||
.serverId("server-id")
|
||||
.ip("192.168.0.1")
|
||||
.macAddress("mac-address")
|
||||
.ips(ImmutableList.of("192.168.0.1"))
|
||||
.macAddress("aa:bb:cc:dd:ee:ff")
|
||||
.dhcpActive(true)
|
||||
.gatewayIp("gateway-ip")
|
||||
.gatewayIp("10.0.0.1")
|
||||
.state(ProvisioningState.AVAILABLE)
|
||||
.firewall(
|
||||
Firewall.builder()
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ServerInfoResponseHandlerTest extends BaseResponseHandlerTest<Serve
|
|||
.lanId(1)
|
||||
.internetAccess(true)
|
||||
.serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
||||
.ip("173.252.120.6")
|
||||
.ips(ImmutableList.of("173.252.120.6"))
|
||||
.macAddress("02:01:09:cd:f0:b0")
|
||||
.firewall(Firewall.builder()
|
||||
.active(false)
|
||||
|
|
|
@ -102,7 +102,7 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
|||
.lanId(1)
|
||||
.internetAccess(true)
|
||||
.serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop")
|
||||
.ip("173.252.120.6")
|
||||
.ips(ImmutableList.of("173.252.120.6"))
|
||||
.macAddress("02:01:09:cd:f0:b0")
|
||||
.firewall(Firewall.builder()
|
||||
.active(false)
|
||||
|
@ -160,7 +160,7 @@ public class ServerListResponseHandlerTest extends BaseResponseHandlerTest<List<
|
|||
.lanId(3)
|
||||
.internetAccess(false)
|
||||
.serverId("asdfghjk-asdf-asdf-asdf-asdfghjklkjl")
|
||||
.ip("202.69.181.241")
|
||||
.ips(ImmutableList.of("202.69.181.241"))
|
||||
.macAddress("02:01:9e:5e:35:1e")
|
||||
.firewall(Firewall.builder()
|
||||
.active(false)
|
||||
|
|
|
@ -59,7 +59,7 @@ public class SnapshotListResponseHandlerTest extends BaseResponseHandlerTest<Lis
|
|||
expected.add(Snapshot.builder()
|
||||
.id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||
.description("description")
|
||||
.size(1024)
|
||||
.size(1024f)
|
||||
.name("snapshot01")
|
||||
.state(ProvisioningState.AVAILABLE)
|
||||
.isBootable(true)
|
||||
|
@ -80,7 +80,7 @@ public class SnapshotListResponseHandlerTest extends BaseResponseHandlerTest<Lis
|
|||
expected.add(Snapshot.builder()
|
||||
.id("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy")
|
||||
.description("description")
|
||||
.size(1024)
|
||||
.size(1024f)
|
||||
.name("snapshot02")
|
||||
.state(ProvisioningState.AVAILABLE)
|
||||
.isBootable(true)
|
||||
|
|
|
@ -53,7 +53,7 @@ public class SnapshotResponseHandlerTest extends BaseResponseHandlerTest<Snapsho
|
|||
Snapshot expected = Snapshot.builder()
|
||||
.id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh")
|
||||
.description("description")
|
||||
.size(1024)
|
||||
.size(1024f)
|
||||
.name("snapshot01")
|
||||
.state(ProvisioningState.AVAILABLE)
|
||||
.isBootable(true)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<requestId>request-id</requestId>
|
||||
<blockId>block-id</blockId>
|
||||
<location>us/las</location>
|
||||
<ips>ip</ips>
|
||||
<ips>10.0.0.1</ips>
|
||||
</return>
|
||||
</ns2:reservePublicIpBlockResponse>
|
||||
</S:Body>
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
<blockId>qwertyui-qwer-qwer-qwer-qwertyyuiiop</blockId>
|
||||
<location>us/las</location>
|
||||
<publicIps>
|
||||
<ip>ip</ip>
|
||||
<ip>10.0.0.2</ip>
|
||||
<nicId>nic-id</nicId>
|
||||
</publicIps>
|
||||
<publicIps>
|
||||
<ip>ip</ip>
|
||||
<ip>10.0.0.3</ip>
|
||||
</publicIps>
|
||||
</return>
|
||||
</ns2:getAllPublicIpBlocksResponse>
|
||||
|
|
|
@ -3,26 +3,26 @@
|
|||
<S:Body>
|
||||
<ns2:getAllPublicIpBlocksResponse xmlns:ns2="http://ws.api.profitbricks.com/">
|
||||
<return>
|
||||
<blockId>block-id</blockId>
|
||||
<blockId>block-id-1</blockId>
|
||||
<location>us/las</location>
|
||||
<publicIps>
|
||||
<ip>1.1</ip>
|
||||
<nicId>nic-id</nicId>
|
||||
<ip>10.0.0.2</ip>
|
||||
<nicId>nic-id-1</nicId>
|
||||
</publicIps>
|
||||
<publicIps>
|
||||
<ip>1.2</ip>
|
||||
<nicId>nic-id</nicId>
|
||||
<ip>10.0.0.3</ip>
|
||||
<nicId>nic-id-2</nicId>
|
||||
</publicIps>
|
||||
</return>
|
||||
<return>
|
||||
<blockId>block-id</blockId>
|
||||
<blockId>block-id-2</blockId>
|
||||
<location>us/las</location>
|
||||
<publicIps>
|
||||
<ip>2.1</ip>
|
||||
<ip>10.0.0.4</ip>
|
||||
</publicIps>
|
||||
<publicIps>
|
||||
<ip>2.2</ip>
|
||||
<nicId>nic-id</nicId>
|
||||
<ip>10.0.0.5</ip>
|
||||
<nicId>nic-id-4</nicId>
|
||||
</publicIps>
|
||||
</return>
|
||||
</ns2:getAllPublicIpBlocksResponse>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<loadBalancerName>load-balancer-name</loadBalancerName>
|
||||
<loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>
|
||||
<ip>192.168.0.1</ip>
|
||||
<lanId>lan-id</lanId>
|
||||
<lanId>1</lanId>
|
||||
<serverIds>server-ids</serverIds>
|
||||
</request>
|
||||
</ws:createLoadBalancer>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<return>
|
||||
<requestId>request-id</requestId>
|
||||
<dataCenterId>datacenter-id</dataCenterId>
|
||||
<dataCenterVersion>datacenter-version</dataCenterVersion>
|
||||
<dataCenterVersion>123</dataCenterVersion>
|
||||
</return>
|
||||
</ns2:deleteLoadBalancerResponse>
|
||||
</S:Body>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>
|
||||
<internetAccess>true</internetAccess>
|
||||
<ip>192.168.0.1</ip>
|
||||
<lanId>lan-id</lanId>
|
||||
<lanId>2</lanId>
|
||||
<balancedServers>
|
||||
<activate>true</activate>
|
||||
<balancedNicId>balanced-nic-id</balancedNicId>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>
|
||||
<internetAccess>true</internetAccess>
|
||||
<ip>192.168.0.1</ip>
|
||||
<lanId>lan-id</lanId>
|
||||
<lanId>1</lanId>
|
||||
<balancedServers>
|
||||
<activate>true</activate>
|
||||
<balancedNicId>balanced-nic-id</balancedNicId>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>
|
||||
<internetAccess>false</internetAccess>
|
||||
<ip>192.168.0.1</ip>
|
||||
<lanId>lan-id</lanId>
|
||||
<lanId>2</lanId>
|
||||
<balancedServers>
|
||||
<activate>false</activate>
|
||||
<balancedNicId>balanced-nic-id</balancedNicId>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<internetAccess>true</internetAccess>
|
||||
<serverId>server-id</serverId>
|
||||
<ips>192.168.0.1</ips>
|
||||
<macAddress>mac-address</macAddress>
|
||||
<macAddress>aa:bb:cc:dd:ee:ff</macAddress>
|
||||
<firewall>
|
||||
<active>true</active>
|
||||
<firewallId>firewall-id</firewallId>
|
||||
|
@ -19,7 +19,7 @@
|
|||
<provisioningState>AVAILABLE</provisioningState>
|
||||
</firewall>
|
||||
<dhcpActive>true</dhcpActive>
|
||||
<gatewayIp>gateway-ip</gatewayIp>
|
||||
<gatewayIp>10.0.0.1</gatewayIp>
|
||||
<provisioningState>AVAILABLE</provisioningState>
|
||||
</return>
|
||||
</ns2:getNicResponse>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<internetAccess>true</internetAccess>
|
||||
<serverId>server-id</serverId>
|
||||
<ips>192.168.0.1</ips>
|
||||
<macAddress>mac-address</macAddress>
|
||||
<macAddress>aa:bb:cc:dd:ee:f1</macAddress>
|
||||
<firewall>
|
||||
<active>true</active>
|
||||
<firewallId>firewall-id</firewallId>
|
||||
|
@ -33,7 +33,7 @@
|
|||
<ips>192.168.0.2</ips>
|
||||
<ips>192.168.0.3</ips>
|
||||
<ips>192.168.0.4</ips>
|
||||
<macAddress>mac-address</macAddress>
|
||||
<macAddress>aa:bb:cc:dd:ee:f2</macAddress>
|
||||
<firewall>
|
||||
<active>false</active>
|
||||
<firewallId>firewall-id2</firewallId>
|
||||
|
|
Loading…
Reference in New Issue