xml enum annotation

This commit is contained in:
danikov 2012-04-10 14:03:22 +01:00
parent fc782dd7ee
commit 5e44ad39c2
21 changed files with 505 additions and 234 deletions

View File

@ -19,15 +19,22 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Function;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/** /**
* Used when OrgLdapMode=CUSTOM to define connection details for * Used when OrgLdapMode=CUSTOM to define connection details for
@ -76,34 +83,74 @@ import com.google.common.base.Objects.ToStringHelper;
"groupAttributes" "groupAttributes"
}) })
public class CustomOrgLdapSettings { public class CustomOrgLdapSettings {
public static final class AuthenticationMechanism { @XmlType
public static final String SIMPLE = "simple"; @XmlEnum(String.class)
public static final String KERBEROS = "kerberos"; public static enum AuthenticationMechanism {
public static final String MD5DIGEST = "md5digest"; @XmlEnumValue("simple") SIMPLE("simple"),
public static final String NTLM = "ntlm"; @XmlEnumValue("kerberos") KERBEROS("kerberos"),
@XmlEnumValue("md5digest") MD5DIGEST("md5digest"),
@XmlEnumValue("ntlm") NTLM("ntlm"),
UNRECOGNIZED("unrecognized");
public static final List<AuthenticationMechanism> ALL = ImmutableList.of(
SIMPLE, KERBEROS, MD5DIGEST, NTLM);
/** protected final String stringValue;
* All acceptable {@link CustomOrgLdapSettings#getAuthenticationMechanism()} values.
* <p/> AuthenticationMechanism(String stringValue) {
* This list must be updated whenever a new authentication mechanism is added. this.stringValue = stringValue;
*/ }
public static final List<String> ALL = Arrays.asList(
SIMPLE, KERBEROS, MD5DIGEST, NTLM public String value() {
); return stringValue;
}
protected final static Map<String, AuthenticationMechanism> AUTHENTICATION_MECHANISM_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(AuthenticationMechanism.values()), new Function<AuthenticationMechanism, String>() {
@Override
public String apply(AuthenticationMechanism input) {
return input.stringValue;
}
});
public static AuthenticationMechanism fromValue(String value) {
AuthenticationMechanism authMechanism = AUTHENTICATION_MECHANISM_BY_ID.get(checkNotNull(value, "stringValue"));
return authMechanism == null ? UNRECOGNIZED : authMechanism;
}
} }
public static final class ConnectorType { @XmlType
public static final String ACTIVE_DIRECTORY = "ACTIVE_DIRECTORY"; @XmlEnum(String.class)
public static final String OPEN_LDAP = "OPEN_LDAP"; public static enum ConnectorType {
@XmlEnumValue("ACTIVE_DIRECTORY") ACTIVE_DIRECTORY("ACTIVE_DIRECTORY"),
@XmlEnumValue("OPEN_LDAP") OPEN_LDAP("OPEN_LDAP"),
UNRECOGNIZED("unrecognized");
public static final List<ConnectorType> ALL = ImmutableList.of(
ACTIVE_DIRECTORY, OPEN_LDAP);
/** protected final String stringValue;
* All acceptable {@link OrgLdapSettings#getLdapMode()} values.
* <p/> ConnectorType(String stringValue) {
* This list must be updated whenever a new mode is added. this.stringValue = stringValue;
*/ }
public static final List<String> ALL = Arrays.asList(
ACTIVE_DIRECTORY, OPEN_LDAP public String value() {
); return stringValue;
}
protected final static Map<String, ConnectorType> CONNECTOR_TYPE_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(ConnectorType.values()), new Function<ConnectorType, String>() {
@Override
public String apply(ConnectorType input) {
return input.stringValue;
}
});
public static ConnectorType fromValue(String value) {
ConnectorType type = CONNECTOR_TYPE_BY_ID.get(checkNotNull(value, "stringValue"));
return type == null ? UNRECOGNIZED : type;
}
} }
public static Builder<?> builder() { public static Builder<?> builder() {

View File

@ -25,7 +25,10 @@ import java.util.Arrays;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
@ -50,21 +53,22 @@ public class Error {
@Resource @Resource
protected static Logger logger = Logger.NULL; protected static Logger logger = Logger.NULL;
@XmlType
@XmlEnum(Integer.class)
public static enum Code { public static enum Code {
@XmlEnumValue("200") OK(200),
OK(200), @XmlEnumValue("201") CREATED(201),
CREATED(201), @XmlEnumValue("202") ACCEPTED(202),
ACCEPTED(202), @XmlEnumValue("204") NO_CONTENT(204),
NO_CONTENT(204), @XmlEnumValue("303") SEE_OTHER(303),
SEE_OTHER(303), @XmlEnumValue("400") BAD_REQUEST(400),
BAD_REQUEST(400), @XmlEnumValue("401") UNAUTHORIZED(401),
UNAUTHORIZED(401), @XmlEnumValue("403") FORBIDDEN(403), // NOTE also means 'not found' for entities
FORBIDDEN(403), // NOTE also means 'not found' for entities @XmlEnumValue("404") NOT_FOUND(404),
NOT_FOUND(404), @XmlEnumValue("405") NOT_ALLOWED(405),
NOT_ALLOWED(405), @XmlEnumValue("500") INTERNAL_ERROR(500),
INTERNAL_ERROR(500), @XmlEnumValue("501") NOT_IMPLEMENTED(501),
NOT_IMPLEMENTED(501), @XmlEnumValue("503") UNAVAILABLE(503),
UNAVAILABLE(503),
UNRECOGNIZED(-1); UNRECOGNIZED(-1);
private Integer majorErrorCode; private Integer majorErrorCode;

View File

@ -21,15 +21,21 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Function;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/** /**
* A link. * A link.
@ -42,71 +48,70 @@ import com.google.common.base.Objects.ToStringHelper;
*/ */
@XmlRootElement(name = "Link") @XmlRootElement(name = "Link")
public class Link extends Reference { public class Link extends Reference {
@XmlType
@XmlEnum(String.class)
public static enum Rel {
@XmlEnumValue("add") ADD("add"),
@XmlEnumValue("alternate") ALTERNATE("alternate"),
@XmlEnumValue("catalogItem") CATALOG_ITEM("catalogItem"),
@XmlEnumValue("collaboration:abort") COLLABORATION_ABORT("collaboration:abort"),
@XmlEnumValue("collaboration:fail") COLLABORATION_FAIL("collaboration:fail"),
@XmlEnumValue("collaboration:resume") COLLABORATION_RESUME("collaboration:resume"),
@XmlEnumValue("consolidate") CONSOLIDATE("consolidate"),
@XmlEnumValue("controlAccess") CONTROL_ACCESS("controlAccess"),
@XmlEnumValue("copy") COPY("copy"),
@XmlEnumValue("deploy") DEPLOY("deploy"),
@XmlEnumValue("disable") DISABLE("disable"),
@XmlEnumValue("discardState") DISCARD_STATE("discardState"),
@XmlEnumValue("down") DOWN("down"),
@XmlEnumValue("download:alternate") DOWNLOAD_ALTERNATE("download:alternate"),
@XmlEnumValue("download:default") DOWNLOAD_DEFAULT("download:default"),
@XmlEnumValue("edit") EDIT("edit"),
@XmlEnumValue("enable") ENABLE("enable"),
@XmlEnumValue("firstPage") FIRST_PAGE("firstPage"),
@XmlEnumValue("installVmwareTools") INSTALL_VMWARE_TOOLS("installVmwareTools"),
@XmlEnumValue("lastPage") LAST_PAGE("lastPage"),
@XmlEnumValue("media:ejectMedia") EJECT_MEDIA("media:ejectMedia"),
@XmlEnumValue("media:insertMedia") INSERT_MEDIA("media:insertMedia"),
@XmlEnumValue("move") MOVE("move"),
@XmlEnumValue("nextPage") NEXT_PAGE("nextPage"),
@XmlEnumValue("ova") OVA("ova"),
@XmlEnumValue("ovf") OVF("ovf"),
@XmlEnumValue("power:powerOff") POWER_OFF("power:powerOff"),
@XmlEnumValue("power:powerOn") POWER_ON("power:powerOn"),
@XmlEnumValue("power:reboot") REBOOT("power:reboot"),
@XmlEnumValue("power:reset") RESET("power:reset"),
@XmlEnumValue("power:shutdown") SHUTDOWN("power:shutdown"),
@XmlEnumValue("power:suspend") SUSPEND("power:suspend"),
@XmlEnumValue("previousPage") PREVIOUS_PAGE("previousPage"),
@XmlEnumValue("publish") PUBLISH("publish"),
@XmlEnumValue("recompose") RECOMPOSE("recompose"),
@XmlEnumValue("reconnect") RECONNECT("reconnect"),
@XmlEnumValue("register") REGISTER("register"),
@XmlEnumValue("reject") REJECT("reject"),
@XmlEnumValue("relocate") RELOCATE("relocate"),
@XmlEnumValue("remove") REMOVE("remove"),
@XmlEnumValue("screen:acquireTicket") SCREEN_ACQUIRE_TICKET("screen:acquireTicket"),
@XmlEnumValue("screen:thumbnail") SCREEN_THUMBNAIL("screen:thumbnail"),
@XmlEnumValue("task:cancel") TASK_CANCEL("task:cancel"),
@XmlEnumValue("blockingTask") BLOCKING_TASK("blockingTask"),
@XmlEnumValue("taskOwner") TASK_OWNER("taskOwner"),
@XmlEnumValue("taskParams") TASK_PARAMS("taskParams"),
@XmlEnumValue("taskRequest") TASK_REQUEST("taskRequest"),
@XmlEnumValue("undeploy") UNDEPLOY("undeploy"),
@XmlEnumValue("unlock") UNLOCK("unlock"),
@XmlEnumValue("unregister") UNREGISTER("unregister"),
@XmlEnumValue("up") UP("up"),
@XmlEnumValue("updateProgress") UPDATE_PROGRESS("updateProgress"),
@XmlEnumValue("upgrade") UPGRADE("upgrade"),
@XmlEnumValue("upload:alternate") UPLOAD_ALTERNATE("upload:alternate"),
@XmlEnumValue("upload:default") UPLOAD_DEFAULT("upload:default"),
@XmlEnumValue("repair") REPAIR("repair"),
public static final class Rel { UNRECOGNIZED("unrecognized");
public static final String ADD = "add";
public static final String ALTERNATE = "alternate"; public static final List<Rel> ALL = ImmutableList.of(
public static final String CATALOG_ITEM = "catalogItem";
public static final String COLLABORATION_ABORT = "collaboration:abort";
public static final String COLLABORATION_FAIL = "collaboration:fail";
public static final String COLLABORATION_RESUME = "collaboration:resume";
public static final String CONSOLIDATE = "consolidate";
public static final String CONTROL_ACCESS = "controlAccess";
public static final String COPY = "copy";
public static final String DEPLOY = "deploy";
public static final String DISABLE = "disable";
public static final String DISCARD_STATE = "discardState";
public static final String DOWN = "down";
public static final String DOWNLOAD_ALTERNATE = "download:alternate";
public static final String DOWNLOAD_DEFAULT = "download:default";
public static final String EDIT = "edit";
public static final String ENABLE = "enable";
public static final String FIRST_PAGE = "firstPage";
public static final String INSTALL_VMWARE_TOOLS = "installVmwareTools";
public static final String LAST_PAGE = "lastPage";
public static final String EJECT_MEDIA = "media:ejectMedia";
public static final String INSERT_MEDIA = "media:insertMedia";
public static final String MOVE = "move";
public static final String NEXT_PAGE = "nextPage";
public static final String OVA = "ova";
public static final String OVF = "ovf";
public static final String POWER_OFF = "power:powerOff";
public static final String POWER_ON = "power:powerOn";
public static final String REBOOT = "power:reboot";
public static final String RESET = "power:reset";
public static final String SHUTDOWN = "power:shutdown";
public static final String SUSPEND = "power:suspend";
public static final String PREVIOUS_PAGE = "previousPage";
public static final String PUBLISH = "publish";
public static final String RECOMPOSE = "recompose";
public static final String RECONNECT = "reconnect";
public static final String REGISTER = "register";
public static final String REJECT = "reject";
public static final String RELOCATE = "relocate";
public static final String REMOVE = "remove";
public static final String SCREEN_ACQUIRE_TICKET = "screen:acquireTicket";
public static final String SCREEN_THUMBNAIL = "screen:thumbnail";
public static final String TASK_CANCEL = "task:cancel";
public static final String BLOCKING_TASK = "blockingTask";
public static final String TASK_OWNER = "taskOwner";
public static final String TASK_PARAMS = "taskParams";
public static final String TASK_REQUEST = "taskRequest";
public static final String UNDEPLOY = "undeploy";
public static final String UNLOCK = "unlock";
public static final String UNREGISTER = "unregister";
public static final String UP = "up";
public static final String UPDATE_PROGRESS = "updateProgress";
public static final String UPGRADE = "upgrade";
public static final String UPLOAD_ALTERNATE = "upload:alternate";
public static final String UPLOAD_DEFAULT = "upload:default";
public static final String REPAIR = "repair";
/**
* All acceptable {@link Link#getRel()} values.
*
* This list must be updated whenever a new relationship is added.
*/
public static final List<String> ALL = Arrays.asList(
ADD, ALTERNATE, CATALOG_ITEM, COLLABORATION_ABORT, ADD, ALTERNATE, CATALOG_ITEM, COLLABORATION_ABORT,
COLLABORATION_FAIL, COLLABORATION_RESUME, CONSOLIDATE, COLLABORATION_FAIL, COLLABORATION_RESUME, CONSOLIDATE,
CONTROL_ACCESS, COPY, DEPLOY, DISABLE, DISCARD_STATE, DOWN, CONTROL_ACCESS, COPY, DEPLOY, DISABLE, DISCARD_STATE, DOWN,
@ -118,8 +123,30 @@ public class Link extends Reference {
SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER, SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER,
TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP, TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP,
UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT, UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT,
UPLOAD_DEFAULT UPLOAD_DEFAULT);
);
protected final String stringValue;
Rel(String stringValue) {
this.stringValue = stringValue;
}
public String value() {
return stringValue;
}
protected final static Map<String, Rel> REL_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(Rel.values()), new Function<Rel, String>() {
@Override
public String apply(Rel input) {
return input.stringValue;
}
});
public static Rel fromValue(String value) {
Rel rel = REL_BY_ID.get(checkNotNull(value, "stringValue"));
return rel == null ? UNRECOGNIZED : rel;
}
} }
public static Builder<?> builder() { public static Builder<?> builder() {

View File

@ -19,16 +19,24 @@ f * Licensed to jclouds, Inc. (jclouds) under one or more
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Function;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/** /**
* Represents a media. * Represents a media.
@ -39,12 +47,38 @@ import com.google.common.base.Objects.ToStringHelper;
*/ */
@XmlRootElement(name = "Media") @XmlRootElement(name = "Media")
public class Media extends ResourceEntityType { public class Media extends ResourceEntityType {
@XmlType
@XmlEnum(String.class)
public static enum ImageType {
@XmlEnumValue("iso") ISO("iso"),
@XmlEnumValue("floppy") FLOPPY("floppy"),
UNRECOGNIZED("unrecognized");
public static final List<ImageType> ALL = ImmutableList.of(ISO, FLOPPY);
public static final class ImageType { protected final String stringValue;
public static final String ISO = "iso";
public static final String FLOPPY = "floppy";
public static final List<String> ALL = Arrays.asList(ISO, FLOPPY); ImageType(String stringValue) {
this.stringValue = stringValue;
}
public String value() {
return stringValue;
}
protected final static Map<String, ImageType> STATUS_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(ImageType.values()), new Function<ImageType, String>() {
@Override
public String apply(ImageType input) {
return input.stringValue;
}
});
public static ImageType fromValue(String value) {
ImageType type = STATUS_BY_ID.get(checkNotNull(value, "stringValue"));
return type == null ? UNRECOGNIZED : type;
}
} }
public static Builder<?> builder() { public static Builder<?> builder() {
@ -61,7 +95,7 @@ public class Media extends ResourceEntityType {
public static abstract class Builder<B extends Builder<B>> extends ResourceEntityType.Builder<B> { public static abstract class Builder<B extends Builder<B>> extends ResourceEntityType.Builder<B> {
private Owner owner; private Owner owner;
private String imageType; private ImageType imageType;
private long size; private long size;
/** /**
@ -75,7 +109,7 @@ public class Media extends ResourceEntityType {
/** /**
* @see Media#getImageType() * @see Media#getImageType()
*/ */
public B imageType(String imageType) { public B imageType(Media.ImageType imageType) {
this.imageType = imageType; this.imageType = imageType;
return self(); return self();
} }
@ -113,7 +147,7 @@ public class Media extends ResourceEntityType {
@XmlElement(name = "Owner") @XmlElement(name = "Owner")
protected Owner owner; protected Owner owner;
@XmlAttribute(required = true) @XmlAttribute(required = true)
protected String imageType; protected ImageType imageType;
@XmlAttribute(required = true) @XmlAttribute(required = true)
protected long size; protected long size;
@ -127,7 +161,7 @@ public class Media extends ResourceEntityType {
/** /**
* Gets the value of the imageType property. * Gets the value of the imageType property.
*/ */
public String getImageType() { public ImageType getImageType() {
return imageType; return imageType;
} }

View File

@ -19,32 +19,60 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Function;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
@XmlSeeAlso({ OrgNetwork.class, ExternalNetwork.class }) @XmlSeeAlso({ OrgNetwork.class, ExternalNetwork.class })
public abstract class Network extends EntityType { public abstract class Network extends EntityType {
public static final class FenceMode {
@XmlType
@XmlEnum(String.class)
public static enum FenceMode {
@XmlEnumValue("bridged") BRIDGED("bridged"),
@XmlEnumValue("isolated") ISOLATED("isolated"),
@XmlEnumValue("natRouted") NAT_ROUTED("natRouted"),
UNRECOGNIZED("unrecognized");
public static final List<FenceMode> ALL = ImmutableList.of(
BRIDGED, ISOLATED, NAT_ROUTED);
public static final String BRIDGED = "bridged"; protected final String stringValue;
public static final String ISOLATED = "isolated";
public static final String NAT_ROUTED = "natRouted";
/** FenceMode(String stringValue) {
* All acceptable {@link Network#getFenceMode()} values. this.stringValue = stringValue;
* <p/> }
* This list must be updated whenever a new mode is added.
*/ public String value() {
public static final List<String> ALL = Arrays.asList( return stringValue;
BRIDGED, ISOLATED, NAT_ROUTED }
);
protected final static Map<String, FenceMode> FENCE_MODE_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(FenceMode.values()), new Function<FenceMode, String>() {
@Override
public String apply(FenceMode input) {
return input.stringValue;
}
});
public static FenceMode fromValue(String value) {
FenceMode mode = FENCE_MODE_BY_ID.get(checkNotNull(value, "stringValue"));
return mode == null ? UNRECOGNIZED : mode;
}
} }
public abstract static class Builder<T extends Builder<T>> extends EntityType.Builder<T> { public abstract static class Builder<T extends Builder<T>> extends EntityType.Builder<T> {

View File

@ -25,6 +25,8 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode;
import com.google.common.base.Objects; import com.google.common.base.Objects;
/** /**
@ -47,7 +49,7 @@ public class NetworkConfiguration {
public static class Builder { public static class Builder {
private IpScope ipScope; private IpScope ipScope;
private Reference parentNetwork; private Reference parentNetwork;
private String fenceMode; private FenceMode fenceMode;
private Boolean retainNetInfoAcrossDeployments; private Boolean retainNetInfoAcrossDeployments;
private NetworkFeatures features; private NetworkFeatures features;
private SyslogServerSettings syslogServerSettings; private SyslogServerSettings syslogServerSettings;
@ -72,7 +74,7 @@ public class NetworkConfiguration {
/** /**
* @see NetworkConfiguration#getFenceMode() * @see NetworkConfiguration#getFenceMode()
*/ */
public Builder fenceMode(String fenceMode) { public Builder fenceMode(FenceMode fenceMode) {
this.fenceMode = fenceMode; this.fenceMode = fenceMode;
return this; return this;
} }
@ -122,7 +124,7 @@ public class NetworkConfiguration {
} }
} }
public NetworkConfiguration(IpScope ipScope, Reference parentNetwork, String fenceMode, Boolean retainNetInfoAcrossDeployments, public NetworkConfiguration(IpScope ipScope, Reference parentNetwork, FenceMode fenceMode, Boolean retainNetInfoAcrossDeployments,
NetworkFeatures features, SyslogServerSettings syslogServerSettings, RouterInfo routerInfo) { NetworkFeatures features, SyslogServerSettings syslogServerSettings, RouterInfo routerInfo) {
this.ipScope = ipScope; this.ipScope = ipScope;
this.parentNetwork = parentNetwork; this.parentNetwork = parentNetwork;
@ -142,7 +144,7 @@ public class NetworkConfiguration {
@XmlElement(name = "ParentNetwork") @XmlElement(name = "ParentNetwork")
private Reference parentNetwork; private Reference parentNetwork;
@XmlElement(name = "FenceMode") @XmlElement(name = "FenceMode")
private String fenceMode; private FenceMode fenceMode;
@XmlElement(name = "RetainNetInfoAcrossDeployments") @XmlElement(name = "RetainNetInfoAcrossDeployments")
private Boolean retainNetInfoAcrossDeployments; private Boolean retainNetInfoAcrossDeployments;
@XmlElement(name = "Features") @XmlElement(name = "Features")
@ -174,7 +176,7 @@ public class NetworkConfiguration {
* isolated (not connected to any other network), natRouted (connected to the ParentNetwork via a * isolated (not connected to any other network), natRouted (connected to the ParentNetwork via a
* NAT service) * NAT service)
*/ */
public String getFenceMode() { public FenceMode getFenceMode() {
return fenceMode; return fenceMode;
} }

View File

@ -23,13 +23,19 @@ import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Function;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/** /**
@ -70,30 +76,38 @@ import com.google.common.collect.ImmutableList;
}) })
public class NetworkConnection { public class NetworkConnection {
@XmlType
@XmlEnum(String.class)
public static enum IpAddressAllocationMode { public static enum IpAddressAllocationMode {
POOL("pool"), @XmlEnumValue("pool") POOL("pool"),
DHCP("dhcp"), @XmlEnumValue("dhcp") DHCP("dhcp"),
MANUAL("manual"), @XmlEnumValue("manual") MANUAL("manual"),
NONE("none"), @XmlEnumValue("none") NONE("none"),
UNRECOGNIZED("unrecognized"); UNRECOGNIZED("unrecognized");
public static final List<IpAddressAllocationMode> ALL = ImmutableList.of(POOL, DHCP, MANUAL, NONE); public static final List<IpAddressAllocationMode> ALL = ImmutableList.of(POOL, DHCP, MANUAL, NONE);
private final String label; protected final String label;
private IpAddressAllocationMode(String label) {
this.label = label; IpAddressAllocationMode(String stringValue) {
this.label = stringValue;
} }
public String getLabel() { public String label() {
return label; return label;
} }
protected final static Map<String, IpAddressAllocationMode> IP_ADDRESS_ALLOCATION_MODE_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(IpAddressAllocationMode.values()), new Function<IpAddressAllocationMode, String>() {
@Override
public String apply(IpAddressAllocationMode input) {
return input.label;
}
});
public static IpAddressAllocationMode fromValue(String value) { public static IpAddressAllocationMode fromValue(String value) {
try { IpAddressAllocationMode mode = IP_ADDRESS_ALLOCATION_MODE_BY_ID.get(checkNotNull(value, "stringValue"));
return valueOf(checkNotNull(value, "value").toUpperCase()); return mode == null ? UNRECOGNIZED : mode;
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
} }
} }

View File

@ -19,16 +19,23 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Function;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/** /**
* Base settings for LDAP connection * Base settings for LDAP connection
* *
@ -54,20 +61,39 @@ import com.google.common.base.Objects.ToStringHelper;
"customOrgLdapSettings" "customOrgLdapSettings"
}) })
public class OrgLdapSettings extends ResourceType { public class OrgLdapSettings extends ResourceType {
@XmlType
@XmlEnum(String.class)
public static enum LdapMode {
@XmlEnumValue("NONE") NONE("NONE"),
@XmlEnumValue("SYSTEM") SYSTEM("SYSTEM"),
@XmlEnumValue("CUSTOM") CUSTOM("CUSTOM"),
UNRECOGNIZED("unrecognized");
public static final List<LdapMode> ALL = ImmutableList.of( NONE, SYSTEM, CUSTOM );
public static final class LdapMode { protected final String stringValue;
public static final String NONE = "NONE";
public static final String SYSTEM = "SYSTEM";
public static final String CUSTOM = "CUSTOM";
/** LdapMode(String stringValue) {
* All acceptable {@link #getLdapMode()} values. this.stringValue = stringValue;
* }
* This list must be updated whenever a new mode is added.
*/ public String value() {
public static final List<String> ALL = Arrays.asList( return stringValue;
NONE, SYSTEM, CUSTOM }
);
protected final static Map<String, LdapMode> LDAP_MODE_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(LdapMode.values()), new Function<LdapMode, String>() {
@Override
public String apply(LdapMode input) {
return input.stringValue;
}
});
public static LdapMode fromValue(String value) {
LdapMode mode = LDAP_MODE_BY_ID.get(checkNotNull(value, "stringValue"));
return mode == null ? UNRECOGNIZED : mode;
}
} }
public static Builder<?> builder() { public static Builder<?> builder() {

View File

@ -1,27 +1,53 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import java.util.Arrays; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import org.jclouds.vcloud.director.v1_5.features.admin.AdminQueryClient; import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
public class Role { //TODO: placeholder for implementation public class Role { //TODO: placeholder for implementation
public static final class DefaultRoles { @XmlType
public static final String USER = "vApp User"; @XmlEnum(String.class)
public static final String AUTHOR = "vApp Author"; public static enum DefaultRoles {
public static final String CATALOG_AUTHOR = "Catalog Author"; @XmlEnumValue("vApp User") USER("vApp User"),
public static final String CONSOLE = "Console Access Only"; @XmlEnumValue("vApp Author") AUTHOR("vApp Author"),
public static final String ORG_ADMIN = "Organization Administrator"; @XmlEnumValue("Catalog Author") CATALOG_AUTHOR("Catalog Author"),
@XmlEnumValue("Console Access Only") CONSOLE("Console Access Only"),
@XmlEnumValue("Organization Administrator") ORG_ADMIN("Organization Administrator");
/** public static final List<DefaultRoles> ALL = ImmutableList.of(
* All default {@link AdminQueryClient#roleReferencesQueryAll()} values. USER, AUTHOR, CATALOG_AUTHOR, CONSOLE, ORG_ADMIN);
* <p/>
* This list must be updated whenever a new default role is added. protected final String stringValue;
*/
public static final List<String> ALL = Arrays.asList( DefaultRoles(String stringValue) {
USER, AUTHOR, CATALOG_AUTHOR, CONSOLE, ORG_ADMIN this.stringValue = stringValue;
); }
public String value() {
return stringValue;
}
protected final static Map<String, DefaultRoles> DEFAULT_ROLES_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(DefaultRoles.values()), new Function<DefaultRoles, String>() {
@Override
public String apply(DefaultRoles input) {
return input.stringValue;
}
});
public static DefaultRoles fromValue(String value) {
return DEFAULT_ROLES_BY_ID.get(checkNotNull(value, "stringValue"));
}
} }
} }

View File

@ -19,19 +19,27 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import com.google.common.base.Function;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/** /**
* Represents an asynchronous or long-running task in the vCloud environment. * Represents an asynchronous or long-running task in the vCloud environment.
@ -48,20 +56,44 @@ import com.google.common.base.Objects.ToStringHelper;
public class Task extends EntityType { public class Task extends EntityType {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASK; public static final String MEDIA_TYPE = VCloudDirectorMediaType.TASK;
@XmlType
@XmlEnum(String.class)
public static enum Status {
@XmlEnumValue("queued") QUEUED("queued"),
@XmlEnumValue("preRunning") PRE_RUNNING("preRunning"),
@XmlEnumValue("running") RUNNING("running"),
@XmlEnumValue("success") SUCCESS("success"),
@XmlEnumValue("error") ERROR("error"),
@XmlEnumValue("canceled") CANCELED("canceled"),
@XmlEnumValue("aborted") ABORTED("aborted"),
UNRECOGNIZED("unrecognized");
public static final List<Status> ALL = ImmutableList.of(
QUEUED, PRE_RUNNING, RUNNING, SUCCESS, ERROR, CANCELED, ABORTED);
public static class Status { protected final String stringValue;
public static final String QUEUED = "queued";
public static final String PRE_RUNNING = "preRunning";
public static final String RUNNING = "running";
public static final String SUCCESS = "success";
public static final String ERROR = "error";
public static final String CANCELED = "canceled";
public static final String ABORTED = "aborted";
public static final List<String> ALL = Arrays.asList( Status(String stringValue) {
QUEUED, PRE_RUNNING, RUNNING, SUCCESS, this.stringValue = stringValue;
ERROR, CANCELED, ABORTED }
);
public String value() {
return stringValue;
}
protected final static Map<String, Status> STATUS_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(Status.values()), new Function<Status, String>() {
@Override
public String apply(Status input) {
return input.stringValue;
}
});
public static Status fromValue(String value) {
Status status = STATUS_BY_ID.get(checkNotNull(value, "stringValue"));
return status == null ? UNRECOGNIZED : status;
}
} }
public static Builder<?> builder() { public static Builder<?> builder() {

View File

@ -19,17 +19,24 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import com.google.common.base.Function;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/** /**
* Represents vApp/VM undeployment parameters. * Represents vApp/VM undeployment parameters.
@ -42,20 +49,42 @@ import com.google.common.base.Objects;
@XmlRootElement(name = "UndeployVAppParams") @XmlRootElement(name = "UndeployVAppParams")
@XmlType(name = "UndeployVAppParamsType") @XmlType(name = "UndeployVAppParamsType")
public class UndeployVAppParams { public class UndeployVAppParams {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.UNDEPLOY_VAPP_PARAMS;
@XmlType
@XmlEnum(String.class)
public static enum PowerAction {
@XmlEnumValue("powerOff") POWER_OFF("powerOff"),
@XmlEnumValue("suspend") SUSPEND("suspend"),
@XmlEnumValue("shutdown") SHUTDOWN("shutdown"),
@XmlEnumValue("force") FORCE("force"),
UNRECOGNIZED("unrecognized");
public static final List<PowerAction> ALL = ImmutableList.of( POWER_OFF, SUSPEND, SHUTDOWN, FORCE );
public static final String MEDIA_TYPe = VCloudDirectorMediaType.UNDEPLOY_VAPP_PARAMS; protected final String stringValue;
public static class PowerAction { PowerAction(String stringValue) {
/** Power off the VMs. This is the default action if this attribute is missing or empty) */ this.stringValue = stringValue;
public static final String POWER_OFF = "powerOff"; }
/** Suspend the VMs. */
public static final String SUSPEND = "suspend";
/** Shut down the VMs. */
public static final String SHUTDOWN = "shutdown";
/** Attempt to power off the VMs. */
public static final String FORCE = "force";
public static final List<String> ALL = Arrays.asList(POWER_OFF, SUSPEND, SHUTDOWN, FORCE); public String value() {
return stringValue;
}
protected final static Map<String, PowerAction> POWER_ACTION_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(PowerAction.values()), new Function<PowerAction, String>() {
@Override
public String apply(PowerAction input) {
return input.stringValue;
}
});
public static PowerAction fromValue(String value) {
PowerAction action = POWER_ACTION_BY_ID.get(checkNotNull(value, "stringValue"));
return action == null ? UNRECOGNIZED : action;
}
} }
public static Builder builder() { public static Builder builder() {

View File

@ -20,12 +20,14 @@ package org.jclouds.vcloud.director.v1_5.predicates;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.Task.Status;
import org.jclouds.vcloud.director.v1_5.features.TaskClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -42,15 +44,14 @@ public class TaskStatusEquals implements Predicate<Task> {
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
private Collection<String> expectedStatuses; private Collection<Status> expectedStatuses;
private Collection<String> failingStatuses; private Collection<Status> failingStatuses;
// TODO Use Task.Status, once it is turned into an enumeration public TaskStatusEquals(TaskClient taskClient, Status expectedStatus, Set<Status> failingStatuses) {
public TaskStatusEquals(TaskClient taskClient, String expectedStatus, Collection<String> failingStatuses) {
this(taskClient, Collections.singleton(expectedStatus), failingStatuses); this(taskClient, Collections.singleton(expectedStatus), failingStatuses);
} }
public TaskStatusEquals(TaskClient taskClient, Collection<String> expectedStatuses, Collection<String> failingStatuses) { public TaskStatusEquals(TaskClient taskClient, Set<Status> expectedStatuses, Set<Status> failingStatuses) {
this.taskClient = taskClient; this.taskClient = taskClient;
this.expectedStatuses = expectedStatuses; this.expectedStatuses = expectedStatuses;
this.failingStatuses = failingStatuses; this.failingStatuses = failingStatuses;
@ -68,13 +69,13 @@ public class TaskStatusEquals implements Predicate<Task> {
if (task == null) return false; if (task == null) return false;
logger.trace("%s: looking for status %s: currently: %s", task, expectedStatuses, task.getStatus()); logger.trace("%s: looking for status %s: currently: %s", task, expectedStatuses, task.getStatus());
for (String failingStatus : failingStatuses) { for (Status failingStatus : failingStatuses) {
if (task.getStatus().equals(failingStatus)) { if (task.getStatus().equals(failingStatus)) {
throw new VCloudDirectorException(task); throw new VCloudDirectorException(task);
} }
} }
for (String expectedStatus : expectedStatuses) { for (Status expectedStatus : expectedStatuses) {
if (task.getStatus().equals(expectedStatus)) { if (task.getStatus().equals(expectedStatus)) {
return true; return true;
} }

View File

@ -345,11 +345,6 @@ public class Checks {
checkEntityType(catalogItem); checkEntityType(catalogItem);
} }
public static void checkImageType(String imageType) {
assertTrue(Media.ImageType.ALL.contains(imageType),
"The Image type of a Media must be one of the allowed list");
}
public static void checkNetwork(Network network) { public static void checkNetwork(Network network) {
// Check optional fields // Check optional fields
NetworkConfiguration config = network.getConfiguration(); NetworkConfiguration config = network.getConfiguration();
@ -756,7 +751,8 @@ public class Checks {
public static void checkMediaFor(String client, Media media) { public static void checkMediaFor(String client, Media media) {
// required // required
assertNotNull(media.getImageType(), String.format(OBJ_FIELD_REQ, client, "imageType")); assertNotNull(media.getImageType(), String.format(OBJ_FIELD_REQ, client, "imageType"));
checkImageType(media.getImageType()); assertTrue(Media.ImageType.ALL.contains(media.getImageType()),
"The Image type of a Media must be one of the allowed list");
assertNotNull(media.getSize(), String.format(OBJ_FIELD_REQ, client, "size")); assertNotNull(media.getSize(), String.format(OBJ_FIELD_REQ, client, "size"));
assertTrue(media.getSize() >= 0, String.format(OBJ_FIELD_GTE_0, client, "size", media.getSize())); assertTrue(media.getSize() >= 0, String.format(OBJ_FIELD_GTE_0, client, "size", media.getSize()));

View File

@ -31,6 +31,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Error;
import org.jclouds.vcloud.director.v1_5.domain.File; import org.jclouds.vcloud.director.v1_5.domain.File;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media;
import org.jclouds.vcloud.director.v1_5.domain.Media.ImageType;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
@ -67,7 +68,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
Media source = Media.builder() Media source = Media.builder()
.size(0) .size(0)
.imageType("iso") .imageType(ImageType.ISO)
.name("Test media 1") .name("Test media 1")
.type("application/vnd.vmware.vcloud.media+xml") .type("application/vnd.vmware.vcloud.media+xml")
.description("Test media generated by testCreateMedia()") .description("Test media generated by testCreateMedia()")
@ -346,7 +347,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
static Media createMedia() { static Media createMedia() {
return Media.builder() return Media.builder()
.size(0) .size(0)
.imageType("iso") .imageType(ImageType.ISO)
.status(0) .status(0)
.name("Test media 1") .name("Test media 1")
.id("urn:vcloud:media:d51b0b9d-099c-499f-97f8-4fbe40ba06d7") .id("urn:vcloud:media:d51b0b9d-099c-499f-97f8-4fbe40ba06d7")
@ -378,7 +379,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
static Media cloneMedia() { static Media cloneMedia() {
return Media.builder() return Media.builder()
.size(175163392) .size(175163392)
.imageType("iso") .imageType(ImageType.ISO)
.status(0) .status(0)
.name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2") .name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2")
.id("urn:vcloud:media:a6b023f2-7f90-4e89-a24d-56e0eba83a5a") .id("urn:vcloud:media:a6b023f2-7f90-4e89-a24d-56e0eba83a5a")
@ -433,7 +434,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
private static Media getMedia() { private static Media getMedia() {
return Media.builder() return Media.builder()
.size(175163392) .size(175163392)
.imageType("iso") .imageType(ImageType.ISO)
.status(1) .status(1)
.name("DansTestMedia") .name("DansTestMedia")
.id("urn:vcloud:media:794eb334-754e-4917-b5a0-5df85cbd61d1") .id("urn:vcloud:media:794eb334-754e-4917-b5a0-5df85cbd61d1")
@ -476,7 +477,7 @@ public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
private static Media updateMedia() { private static Media updateMedia() {
return Media.builder() return Media.builder()
.size(175163392) .size(175163392)
.imageType("iso") .imageType(ImageType.ISO)
.status(1) .status(1)
.name("new testMedia1") .name("new testMedia1")
.id("urn:vcloud:media:c93e5cdc-f29a-4749-8ed2-093df04cc75e") .id("urn:vcloud:media:c93e5cdc-f29a-4749-8ed2-093df04cc75e")

View File

@ -37,6 +37,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Network; import org.jclouds.vcloud.director.v1_5.domain.Network;
import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures; import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures;
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
@ -217,7 +218,7 @@ public class NetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest
.build()) .build())
.build()) .build())
.build()) .build())
.fenceMode("isolated") .fenceMode(FenceMode.ISOLATED)
.retainNetInfoAcrossDeployments(false) .retainNetInfoAcrossDeployments(false)
.features(NetworkFeatures.builder() .features(NetworkFeatures.builder()
.service(DhcpService.builder() .service(DhcpService.builder()

View File

@ -57,6 +57,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.NatOneToOneVmRule; import org.jclouds.vcloud.director.v1_5.domain.NatOneToOneVmRule;
import org.jclouds.vcloud.director.v1_5.domain.NatRule; import org.jclouds.vcloud.director.v1_5.domain.NatRule;
import org.jclouds.vcloud.director.v1_5.domain.NatService; import org.jclouds.vcloud.director.v1_5.domain.NatService;
import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures; import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures;
@ -679,7 +680,7 @@ public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpec
.ipRanges(IpRanges.builder().ipRange(IpRange.builder().startAddress("10.147.56.1").endAddress("10.147.56.1").build()).build()) .ipRanges(IpRanges.builder().ipRange(IpRange.builder().startAddress("10.147.56.1").endAddress("10.147.56.1").build()).build())
.build()) .build())
.parentNetwork(Reference.builder().href(URI.create("http://vcloud.example.com/api/v1.0/network/54")).type("application/vnd.vmware.vcloud.network+xml").name("Internet").build()) .parentNetwork(Reference.builder().href(URI.create("http://vcloud.example.com/api/v1.0/network/54")).type("application/vnd.vmware.vcloud.network+xml").name("Internet").build())
.fenceMode("natRouted") .fenceMode(FenceMode.NAT_ROUTED)
.features(NetworkFeatures.builder().services(ImmutableSet.of(firewallService, natService)).build()) .features(NetworkFeatures.builder().services(ImmutableSet.of(firewallService, natService)).build())
.build(); .build();

View File

@ -38,6 +38,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Error;
import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media;
import org.jclouds.vcloud.director.v1_5.domain.Media.ImageType;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
@ -297,7 +298,7 @@ public class VdcClientExpectTest extends VCloudDirectorAdminClientExpectTest {
Media source = Media.builder() Media source = Media.builder()
.size(0) .size(0)
.imageType("iso") .imageType(ImageType.ISO)
.name("Test media 1") .name("Test media 1")
.type("application/vnd.vmware.vcloud.media+xml") .type("application/vnd.vmware.vcloud.media+xml")
.description("Test media generated by testCreateMedia()") .description("Test media generated by testCreateMedia()")

View File

@ -40,6 +40,7 @@ import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.InstantiationParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiationParams;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Network.FenceMode;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
@ -246,7 +247,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
NetworkConfiguration networkConfiguration = NetworkConfiguration.builder() NetworkConfiguration networkConfiguration = NetworkConfiguration.builder()
.parentNetwork(parentNetwork.get()) .parentNetwork(parentNetwork.get())
.fenceMode("bridged") .fenceMode(FenceMode.BRIDGED)
.build(); .build();
NetworkConfigSection networkConfigSection = NetworkConfigSection.builder() NetworkConfigSection networkConfigSection = NetworkConfigSection.builder()

View File

@ -119,7 +119,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.password("newPassword") .password("newPassword")
// TODO test setting other fields? // TODO test setting other fields?
// .name("new"+oldUser.getName()) // .name("new"+oldUser.getName())
.role(getRoleReferenceFor(DefaultRoles.AUTHOR)) .role(getRoleReferenceFor(DefaultRoles.AUTHOR.value()))
.build(); .build();
userClient.updateUser(user.getHref(), newUser); userClient.updateUser(user.getHref(), newUser);

View File

@ -217,7 +217,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
} }
public User randomTestUser(String prefix) { public User randomTestUser(String prefix) {
return randomTestUser(prefix, getRoleReferenceFor(DefaultRoles.USER)); return randomTestUser(prefix, getRoleReferenceFor(DefaultRoles.USER.value()));
} }
public User randomTestUser(String prefix, Reference role) { public User randomTestUser(String prefix, Reference role) {
@ -303,11 +303,11 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
assertTrue(retryTaskSuccessLong.apply(task), String.format(TASK_COMPLETE_TIMELY, task)); assertTrue(retryTaskSuccessLong.apply(task), String.format(TASK_COMPLETE_TIMELY, task));
} }
protected void assertTaskStatusEventually(Task task, String expectedStatus, Collection<String> failingStatuses) { protected void assertTaskStatusEventually(Task task, org.jclouds.vcloud.director.v1_5.domain.Task.Status running, ImmutableSet<org.jclouds.vcloud.director.v1_5.domain.Task.Status> immutableSet) {
TaskClient taskClient = context.getApi().getTaskClient(); TaskClient taskClient = context.getApi().getTaskClient();
TaskStatusEquals predicate = new TaskStatusEquals(taskClient, expectedStatus, failingStatuses); TaskStatusEquals predicate = new TaskStatusEquals(taskClient, running, immutableSet);
RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, TASK_TIMEOUT_SECONDS * 1000L); RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, TASK_TIMEOUT_SECONDS * 1000L);
assertTrue(retryablePredicate.apply(task), "Task must enter status "+expectedStatus); assertTrue(retryablePredicate.apply(task), "Task must enter status "+running);
} }
protected void assertTaskDoneEventually(Task task) { protected void assertTaskDoneEventually(Task task) {
@ -315,7 +315,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
TaskStatusEquals predicate = new TaskStatusEquals( TaskStatusEquals predicate = new TaskStatusEquals(
taskClient, taskClient,
ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS),
Collections.<String>emptySet()); Collections.<Task.Status>emptySet());
RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L); RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L);
assertTrue(retryablePredicate.apply(task), "Task must be done"); assertTrue(retryablePredicate.apply(task), "Task must be done");
} }

View File

@ -124,7 +124,7 @@ public class VCloudDirectorTestSession {
.name(userIdentity) .name(userIdentity)
.password(userCredential) .password(userCredential)
.description("test user with user-level privileges") .description("test user with user-level privileges")
.role(BaseVCloudDirectorClientLiveTest.getRoleReferenceFor(DefaultRoles.USER, adminContext)) .role(BaseVCloudDirectorClientLiveTest.getRoleReferenceFor(DefaultRoles.USER.value(), adminContext))
.deployedVmQuota(BaseVCloudDirectorClientLiveTest.REQUIRED_USER_VM_QUOTA) .deployedVmQuota(BaseVCloudDirectorClientLiveTest.REQUIRED_USER_VM_QUOTA)
.isEnabled(true) .isEnabled(true)
.build()); .build());