Merge branch 'master' of github.com:jclouds/jclouds

* 'master' of github.com:jclouds/jclouds: (34 commits)
  add error strings to new tests
  move annotation to classes
  fix headers using primer approach
  fix accept type
  test groupings + metadataclient delegation
  tidy up test groupings
  disable UploadClient dependent tests
  tidy test, add missing test, remove leftovers
  add endpoint parsers
  disable broken class
  rename to match field
  merge to master
  exemplar xml for expect tests
  add XmlRootElement annotation
  fix clone method and xmlElement name
  fix builder
  add incremental builder method
  pass clone media
  remove comments and name correctly
  move and complete media tests
  ...
This commit is contained in:
Adrian Cole 2012-03-05 10:33:30 -08:00
commit b398122b45
58 changed files with 1140 additions and 711 deletions

View File

@ -31,6 +31,7 @@ import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient; import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient; import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient; import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient; import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient;
@ -92,6 +93,13 @@ public interface VCloudDirectorAsyncClient {
@Delegate @Delegate
VdcAsyncClient getVdcClient(); VdcAsyncClient getVdcClient();
/**
* @return asynchronous access to Upload features
*/
@Delegate
UploadAsyncClient getUploadClient();
/** /**
* @return asynchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features * @return asynchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features
*/ */

View File

@ -35,6 +35,7 @@ import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient;
import org.jclouds.vcloud.director.v1_5.features.QueryClient; import org.jclouds.vcloud.director.v1_5.features.QueryClient;
import org.jclouds.vcloud.director.v1_5.features.TaskClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient;
import org.jclouds.vcloud.director.v1_5.features.UploadClient;
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient;
import org.jclouds.vcloud.director.v1_5.features.VdcClient; import org.jclouds.vcloud.director.v1_5.features.VdcClient;
@ -96,7 +97,13 @@ public interface VCloudDirectorClient {
@Delegate @Delegate
VdcClient getVdcClient(); VdcClient getVdcClient();
/* /**
* @return synchronous access to {@link Upload} features
*/
@Delegate
UploadClient getUploadClient();
/**
* @return synchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features * @return synchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features
*/ */
@Delegate @Delegate

View File

@ -142,8 +142,9 @@ public class VCloudDirectorMediaType {
COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS, COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS,
UPLOAD_VAPP_TEMPLATE_PARAMS, UPLOAD_VAPP_TEMPLATE_PARAMS,
QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS, QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS,
CONTROL_ACCESS,
VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION, NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION, VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION, NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION,
CONTROL_ACCESS CLONE_MEDIA_PARAMS
, ,
LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE
); );

View File

@ -43,6 +43,10 @@ import org.jclouds.vcloud.director.v1_5.annotations.Login;
import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
import org.jclouds.vcloud.director.v1_5.features.*; import org.jclouds.vcloud.director.v1_5.features.*;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.MetadataClient;
import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.UploadClient;
import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword; import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword;
import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose; import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose;
import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler; import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler;
@ -78,6 +82,9 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
.put(TaskClient.class, TaskAsyncClient.class) .put(TaskClient.class, TaskAsyncClient.class)
.put(VdcClient.class, VdcAsyncClient.class) .put(VdcClient.class, VdcAsyncClient.class)
.put(VAppTemplateClient.class, VAppTemplateAsyncClient.class) .put(VAppTemplateClient.class, VAppTemplateAsyncClient.class)
.put(UploadClient.class, UploadAsyncClient.class)
.put(MetadataClient.Readable.class, MetadataAsyncClient.Readable.class)
.put(MetadataClient.Writeable.class, MetadataAsyncClient.Writable.class)
.build(); .build();
public VCloudDirectorRestClientModule() { public VCloudDirectorRestClientModule() {

View File

@ -65,7 +65,7 @@ import com.google.common.collect.Sets;
*/ */
@XmlType(name = "CaptureVAppParams", propOrder = { @XmlType(name = "CaptureVAppParams", propOrder = {
"source", "source",
"section" "sections"
}) })
public class CaptureVAppParams public class CaptureVAppParams
extends ParamsType<CaptureVAppParams> extends ParamsType<CaptureVAppParams>

View File

@ -22,6 +22,7 @@ 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 javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
@ -50,7 +51,8 @@ import com.google.common.base.Objects;
* &lt;/complexType> * &lt;/complexType>
* </pre> * </pre>
*/ */
@XmlType(name = "CloneMediaParams", propOrder = { @XmlRootElement(name = "CloneMediaParams")
@XmlType(propOrder = {
"source", "source",
"isSourceDelete" "isSourceDelete"
}) })
@ -92,6 +94,22 @@ public class CloneMediaParams
return new CloneMediaParams(description, name, source, isSourceDelete); return new CloneMediaParams(description, name, source, isSourceDelete);
} }
/**
* @see ParamsType#getDescription()
*/
public Builder description(String description) {
this.description = description;
return this;
}
/**
* @see ParamsType#getName()
*/
public Builder name(String name) {
this.name = name;
return this;
}
@Override @Override
public Builder fromParamsType(ParamsType<CloneMediaParams> in) { public Builder fromParamsType(ParamsType<CloneMediaParams> in) {
return Builder.class.cast(super.fromParamsType(in)); return Builder.class.cast(super.fromParamsType(in));

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ -137,7 +138,7 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
@XmlElement(name = "Description") @XmlElement(name = "Description")
private String description; private String description;
@XmlElement(name = "TasksInProgress") @XmlElement(name = "Tasks")
private TasksInProgress tasksInProgress; private TasksInProgress tasksInProgress;
@XmlAttribute @XmlAttribute
private String id; private String id;
@ -199,6 +200,16 @@ public abstract class EntityType<T extends EntityType<T>> extends ResourceType<T
equal(this.tasksInProgress, that.tasksInProgress) && equal(this.name, that.name); equal(this.tasksInProgress, that.tasksInProgress) && equal(this.name, that.name);
} }
@Override
public boolean clone(Object o) {
if (this == o)
return false;
if (o == null || getClass() != o.getClass())
return false;
EntityType<?> that = EntityType.class.cast(o);
return super.clone(that);
}
@Override @Override
public int hashCode() { public int hashCode() {
return super.hashCode() + Objects.hashCode(description, tasksInProgress, id, name); return super.hashCode() + Objects.hashCode(description, tasksInProgress, id, name);

View File

@ -31,6 +31,7 @@ import javax.xml.bind.annotation.adapters.NormalizedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -57,7 +58,6 @@ import com.google.common.collect.Sets;
*/ */
@XmlType(name = "File") @XmlType(name = "File")
public class File extends EntityType<File> { public class File extends EntityType<File> {
@SuppressWarnings("unchecked")
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
} }
@ -99,14 +99,30 @@ public class File extends EntityType<File> {
public File build() { public File build() {
return new File(href, type, links, description, tasksInProgress, id, name, size, bytesTransferred, checksum); return new File(href, type, links, description, tasksInProgress, id, name, size, bytesTransferred, checksum);
} }
/**
* @see EntityType#getName()
*/
public Builder name(String name) {
super.name(name);
return this;
}
/**
* @see EntityType#getDescription()
*/
public Builder description(String description) {
super.description(description);
return this;
}
/** /**
* @see EntityType#getId() * @see EntityType#getId()
*/ */
@Override @Override
public Builder id(String id) { public Builder id(String id) {
this.id = id; super.id(id);
return this; return this;
} }
@ -115,7 +131,7 @@ public class File extends EntityType<File> {
*/ */
@Override @Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) { public Builder tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress; super.tasksInProgress (tasksInProgress);
return this; return this;
} }
@ -124,7 +140,7 @@ public class File extends EntityType<File> {
*/ */
@Override @Override
public Builder href(URI href) { public Builder href(URI href) {
this.href = href; super.href(href);
return this; return this;
} }
@ -177,11 +193,11 @@ public class File extends EntityType<File> {
this.checksum = checksum; this.checksum = checksum;
} }
@SuppressWarnings("unused")
private File() { private File() {
// For JAXB and builder use // For JAXB
} }
@XmlAttribute @XmlAttribute
protected Long size; protected Long size;
@XmlAttribute @XmlAttribute
@ -228,24 +244,26 @@ public class File extends EntityType<File> {
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
File that = File.class.cast(o); File that = File.class.cast(o);
return equal(size, that.size) && return super.equals(that) &&
equal(size, that.size) &&
equal(bytesTransferred, that.bytesTransferred) && equal(bytesTransferred, that.bytesTransferred) &&
equal(checksum, that.checksum); equal(checksum, that.checksum);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(size, return Objects.hashCode(super.hashCode(),
size,
bytesTransferred, bytesTransferred,
checksum); checksum);
} }
@Override @Override
public String toString() { public ToStringHelper string() {
return Objects.toStringHelper("") return super.string()
.add("size", size) .add("size", size)
.add("bytesTransferred", bytesTransferred) .add("bytesTransferred", bytesTransferred)
.add("checksum", checksum).toString(); .add("checksum", checksum);
} }
} }

View File

@ -20,14 +20,16 @@
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.List;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets; import com.google.common.collect.Lists;
/** /**
@ -66,23 +68,29 @@ public class FilesList {
public static class Builder { public static class Builder {
private Set<File> files = Sets.newLinkedHashSet(); private List<File> files = Lists.newLinkedList();
/** /**
* @see FilesList#getFiles() * @see FilesList#getFiles()
*/ */
public Builder files(Set<File> files) { public Builder files(List<File> files) {
this.files = files; this.files = Lists.newLinkedList(checkNotNull(files, "files"));
return this; return this;
} }
/**
* @see FilesList#getFiles()
*/
public Builder file(File file) {
files.add(checkNotNull(file, "file"));
return this;
}
public FilesList build() { public FilesList build() {
FilesList filesList = new FilesList(files); FilesList filesList = new FilesList(files);
return filesList; return filesList;
} }
public Builder fromFilesList(FilesList in) { public Builder fromFilesList(FilesList in) {
return files(in.getFiles()); return files(in.getFiles());
} }
@ -92,18 +100,18 @@ public class FilesList {
// For JAXB and builder use // For JAXB and builder use
} }
private FilesList(Set<File> files) { private FilesList(List<File> files) {
this.files = ImmutableSet.copyOf(files); this.files = ImmutableList.copyOf(files);
} }
@XmlElement(name = "File", required = true) @XmlElement(name = "File", required = true)
protected Set<File> files = Sets.newLinkedHashSet(); protected List<File> files = Lists.newLinkedList();
/** /**
* Gets the value of the file property. * Gets the value of the file property.
*/ */
public Set<File> getFiles() { public List<File> getFiles() {
return this.files; return this.files;
} }

View File

@ -58,6 +58,7 @@ public class Link extends ReferenceType<Link> {
public static final String LAST_PAGE = "lastPage"; public static final String LAST_PAGE = "lastPage";
public static final String FIRST_PAGE = "firstPage"; public static final String FIRST_PAGE = "firstPage";
public static final String CONTROL_ACCESS = "controlAccess"; public static final String CONTROL_ACCESS = "controlAccess";
public static final String UPLOAD_DEFAULT = "upload:default";
/** /**
* All acceptable {@link Link#getRel()} values. * All acceptable {@link Link#getRel()} values.
@ -67,7 +68,7 @@ public class Link extends ReferenceType<Link> {
public static final List<String> ALL = Arrays.asList( public static final List<String> ALL = Arrays.asList(
UP, DOWN, EDIT, ADD, DELETE, REMOVE, CATALOG_ITEM, TASK_CANCEL, UP, DOWN, EDIT, ADD, DELETE, REMOVE, CATALOG_ITEM, TASK_CANCEL,
ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE, ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE,
CONTROL_ACCESS CONTROL_ACCESS, UPLOAD_DEFAULT
); );
} }

View File

@ -48,7 +48,6 @@ public class Media extends ResourceEntityType<Media> {
public static final List<String> ALL = Arrays.asList(ISO, FLOPPY); public static final List<String> ALL = Arrays.asList(ISO, FLOPPY);
} }
@SuppressWarnings("unchecked")
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
} }
@ -245,6 +244,17 @@ public class Media extends ResourceEntityType<Media> {
equal(this.owner, that.owner) && equal(this.imageType, that.imageType) && equal(this.size, that.size); equal(this.owner, that.owner) && equal(this.imageType, that.imageType) && equal(this.size, that.size);
} }
@Override
public boolean clone(Object o) {
if (this == o)
return false;
if (o == null || getClass() != o.getClass())
return false;
Media that = Media.class.cast(o);
return super.clone(that) &&
equal(this.imageType, that.imageType) && equal(this.size, that.size);
}
@Override @Override
public int hashCode() { public int hashCode() {
return super.hashCode() + Objects.hashCode(owner, imageType, size); return super.hashCode() + Objects.hashCode(owner, imageType, size);

View File

@ -55,7 +55,7 @@ import com.google.common.base.Objects;
"description" "description"
}) })
@XmlSeeAlso({ @XmlSeeAlso({
CaptureVAppParams.class, // CaptureVAppParams.class, // FIXME!
CloneVAppTemplateParams.class, CloneVAppTemplateParams.class,
CloneMediaParams.class, CloneMediaParams.class,
UploadVAppTemplateParams.class UploadVAppTemplateParams.class

View File

@ -88,6 +88,10 @@ public class Reference extends ReferenceType<Reference> {
public Builder fromReference(Reference in) { public Builder fromReference(Reference in) {
return fromReferenceType(in); return fromReferenceType(in);
} }
public Builder fromEntity(EntityType<?> in) {
return href(in.getHref()).id(in.getId()).name(in.getName()).type(in.getType());
}
} }
public Reference(URI href, String id, String name, String type) { public Reference(URI href, String id, String name, String type) {

View File

@ -168,6 +168,16 @@ public abstract class ResourceEntityType<T extends ResourceEntityType<T>> extend
return super.equals(that) && equal(this.files, that.files) && equal(this.status, that.status); return super.equals(that) && equal(this.files, that.files) && equal(this.status, that.status);
} }
@Override
public boolean clone(Object o) {
if (this == o)
return false;
if (o == null || getClass() != o.getClass())
return false;
ResourceEntityType<?> that = ResourceEntityType.class.cast(o);
return super.clone(that) && equal(this.files, that.files);
}
@Override @Override
public int hashCode() { public int hashCode() {
return super.hashCode() + Objects.hashCode(files, status); return super.hashCode() + Objects.hashCode(files, status);

View File

@ -161,6 +161,15 @@ public abstract class ResourceType<T extends ResourceType<T>> implements URISupp
return equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type); return equal(this.href, that.href) && equal(this.links, that.links) && equal(this.type, that.type);
} }
public boolean clone(Object o) {
if (this == o)
return false;
if (o == null || getClass() != o.getClass())
return false;
ResourceType<?> that = ResourceType.class.cast(o);
return equal(this.type, that.type);
}
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(href, links, type); return Objects.hashCode(href, links, type);

View File

@ -32,4 +32,16 @@ public interface URISupplier {
* @see ReferenceType#getHref() * @see ReferenceType#getHref()
*/ */
public URI getURI(); public URI getURI();
public static class SingleURI {
public static URISupplier fromURI(final URI uri) {
return new URISupplier(){
@Override
public URI getURI() {
return uri;
}
};
}
}
} }

View File

@ -24,10 +24,10 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.PUT; import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
@ -37,12 +37,10 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
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.URISupplier;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -60,7 +58,7 @@ public interface CatalogAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Catalog> getCatalog(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef); ListenableFuture<Catalog> getCatalog(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef);
/** /**
* Creates a catalog item in a catalog. * Creates a catalog item in a catalog.
@ -71,30 +69,9 @@ public interface CatalogAsyncClient {
@Produces(VCloudDirectorMediaType.CATALOG_ITEM) @Produces(VCloudDirectorMediaType.CATALOG_ITEM)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<CatalogItem> addCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef, ListenableFuture<CatalogItem> addCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef,
@BinderParam(BindToXMLPayload.class) CatalogItem catalogItem); @BinderParam(BindToXMLPayload.class) CatalogItem catalogItem);
/**
* Returns the metadata associated with the catalog.
*/
@GET
@Path("/metadata")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getCatalogMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef);
/**
* Returns the metadata associated with the catalog for the specified key.
*/
@GET
@Path("/metadata/{key}")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataValue> getCatalogMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef,
@PathParam("key") String key);
/** /**
* Retrieves a catalog item. * Retrieves a catalog item.
*/ */
@ -102,7 +79,7 @@ public interface CatalogAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<CatalogItem> getCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef); ListenableFuture<CatalogItem> getCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef);
/** /**
* Modifies a catalog item. * Modifies a catalog item.
@ -112,7 +89,7 @@ public interface CatalogAsyncClient {
@Produces(VCloudDirectorMediaType.CATALOG_ITEM) @Produces(VCloudDirectorMediaType.CATALOG_ITEM)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<CatalogItem> updateCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef, ListenableFuture<CatalogItem> updateCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef,
@BinderParam(BindToXMLPayload.class) CatalogItem catalogItem); @BinderParam(BindToXMLPayload.class) CatalogItem catalogItem);
/** /**
@ -122,61 +99,11 @@ public interface CatalogAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Void> deleteCatalogItem(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef); ListenableFuture<Void> deleteCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef);
/** /**
* Returns the metadata associated with the catalog item. * @return asynchronous access to {@link Metadata.Writeable} features
*/ */
@GET @Delegate
@Path("/metadata") MetadataAsyncClient.Writable getMetadataClient();
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getCatalogItemMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef);
/**
* Merges the metadata for a catalog item with the information provided.
*/
@POST
@Path("/metadata")
@Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.METADATA)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> mergeCatalogItemMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
@BinderParam(BindToXMLPayload.class) Metadata catalogItemMetadata);
/**
* Returns the metadata associated with the catalog item for the specified key.
*/
@GET
@Path("/metadata/{key}")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataValue> getCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
@PathParam("key") String key);
/**
* Sets the metadata for the particular key for the catalog item to the value provided.
*/
@PUT
@Path("/metadata/{key}")
@Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.METADATA_VALUE)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> setCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
@PathParam("key") String key, @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue);
/**
* Deletes the metadata for the particular key for the catalog item.
*/
@DELETE
@Path("/metadata/{key}")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> deleteCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
@PathParam("key") String key);
} }

View File

@ -21,12 +21,11 @@ package org.jclouds.vcloud.director.v1_5.features;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
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.URISupplier;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.Task;
/** /**
* Provides synchronous access to {@link Catalog} objects. * Provides synchronous access to {@link Catalog} objects.
@ -47,7 +46,7 @@ public interface CatalogClient {
* @param catalogRef the reference for the catalog * @param catalogRef the reference for the catalog
* @return a catalog * @return a catalog
*/ */
Catalog getCatalog(ReferenceType<?> catalogRef); Catalog getCatalog(URISupplier catalogRef);
/** /**
* Creates a catalog item in a catalog. * Creates a catalog item in a catalog.
@ -60,32 +59,7 @@ public interface CatalogClient {
* @param item the catalog item to create * @param item the catalog item to create
* @return the created catalog item * @return the created catalog item
*/ */
CatalogItem addCatalogItem(ReferenceType<?> catalogRef, CatalogItem item); CatalogItem addCatalogItem(URISupplier catalogRef, CatalogItem item);
/**
* Returns the metadata associated with the catalog.
*
* <pre>
* GET /catalog/{id}/metadata
* </pre>
*
* @param catalogRef the reference for the catalog
* @return the catalog metadata
*/
Metadata getCatalogMetadata(ReferenceType<?> catalogRef);
/**
* Returns the metadata associated with the catalog for the specified key.
*
* <pre>
* GET /catalog/{id}/metadata/{key}
* </pre>
*
* @param catalogRef the reference for the catalog
* @param key the metadata entry key
* @return the catalog metadata value
*/
MetadataValue getCatalogMetadataValue(ReferenceType<?> catalogRef, String key);
/** /**
* Retrieves a catalog item. * Retrieves a catalog item.
@ -97,7 +71,7 @@ public interface CatalogClient {
* @param catalogItemRef the reference for the catalog item * @param catalogItemRef the reference for the catalog item
* @return the catalog item * @return the catalog item
*/ */
CatalogItem getCatalogItem(ReferenceType<?> catalogItemRef); CatalogItem getCatalogItem(URISupplier catalogItemRef);
/** /**
* Modifies a catalog item. * Modifies a catalog item.
@ -110,7 +84,7 @@ public interface CatalogClient {
* @param catalogItem the catalog item * @param catalogItem the catalog item
* @return the updated catalog item * @return the updated catalog item
*/ */
CatalogItem updateCatalogItem(ReferenceType<?> catalogItemRef, CatalogItem catalogItem); CatalogItem updateCatalogItem(URISupplier catalogItemRef, CatalogItem catalogItem);
/** /**
* Deletes a catalog item. * Deletes a catalog item.
@ -121,70 +95,11 @@ public interface CatalogClient {
* *
* @param catalogItemRef the reference for the catalog item * @param catalogItemRef the reference for the catalog item
*/ */
void deleteCatalogItem(ReferenceType<?> catalogItemRef); void deleteCatalogItem(URISupplier catalogItemRef);
/** /**
* Returns the metadata associated with the catalog item. * @return synchronous access to {@link Metadata.Writeable} features
*
* <pre>
* GET /catalogItem/{id}/metadata
* </pre>
*
* @param catalogItemRef the reference for the catalog item
* @return the catalog item metadata
*/ */
Metadata getCatalogItemMetadata(ReferenceType<?> catalogItemRef); @Delegate
MetadataClient.Writeable getMetadataClient();
/**
* Merges the metadata for a catalog item with the information provided.
*
* <pre>
* POST /catalogItem/{id}/metadata
* </pre>
*
* @param catalogItemRef the reference for the catalog item
* @param catalogItemMetadata the metadata for the catalog item
* @return a task for the merge operation
*/
Task mergeCatalogItemMetadata(ReferenceType<?> catalogItemRef, Metadata catalogItemMetadata);
/**
* Returns the metadata associated with the catalog item for the specified key.
*
* <pre>
* GET /catalog/{id}/metadata/{key}
* </pre>
*
* @param catalogItemRef the reference for the catalog item
* @param key the metadata entry key
* @return the catalog item metadata value
*/
MetadataValue getCatalogItemMetadataValue(ReferenceType<?> catalogItemRef, String key);
/**
* Sets the metadata for the particular key for the catalog item to the value provided.
*
* <pre>
* PUT /catalog/{id}/metadata/{key}
* </pre>
*
* @param catalogItemRef the reference for the catalog item
* @param key the metadata entry key
* @param value the metadata value
* @return a task for the set operation
*/
Task setCatalogItemMetadataValue(ReferenceType<?> catalogItemRef, String key, MetadataValue value);
/**
* Deletes the metadata for the particular key for the catalog item.
*
* <pre>
* DELETE /catalog/{id}/metadata/{key}
* </pre>
*
* @param catalogItemRef the reference for the catalog item
* @param key the metadata entry key
* @return a task for the delete operation
*/
Task deleteCatalogItemMetadataValue(ReferenceType<?> catalogItemRef, String key);
} }

View File

@ -21,13 +21,12 @@ package org.jclouds.vcloud.director.v1_5.features;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT; import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
@ -36,13 +35,12 @@ import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
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.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.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
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.URISupplier;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -54,99 +52,47 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface MediaAsyncClient { public interface MediaAsyncClient {
/** /**
* @see MediaClient#getMedia(Reference) * @see MediaClient#getMedia(URISupplier)
*/ */
@GET @GET
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Media> getMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef); ListenableFuture<Media> getMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef);
/** /**
* @see MediaClient#updateMedia(Reference, Media)) * @see MediaClient#updateMedia(URISupplier, Media))
*/ */
@PUT @PUT
@Consumes(VCloudDirectorMediaType.TASK) @Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.MEDIA) @Produces(VCloudDirectorMediaType.MEDIA)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> updateMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef, ListenableFuture<Task> updateMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef,
@BinderParam(BindToXMLPayload.class) Media media); @BinderParam(BindToXMLPayload.class) Media media);
/** /**
* @see MediaClient#deleteMedia(Reference)) * @see MediaClient#deleteMedia(URISupplier))
*/ */
@DELETE @DELETE
@Consumes(VCloudDirectorMediaType.TASK) @Consumes(VCloudDirectorMediaType.TASK)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> deleteMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef); ListenableFuture<Task> deleteMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef);
/** /**
* @see MediaClient#getOwner(Reference) * @see MediaClient#getOwner(URISupplier)
*/ */
@GET @GET
@Path("/owner") @Path("/owner")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Owner> getOwner(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef); ListenableFuture<Owner> getOwner(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef);
/** /**
* @see MediaClient#getMetadata(Reference)) * @return asynchronous access to {@link Metadata.Writeable} features
*/ */
@GET @Delegate
@Path("/metadata") MetadataAsyncClient.Writable getMetadataClient();
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef);
/**
* @see MediaClient#mergeMetadata(Reference, Metadata))
*/
@POST
@Path("/metadata")
@Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.METADATA)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> mergeMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef,
@BinderParam(BindToXMLPayload.class) Metadata metadata);
/**
* @see MediaClient#getMetadataEntry(Reference, String))
*/
@GET
@Path("/metadata/{key}")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataValue> getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef,
@PathParam("key") String key);
/**
* @see MediaClient#setMetadata(Reference, String, MetadataEntry))
*/
@PUT
@Path("/metadata/{key}")
@Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.METADATA_VALUE)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> setMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference metaDataRef,
@PathParam("key") String key,
@BinderParam(BindToXMLPayload.class) MetadataValue metadataValue);
/**
* @see MediaClient#deleteMetadataEntry(Reference, String))
*/
@DELETE
@Path("/metadata/{key}")
@Consumes(VCloudDirectorMediaType.TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> deleteMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) Reference metaDataRef,
@PathParam("key") String key);
} }

View File

@ -21,12 +21,12 @@ package org.jclouds.vcloud.director.v1_5.features;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
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.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.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
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.URISupplier;
/** /**
* Provides synchronous access to Media. * Provides synchronous access to Media.
@ -44,7 +44,7 @@ public interface MediaClient {
* *
* @return the media or null if not found * @return the media or null if not found
*/ */
Media getMedia(Reference mediaRef); Media getMedia(URISupplier mediaRef);
/** /**
* Updates the name/description of a media. * Updates the name/description of a media.
@ -52,57 +52,24 @@ public interface MediaClient {
* @return a task. This operation is asynchronous and the user should monitor the returned * @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed. * task status in order to check when it is completed.
*/ */
Task updateMedia(Reference mediaRef, Media media); Task updateMedia(URISupplier mediaRef, Media media);
/** /**
* Deletes a media. * Deletes a media.
*/ */
Task deleteMedia(Reference mediaRef); Task deleteMedia(URISupplier mediaRef);
/** /**
* Retrieves an owner. * Retrieves an owner.
* *
* @return the owner or null if not found * @return the owner or null if not found
*/ */
Owner getOwner(Reference mediaRef); Owner getOwner(URISupplier mediaRef);
/** /**
* Retrieves an list of the media's metadata * @return synchronous access to {@link Metadata.Writeable} features
*
* @return a list of metadata
*/ */
Metadata getMetadata(Reference mediaRef); @Delegate
/** MetadataClient.Writeable getMetadataClient();
* Merges the metadata for a media with the information provided.
*
* @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task mergeMetadata(Reference mediaRef, Metadata metadata);
/**
* Retrieves a metadata value
*
* @return the metadata value, or null if not found
*/
MetadataValue getMetadataValue(Reference mediaRef, String key);
/**
* Sets the metadata for the particular key for the media to the value provided.
* Note: this will replace any existing metadata information
*
* @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task setMetadata(Reference mediaRef, String key, MetadataValue metadataValue);
/**
* Deletes a metadata entry.
*
* @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task deleteMetadataEntry(Reference mediaRef, String key);
} }

View File

@ -0,0 +1,116 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.vcloud.director.v1_5.features;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
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.Task;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @see NetworkClient
* @author danikov
*/
public interface MetadataAsyncClient {
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public static interface Readable extends MetadataAsyncClient {
/**
* @see MetadataClient.Readable#getMetadata(URISupplier)
*/
@GET
@Path("/metadata")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef);
/**
* @see MetadataClient.Readable#getMetadataEntry(URISupplier, String)
*/
@GET
@Path("/metadata/{key}")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataValue> getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef ,
@PathParam("key") String key);
}
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public static interface Writable extends Readable {
/**
* @see MetadataClient.Writable#mergeMetadata(URISupplier, Metadata))
*/
@POST
@Path("/metadata")
@Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.METADATA)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef,
@BinderParam(BindToXMLPayload.class) Metadata metadata);
/**
* @see MetadataClient.Writable#setMetadata(URISupplier, String, MetadataEntry))
*/
@PUT
@Path("/metadata/{key}")
@Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.METADATA_VALUE)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> setMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef,
@PathParam("key") String key,
@BinderParam(BindToXMLPayload.class) MetadataValue metadataValue);
/**
* @see MetadataClient.Writable#deleteMetadataEntry(URISupplier, String))
*/
@DELETE
@Path("/metadata/{key}")
@Consumes(VCloudDirectorMediaType.TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> deleteMetadataEntry(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef,
@PathParam("key") String key);
}
}

View File

@ -0,0 +1,82 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.vcloud.director.v1_5.features;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
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.Task;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
/**
* Provides synchronous access to Upload.
* <p/>
*
* @see MetadataAsyncClient
* @see <a href= "http://support.theenterprisecloud.com/kb/default.asp?id=984&Lang=1&SID=" />
* @author danikov
*/
public interface MetadataClient {
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public static interface Readable extends MetadataClient {
/**
* Retrieves an list of metadata
*
* @return a list of metadata
*/
Metadata getMetadata(URISupplier parentRef);
/**
* Retrieves a metadata value
*
* @return the metadata value, or null if not found
*/
MetadataValue getMetadataValue(URISupplier parentRef, String key);
}
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public static interface Writeable extends Readable {
/**
* Merges the metadata for a media with the information provided.
*
* @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task mergeMetadata(URISupplier parentRef, Metadata metadata);
/**
* Sets the metadata for the particular key for the media to the value provided.
* Note: this will replace any existing metadata information
*
* @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task setMetadata(URISupplier parentRef, String key, MetadataValue metadataValue);
/**
* Deletes a metadata entry.
*
* @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed.
*/
Task deleteMetadataEntry(URISupplier parentRef, String key);
}
}

View File

@ -20,20 +20,18 @@ package org.jclouds.vcloud.director.v1_5.features;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
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.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -46,33 +44,18 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface NetworkAsyncClient { public interface NetworkAsyncClient {
/** /**
* @see NeworkClient#getNetwork(Reference) * @see NeworkClient#getNetwork(URISupplier)
*/ */
@GET @GET
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<OrgNetwork> getNetwork(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef); ListenableFuture<OrgNetwork> getNetwork(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef);
/** /**
* @see NeworkClient#getMetadata(Reference) * @return asynchronous access to {@link Metadata.Readable} features
*/ */
@GET @Delegate
@Path("/metadata") MetadataAsyncClient.Readable getMetadataClient();
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef);
/**
* @see NeworkClient#getMetadataValue(Reference, String)
*/
@GET
@Path("/metadata/{key}")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataValue> getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference networkRef ,
@PathParam("key") String key);
} }

View File

@ -21,10 +21,10 @@ package org.jclouds.vcloud.director.v1_5.features;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
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.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
/** /**
* Provides synchronous access to Network. * Provides synchronous access to Network.
@ -42,20 +42,11 @@ public interface NetworkClient {
* *
* @return the network or null if not found * @return the network or null if not found
*/ */
OrgNetwork getNetwork(Reference networkRef); OrgNetwork getNetwork(URISupplier networkRef);
/** /**
* Retrieves an list of the network's metadata * @return synchronous access to {@link Metadata.Readable} features
*
* @return a list of metadata
*/ */
Metadata getMetadata(Reference networkRef); @Delegate
MetadataClient.Readable getMetadataClient();
/**
* Retrieves a metadata value
*
* @return the metadata value, or null if not found
*/
MetadataValue getMetadataValue(Reference networkRef, String key);
} }

View File

@ -21,20 +21,20 @@ package org.jclouds.vcloud.director.v1_5.features;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
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.Org; import org.jclouds.vcloud.director.v1_5.domain.Org;
import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.OrgList;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -61,26 +61,11 @@ public interface OrgAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Org> getOrg(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef); ListenableFuture<Org> getOrg(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef);
/** /**
* @see OrgClient#getMetadata(ReferenceType) * @return asynchronous access to {@link Metadata.Readable} features
*/ */
@GET @Delegate
@Path("/metadata") MetadataAsyncClient.Readable getMetadataClient();
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getOrgMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef);
/**
* @see OrgClient#getMetadataEntry(ReferenceType, String)
*/
@GET
@Path("/metadata/{key}")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataValue> getOrgMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef,
@PathParam("key") String key);
} }

View File

@ -21,11 +21,11 @@ package org.jclouds.vcloud.director.v1_5.features;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
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.Org; import org.jclouds.vcloud.director.v1_5.domain.Org;
import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.OrgList;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
/** /**
* Provides synchronous access to Org. * Provides synchronous access to Org.
@ -57,27 +57,11 @@ public interface OrgClient {
* *
* @return the org or null if not found * @return the org or null if not found
*/ */
Org getOrg(ReferenceType<?> orgRef); Org getOrg(URISupplier orgRef);
/** /**
* Retrieves an list of the organization's metadata * @return synchronous access to {@link Metadata.Readable} features
*
* <pre>
* GET /org/{id}/metadata
* </pre>
*
* @return a list of metadata
*/ */
Metadata getOrgMetadata(ReferenceType<?> orgRef); @Delegate
MetadataClient.Readable getMetadataClient();
/**
* Retrieves a metadata entry.
*
* <pre>
* GET /org/{id}/metadata{key}
* </pre>
*
* @return the metadata entry or null if not found
*/
MetadataValue getOrgMetadataValue(ReferenceType<?> orgRef, String key);
} }

View File

@ -29,12 +29,13 @@ import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
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.TasksList; import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.OrgReferenceToTaskListEndpoint; import org.jclouds.vcloud.director.v1_5.functions.OrgReferenceToTaskListEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -46,13 +47,13 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface TaskAsyncClient { public interface TaskAsyncClient {
/** /**
* @see TaskClient#getTaskList(ReferenceType<?>) * @see TaskClient#getTaskList(URISupplier)
*/ */
@GET @GET
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<TasksList> getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) Reference orgRef); ListenableFuture<TasksList> getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) URISupplier orgRef);
/** /**
* @see TaskClient#getTask(URI) * @see TaskClient#getTask(URI)
@ -61,7 +62,7 @@ public interface TaskAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> getTask(@EndpointParam URI taskUri); ListenableFuture<Task> getTask(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier taskRef);
/** /**
* @see TaskClient#cancelTask(URI) * @see TaskClient#cancelTask(URI)
@ -71,5 +72,5 @@ public interface TaskAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Void> cancelTask(@EndpointParam URI taskUri); ListenableFuture<Void> cancelTask(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier taskRef);
} }

View File

@ -18,13 +18,12 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import java.net.URI;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
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.TasksList; import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
/** /**
* Provides synchronous access to {@link Task} objects. * Provides synchronous access to {@link Task} objects.
@ -45,7 +44,7 @@ public interface TaskClient {
* @param orgId the unique id for the organization * @param orgId the unique id for the organization
* @return a list of tasks * @return a list of tasks
*/ */
TasksList getTaskList(Reference orgRef); TasksList getTaskList(URISupplier orgRef);
/** /**
* Retrieves a task. * Retrieves a task.
@ -56,7 +55,7 @@ public interface TaskClient {
* *
* @return the task or null if not found * @return the task or null if not found
*/ */
Task getTask(URI taskUri); Task getTask(URISupplier taskUri);
/** /**
* Cancels a task. * Cancels a task.
@ -65,5 +64,5 @@ public interface TaskClient {
* POST /task/{id}/action/cancel * POST /task/{id}/action/cancel
* </pre> * </pre>
*/ */
void cancelTask(URI taskUri); void cancelTask(URISupplier taskUri);
} }

View File

@ -0,0 +1,55 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.vcloud.director.v1_5.features;
import java.io.File;
import javax.ws.rs.PUT;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @see UploadClient
* @author danikov
*/
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface UploadAsyncClient { // TODO: implement these operations correctly
/**
* @see UploadClient#uploadFile(URISupplier, File)
*/
@PUT
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Object> uploadFile(URISupplier target, File file);
/**
* @see UploadClient#uploadBigFile(URISupplier, File)
*/
@PUT
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Object> uploadBigFile(URISupplier target, File file);
}

View File

@ -0,0 +1,48 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.vcloud.director.v1_5.features;
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
/**
* Provides synchronous access to Upload.
* <p/>
*
* @see UploadAsyncClient
* @see <a href= "http://support.theenterprisecloud.com/kb/default.asp?id=984&Lang=1&SID=" />
* @author danikov
*/
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface UploadClient {
/**
* Uploads a file.
*/
void uploadFile(URISupplier target, File file);
/**
* Uploads a file using ranged PUTs.
*/
void uploadBigFile(URISupplier target, File file);
}

View File

@ -22,10 +22,10 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
@ -40,15 +40,14 @@ import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType;
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.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.URISupplier;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import org.jclouds.vcloud.director.v1_5.functions.URISupplierToEndpoint;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -61,16 +60,16 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface VdcAsyncClient { public interface VdcAsyncClient {
/** /**
* @see VdcClient#getVdc(Reference) * @see VdcClient#getVdc(URISupplier)
*/ */
@GET @GET
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Vdc> getVdc(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef); ListenableFuture<Vdc> getVdc(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef);
/** /**
* @see VdcClient#captureVApp(Reference, CaptureVAppParams) * @see VdcClient#captureVApp(URISupplier, CaptureVAppParams)
*/ */
@POST @POST
@Path("/action/captureVApp") @Path("/action/captureVApp")
@ -78,112 +77,97 @@ public interface VdcAsyncClient {
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<VAppTemplate> captureVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, ListenableFuture<VAppTemplate> captureVApp(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef,
@BinderParam(BindToXMLPayload.class) CaptureVAppParams params); @BinderParam(BindToXMLPayload.class) CaptureVAppParams params);
/** /**
* @see VdcClient#cloneMedia(Reference, CloneMediaParams) * @see VdcClient#cloneMedia(URISupplier, CloneMediaParams)
*/ */
@POST @POST
@Path("/action/cloneMedia") @Path("/action/cloneMedia")
@Consumes(VCloudDirectorMediaType.MEDIA) @Consumes(VCloudDirectorMediaType.MEDIA)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @Produces(VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Media> cloneMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, ListenableFuture<Media> cloneMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef,
@BinderParam(BindToXMLPayload.class) CloneMediaParams params); @BinderParam(BindToXMLPayload.class) CloneMediaParams params);
/** /**
* @see VdcClient#cloneVApp(Reference, CloneVAppParams) * @see VdcClient#cloneVApp(URISupplier, CloneVAppParams)
*/ */
@POST @POST
@Path("/action/cloneVApp") @Path("/action/cloneVApp")
@Consumes(VCloudDirectorMediaType.V_APP) @Consumes(VCloudDirectorMediaType.V_APP)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @Produces(VCloudDirectorMediaType.CLONE_V_APP_PARAMS) //TODO fix these etc.
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<VApp> cloneVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, ListenableFuture<VApp> cloneVApp(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef,
@BinderParam(BindToXMLPayload.class) CloneVAppParams params); @BinderParam(BindToXMLPayload.class) CloneVAppParams params);
/** /**
* @see VdcClient#cloneVAppTemplate(Reference, CloneVAppTemplateParams) * @see VdcClient#cloneVAppTemplate(URISupplier, CloneVAppTemplateParams)
*/ */
@POST @POST
@Path("/action/cloneVAppTemplate") @Path("/action/cloneVAppTemplate")
@Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE) @Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @Produces(VCloudDirectorMediaType.CLONE_V_APP_TEMPLATE_PARAMS)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<VAppTemplate> cloneVAppTemplate(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, ListenableFuture<VAppTemplate> cloneVAppTemplate(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef,
@BinderParam(BindToXMLPayload.class) CloneVAppTemplateParams params); @BinderParam(BindToXMLPayload.class) CloneVAppTemplateParams params);
/** /**
* @see VdcClient#composeVApp(Reference, ComposeVAppParams) * @see VdcClient#composeVApp(URISupplier, ComposeVAppParams)
*/ */
@POST @POST
@Path("/action/composeVApp") @Path("/action/composeVApp")
@Consumes(VCloudDirectorMediaType.V_APP) @Consumes(VCloudDirectorMediaType.V_APP)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @Produces(VCloudDirectorMediaType.COMPOSE_VAPP_PARAMS)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<VApp> composeVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, ListenableFuture<VApp> composeVApp(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef,
@BinderParam(BindToXMLPayload.class) ComposeVAppParams params); @BinderParam(BindToXMLPayload.class) ComposeVAppParams params);
/** /**
* @see VdcClient#instantiateVApp(Reference, InstantiateVAppParamsType) * @see VdcClient#instantiateVApp(URISupplier, InstantiateVAppParamsType)
*/ */
@POST @POST
@Path("/action/instantiateVApp") @Path("/action/instantiateVApp")
@Consumes(VCloudDirectorMediaType.V_APP) @Consumes(VCloudDirectorMediaType.V_APP)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @Produces(VCloudDirectorMediaType.INSTANTIATE_VAPP_TEMPLATE_PARAMS)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<VApp> instantiateVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, ListenableFuture<VApp> instantiateVApp(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef,
@BinderParam(BindToXMLPayload.class) InstantiateVAppParamsType<?> params); @BinderParam(BindToXMLPayload.class) InstantiateVAppParamsType<?> params);
/** /**
* @see VdcClient#uploadVAppTemplate(Reference, UploadVAppTemplateParams) * @see VdcClient#uploadVAppTemplate(URISupplier, UploadVAppTemplateParams)
*/ */
@POST @POST
@Path("/action/uploadVAppTemplate") @Path("/action/uploadVAppTemplate")
@Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE) @Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @Produces(VCloudDirectorMediaType.UPLOAD_VAPP_TEMPLATE_PARAMS)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<VAppTemplate> uploadVAppTemplate(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, ListenableFuture<VAppTemplate> uploadVAppTemplate(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef,
@BinderParam(BindToXMLPayload.class) UploadVAppTemplateParams params); @BinderParam(BindToXMLPayload.class) UploadVAppTemplateParams params);
/** /**
* @see VdcClient#createMedia(Reference, Media) * @see VdcClient#createMedia(URISupplier, Media)
*/ */
@POST @POST
@Path("/media") @Path("/media")
@Consumes(VCloudDirectorMediaType.MEDIA) @Consumes(VCloudDirectorMediaType.MEDIA)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @Produces(VCloudDirectorMediaType.MEDIA)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Media> createMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, ListenableFuture<Media> createMedia(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef,
@BinderParam(BindToXMLPayload.class) Media media); @BinderParam(BindToXMLPayload.class) Media media);
/** /**
* @see VdcClient#getMetadata(Reference) * @return asynchronous access to {@link Metadata.Readable} features
*/ */
@GET @Delegate
@Path("/metadata") MetadataAsyncClient.Readable getMetadataClient();
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef);
/**
* @see VdcClient#getMetadataEntry(Reference, String)
*/
@GET
@Path("/metadata/{key}")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataValue> getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef ,
@PathParam("key") String key);
} }

View File

@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.features;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams;
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams;
@ -29,8 +30,7 @@ import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType;
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.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.URISupplier;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
@ -52,7 +52,7 @@ public interface VdcClient {
* *
* @return the vdc or null if not found * @return the vdc or null if not found
*/ */
Vdc getVdc(Reference vdcRef); Vdc getVdc(URISupplier vdcRef);
/** /**
* Captures a vApp into vApp template. * Captures a vApp into vApp template.
@ -61,7 +61,7 @@ public interface VdcClient {
* @return a VApp resource which will contain a task. * @return a VApp resource which will contain a task.
* The user should should wait for this task to finish to be able to use the vApp. * The user should should wait for this task to finish to be able to use the vApp.
*/ */
VAppTemplate captureVApp(Reference vdcRef, CaptureVAppParams params); VAppTemplate captureVApp(URISupplier vdcRef, CaptureVAppParams params);
/** /**
* Clones a media into new one. * Clones a media into new one.
@ -70,7 +70,7 @@ public interface VdcClient {
* @return a Media resource which will contain a task. * @return a Media resource which will contain a task.
* The user should monitor the contained task status in order to check when it is completed. * The user should monitor the contained task status in order to check when it is completed.
*/ */
Media cloneMedia(Reference vdcRef, CloneMediaParams params); Media cloneMedia(URISupplier vdcRef, CloneMediaParams params);
/** /**
* Clones a vApp into new one. The status of vApp will be in UNRESOLVED(0) until the clone task is finished. * Clones a vApp into new one. The status of vApp will be in UNRESOLVED(0) until the clone task is finished.
@ -78,7 +78,7 @@ public interface VdcClient {
* @return a VApp resource which will contain a task. * @return a VApp resource which will contain a task.
* The user should should wait for this task to finish to be able to use the vApp. * The user should should wait for this task to finish to be able to use the vApp.
*/ */
VApp cloneVApp(Reference vdcRef, CloneVAppParams params); VApp cloneVApp(URISupplier vdcRef, CloneVAppParams params);
/** /**
* Clones a vApp template into new one. * Clones a vApp template into new one.
@ -87,7 +87,7 @@ public interface VdcClient {
* @return a VAppTemplate resource which will contain a task. * @return a VAppTemplate resource which will contain a task.
* The user should should wait for this task to finish to be able to use the VAppTemplate. * The user should should wait for this task to finish to be able to use the VAppTemplate.
*/ */
VAppTemplate cloneVAppTemplate(Reference vdcRef, CloneVAppTemplateParams params); VAppTemplate cloneVAppTemplate(URISupplier vdcRef, CloneVAppTemplateParams params);
/** /**
* Composes a new vApp using VMs from other vApps or vApp templates. The vCloud API supports * Composes a new vApp using VMs from other vApps or vApp templates. The vCloud API supports
@ -111,7 +111,7 @@ public interface VdcClient {
* @return a VApp resource which will contain a task. * @return a VApp resource which will contain a task.
* The user should should wait for this task to finish to be able to use the vApp. * The user should should wait for this task to finish to be able to use the vApp.
*/ */
VApp composeVApp(Reference vdcRef, ComposeVAppParams params); VApp composeVApp(URISupplier vdcRef, ComposeVAppParams params);
/** /**
* Instantiate a vApp template into a new vApp. * Instantiate a vApp template into a new vApp.
@ -120,7 +120,7 @@ public interface VdcClient {
* @return a VApp resource which will contain a task. * @return a VApp resource which will contain a task.
* The user should should wait for this task to finish to be able to use the vApp. * The user should should wait for this task to finish to be able to use the vApp.
*/ */
VApp instantiateVApp(Reference vdcRef, InstantiateVAppParamsType<?> params); VApp instantiateVApp(URISupplier vdcRef, InstantiateVAppParamsType<?> params);
/** /**
* Uploading vApp template to a vDC. The operation is separate on several steps: * Uploading vApp template to a vDC. The operation is separate on several steps:
@ -134,27 +134,19 @@ public interface VdcClient {
* @return a VAppTemplate resource which will contain a task. * @return a VAppTemplate resource which will contain a task.
* The user should should wait for this task to finish to be able to use the VAppTemplate. * The user should should wait for this task to finish to be able to use the VAppTemplate.
*/ */
VAppTemplate uploadVAppTemplate(Reference vdcRef, UploadVAppTemplateParams params); VAppTemplate uploadVAppTemplate(URISupplier vdcRef, UploadVAppTemplateParams params);
/** /**
* Creates a media (and present upload link for the floppy/iso file). * Creates a media (and present upload link for the floppy/iso file).
* *
* @return The response will return a link to transfer site to be able to continue with uploading the media. * @return The response will return a link to transfer site to be able to continue with uploading the media.
*/ */
Media createMedia(Reference vdcRef, Media media); Media createMedia(URISupplier vdcRef, Media media);
/** /**
* Retrieves an list of the vdc's metadata * @return synchronous access to {@link Metadata.Readable} features
*
* @return a list of metadata
*/ */
Metadata getMetadata(Reference vdcRef); @Delegate
MetadataClient.Readable getMetadataClient();
/**
* Retrieves a metadata value
*
* @return the metadata value, or null if not found
*/
MetadataValue getMetadataValue(Reference vdcRef, String key);
} }

View File

@ -26,7 +26,7 @@ import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
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.Org; import org.jclouds.vcloud.director.v1_5.domain.Org;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -47,8 +47,8 @@ public class OrgReferenceToTaskListEndpoint implements Function<Object, URI> {
@Override @Override
public URI apply(Object input) { public URI apply(Object input) {
Preconditions.checkNotNull(input); Preconditions.checkNotNull(input);
Preconditions.checkArgument(input instanceof ReferenceType<?>); Preconditions.checkArgument(input instanceof URISupplier);
ReferenceType<?> reference = (ReferenceType<?>) input; URISupplier reference = (URISupplier) input;
Org org = client.getOrg(reference); Org org = client.getOrg(reference);
for (Link link : org.getLinks()) { for (Link link : org.getLinks()) {
if (link.getType().equals(VCloudDirectorMediaType.TASKS_LIST)) { if (link.getType().equals(VCloudDirectorMediaType.TASKS_LIST)) {

View File

@ -29,6 +29,7 @@ import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
/** /**
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Deprecated
public class ReferenceToEndpoint implements Function<Object, URI> { public class ReferenceToEndpoint implements Function<Object, URI> {
@Override @Override

View File

@ -0,0 +1,40 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.vcloud.director.v1_5.functions;
import java.net.URI;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
/**
* @author danikov
*/
public class URISupplierToEndpoint implements Function<Object, URI> {
@Override
public URI apply(Object input) {
Preconditions.checkNotNull(input);
Preconditions.checkArgument(input instanceof URISupplier);
URISupplier provider = (URISupplier) input;
return provider.getURI();
};
}

View File

@ -18,8 +18,6 @@
*/ */
package org.jclouds.vcloud.director.v1_5.predicates; package org.jclouds.vcloud.director.v1_5.predicates;
import java.net.URI;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -27,6 +25,7 @@ import javax.inject.Singleton;
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.URISupplier;
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;
@ -37,7 +36,7 @@ import com.google.common.base.Predicate;
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Singleton @Singleton
public class TaskSuccess implements Predicate<URI> { public class TaskSuccess implements Predicate<URISupplier> {
private final TaskClient taskClient; private final TaskClient taskClient;
@ -51,10 +50,10 @@ public class TaskSuccess implements Predicate<URI> {
/** @see Predicate#apply(Object) */ /** @see Predicate#apply(Object) */
@Override @Override
public boolean apply(URI taskUri) { public boolean apply(URISupplier taskRef) {
logger.trace("looking for status on task %s", taskUri); logger.trace("looking for status on task %s", taskRef);
Task task = taskClient.getTask(taskUri); Task task = taskClient.getTask(taskRef);
// perhaps task isn't available, yet // perhaps task isn't available, yet
if (task == null) return false; if (task == null) return false;
logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus()); logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus());

View File

@ -71,4 +71,6 @@ public class VCloudDirectorLiveTestConstants {
public static final String CORRECT_VALUE_OBJECT_FMT = "ERR-122: The %s field of the %s must be '%s': '%s'"; public static final String CORRECT_VALUE_OBJECT_FMT = "ERR-122: The %s field of the %s must be '%s': '%s'";
public static final String OBJ_FIELD_CLONE = "ERR-123: %s %s must be a clone of \"%s\" (%s)";
} }

View File

@ -46,7 +46,7 @@ import com.google.common.collect.ImmutableSet;
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "CatalogClientExpectTest") @Test(groups = { "unit", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest")
public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test @Test
@ -149,7 +149,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
.entries(ImmutableSet.of(metadataEntry())) .entries(ImmutableSet.of(metadataEntry()))
.build(); .build();
assertEquals(client.getCatalogClient().getCatalogMetadata(catalogRef), expected); assertEquals(client.getCatalogClient().getMetadataClient().getMetadata(catalogRef), expected);
} }
@Test @Test
@ -178,7 +178,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
MetadataValue expected = metadataValue(); MetadataValue expected = metadataValue();
assertEquals(client.getCatalogClient().getCatalogMetadataValue(catalogRef, "KEY"), expected); assertEquals(client.getCatalogClient().getMetadataClient().getMetadataValue(catalogRef, "KEY"), expected);
} }
@Test @Test
@ -301,7 +301,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
.entries(ImmutableSet.of(itemMetadataEntry())) .entries(ImmutableSet.of(itemMetadataEntry()))
.build(); .build();
assertEquals(client.getCatalogClient().getCatalogItemMetadata(catalogItemReference), expected); assertEquals(client.getCatalogClient().getMetadataClient().getMetadata(catalogItemReference), expected);
} }
@Test @Test
@ -333,7 +333,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
Task expected = mergeMetadataTask(); Task expected = mergeMetadataTask();
assertEquals(client.getCatalogClient().mergeCatalogItemMetadata(catalogItemReference, metadata), expected); assertEquals(client.getCatalogClient().getMetadataClient().mergeMetadata(catalogItemReference, metadata), expected);
} }
@Test @Test
@ -362,7 +362,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
MetadataValue expected = itemMetadataValue(); MetadataValue expected = itemMetadataValue();
assertEquals(client.getCatalogClient().getCatalogItemMetadataValue(catalogItemReference, "KEY"), expected); assertEquals(client.getCatalogClient().getMetadataClient().getMetadataValue(catalogItemReference, "KEY"), expected);
} }
@Test @Test
@ -394,7 +394,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
Task expected = setMetadataValueTask(); Task expected = setMetadataValueTask();
assertEquals(client.getCatalogClient().setCatalogItemMetadataValue(catalogItemReference, "KEY", value), expected); assertEquals(client.getCatalogClient().getMetadataClient().setMetadata(catalogItemReference, "KEY", value), expected);
} }
@Test @Test
@ -403,7 +403,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
.method("DELETE") .method("DELETE")
.endpoint(URI.create(endpoint + "/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata/KEY")) .endpoint(URI.create(endpoint + "/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata/KEY"))
.headers(ImmutableMultimap.<String, String> builder() .headers(ImmutableMultimap.<String, String> builder()
.put("Accept", "*/*") .put("Accept", "application/vnd.vmware.vcloud.task+xml")
.put("x-vcloud-authorization", token) .put("x-vcloud-authorization", token)
.build()) .build())
.build(); .build();
@ -423,7 +423,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
Task expected = deleteMetadataEntryTask(); Task expected = deleteMetadataEntryTask();
assertEquals(client.getCatalogClient().deleteCatalogItemMetadataValue(catalogItemReference, "KEY"), expected); assertEquals(client.getCatalogClient().getMetadataClient().deleteMetadataEntry(catalogItemReference, "KEY"), expected);
} }
public static final Catalog catalog() { public static final Catalog catalog() {

View File

@ -55,7 +55,7 @@ import com.google.common.collect.Iterables;
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "CatalogClientLiveTest") @Test(groups = { "live", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest")
public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
/* /*
@ -150,7 +150,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// NOTE for this test to work, we need to be able to create metadata on a Catalog, specifically { "KEY", "VALUE" } // NOTE for this test to work, we need to be able to create metadata on a Catalog, specifically { "KEY", "VALUE" }
@Test(testName = "GET /catalog/{id}/metadata", dependsOnMethods = { "testGetCatalog" }, enabled = false) @Test(testName = "GET /catalog/{id}/metadata", dependsOnMethods = { "testGetCatalog" }, enabled = false)
public void testGetCatalogMetadata() { public void testGetCatalogMetadata() {
catalogMetadata = catalogClient.getCatalogMetadata(catalogRef); catalogMetadata = catalogClient.getMetadataClient().getMetadata(catalogRef);
checkMetadata(catalogMetadata); checkMetadata(catalogMetadata);
} }
@ -163,7 +163,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
return input.getKey().equals("KEY"); return input.getKey().equals("KEY");
} }
}); });
MetadataValue metadataValue = catalogClient.getCatalogMetadataValue(catalogRef, "KEY"); MetadataValue metadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogRef, "KEY");
assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(), assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(),
String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", existingMetadataEntry.getValue(), metadataValue.getValue())); String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", existingMetadataEntry.getValue(), metadataValue.getValue()));
checkMetadataValue(metadataValue); checkMetadataValue(metadataValue);
@ -172,7 +172,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /catalogItem/{id}/metadata", dependsOnMethods = { "testGetCatalogItem" }) @Test(testName = "GET /catalogItem/{id}/metadata", dependsOnMethods = { "testGetCatalogItem" })
public void testGetCatalogItemMetadata() { public void testGetCatalogItemMetadata() {
resetCatalogItemMetadata(catalogItemRef); resetCatalogItemMetadata(catalogItemRef);
catalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); catalogItemMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef);
assertEquals(catalogItemMetadata.getMetadataEntries().size(), 1, String.format(MUST_EXIST_FMT, "MetadataEntry", "CatalogItem")); assertEquals(catalogItemMetadata.getMetadataEntries().size(), 1, String.format(MUST_EXIST_FMT, "MetadataEntry", "CatalogItem"));
checkMetadata(catalogItemMetadata); checkMetadata(catalogItemMetadata);
} }
@ -184,22 +184,22 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.entry(MetadataEntry.builder().entry("VEGIMITE", "VALUE").build()) .entry(MetadataEntry.builder().entry("VEGIMITE", "VALUE").build())
.build(); .build();
Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); Task mergeCatalogItemMetadata = catalogClient.getMetadataClient().mergeMetadata(catalogItemRef, newMetadata);
checkTask(mergeCatalogItemMetadata); checkTask(mergeCatalogItemMetadata);
assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata.getHref()), assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata),
String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
Metadata mergedCatalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); Metadata mergedCatalogItemMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef);
// XXX // XXX
assertEquals(mergedCatalogItemMetadata.getMetadataEntries().size(), catalogItemMetadata.getMetadataEntries().size() + 1, assertEquals(mergedCatalogItemMetadata.getMetadataEntries().size(), catalogItemMetadata.getMetadataEntries().size() + 1,
"Should have added another MetadataEntry to the CatalogItem"); "Should have added another MetadataEntry to the CatalogItem");
MetadataValue keyMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); MetadataValue keyMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY");
// XXX // XXX
assertEquals(keyMetadataValue.getValue(), "MARMALADE", "The Value of the MetadataValue for KEY should have changed"); assertEquals(keyMetadataValue.getValue(), "MARMALADE", "The Value of the MetadataValue for KEY should have changed");
checkMetadataValue(keyMetadataValue); checkMetadataValue(keyMetadataValue);
MetadataValue newKeyMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "VEGIMITE"); MetadataValue newKeyMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "VEGIMITE");
// XXX // XXX
assertEquals(newKeyMetadataValue.getValue(), "VALUE", "The Value of the MetadataValue for NEW_KEY should have been set"); assertEquals(newKeyMetadataValue.getValue(), "VALUE", "The Value of the MetadataValue for NEW_KEY should have been set");
checkMetadataValue(newKeyMetadataValue); checkMetadataValue(newKeyMetadataValue);
@ -215,7 +215,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
return input.getKey().equals("KEY"); return input.getKey().equals("KEY");
} }
}); });
MetadataValue metadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); MetadataValue metadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY");
assertEquals(existingMetadataEntry.getValue(), metadataValue.getValue()); assertEquals(existingMetadataEntry.getValue(), metadataValue.getValue());
checkMetadataValue(metadataValue); checkMetadataValue(metadataValue);
} }
@ -224,13 +224,13 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public void testSetCatalogItemMetadataValue() { public void testSetCatalogItemMetadataValue() {
MetadataValue newMetadataValue = MetadataValue.builder().value("NEW").build(); MetadataValue newMetadataValue = MetadataValue.builder().value("NEW").build();
Task setCatalogItemMetadataValue = catalogClient.setCatalogItemMetadataValue(catalogItemRef, "KEY", newMetadataValue); Task setCatalogItemMetadataValue = catalogClient.getMetadataClient().setMetadata(catalogItemRef, "KEY", newMetadataValue);
checkTask(setCatalogItemMetadataValue); checkTask(setCatalogItemMetadataValue);
Checks.checkTask(setCatalogItemMetadataValue); Checks.checkTask(setCatalogItemMetadataValue);
assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue.getHref()), assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue),
String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue")); String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue"));
MetadataValue updatedMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); MetadataValue updatedMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY");
assertEquals(updatedMetadataValue.getValue(), newMetadataValue.getValue(), assertEquals(updatedMetadataValue.getValue(), newMetadataValue.getValue(),
String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", newMetadataValue.getValue(), updatedMetadataValue.getValue())); String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", newMetadataValue.getValue(), updatedMetadataValue.getValue()));
checkMetadataValue(updatedMetadataValue); checkMetadataValue(updatedMetadataValue);
@ -238,13 +238,13 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "DELETE /catalog/{id}/metadata/{key}", dependsOnMethods = { "testSetCatalogItemMetadataValue" }) @Test(testName = "DELETE /catalog/{id}/metadata/{key}", dependsOnMethods = { "testSetCatalogItemMetadataValue" })
public void testDeleteCatalogItemMetadataValue() { public void testDeleteCatalogItemMetadataValue() {
Task deleteCatalogItemMetadataValue = catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, "KEY"); Task deleteCatalogItemMetadataValue = catalogClient.getMetadataClient().deleteMetadataEntry(catalogItemRef, "KEY");
checkTask(deleteCatalogItemMetadataValue); checkTask(deleteCatalogItemMetadataValue);
Checks.checkTask(deleteCatalogItemMetadataValue); Checks.checkTask(deleteCatalogItemMetadataValue);
assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue.getHref()), assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue),
String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue")); String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue"));
try { try {
catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY");
fail("The CatalogItem MetadataValue for KEY should have been deleted"); fail("The CatalogItem MetadataValue for KEY should have been deleted");
} catch (VCloudDirectorException vcde) { } catch (VCloudDirectorException vcde) {
Error error = vcde.getError(); Error error = vcde.getError();
@ -256,20 +256,20 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
private void deleteAllCatalogItemMetadata(ReferenceType<?> catalogItemRef) { private void deleteAllCatalogItemMetadata(ReferenceType<?> catalogItemRef) {
Metadata currentMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); Metadata currentMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef);
for (MetadataEntry currentMetadataEntry : currentMetadata.getMetadataEntries()) { for (MetadataEntry currentMetadataEntry : currentMetadata.getMetadataEntries()) {
catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, currentMetadataEntry.getKey()); catalogClient.getMetadataClient().deleteMetadataEntry(catalogItemRef, currentMetadataEntry.getKey());
} }
Metadata emptyMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); Metadata emptyMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef);
assertTrue(emptyMetadata.getMetadataEntries().isEmpty(), "The catalogItem Metadata should be empty"); assertTrue(emptyMetadata.getMetadataEntries().isEmpty(), "The catalogItem Metadata should be empty");
} }
private void resetCatalogItemMetadata(ReferenceType<?> catalogItemRef) { private void resetCatalogItemMetadata(ReferenceType<?> catalogItemRef) {
deleteAllCatalogItemMetadata(catalogItemRef); deleteAllCatalogItemMetadata(catalogItemRef);
Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build(); Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build();
Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); Task mergeCatalogItemMetadata = catalogClient.getMetadataClient().mergeMetadata(catalogItemRef, newMetadata);
Checks.checkTask(mergeCatalogItemMetadata); Checks.checkTask(mergeCatalogItemMetadata);
assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata.getHref()), assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata),
String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
} }
} }

View File

@ -26,7 +26,10 @@ import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams;
import org.jclouds.vcloud.director.v1_5.domain.Error; 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.FilesList;
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.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
@ -35,6 +38,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
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.TasksInProgress;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -43,10 +47,70 @@ import org.testng.annotations.Test;
* *
* @author danikov * @author danikov
*/ */
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "NetworkClientExpectTest") @Test(groups = { "unit", "media" }, singleThreaded = true, testName = "MediaClientExpectTest")
public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test(enabled = false) @Test
public void testCreateMedia() {
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/media")
.acceptMedia(VCloudDirectorMediaType.MEDIA)
.xmlFilePayload("/media/createMediaSource.xml", VCloudDirectorMediaType.MEDIA)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/createMedia.xml", VCloudDirectorMediaType.MEDIA)
.httpResponseBuilder().statusCode(201).build());
Media source = Media.builder()
.size(0)
.imageType("iso")
.name("Test media 1")
.type("application/vnd.vmware.vcloud.media+xml")
.description("Test media generated by testCreateMedia()")
.build();
Media expected = createMedia();
Reference vdcRef = Reference.builder().href(vdcUri).build();
assertEquals(client.getVdcClient().createMedia(vdcRef, source), expected);
}
@Test
public void testCloneMedia() {
URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia")
.acceptMedia(VCloudDirectorMediaType.MEDIA)
.xmlFilePayload("/media/cloneMediaParams.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/cloneMedia.xml", VCloudDirectorMediaType.MEDIA)
.httpResponseBuilder().statusCode(201).build());
CloneMediaParams params = CloneMediaParams.builder()
.name("moved test media")
.description("moved by testCloneMedia()")
.source(Reference.builder()
.type("application/vnd.vmware.vcloud.media+xml")
.name("copied test media")
.id("urn:vcloud:media:da8361af-cccd-4103-a71c-493513c49094")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/da8361af-cccd-4103-a71c-493513c49094"))
.build())
.isSourceDelete(false)
.build();
Media expected = cloneMedia();
Reference vdcRef = Reference.builder().href(vdcUri).build();
assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected);
}
@Test
public void testGetMedia() { public void testGetMedia() {
URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1"); URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
@ -59,13 +123,14 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
.xmlFilePayload("/media/media.xml", VCloudDirectorMediaType.MEDIA) .xmlFilePayload("/media/media.xml", VCloudDirectorMediaType.MEDIA)
.httpResponseBuilder().build()); .httpResponseBuilder().build());
Media expected = media(); Media expected = getMedia();
Reference mediaRef = Reference.builder().href(mediaUri).build(); Reference mediaRef = Reference.builder().href(mediaUri).build();
assertEquals(client.getMediaClient().getMedia(mediaRef), expected); assertEquals(client.getMediaClient().getMedia(mediaRef), expected);
} }
@Test
public void testResponse400ForInvalidMedia() { public void testResponse400ForInvalidMedia() {
URI mediaUri = URI.create(endpoint + "/media/NOTAUUID"); URI mediaUri = URI.create(endpoint + "/media/NOTAUUID");
@ -215,7 +280,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
Metadata expected = metadata(); Metadata expected = metadata();
assertEquals(client.getMediaClient().getMetadata(mediaRef), expected); assertEquals(client.getMediaClient().getMetadataClient().getMetadata(mediaRef), expected);
} }
@Test @Test
@ -236,7 +301,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
Metadata inputMetadata = metadata(); Metadata inputMetadata = metadata();
Task expectedTask = mergeMetadataTask(); Task expectedTask = mergeMetadataTask();
assertEquals(client.getMediaClient().mergeMetadata(mediaRef, inputMetadata), expectedTask); assertEquals(client.getMediaClient().getMetadataClient().mergeMetadata(mediaRef, inputMetadata), expectedTask);
} }
public void testGetMetadataValue() { public void testGetMetadataValue() {
@ -255,7 +320,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
Reference mediaRef = Reference.builder().href(mediaUri).build(); Reference mediaRef = Reference.builder().href(mediaUri).build();
assertEquals(client.getMediaClient().getMetadataValue(mediaRef, "key"), expected); assertEquals(client.getMediaClient().getMetadataClient().getMetadataValue(mediaRef, "key"), expected);
} }
@Test @Test
@ -277,7 +342,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
Task expectedTask = setMetadataEntryTask(); Task expectedTask = setMetadataEntryTask();
assertEquals(client.getMediaClient().setMetadata(mediaRef, "key", inputMetadataValue), expectedTask); assertEquals(client.getMediaClient().getMetadataClient().setMetadata(mediaRef, "key", inputMetadataValue), expectedTask);
} }
@Test @Test
@ -296,7 +361,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
Reference mediaRef = Reference.builder().href(mediaUri).build(); Reference mediaRef = Reference.builder().href(mediaUri).build();
Task expectedTask = deleteMetadataEntryTask(); Task expectedTask = deleteMetadataEntryTask();
assertEquals(client.getMediaClient().deleteMetadataEntry(mediaRef, "key"), expectedTask); assertEquals(client.getMediaClient().getMetadataClient().deleteMetadataEntry(mediaRef, "key"), expectedTask);
} }
@Test @Test
@ -319,7 +384,96 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
assertEquals(client.getMediaClient().getOwner(mediaRef), expected); assertEquals(client.getMediaClient().getOwner(mediaRef), expected);
} }
private static Media media() { private static Media createMedia() {
return Media.builder()
.size(0)
.imageType("iso")
.status(0)
.name("Test media 1")
.id("urn:vcloud:media:d51b0b9d-099c-499f-97f8-4fbe40ba06d7")
.type("application/vnd.vmware.vcloud.media+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/d51b0b9d-099c-499f-97f8-4fbe40ba06d7"))
.link(Link.builder()
.rel("up")
.type("application/vnd.vmware.vcloud.vdc+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"))
.build())
.link(Link.builder()
.rel("remove")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/d51b0b9d-099c-499f-97f8-4fbe40ba06d7"))
.build())
.description("Test media generated by testCreateMedia()")
.files(FilesList.builder()
.file(File.builder()
.size(0l)
.bytesTransferred(0l)
.name("file")
.link(Link.builder()
.rel("upload:default")
.href(URI.create("https://mycloud.greenhousedata.com:443/transfer/b1fdf2d0-feff-4414-a8d1-3a8d86c4ccc5/file"))
.build())
.build())
.build())
.owner(owner())
.build();
}
private static Media cloneMedia() {
return Media.builder()
.size(175163392)
.imageType("iso")
.status(0)
.name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2")
.id("urn:vcloud:media:a6b023f2-7f90-4e89-a24d-56e0eba83a5a")
.type("application/vnd.vmware.vcloud.media+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a"))
.link(Link.builder()
.rel("up")
.type("application/vnd.vmware.vcloud.vdc+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"))
.build())
.link(Link.builder()
.rel("remove")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a"))
.build())
.description("copied by testCloneMedia()")
.tasksInProgress(TasksInProgress.builder()
.task(Task.builder()
.status("running")
.startTime(dateService.iso8601DateParse("2012-03-02T04:58:48.754-07:00"))
.operationName("vdcCopyMedia")
.operation("Copying Media File copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2(a6b023f2-7f90-4e89-a24d-56e0eba83a5a)")
.expiryTime(dateService.iso8601DateParse("2012-05-31T04:58:48.754-06:00"))
.name("task")
.id("urn:vcloud:task:7e4f6baf-7ef0-43ea-93cc-62cc329afb5d")
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/task/7e4f6baf-7ef0-43ea-93cc-62cc329afb5d"))
.link(Link.builder()
.rel("task:cancel")
.href(URI.create("https://mycloud.greenhousedata.com/api/task/7e4f6baf-7ef0-43ea-93cc-62cc329afb5d/action/cancel"))
.build())
.owner(Reference.builder()
.type("application/vnd.vmware.vcloud.media+xml")
.name("copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("acole")
.href(URI.create("https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120"))
.build())
.org(Reference.builder()
.type("application/vnd.vmware.vcloud.org+xml")
.name("cloudsoft")
.href(URI.create("https://mycloud.greenhousedata.com/api/org/c076f90a-397a-49fa-89b8-b294c1599cd0"))
.build())
.build())
.build())
.owner(owner())
.build();
}
private static Media getMedia() {
return Media.builder() return Media.builder()
.size(175163392) .size(175163392)
.imageType("iso") .imageType("iso")
@ -356,7 +510,8 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
.type("application/vnd.vmware.vcloud.metadata+xml") .type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata")) .href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata"))
.build()) .build())
.description("Windows 2003 R2 Disk2 Standard 32bit &amp; 64bit") .type("application/vnd.vmware.vcloud.media+xml")
.description("Windows 2003 R2 Disk2 Standard 32bit & 64bit")
.owner(owner()) .owner(owner())
.build(); .build();
} }

View File

@ -23,11 +23,16 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*
import static org.testng.Assert.*; import static org.testng.Assert.*;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import java.util.Set; import java.util.Set;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams;
import org.jclouds.vcloud.director.v1_5.domain.Error; 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.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.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;
@ -35,9 +40,9 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
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.URISupplier;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -48,53 +53,84 @@ import com.google.common.collect.Iterables;
* *
* @author danikov * @author danikov
*/ */
@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "MediaClientLiveTest") @Test(groups = { "live", "user", "media" }, singleThreaded = true, testName = "MediaClientLiveTest")
public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String MEDIA = "media"; public static final String MEDIA = "media";
public static final String VDC = "vdc";
/* /*
* Convenience references to API clients. * Convenience references to API clients.
*/ */
private Reference mediaRef; private URISupplier vdcRef;
protected VdcClient vdcClient;
protected MediaClient mediaClient; protected MediaClient mediaClient;
@BeforeClass(inheritGroups = true) @BeforeClass(inheritGroups = true)
@Override @Override
public void setupRequiredClients() { public void setupRequiredClients() {
mediaRef = Reference.builder() vdcRef = Reference.builder()
.type("application/vnd.vmware.vcloud.media+xml") .type("application/vnd.vmware.vcloud.vdc+xml")
.name("") .name("")
.href(URI.create(endpoint+"/media/" + mediaId)) .href(URI.create(endpoint+"/vdc/"+vdcId))
.id(mediaId) .id(vdcId)
.build(); .build();
vdcClient = context.getApi().getVdcClient();
mediaClient = context.getApi().getMediaClient(); mediaClient = context.getApi().getMediaClient();
} }
/* /*
* Shared state between dependent tests. * Shared state between dependent tests.
*/ */
private Media media; private Media media, oldMedia;
private Owner owner; private Owner owner;
private Metadata metadata; private Metadata metadata;
private MetadataValue metadataValue; private MetadataValue metadataValue;
private String metadataEntryValue = "value"; private String metadataEntryValue = "value";
@BeforeGroups(groups = { "live" }) @Test(testName = "POST /vdc/{id}/media", enabled = false)
public void createReferenceData() { public void testCreateMedia() throws URISyntaxException {
// FIXME: don't want to be modifying anything here! assertNotNull(vdcRef, String.format(REF_REQ_LIVE, VDC));
mediaClient.setMetadata(mediaRef, "key", MetadataValue.builder().value("value").build()); assertNotNull(vdcClient.getVdc(vdcRef), String.format(OBJ_REQ_LIVE, VDC));
java.io.File sourceFile = new java.io.File(getClass().getResource("/media/test.iso").toURI());
Media sourceMedia = Media.builder()
.type(VCloudDirectorMediaType.MEDIA)
.name("Test media 1")
.size(sourceFile.length())
.imageType(Media.ImageType.ISO)
.description("Test media generated by testCreateMedia()")
.build();
media = vdcClient.createMedia(vdcRef, sourceMedia);
Checks.checkMediaFor(MEDIA, media);
assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files"));
assertTrue(media.getFiles().getFiles().size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "files.size()", "1",
media.getFiles().getFiles().size()));
File uploadFile = Iterables.getFirst(media.getFiles().getFiles(), null);
assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first"));
assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()",
sourceMedia.getSize(), uploadFile.getSize()));
Set<Link> links = uploadFile.getLinks();
assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links"));
assertTrue(links.size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "uploadfile.links.size()", "1",
links.size()));
Link uploadLink = Iterables.getFirst(links, null);
assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first"));
fail(); //TODO upload file and assert it succeeds
context.getApi().getUploadClient().uploadFile(uploadLink, sourceFile);
} }
@Test(testName = "GET /media/{id}") @Test(testName = "GET /media/{id}", dependsOnMethods = { "testCreateMedia" }, enabled = false)
public void testGetMedia() { public void testGetMedia() {
// required for testing media = mediaClient.getMedia(media);
assertNotNull(mediaRef, String.format(REF_REQ_LIVE, MEDIA));
media = mediaClient.getMedia(mediaRef);
assertNotNull(media, String.format(OBJ_REQ_LIVE, MEDIA)); assertNotNull(media, String.format(OBJ_REQ_LIVE, MEDIA));
assertTrue(!media.getDescription().equals("DO NOT USE"), "Media isn't to be used for testing");
owner = media.getOwner(); owner = media.getOwner();
assertNotNull(owner, String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "owner")); assertNotNull(owner, String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "owner"));
@ -104,9 +140,9 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
@Test(testName = "GET /media/{id}/owner", @Test(testName = "GET /media/{id}/owner",
dependsOnMethods = { "testGetMedia" }) dependsOnMethods = { "testGetMedia" }, enabled = false)
public void testGetMediaOwner() { public void testGetMediaOwner() {
Owner directOwner = mediaClient.getOwner(mediaRef); Owner directOwner = mediaClient.getOwner(media);
assertEquals(owner, directOwner, String.format(GETTER_RETURNS_SAME_OBJ, assertEquals(owner, directOwner, String.format(GETTER_RETURNS_SAME_OBJ,
"getOwner()", "owner", "media.getOwner()", owner.toString(), directOwner.toString())); "getOwner()", "owner", "media.getOwner()", owner.toString(), directOwner.toString()));
@ -118,8 +154,58 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Checks.checkReferenceType(directOwner.getUser()); Checks.checkReferenceType(directOwner.getUser());
} }
@Test(testName = "POST /vdc/{id}/action/cloneMedia",
dependsOnMethods = { "testGetMediaOwner" }, enabled = false)
public void testCloneMedia() {
oldMedia = media;
media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder()
.source(Reference.builder().fromEntity(media).build())
.name("copied test media")
.description("copied by testCloneMedia()")
.build());
Checks.checkMediaFor(VDC, media);
if (media.getTasksInProgress() != null) {
Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null);
if (copyTask != null) {
Checks.checkTask(copyTask);
assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask"));
media = mediaClient.getMedia(media);
}
}
Checks.checkMediaFor(MEDIA, media);
assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "copied media",
media.toString(), oldMedia.toString()));
mediaClient.getMetadataClient().setMetadata(media, "key", MetadataValue.builder().value("value").build());
media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder()
.source(Reference.builder().fromEntity(media).build())
.name("moved test media")
.description("moved by testCloneMedia()")
.isSourceDelete(true)
.build());
Checks.checkMediaFor(VDC, media);
if (media.getTasksInProgress() != null) {
Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null);
if (copyTask != null) {
Checks.checkTask(copyTask);
assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask"));
media = mediaClient.getMedia(media);
}
}
Checks.checkMediaFor(MEDIA, media);
assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "moved media",
media.toString(), oldMedia.toString()));
}
@Test(testName = "PUT /media/{id}", @Test(testName = "PUT /media/{id}",
dependsOnMethods = { "testGetMedia" }) dependsOnMethods = { "testCloneMedia" }, enabled = false)
public void testSetMedia() { public void testSetMedia() {
String oldName = media.getName(); String oldName = media.getName();
String newName = "new "+oldName; String newName = "new "+oldName;
@ -127,10 +213,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
String newDescription = "new "+oldDescription; String newDescription = "new "+oldDescription;
media = media.toBuilder().name(newName).description(newDescription).build(); media = media.toBuilder().name(newName).description(newDescription).build();
Task updateMedia = mediaClient.updateMedia(mediaRef, media); Task updateMedia = mediaClient.updateMedia(media, media);
Checks.checkTask(updateMedia); Checks.checkTask(updateMedia);
assertTrue(retryTaskSuccess.apply(updateMedia.getHref()), String.format(TASK_COMPLETE_TIMELY, "updateMedia")); assertTrue(retryTaskSuccess.apply(updateMedia), String.format(TASK_COMPLETE_TIMELY, "updateMedia"));
media = mediaClient.getMedia(mediaRef); media = mediaClient.getMedia(media);
assertTrue(equal(media.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, MEDIA, "name")); assertTrue(equal(media.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, MEDIA, "name"));
assertTrue(equal(media.getDescription(), newDescription), assertTrue(equal(media.getDescription(), newDescription),
@ -142,16 +228,16 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
media = media.toBuilder().name(oldName).description(oldDescription).build(); media = media.toBuilder().name(oldName).description(oldDescription).build();
updateMedia = mediaClient.updateMedia(mediaRef, media); updateMedia = mediaClient.updateMedia(media, media);
Checks.checkTask(updateMedia); Checks.checkTask(updateMedia);
assertTrue(retryTaskSuccess.apply(updateMedia.getHref()), String.format(TASK_COMPLETE_TIMELY, "updateMedia")); assertTrue(retryTaskSuccess.apply(updateMedia), String.format(TASK_COMPLETE_TIMELY, "updateMedia"));
media = mediaClient.getMedia(mediaRef); media = mediaClient.getMedia(media);
} }
@Test(testName = "GET /media/{id}/metadata", @Test(testName = "GET /media/{id}/metadata",
dependsOnMethods = { "testGetMedia" }) dependsOnMethods = { "testGetMedia" }, enabled = false)
public void testGetMetadata() { public void testGetMetadata() {
metadata = mediaClient.getMetadata(mediaRef); metadata = mediaClient.getMetadataClient().getMetadata(media);
// required for testing // required for testing
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries")); String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries"));
@ -160,7 +246,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
@Test(testName = "POST /media/{id}/metadata", @Test(testName = "POST /media/{id}/metadata",
dependsOnMethods = { "testGetMetadata" }) dependsOnMethods = { "testGetMetadata" }, enabled = false)
public void testMergeMetadata() { public void testMergeMetadata() {
// test new // test new
Set<MetadataEntry> inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "testValue").build()); Set<MetadataEntry> inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "testValue").build());
@ -168,14 +254,14 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.entries(inputEntries) .entries(inputEntries)
.build(); .build();
Task mergeMetadata = mediaClient.mergeMetadata(mediaRef, inputMetadata); Task mergeMetadata = mediaClient.getMetadataClient().mergeMetadata(media, inputMetadata);
Checks.checkTask(mergeMetadata); Checks.checkTask(mergeMetadata);
assertTrue(retryTaskSuccess.apply(mergeMetadata.getHref()), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)")); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)"));
metadata = mediaClient.getMetadata(mediaRef); metadata = mediaClient.getMetadataClient().getMetadata(media);
Checks.checkMetadataFor(MEDIA, metadata); Checks.checkMetadataFor(MEDIA, metadata);
checkMetadataContainsEntries(metadata, inputEntries); checkMetadataContainsEntries(metadata, inputEntries);
media = mediaClient.getMedia(mediaRef); media = mediaClient.getMedia(media);
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
// test modify // test modify
@ -184,14 +270,14 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.entries(inputEntries) .entries(inputEntries)
.build(); .build();
mergeMetadata = mediaClient.mergeMetadata(mediaRef, inputMetadata); mergeMetadata = mediaClient.getMetadataClient().mergeMetadata(media, inputMetadata);
Checks.checkTask(mergeMetadata); Checks.checkTask(mergeMetadata);
assertTrue(retryTaskSuccess.apply(mergeMetadata.getHref()), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(modify)")); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(modify)"));
metadata = mediaClient.getMetadata(mediaRef); metadata = mediaClient.getMetadataClient().getMetadata(media);
Checks.checkMetadataFor(MEDIA, metadata); Checks.checkMetadataFor(MEDIA, metadata);
checkMetadataContainsEntries(metadata, inputEntries); checkMetadataContainsEntries(metadata, inputEntries);
media = mediaClient.getMedia(mediaRef); media = mediaClient.getMedia(media);
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
} }
@ -213,32 +299,32 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
@Test(testName = "GET /media/{id}/metadata/{key}", @Test(testName = "GET /media/{id}/metadata/{key}",
dependsOnMethods = { "testMergeMetadata" }) dependsOnMethods = { "testMergeMetadata" }, enabled = false)
public void testGetMetadataValue() { public void testGetMetadataValue() {
metadataValue = mediaClient.getMetadataValue(mediaRef, "key"); metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key");
Checks.checkMetadataValueFor(MEDIA, metadataValue); Checks.checkMetadataValueFor(MEDIA, metadataValue);
} }
@Test(testName = "PUT /media/{id}/metadata/{key}", @Test(testName = "PUT /media/{id}/metadata/{key}",
dependsOnMethods = { "testGetMetadataValue" }) dependsOnMethods = { "testGetMetadataValue" }, enabled = false)
public void testSetMetadataValue() { public void testSetMetadataValue() {
metadataEntryValue = "newValue"; metadataEntryValue = "newValue";
MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build(); MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build();
Task setMetadataEntry = mediaClient.setMetadata(mediaRef, "key", newValue); Task setMetadataEntry = mediaClient.getMetadataClient().setMetadata(media, "key", newValue);
Checks.checkTask(setMetadataEntry); Checks.checkTask(setMetadataEntry);
assertTrue(retryTaskSuccess.apply(setMetadataEntry.getHref()), assertTrue(retryTaskSuccess.apply(setMetadataEntry),
String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry")); String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry"));
metadataValue = mediaClient.getMetadataValue(mediaRef, "key"); metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key");
Checks.checkMetadataValueFor(MEDIA, metadataValue); Checks.checkMetadataValueFor(MEDIA, metadataValue);
} }
@Test(testName = "DELETE /media/{id}/metadata/{key}", @Test(testName = "DELETE /media/{id}/metadata/{key}",
dependsOnMethods = { "testSetMetadataValue" } ) dependsOnMethods = { "testSetMetadataValue" }, enabled = false )
public void testDeleteMetadata() { public void testDeleteMetadata() {
Task deleteMetadataEntry = mediaClient.deleteMetadataEntry(mediaRef, "testKey"); Task deleteMetadataEntry = mediaClient.getMetadataClient().deleteMetadataEntry(media, "testKey");
Checks.checkTask(deleteMetadataEntry); Checks.checkTask(deleteMetadataEntry);
assertTrue(retryTaskSuccess.apply(deleteMetadataEntry.getHref()), assertTrue(retryTaskSuccess.apply(deleteMetadataEntry),
String.format(TASK_COMPLETE_TIMELY, "deleteMetadataEntry")); String.format(TASK_COMPLETE_TIMELY, "deleteMetadataEntry"));
Error expected = Error.builder() Error expected = Error.builder()
@ -248,7 +334,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.build(); .build();
try { try {
metadataValue = mediaClient.getMetadataValue(mediaRef, "testKey"); metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "testKey");
fail("Should give HTTP 403 error"); fail("Should give HTTP 403 error");
} catch (VCloudDirectorException vde) { } catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected); assertEquals(vde.getError(), expected);
@ -263,31 +349,31 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
"metadataEntry", metadataValue.toString())); "metadataEntry", metadataValue.toString()));
} }
metadataValue = mediaClient.getMetadataValue(mediaRef, "key"); metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key");
Checks.checkMetadataValueFor(MEDIA, metadataValue); Checks.checkMetadataValueFor(MEDIA, metadataValue);
media = mediaClient.getMedia(mediaRef); media = mediaClient.getMedia(media);
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
} }
@Test(testName = "DELETE /media/{id}", @Test(testName = "DELETE /media/{id}",
dependsOnMethods = { "testDeleteMetadata" } ) dependsOnMethods = { "testDeleteMetadata" }, enabled = false )
public void testDeleteMedia() { public void testDeleteMedia() {
Task deleteMedia = mediaClient.deleteMedia(mediaRef); Task deleteMedia = mediaClient.deleteMedia(media);
Checks.checkTask(deleteMedia); Checks.checkTask(deleteMedia);
assertTrue(retryTaskSuccess.apply(deleteMedia.getHref()), assertTrue(retryTaskSuccess.apply(deleteMedia),
String.format(TASK_COMPLETE_TIMELY, "deleteMedia")); String.format(TASK_COMPLETE_TIMELY, "deleteMedia"));
Error expected = Error.builder() Error expected = Error.builder()
.message(String.format( .message(String.format(
"No access to entity \"(com.vmware.vcloud.entity.media:%s)\".", "No access to entity \"(com.vmware.vcloud.entity.media:%s)\".",
mediaRef.getId())) media.getId()))
.majorErrorCode(403) .majorErrorCode(403)
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
.build(); .build();
try { try {
media = mediaClient.getMedia(mediaRef); media = mediaClient.getMedia(media);
fail("Should give HTTP 403 error"); fail("Should give HTTP 403 error");
} catch (VCloudDirectorException vde) { } catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected); assertEquals(vde.getError(), expected);
@ -299,5 +385,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
if (media != null) { // guard against NPE on the .toStrings if (media != null) { // guard against NPE on the .toStrings
assertNull(metadataValue, String.format(OBJ_DEL, MEDIA, media.toString())); assertNull(metadataValue, String.format(OBJ_DEL, MEDIA, media.toString()));
} }
deleteMedia = mediaClient.deleteMedia(oldMedia);
Checks.checkTask(deleteMedia);
} }
} }

View File

@ -48,7 +48,7 @@ import com.google.common.collect.ImmutableSet;
* *
* @author danikov * @author danikov
*/ */
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "NetworkClientExpectTest") @Test(groups = { "unit", "user", "network" }, singleThreaded = true, testName = "NetworkClientExpectTest")
public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test @Test
@ -148,8 +148,13 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
URI networkUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c"); URI networkUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"), new VcloudHttpRequestPrimer()
getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATA)); .apiCommand("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/network/metadata.xml", VCloudDirectorMediaType.METADATA)
.httpResponseBuilder().build());
Metadata expected = Metadata.builder() Metadata expected = Metadata.builder()
.type("application/vnd.vmware.vcloud.metadata+xml") .type("application/vnd.vmware.vcloud.metadata+xml")
@ -164,7 +169,7 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
Reference networkRef = Reference.builder().href(networkUri).build(); Reference networkRef = Reference.builder().href(networkUri).build();
assertEquals(client.getNetworkClient().getMetadata(networkRef), expected); assertEquals(client.getNetworkClient().getMetadataClient().getMetadata(networkRef), expected);
} }
@Test(enabled=false) // No metadata in exemplar xml... @Test(enabled=false) // No metadata in exemplar xml...
@ -181,7 +186,7 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
Reference networkRef = Reference.builder().href(networkUri).build(); Reference networkRef = Reference.builder().href(networkUri).build();
assertEquals(client.getNetworkClient().getMetadataValue(networkRef, "KEY"), expected); assertEquals(client.getNetworkClient().getMetadataClient().getMetadataValue(networkRef, "KEY"), expected);
} }
public static OrgNetwork orgNetwork() { public static OrgNetwork orgNetwork() {

View File

@ -50,7 +50,7 @@ import com.google.common.collect.Iterables;
* *
* @author danikov * @author danikov
*/ */
@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "NetworkClientLiveTest") @Test(groups = { "live", "user", "network" }, singleThreaded = true, testName = "NetworkClientLiveTest")
public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String NETWORK = "network"; public static final String NETWORK = "network";
@ -100,7 +100,7 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /network/{id}/metadata") @Test(testName = "GET /network/{id}/metadata")
public void testGetMetadata() { public void testGetMetadata() {
Metadata metadata = networkClient.getMetadata(networkRef); Metadata metadata = networkClient.getMetadataClient().getMetadata(networkRef);
// required for testing // required for testing
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
String.format(OBJ_FIELD_REQ_LIVE, NETWORK, "metadata.entries")); String.format(OBJ_FIELD_REQ_LIVE, NETWORK, "metadata.entries"));
@ -122,7 +122,7 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /network/{id}/metadata/{key}") @Test(testName = "GET /network/{id}/metadata/{key}")
public void testGetMetadataValue() { public void testGetMetadataValue() {
MetadataValue metadataValue = networkClient.getMetadataValue(networkRef, "key"); MetadataValue metadataValue = networkClient.getMetadataClient().getMetadataValue(networkRef, "key");
// Check parent type // Check parent type
checkResourceType(metadataValue); checkResourceType(metadataValue);

View File

@ -45,7 +45,7 @@ import com.google.common.collect.Iterables;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "OrgClientExpectTest") @Test(groups = { "unit", "user", "org" }, singleThreaded = true, testName = "OrgClientExpectTest")
public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test @Test
@ -179,8 +179,13 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
URI orgUri = URI.create(endpoint + "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"); URI orgUri = URI.create(endpoint + "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"), new VcloudHttpRequestPrimer()
getStandardPayloadResponse("/org/orgMetadata.xml", VCloudDirectorMediaType.METADATA)); .apiCommand("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/org/orgMetadata.xml", VCloudDirectorMediaType.METADATA)
.httpResponseBuilder().build());
Metadata expected = Metadata.builder() Metadata expected = Metadata.builder()
.type("application/vnd.vmware.vcloud.metadata+xml") .type("application/vnd.vmware.vcloud.metadata+xml")
@ -195,7 +200,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
Reference orgRef = Reference.builder().href(orgUri).build(); Reference orgRef = Reference.builder().href(orgUri).build();
assertEquals(client.getOrgClient().getOrgMetadata(orgRef), expected); assertEquals(client.getOrgClient().getMetadataClient().getMetadata(orgRef), expected);
} }
@Test @Test
@ -203,14 +208,19 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
URI orgUri = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"); URI orgUri = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY"), new VcloudHttpRequestPrimer()
getStandardPayloadResponse("/org/orgMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE)); .apiCommand("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/org/orgMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE)
.httpResponseBuilder().build());
MetadataValue expected = metadataValue(); MetadataValue expected = metadataValue();
Reference orgRef = Reference.builder().href(orgUri).build(); Reference orgRef = Reference.builder().href(orgUri).build();
assertEquals(client.getOrgClient().getOrgMetadataValue(orgRef, "KEY"), expected); assertEquals(client.getOrgClient().getMetadataClient().getMetadataValue(orgRef, "KEY"), expected);
} }
public static Org org() { public static Org org() {

View File

@ -45,7 +45,7 @@ import com.google.common.collect.Iterables;
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "OrgClientLiveTest") @Test(groups = { "live", "user", "org" }, singleThreaded = true, testName = "OrgClientLiveTest")
public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
/* /*
@ -97,7 +97,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testGetOrg" }) @Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testGetOrg" })
public void testGetOrgMetadata() { public void testGetOrgMetadata() {
// Call the method being tested // Call the method being tested
Metadata metadata = orgClient.getOrgMetadata(orgRef); Metadata metadata = orgClient.getMetadataClient().getMetadata(orgRef);
// NOTE The environment MUST have at one metadata entry for the first organisation configured // NOTE The environment MUST have at one metadata entry for the first organisation configured
@ -110,7 +110,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" }) @Test(testName = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" })
public void testGetOrgMetadataValue() { public void testGetOrgMetadataValue() {
// Call the method being tested // Call the method being tested
MetadataValue value = orgClient.getOrgMetadataValue(orgRef, "KEY"); MetadataValue value = orgClient.getMetadataClient().getMetadataValue(orgRef, "KEY");
// NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE" )' // NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE" )'

View File

@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableMultimap;
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "QueryClientExpectTest") @Test(groups = { "unit", "user", "query" }, singleThreaded = true, testName = "QueryClientExpectTest")
public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test @Test

View File

@ -32,7 +32,7 @@ import org.testng.annotations.Test;
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "QueryClientLiveTest") @Test(groups = { "live", "user", "query" }, singleThreaded = true, testName = "QueryClientLiveTest")
public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest { public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
/* /*

View File

@ -32,6 +32,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Error;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
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.TasksList; import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -42,7 +43,7 @@ import com.google.common.collect.ImmutableMultimap;
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "TaskClientExpectTest") @Test(groups = { "unit", "user", "task" }, singleThreaded = true, testName = "TaskClientExpectTest")
public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test @Test
@ -202,7 +203,7 @@ public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse);
URI taskUri = URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"); URISupplier taskUri = URISupplier.SingleURI.fromURI(URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"));
Task expected = taskOne(); Task expected = taskOne();
@ -226,7 +227,7 @@ public class TaskClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, taskRequest, taskResponse);
URI taskUri = URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"); URISupplier taskUri = URISupplier.SingleURI.fromURI(URI.create(endpoint + "/task/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"));
client.getTaskClient().cancelTask(taskUri); client.getTaskClient().cancelTask(taskUri);
} }

View File

@ -22,12 +22,11 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.N
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkTask; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkTask;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import java.net.URI;
import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.OrgList;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
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.TasksList; import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -39,7 +38,7 @@ import com.google.common.collect.Iterables;
* *
* @author grkvlt@apache.org * @author grkvlt@apache.org
*/ */
@Test(groups = { "live", "api", "user" }, singleThreaded = true, testName = "TaskClientLiveTest") @Test(groups = { "live", "user", "task" }, singleThreaded = true, testName = "TaskClientLiveTest")
public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest { public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
/* /*
@ -64,7 +63,7 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private Reference orgRef; private Reference orgRef;
private TasksList taskList; private TasksList taskList;
private Task task; private Task task;
private URI taskUri; private URISupplier taskRef;
@Test(testName = "GET /tasksList/{id}") @Test(testName = "GET /tasksList/{id}")
public void testGetTaskList() { public void testGetTaskList() {
@ -86,10 +85,10 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /task/{id}", dependsOnMethods = { "testGetTaskList" }) @Test(testName = "GET /task/{id}", dependsOnMethods = { "testGetTaskList" })
public void testGetTask() { public void testGetTask() {
taskUri = Iterables.getFirst(taskList.getTasks(), null).getHref(); taskRef = Iterables.getFirst(taskList.getTasks(), null);
// Call the method being tested // Call the method being tested
task = taskClient.getTask(taskUri); task = taskClient.getTask(taskRef);
// Check required elements and attributes // Check required elements and attributes
checkTask(task); checkTask(task);
@ -98,6 +97,6 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /task/{id}/metadata/", dependsOnMethods = { "testGetTask" }) @Test(testName = "GET /task/{id}/metadata/", dependsOnMethods = { "testGetTask" })
public void testCancelTask() { public void testCancelTask() {
// Call the method being tested // Call the method being tested
taskClient.cancelTask(taskUri); taskClient.cancelTask(taskRef);
} }
} }

View File

@ -0,0 +1,49 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
*(Link.builder().regarding copyright ownership. jclouds 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(Link.builder().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.vcloud.director.v1_5.features;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Tests behavior of {@link NetworkClient}
*
* @author danikov
*/
@Test(groups = { "live", "user", "upload" }, singleThreaded = true, testName = "UploadClientLiveTest")
public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String UPLOAD = "upload";
/*
* Convenience reference to API client.
*/
protected UploadClient uploadClient;
@BeforeClass(inheritGroups = true)
@Override
public void setupRequiredClients() {
uploadClient = context.getApi().getUploadClient();
}
@Test(testName = "PUT ???", enabled = false)
public void testUpload() {
}
}

View File

@ -30,7 +30,6 @@ import org.jclouds.vcloud.director.v1_5.domain.AvailableNetworks;
import org.jclouds.vcloud.director.v1_5.domain.Capabilities; import org.jclouds.vcloud.director.v1_5.domain.Capabilities;
import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage; import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage;
import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams;
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams;
@ -57,14 +56,14 @@ import org.testng.annotations.Test;
* *
* @author danikov * @author danikov
*/ */
@Test(groups = { "unit", "apitests", "user" }, singleThreaded = true, testName = "VdcClientExpectTest") @Test(groups = { "unit", "user", "vdc" }, singleThreaded = true, testName = "VdcClientExpectTest")
public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
private Reference vdcRef; private Reference vdcRef;
@BeforeClass @BeforeClass
public void before() { public void before() {
String vdcId = "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"; String vdcId = "e9cd3387-ac57-4d27-a481-9bee75e0690f";
vdcRef = Reference.builder() vdcRef = Reference.builder()
.type("application/vnd.vmware.vcloud.vdc+xml") .type("application/vnd.vmware.vcloud.vdc+xml")
.name("") .name("")
@ -73,7 +72,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.build(); .build();
} }
@Test(enabled = false) @Test
public void testGetVdc() { public void testGetVdc() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
@ -89,8 +88,10 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
assertEquals(client.getVdcClient().getVdc(vdcRef), expected); assertEquals(client.getVdcClient().getVdc(vdcRef), expected);
} }
@Test(enabled = false) @Test
public void testResponse400ForInvalidVdcId() { public void testResponse400ForInvalidVdcId() {
URI vdcUri = URI.create(endpoint + "/vdc/NOTAUUID");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
.apiCommand("GET", "/vdc/NOTAUUID") .apiCommand("GET", "/vdc/NOTAUUID")
@ -106,6 +107,8 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.minorErrorCode("BAD_REQUEST") .minorErrorCode("BAD_REQUEST")
.build(); .build();
Reference vdcRef = Reference.builder().href(vdcUri).build();
try { try {
client.getVdcClient().getVdc(vdcRef); client.getVdcClient().getVdc(vdcRef);
fail("Should give HTTP 400 error"); fail("Should give HTTP 400 error");
@ -116,8 +119,10 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
} }
} }
@Test(enabled = false) @Test
public void testResponse403ForFakeVdcId() { public void testResponse403ForFakeVdcId() {
URI vdcUri = URI.create(endpoint + "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
.apiCommand("GET", "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .apiCommand("GET", "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
@ -133,6 +138,8 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
.build(); .build();
Reference vdcRef = Reference.builder().href(vdcUri).build();
try { try {
client.getVdcClient().getVdc(vdcRef); client.getVdcClient().getVdc(vdcRef);
fail("Should give HTTP 403 error"); fail("Should give HTTP 403 error");
@ -193,33 +200,11 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
} }
} }
@Test(enabled = false)
public void testCloneMedia() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia")
.xmlFilePayload("/vdc/params/cloneMedia.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vdc/cloneMedia.xml", VCloudDirectorMediaType.MEDIA)
.httpResponseBuilder().build());
Media expected = cloneMedia();
// TODO: configure params
CloneMediaParams params = CloneMediaParams.builder()
.build();
assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected);
}
@Test(enabled = false) @Test(enabled = false)
public void testCloneVApp() { public void testCloneVApp() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer() new VcloudHttpRequestPrimer()
.apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVApp") .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVAppTemplate")
.xmlFilePayload("/vdc/params/cloneVApp.xml", VCloudDirectorMediaType.CLONE_V_APP_PARAMS) .xmlFilePayload("/vdc/params/cloneVApp.xml", VCloudDirectorMediaType.CLONE_V_APP_PARAMS)
.acceptAnyMedia() .acceptAnyMedia()
.httpRequestBuilder().build(), .httpRequestBuilder().build(),
@ -364,7 +349,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
Metadata expected = metadata(); Metadata expected = metadata();
assertEquals(client.getMediaClient().getMetadata(mediaRef), expected); assertEquals(client.getVdcClient().getMetadataClient().getMetadata(mediaRef), expected);
} }
@Test(enabled = false) @Test(enabled = false)
@ -384,7 +369,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
Reference mediaRef = Reference.builder().href(vdcUri).build(); Reference mediaRef = Reference.builder().href(vdcUri).build();
assertEquals(client.getVdcClient().getMetadataValue(mediaRef, "key"), expected); assertEquals(client.getVdcClient().getMetadataClient().getMetadataValue(mediaRef, "key"), expected);
} }
public static Vdc getVdc() { public static Vdc getVdc() {
@ -522,11 +507,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
return null; return null;
} }
private Media cloneMedia() {
// TODO Auto-generated method stub
return null;
}
private VApp cloneVApp() { private VApp cloneVApp() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;

View File

@ -31,12 +31,10 @@ import java.net.URI;
import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams;
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.Media;
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;
@ -55,7 +53,7 @@ import com.google.common.collect.Iterables;
* *
* @author danikov * @author danikov
*/ */
@Test(groups = { "live", "apitests", "user" }, testName = "VdcClientLiveTest") @Test(groups = { "live", "user", "vdc" }, testName = "VdcClientLiveTest")
public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String VDC = "vdc"; public static final String VDC = "vdc";
@ -73,8 +71,8 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
vdcRef = Reference.builder() vdcRef = Reference.builder()
.type("application/vnd.vmware.vcloud.vdc+xml") .type("application/vnd.vmware.vcloud.vdc+xml")
.name("") .name("")
.href(URI.create(endpoint+"/vdc/"+vDCId)) .href(URI.create(endpoint+"/vdc/"+vdcId))
.id(vDCId) .id(vdcId)
.build(); .build();
vdcClient = context.getApi().getVdcClient(); vdcClient = context.getApi().getVdcClient();
} }
@ -143,23 +141,6 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// TODO: make assertions that the task was successful // TODO: make assertions that the task was successful
} }
@Test(testName = "POST /vdc/{id}/action/cloneMedia")
public void testCloneMedia() {
Reference mediaSource = null; // TODO: media reference
Media media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder()
.source(mediaSource)
// TODO: test optional params
//.name("")
//.description("")
//.isSourceDelete(true)
.build());
Checks.checkMediaFor(VDC, media);
// TODO: await task to complete
// TODO: make assertions that the task was successful
}
@Test(testName = "POST /vdc/{id}/action/cloneVApp", enabled = false) @Test(testName = "POST /vdc/{id}/action/cloneVApp", enabled = false)
public void testCloneVApp() { public void testCloneVApp() {
Reference vAppSource = null; // TODO: vApp reference Reference vAppSource = null; // TODO: vApp reference
@ -260,27 +241,9 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// TODO: make assertions that the task was successful // TODO: make assertions that the task was successful
} }
@Test(testName = "POST /vdc/{id}/media") @Test(testName = "GET /network/{id}/metadata", enabled = false)
public void testCreateMedia() {
Media media = vdcClient.createMedia(vdcRef, Media.builder()
.name("")
.imageType(Media.ImageType.ISO)
.size(0)
// TODO: test optional params
//.name("")
//.description("")
//.isSourceDelete(true)
.build());
Checks.checkMediaFor(VDC, media);
// TODO: await task to complete
// TODO: make assertions that the task was successful
}
@Test(testName = "GET /network/{id}/metadata")
public void testGetMetadata() { public void testGetMetadata() {
Metadata metadata = vdcClient.getMetadata(vdcRef); Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcRef);
// required for testing // required for testing
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries")); String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries"));
@ -288,9 +251,9 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Checks.checkMetadataFor(VDC, metadata); Checks.checkMetadataFor(VDC, metadata);
} }
@Test(testName = "GET /network/{id}/metadata/{key}") @Test(testName = "GET /network/{id}/metadata/{key}", enabled = false)
public void testGetMetadataValue() { public void testGetMetadataValue() {
MetadataValue metadataValue = vdcClient.getMetadataValue(vdcRef, "key"); MetadataValue metadataValue = vdcClient.getMetadataClient().getMetadataValue(vdcRef, "key");
Checks.checkMetadataValueFor(VDC, metadataValue); Checks.checkMetadataValueFor(VDC, metadataValue);
} }

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.vcloud.director.v1_5.internal; package org.jclouds.vcloud.director.v1_5.internal;
import java.net.URI;
import java.util.Properties; import java.util.Properties;
import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.BaseVersionedServiceLiveTest;
@ -29,6 +28,7 @@ import org.jclouds.rest.RestContextFactory;
import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.domain.URISupplier;
import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess; import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -51,24 +51,21 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
} }
protected String catalogName; protected String catalogName;
protected String mediaId;
protected String vAppTemplateId; protected String vAppTemplateId;
protected String networkId; protected String networkId;
protected String vDCId; protected String vdcId;
@Override @Override
protected Properties setupProperties() { protected Properties setupProperties() {
Properties overrides= super.setupProperties(); Properties overrides= super.setupProperties();
if (catalogName != null) if (catalogName != null)
overrides.setProperty(provider + ".catalog-name", catalogName); overrides.setProperty(provider + ".catalog-name", catalogName);
if (mediaId != null)
overrides.setProperty(provider + ".media-id", mediaId);
if (vAppTemplateId != null) if (vAppTemplateId != null)
overrides.setProperty(provider + ".vapptemplate-id", vAppTemplateId); overrides.setProperty(provider + ".vapptemplate-id", vAppTemplateId);
if (networkId != null) if (networkId != null)
overrides.setProperty(provider + ".network-id", networkId); overrides.setProperty(provider + ".network-id", networkId);
if (vDCId != null) if (vdcId != null)
overrides.setProperty(provider + ".vcd-id", vDCId); overrides.setProperty(provider + ".vdc-id", vdcId);
return overrides; return overrides;
} }
@ -77,7 +74,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
public abstract void setupRequiredClients(); public abstract void setupRequiredClients();
/** Injected by {@link #setupContext} */ /** Injected by {@link #setupContext} */
public Predicate<URI> retryTaskSuccess; public Predicate<URISupplier> retryTaskSuccess;
@Override @Override
@BeforeClass(groups = { "live" }) @BeforeClass(groups = { "live" })
@ -85,10 +82,9 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
super.setupCredentials(); super.setupCredentials();
catalogName = System.getProperty("test." + provider + ".catalog-name"); catalogName = System.getProperty("test." + provider + ".catalog-name");
mediaId = System.getProperty("test." + provider + ".media-id");
vAppTemplateId = System.getProperty("test." + provider + ".vapptemplate-id"); vAppTemplateId = System.getProperty("test." + provider + ".vapptemplate-id");
networkId = System.getProperty("test." + provider + ".network-id"); networkId = System.getProperty("test." + provider + ".network-id");
vDCId = System.getProperty("test." + provider + ".vdc-id"); vdcId = System.getProperty("test." + provider + ".vdc-id");
} }
protected RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> context; protected RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> context;
@ -103,7 +99,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides);
TaskSuccess taskSuccess = context.utils().injector().getInstance(TaskSuccess.class); TaskSuccess taskSuccess = context.utils().injector().getInstance(TaskSuccess.class);
retryTaskSuccess = new RetryablePredicate<URI>(taskSuccess, 1000L); retryTaskSuccess = new RetryablePredicate<URISupplier>(taskSuccess, 1000L);
} }
protected void tearDown() { protected void tearDown() {

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Media xmlns="http://www.vmware.com/vcloud/v1.5" size="175163392" imageType="iso" status="0" name="copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2" id="urn:vcloud:media:a6b023f2-7f90-4e89-a24d-56e0eba83a5a" type="application/vnd.vmware.vcloud.media+xml" href="https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://mycloud.greenhousedata.com/api/v1.5/schema/master.xsd">
<Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"/>
<Link rel="remove" href="https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a"/>
<Description>copied by testCloneMedia()</Description>
<Tasks>
<Task status="running" startTime="2012-03-02T04:58:48.754-07:00" operationName="vdcCopyMedia" operation="Copying Media File copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2(a6b023f2-7f90-4e89-a24d-56e0eba83a5a)" expiryTime="2012-05-31T04:58:48.754-06:00" name="task" id="urn:vcloud:task:7e4f6baf-7ef0-43ea-93cc-62cc329afb5d" type="application/vnd.vmware.vcloud.task+xml" href="https://mycloud.greenhousedata.com/api/task/7e4f6baf-7ef0-43ea-93cc-62cc329afb5d">
<Link rel="task:cancel" href="https://mycloud.greenhousedata.com/api/task/7e4f6baf-7ef0-43ea-93cc-62cc329afb5d/action/cancel"/>
<Owner type="application/vnd.vmware.vcloud.media+xml" name="copied test media-copy-671136ae-b8f0-4389-bca6-50e9c42268f2" href="https://mycloud.greenhousedata.com/api/media/a6b023f2-7f90-4e89-a24d-56e0eba83a5a"/>
<User type="application/vnd.vmware.admin.user+xml" name="acole" href="https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120"/>
<Organization type="application/vnd.vmware.vcloud.org+xml" name="cloudsoft" href="https://mycloud.greenhousedata.com/api/org/c076f90a-397a-49fa-89b8-b294c1599cd0"/>
</Task>
</Tasks>
<Owner type="application/vnd.vmware.vcloud.owner+xml">
<User type="application/vnd.vmware.admin.user+xml" name="acole" href="https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120"/>
</Owner>
</Media>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CloneMediaParams name="moved test media" xmlns="http://www.vmware.com/vcloud/v1.5">
<Description>moved by testCloneMedia()</Description>
<Source type="application/vnd.vmware.vcloud.media+xml" name="copied test media" id="urn:vcloud:media:da8361af-cccd-4103-a71c-493513c49094" href="https://mycloud.greenhousedata.com/api/media/da8361af-cccd-4103-a71c-493513c49094"/>
<IsSourceDelete>false</IsSourceDelete>
</CloneMediaParams>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<Media xmlns="http://www.vmware.com/vcloud/v1.5" size="0" imageType="iso" status="0" name="Test media 1" id="urn:vcloud:media:d51b0b9d-099c-499f-97f8-4fbe40ba06d7" type="application/vnd.vmware.vcloud.media+xml" href="https://mycloud.greenhousedata.com/api/media/d51b0b9d-099c-499f-97f8-4fbe40ba06d7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://mycloud.greenhousedata.com/api/v1.5/schema/master.xsd">
<Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml" href="https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"/>
<Link rel="remove" href="https://mycloud.greenhousedata.com/api/media/d51b0b9d-099c-499f-97f8-4fbe40ba06d7"/>
<Description>Test media generated by testCreateMedia()</Description>
<Files>
<File size="0" bytesTransferred="0" name="file">
<Link rel="upload:default" href="https://mycloud.greenhousedata.com:443/transfer/b1fdf2d0-feff-4414-a8d1-3a8d86c4ccc5/file"/>
</File>
</Files>
<Owner type="application/vnd.vmware.vcloud.owner+xml">
<User type="application/vnd.vmware.admin.user+xml" name="acole" href="https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120"/>
</Owner>
</Media>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Media size="0" imageType="iso" name="Test media 1" type="application/vnd.vmware.vcloud.media+xml" xmlns="http://www.vmware.com/vcloud/v1.5">
<Description>Test media generated by testCreateMedia()</Description>
</Media>