Merge pull request #369 from danikov/vclouds-director-media

Issue 830: vCloud director Media
This commit is contained in:
Adrian Cole 2012-02-15 00:27:55 -08:00
commit 185bbc7242
27 changed files with 2196 additions and 9 deletions

View File

@ -43,26 +43,32 @@ public interface VCloudDirectorAsyncClient {
Session getCurrentSession(); Session getCurrentSession();
/** /**
* @return asynchronous access to Org features * @return asynchronous access to {@link Org} features
*/ */
@Delegate @Delegate
OrgAsyncClient getOrgClient(); OrgAsyncClient getOrgClient();
/** /**
* @return asynchronous access to Task features * @return asynchronous access to {@link Task} features
*/ */
@Delegate @Delegate
TaskAsyncClient getTaskClient(); TaskAsyncClient getTaskClient();
/** /**
* @return asynchronous access to Network features * @return asynchronous access to {@link Network} features
*/ */
@Delegate @Delegate
NetworkAsyncClient getNetworkClient(); NetworkAsyncClient getNetworkClient();
/** /**
* @return asynchronous access to Catalog features * @return asynchronous access to {@link Catalog} features
*/ */
@Delegate @Delegate
CatalogAsyncClient getCatalogClient(); CatalogAsyncClient getCatalogClient();
/**
* @return asynchronous access to {@link Media} features
*/
@Delegate
CatalogAsyncClient getMediaClient();
} }

View File

@ -24,6 +24,7 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
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.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
import org.jclouds.vcloud.director.v1_5.features.MediaClient;
import org.jclouds.vcloud.director.v1_5.features.NetworkClient; 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.TaskClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient;
@ -59,7 +60,7 @@ public interface VCloudDirectorClient {
TaskClient getTaskClient(); TaskClient getTaskClient();
/** /**
* @return synchronous access to Network features * @return synchronous access to {@link Network} features
*/ */
@Delegate @Delegate
NetworkClient getNetworkClient(); NetworkClient getNetworkClient();
@ -70,4 +71,9 @@ public interface VCloudDirectorClient {
@Delegate @Delegate
CatalogClient getCatalogClient(); CatalogClient getCatalogClient();
/**
* @return synchronous access to {@link Media} features
*/
@Delegate
MediaClient getMediaClient();
} }

View File

@ -63,9 +63,14 @@ public class VCloudDirectorMediaType {
public static final String PROPERTY = "application/vnd.vmware.vcloud.property+xml"; public static final String PROPERTY = "application/vnd.vmware.vcloud.property+xml";
public static final String MEDIA = "application/vnd.vmware.vcloud.media+xml";
public static final String OWNER = "application/vnd.vmware.vcloud.owner+xml";
public static final List<String> ALL = Arrays.asList( public static final List<String> ALL = Arrays.asList(
SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY,
METADATA_VALUE, ORG, TASKS_LIST, TASK, ORG_NETWORK, METADATA_VALUE, ORG, TASKS_LIST, TASK, ORG_NETWORK,
CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY,
MEDIA, OWNER
); );
} }

View File

@ -44,6 +44,8 @@ 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.CatalogAsyncClient; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
import org.jclouds.vcloud.director.v1_5.features.MediaAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.MediaClient;
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.NetworkClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
@ -80,6 +82,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
.put(CatalogClient.class, CatalogAsyncClient.class) .put(CatalogClient.class, CatalogAsyncClient.class)
.put(NetworkClient.class, NetworkAsyncClient.class) .put(NetworkClient.class, NetworkAsyncClient.class)
.put(OrgClient.class, OrgAsyncClient.class) .put(OrgClient.class, OrgAsyncClient.class)
.put(MediaClient.class, MediaAsyncClient.class)
.put(TaskClient.class, TaskAsyncClient.class) .put(TaskClient.class, TaskAsyncClient.class)
.build(); .build();

View File

@ -0,0 +1,300 @@
/**
* 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.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.NormalizedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
* Represents a file to be transferred (uploaded or downloaded).
*
*
* <p>Java class for File complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="File">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}EntityType">
* &lt;attribute name="size" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="bytesTransferred" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="checksum" type="{http://www.w3.org/2001/XMLSchema}normalizedString" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "File")
public class File
extends EntityType<File>
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromFile(this);
}
public static class Builder extends EntityType.Builder<File> {
private Long size;
private Long bytesTransferred;
private String checksum;
/**
* @see File#getSize()
*/
public Builder size(Long size) {
this.size = size;
return this;
}
/**
* @see File#getBytesTransferred()
*/
public Builder bytesTransferred(Long bytesTransferred) {
this.bytesTransferred = bytesTransferred;
return this;
}
/**
* @see File#getChecksum()
*/
public Builder checksum(String checksum) {
this.checksum = checksum;
return this;
}
public File build() {
File file = new File();
file.setSize(size);
file.setBytesTransferred(bytesTransferred);
file.setChecksum(checksum);
return file;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress;
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder link(Link link) {
this.links.add(checkNotNull(link, "link"));
return this;
}
@Override
public Builder fromEntityType(EntityType<File> in) {
return Builder.class.cast(super.fromEntityType(in));
}
public Builder fromFile(File in) {
return fromEntityType(in)
.size(in.getSize())
.bytesTransferred(in.getBytesTransferred())
.checksum(in.getChecksum());
}
}
private File() {
// For JAXB and builder use
}
@XmlAttribute
protected Long size;
@XmlAttribute
protected Long bytesTransferred;
@XmlAttribute
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String checksum;
/**
* Gets the value of the size property.
*
* @return
* possible object is
* {@link Long }
*
*/
public Long getSize() {
return size;
}
/**
* Sets the value of the size property.
*
* @param value
* allowed object is
* {@link Long }
*
*/
public void setSize(Long value) {
this.size = value;
}
/**
* Gets the value of the bytesTransferred property.
*
* @return
* possible object is
* {@link Long }
*
*/
public Long getBytesTransferred() {
return bytesTransferred;
}
/**
* Sets the value of the bytesTransferred property.
*
* @param value
* allowed object is
* {@link Long }
*
*/
public void setBytesTransferred(Long value) {
this.bytesTransferred = value;
}
/**
* Gets the value of the checksum property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getChecksum() {
return checksum;
}
/**
* Sets the value of the checksum property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setChecksum(String value) {
this.checksum = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
File that = File.class.cast(o);
return equal(size, that.size) &&
equal(bytesTransferred, that.bytesTransferred) &&
equal(checksum, that.checksum);
}
@Override
public int hashCode() {
return Objects.hashCode(size,
bytesTransferred,
checksum);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("size", size)
.add("bytesTransferred", bytesTransferred)
.add("checksum", checksum).toString();
}
}

View File

@ -0,0 +1,159 @@
/**
* 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.domain;
import static com.google.common.base.Objects.equal;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
/**
*
* Represents a list of files to be transferred (uploaded
* or downloaded).
*
*
* <p>Java class for FilesList complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="FilesList">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence>
* &lt;element name="File" type="{http://www.vmware.com/vcloud/v1.5}FileType" maxOccurs="unbounded"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "FilesList", propOrder = {
"files"
})
public class FilesList {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromFilesList(this);
}
public static class Builder {
private List<File> files;
/**
* @see FilesList#getFile()
*/
public Builder file(List<File> file) {
this.files = file;
return this;
}
public FilesList build() {
FilesList filesList = new FilesList(files);
return filesList;
}
public Builder fromFilesList(FilesList in) {
return file(in.getFile());
}
}
private FilesList() {
// For JAXB and builder use
}
private FilesList(List<File> files) {
this.files = files;
}
@XmlElement(name = "File", required = true)
protected List<File> files;
/**
* Gets the value of the file property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the file property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getFile().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link FileType }
*
*
*/
public List<File> getFile() {
if (files == null) {
files = new ArrayList<File>();
}
return this.files;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
FilesList that = FilesList.class.cast(o);
return equal(files, that.files);
}
@Override
public int hashCode() {
return Objects.hashCode(files);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("file", files).toString();
}
}

View File

@ -0,0 +1,322 @@
/**
* 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.domain;
import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
/**
*
* Represents a media.
*
*
* <p>Java class for Media complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Media">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}ResourceEntityType">
* &lt;sequence>
* &lt;element name="Owner" type="{http://www.vmware.com/vcloud/v1.5}OwnerType" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="imageType" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="size" use="required" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Media")
@XmlType(propOrder = {"owner"})
public class Media
extends ResourceEntityType<Media>
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromMedia(this);
}
public static class Builder extends ResourceEntityType.Builder<Media> {
private Owner owner;
private String imageType;
private long size;
/**
* @see Media#getOwner()
*/
public Builder owner(Owner owner) {
this.owner = owner;
return this;
}
/**
* @see Media#getImageType()
*/
public Builder imageType(String imageType) {
this.imageType = imageType;
return this;
}
/**
* @see Media#getSize()
*/
public Builder size(long size) {
this.size = size;
return this;
}
public Media build() {
Media media = new Media();
media.setOwner(owner);
media.setImageType(imageType);
media.setSize(size);
return media;
}
/**
* @see ResourceEntityType#getFiles()
*/
public Builder files(FilesList files) {
super.files(files);
return this;
}
/**
* @see ResourceEntityType#getStatus()
*/
public Builder status(Integer status) {
super.status(status);
return this;
}
/**
* @see EntityType#getName()
*/
@Override
public Builder name(String name) {
super.name(name);
return this;
}
/**
* @see EntityType#getDescription()
*/
@Override
public Builder description(String description) {
super.description(description);
return this;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder id(String id) {
super.id(id);
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
super.tasksInProgress(tasksInProgress);
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder href(URI href) {
super.href(href);
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder type(String type) {
super.type(type);
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
super.links(links);
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder link(Link link) {
super.link(link);
return this;
}
@Override
public Builder fromResourceEntityType(ResourceEntityType<Media> in) {
return Builder.class.cast(super.fromResourceEntityType(in));
}
public Builder fromMedia(Media in) {
return fromResourceEntityType(in)
.owner(in.getOwner())
.imageType(in.getImageType())
.size(in.getSize());
}
}
public Media() {
super();
}
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Owner")
protected Owner owner;
@XmlAttribute(required = true)
protected String imageType;
@XmlAttribute(required = true)
protected long size;
/**
* Gets the value of the owner property.
*
* @return
* possible object is
* {@link Owner }
*
*/
public Owner getOwner() {
return owner;
}
/**
* Sets the value of the owner property.
*
* @param value
* allowed object is
* {@link Owner }
*
*/
public void setOwner(Owner value) {
this.owner = value;
}
/**
* Gets the value of the imageType property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getImageType() {
return imageType;
}
/**
* Sets the value of the imageType property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setImageType(String value) {
this.imageType = value;
}
/**
* Gets the value of the size property.
*
*/
public long getSize() {
return size;
}
/**
* Sets the value of the size property.
*
*/
public void setSize(long value) {
this.size = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Media that = Media.class.cast(o);
return equal(owner, that.owner) &&
equal(imageType, that.imageType) &&
equal(size, that.size);
}
@Override
public int hashCode() {
return Objects.hashCode(owner,
imageType,
size);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("owner", owner)
.add("imageType", imageType)
.add("size", size).toString();
}
}

View File

@ -0,0 +1,199 @@
/**
* 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.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
* Represents the owner of this entity.
*
*
* <p>Java class for Owner complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Owner">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}ResourceType">
* &lt;sequence>
* &lt;element name="User" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Owner")
@XmlType(propOrder = {"user"})
public class Owner
extends ResourceType<Owner>
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromOwner(this);
}
public static class Builder extends ResourceType.Builder<Owner> {
private Reference user;
/**
* @see Owner#getUser()
*/
public Builder user(Reference user) {
this.user = user;
return this;
}
public Owner build() {
Owner owner = new Owner();
owner.setUser(user);
return owner;
}
/**
* @see ResourceType#getHref()
*/
@Override
public Builder href(URI href) {
super.href(href);
return this;
}
/**
* @see ResourceType#getType()
*/
@Override
public Builder type(String type) {
super.type(type);
return this;
}
/**
* @see ResourceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
super.links(Sets.newLinkedHashSet(checkNotNull(links, "links")));
return this;
}
/**
* @see ResourceType#getLinks()
*/
@Override
public Builder link(Link link) {
super.link(link);
return this;
}
@Override
public Builder fromResourceType(ResourceType<Owner> in) {
return Builder.class.cast(super.fromResourceType(in));
}
public Builder fromOwner(Owner in) {
return fromResourceType(in)
.user(in.getUser());
}
}
private Owner() {
// For JAXB and builder use
}
@XmlElement(name = "User", required = true)
protected Reference user;
/**
* Gets the value of the user property.
*
* @return
* possible object is
* {@link Reference }
*
*/
public Reference getUser() {
return user;
}
/**
* Sets the value of the user property.
*
* @param value
* allowed object is
* {@link Reference }
*
*/
public void setUser(Reference value) {
this.user = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Owner that = Owner.class.cast(o);
return equal(user, that.user);
}
@Override
public int hashCode() {
return Objects.hashCode(user);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("user", user).toString();
}
}

View File

@ -0,0 +1,265 @@
/**
* 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.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
* Base type that represents a resource entity such as a vApp
* template or virtual media.
*
*
* <p>Java class for ResourceEntity complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ResourceEntity">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}EntityType">
* &lt;sequence>
* &lt;element name="Files" type="{http://www.vmware.com/vcloud/v1.5}FilesListType" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="status" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ResourceEntity", propOrder = {
"files"
})
//@XmlSeeAlso({
// MediaType.class,
// VAppTemplateType.class,
// AbstractVAppType.class,
// NetworkPoolType.class
//})
public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityType<T> {
public static <T extends ResourceEntityType<T>> Builder<T> builder() {
return new Builder<T>();
}
@Override
public Builder<T> toBuilder() {
return new Builder<T>().fromResourceEntityType(this);
}
public static class Builder<T extends ResourceEntityType<T>> extends EntityType.Builder<T> {
private FilesList files;
private Integer status;
/**
* @see ResourceEntityType#getFiles()
*/
public Builder<T> files(FilesList files) {
this.files = files;
return this;
}
/**
* @see ResourceEntityType#getStatus()
*/
public Builder<T> status(Integer status) {
this.status = status;
return this;
}
public ResourceEntityType<T> build() {
ResourceEntityType<T> resourceEntity = new ResourceEntityType<T>();
resourceEntity.setFiles(files);
resourceEntity.setStatus(status);
return resourceEntity;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder<T> id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress;
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder<T> href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder<T> type(String type) {
this.type = type;
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder<T> links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder<T> link(Link link) {
this.links.add(checkNotNull(link, "link"));
return this;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Builder<T> fromResourceType(ResourceType<T> in) {
return Builder.class.cast(super.fromResourceType(in));
}
public Builder<T> fromResourceEntityType(ResourceEntityType<T> in) {
return fromResourceType(in)
.files(in.getFiles())
.status(in.getStatus());
}
}
public ResourceEntityType() {
}
@XmlElement(name = "Files")
protected FilesList files;
@XmlAttribute
protected Integer status;
/**
* Gets the value of the files property.
*
* @return
* possible object is
* {@link FilesList }
*
*/
public FilesList getFiles() {
return files;
}
/**
* Sets the value of the files property.
*
* @param value
* allowed object is
* {@link FilesList }
*
*/
public void setFiles(FilesList value) {
this.files = value;
}
/**
* Gets the value of the status property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getStatus() {
return status;
}
/**
* Sets the value of the status property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setStatus(Integer value) {
this.status = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ResourceEntityType<?> that = ResourceEntityType.class.cast(o);
return equal(files, that.files) &&
equal(status, that.status);
}
@Override
public int hashCode() {
return Objects.hashCode(files,
status);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("files", files)
.add("status", status).toString();
}
}

View File

@ -0,0 +1,153 @@
/**
* 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.Media;
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.MetadataValue;
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.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @see MediaClient
* @author danikov
*/
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface MediaAsyncClient {
/**
* @see MediaClient#getMedia(Reference)
*/
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Media> getMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef);
/**
* @see MediaClient#updateMedia(Reference, Media))
*/
@PUT
@Consumes(VCloudDirectorMediaType.TASK)
@Produces(VCloudDirectorMediaType.MEDIA)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> updateMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef,
@BinderParam(BindToXMLPayload.class) Media media);
/**
* @see MediaClient#deleteMedia(Reference))
*/
@DELETE
@Consumes(VCloudDirectorMediaType.TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> deleteMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef);
/**
* @see MediaClient#getOwner(Reference)
*/
@GET
@Path("/owner")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Owner> getOwner(@EndpointParam(parser = ReferenceToEndpoint.class) Reference mediaRef);
/**
* @see MediaClient#getMetadata(Reference))
*/
@GET
@Path("/metadata")
@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<MetadataEntry> getMetadataEntry(@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

@ -0,0 +1,109 @@
/**
* 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.Media;
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.MetadataValue;
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;
/**
* Provides synchronous access to Media.
* <p/>
*
* @see MediaAsyncClient
* @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 MediaClient {
/**
* Retrieves a media.
*
* @return the media or null if not found
*/
Media getMedia(Reference mediaRef);
/**
* Updates the name/description of a media.
*
* @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 updateMedia(Reference mediaRef, Media media);
/**
* Deletes a media.
*/
Task deleteMedia(Reference mediaRef);
/**
* Retrieves an owner.
*
* @return the owner or null if not found
*/
Owner getOwner(Reference mediaRef);
/**
* Retrieves an list of the media's metadata
*
* @return a list of metadata
*/
Metadata getMetadata(Reference mediaRef);
/**
* 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 entry
*
* @return the metadata entry, or null if not found
*/
MetadataEntry getMetadataEntry(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 metadataEntry);
/**
* 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,577 @@
/**
* 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 static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Error;
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.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.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.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test;
/**
* Allows us to test a client via its side effects.
*
* @author danikov
*/
@Test(groups = "unit", singleThreaded = true, testName = "NetworkClientExpectTest")
public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test
public void testWhenResponseIs2xxLoginReturnsValidMedia() {
URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/media.xml", VCloudDirectorMediaType.MEDIA)
.httpResponseBuilder().build());
Media expected = media();
Reference mediaRef = Reference.builder().href(mediaUri).build();
assertEquals(client.getMediaClient().getMedia(mediaRef), expected);
}
public void testWhenResponseIs400ForInvalidMediaId() {
URI mediaUri = URI.create(endpoint + "/media/NOTAUUID");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/media/NOTAUUID")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/error400.xml", VCloudDirectorMediaType.ERROR)
.httpResponseBuilder().statusCode(400).build());
Error expected = Error.builder()
.message("validation error on field 'id': String value has invalid format or length")
.majorErrorCode(400)
.minorErrorCode("BAD_REQUEST")
.build();
Reference mediaRef = Reference.builder().href(mediaUri).build();
try {
client.getMediaClient().getMedia(mediaRef);
fail("Should give HTTP 400 error");
} catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected);
} catch (Exception e) {
fail("Should have thrown a VCloudDirectorException");
}
}
@Test
public void testWhenResponseIs403ForCatalogIdUsedAsMediaId() {
URI mediaUri = URI.create(endpoint + "/media/e9cd3387-ac57-4d27-a481-9bee75e0690f");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/media/e9cd3387-ac57-4d27-a481-9bee75e0690f")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/error403-catalog.xml", VCloudDirectorMediaType.ERROR)
.httpResponseBuilder().statusCode(403).build());
Error expected = Error.builder()
.message("No access to entity \"(com.vmware.vcloud.entity.media:e9cd3387-ac57-4d27-a481-9bee75e0690f)\".")
.majorErrorCode(403)
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
.build();
Reference mediaRef = Reference.builder().href(mediaUri).build();
try {
client.getMediaClient().getMedia(mediaRef);
fail("Should give HTTP 403 error");
} catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected);
} catch (Exception e) {
fail("Should have thrown a VCloudDirectorException");
}
}
@Test
public void testWhenResponseIs403ForFakeMediaId() {
URI mediaUri = URI.create(endpoint + "/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/media/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/error403-fake.xml", VCloudDirectorMediaType.ERROR)
.httpResponseBuilder().statusCode(403).build());
Error expected = Error.builder()
.message("No access to entity \"(com.vmware.vcloud.entity.media:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee)\".")
.majorErrorCode(403)
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
.build();
Reference mediaRef = Reference.builder().href(mediaUri).build();
try {
client.getMediaClient().getMedia(mediaRef);
fail("Should give HTTP 403 error");
} catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected);
} catch (Exception e) {
fail("Should have thrown a VCloudDirectorException");
}
}
@Test
public void testWhenResponseIs2xxLoginUpdateReturnsValidMedia() {
URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1")
.xmlFilePayload("/media/updateMedia.xml", VCloudDirectorMediaType.MEDIA)
.acceptMedia(VCloudDirectorMediaType.TASK)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/updateMediaTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
Media update = updateMedia();
Task expected = updateMediaTask();
Reference mediaRef = Reference.builder().href(mediaUri).build();
assertEquals(client.getMediaClient().updateMedia(mediaRef, update), expected);
}
@Test
public void testWhenResponseIs2xxLoginDeleteMediaReturnsValidTask() {
URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("DELETE", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1")
.acceptMedia(VCloudDirectorMediaType.TASK)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/deleteMediaTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
Task expected = deleteMediaTask();
Reference mediaRef = Reference.builder().href(mediaUri).build();
assertEquals(client.getMediaClient().deleteMedia(mediaRef), expected);
}
@Test
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
URI mediaUri = URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/metadata.xml", VCloudDirectorMediaType.METADATA)
.httpResponseBuilder().build());
Reference mediaRef = Reference.builder().href(mediaUri).build();
Metadata expected = metadata();
assertEquals(client.getMediaClient().getMetadata(mediaRef), expected);
}
@Test
public void testWhenResponseIs2xxLoginMergeMetadataReturnsValidTask() {
URI mediaUri = URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata")
.xmlFilePayload("/media/metadata.xml", VCloudDirectorMediaType.METADATA)
.acceptMedia(VCloudDirectorMediaType.TASK)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/mergeMetadataTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
Reference mediaRef = Reference.builder().href(mediaUri).build();
Metadata inputMetadata = metadata();
Task expectedTask = mergeMetadataTask();
assertEquals(client.getMediaClient().mergeMetadata(mediaRef, inputMetadata), expectedTask);
}
public void testWhenResponseIs2xxLoginReturnsValidMetadataEntry() {
URI mediaUri = URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata/key")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/metadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY)
.httpResponseBuilder().build());
MetadataEntry expected = metadataEntry();
Reference mediaRef = Reference.builder().href(mediaUri).build();
assertEquals(client.getMediaClient().getMetadataEntry(mediaRef, "key"), expected);
}
@Test
public void testWhenResponseIs2xxLoginSetMetadataReturnsValidTask() {
URI mediaUri = URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("PUT", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata/key")
.xmlFilePayload("/media/setMetadata.xml", VCloudDirectorMediaType.METADATA_VALUE)
.acceptMedia(VCloudDirectorMediaType.TASK)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/setMetadataTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
Reference mediaRef = Reference.builder().href(mediaUri).build();
MetadataValue inputMetadataValue = MetadataValue.builder().value("value").build();
Task expectedTask = setMetadataEntryTask();
assertEquals(client.getMediaClient().setMetadata(mediaRef, "key", inputMetadataValue), expectedTask);
}
@Test
public void testWhenResponseIs2xxLoginDeleteMetadataEntryReturnsValidTask() {
URI mediaUri = URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("DELETE", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata/key")
.acceptMedia(VCloudDirectorMediaType.TASK)
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/deleteMetadataEntryTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
Reference mediaRef = Reference.builder().href(mediaUri).build();
Task expectedTask = deleteMetadataEntryTask();
assertEquals(client.getMediaClient().deleteMetadataEntry(mediaRef, "key"), expectedTask);
}
@Test
public void testWhenResponseIs2xxLoginReturnsValidOwner() {
URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1/owner")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/media/owner.xml", VCloudDirectorMediaType.OWNER)
.httpResponseBuilder().build());
Owner expected = owner();
Reference mediaRef = Reference.builder().href(mediaUri).build();
assertEquals(client.getMediaClient().getOwner(mediaRef), expected);
}
private static Media media() {
return Media.builder()
.size(175163392)
.imageType("iso")
.status(1)
.name("DansTestMedia")
.id("urn:vcloud:media:794eb334-754e-4917-b5a0-5df85cbd61d1")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.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("catalogItem")
.type("application/vnd.vmware.vcloud.catalogItem+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/catalogItem/1979d680-304e-4118-9283-9210c3b3ed8d"))
.build())
.link(Link.builder()
.rel("remove")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.build())
.link(Link.builder()
.rel("edit")
.type("application/vnd.vmware.vcloud.media+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.vcloud.owner+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/owner"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata"))
.build())
.description("Windows 2003 R2 Disk2 Standard 32bit &amp; 64bit")
.owner(owner())
.build();
}
private static Media updateMedia() {
return Media.builder()
.size(175163392)
.imageType("iso")
.owner(Owner.builder()
.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())
.build())
.build();
}
private static Task updateMediaTask() {
return Task.builder()
.name("task")
.id("urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c")
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c"))
.status("running")
.startTime(dateService.iso8601DateParse("2012-02-13T06:35:08.011-05:00"))
.expiryTime(dateService.iso8601DateParse("2012-05-13T06:35:08.011-04:00"))
.operationName("mediaUpdate")
.operation("Updating Media (794eb334-754e-4917-b5a0-5df85cbd61d1)")
.link(Link.builder()
.rel("task:cancel")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"))
.build())
.owner(Reference.builder()
.type("application/vnd.vmware.vcloud.media+xml")
.name("")
.href(URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("adk@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.build())
.org(Reference.builder()
.type("application/vnd.vmware.vcloud.org+xml")
.name("JClouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.build();
}
public static Task deleteMediaTask() {
return Task.builder()
.name("task")
.id("urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c")
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c"))
.status("running")
.startTime(dateService.iso8601DateParse("2012-02-13T06:35:08.011-05:00"))
.expiryTime(dateService.iso8601DateParse("2012-05-13T06:35:08.011-04:00"))
.operationName("mediaDelete")
.operation("Deleting Media (794eb334-754e-4917-b5a0-5df85cbd61d1)")
.link(Link.builder()
.rel("task:cancel")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"))
.build())
.owner(Reference.builder()
.type("application/vnd.vmware.vcloud.media+xml")
.name("")
.href(URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("adk@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.build())
.org(Reference.builder()
.type("application/vnd.vmware.vcloud.org+xml")
.name("JClouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.build();
}
private static Owner owner() {
return Owner.builder()
.type("application/vnd.vmware.vcloud.owner+xml")
.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())
.build();
}
private static Metadata metadata() {
return Metadata.builder()
.type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata"))
.link(Link.builder()
.rel("up")
.type("application/vnd.vmware.vcloud.media+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.build())
.entry(MetadataEntry.builder().key("key").value("value").build())
.build();
}
private static MetadataEntry metadataEntry() {
return MetadataEntry.builder()
.href(URI.create("https://vcloudbeta.bluelock.com/api/cmedia/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata/key"))
.link(Link.builder()
.rel("up")
.type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata"))
.build())
.key("key").value("value").build();
}
private Task mergeMetadataTask() {
return Task.builder()
.status("running")
.startTime(dateService.iso8601DateParse("2012-02-13T06:35:08.011-05:00"))
.operationName("metadataMerge")
.operation("Merging metadata for Media (794eb334-754e-4917-b5a0-5df85cbd61d1)")
.expiryTime(dateService.iso8601DateParse("2012-05-13T06:35:08.011-04:00"))
.name("task")
.id("urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c")
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c"))
.link(Link.builder()
.rel("task:cancel")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"))
.build())
.owner(Reference.builder()
.type("application/vnd.vmware.vcloud.media+xml")
.name("")
.href(URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("adk@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.build())
.org(Reference.builder()
.type("application/vnd.vmware.vcloud.org+xml")
.name("JClouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.build();
}
private Task setMetadataEntryTask() {
return Task.builder()
.status("running")
.startTime(dateService.iso8601DateParse("2012-02-13T06:35:08.011-05:00"))
.operationName("metadataSet")
.operation("Setting metadata for Media (794eb334-754e-4917-b5a0-5df85cbd61d1)")
.expiryTime(dateService.iso8601DateParse("2012-05-13T06:35:08.011-04:00"))
.name("task")
.id("urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c")
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c"))
.link(Link.builder()
.rel("task:cancel")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"))
.build())
.owner(Reference.builder()
.type("application/vnd.vmware.vcloud.media+xml")
.name("")
.href(URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("adk@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.build())
.org(Reference.builder()
.type("application/vnd.vmware.vcloud.org+xml")
.name("JClouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.build();
}
public static Task deleteMetadataEntryTask() {
return Task.builder()
.name("task")
.id("urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c")
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c"))
.status("running")
.startTime(dateService.iso8601DateParse("2012-02-13T06:35:08.011-05:00"))
.expiryTime(dateService.iso8601DateParse("2012-05-13T06:35:08.011-04:00"))
.operationName("metadataDelete")
.operation("Deleting metadata for Media (794eb334-754e-4917-b5a0-5df85cbd61d1)")
.link(Link.builder()
.rel("task:cancel")
.href(URI.create("https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"))
.build())
.owner(Reference.builder()
.type("application/vnd.vmware.vcloud.media+xml")
.name("")
.href(URI.create("https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
.build())
.user(Reference.builder()
.type("application/vnd.vmware.admin.user+xml")
.name("adk@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.build())
.org(Reference.builder()
.type("application/vnd.vmware.vcloud.org+xml")
.name("JClouds")
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.build();
}
}

View File

@ -18,8 +18,8 @@
*/ */
package org.jclouds.vcloud.director.v1_5.internal; package org.jclouds.vcloud.director.v1_5.internal;
import static org.testng.Assert.assertNotNull;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
@ -31,8 +31,8 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.inject.Guice; import com.google.inject.Guice;
@ -158,7 +158,7 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
* *
*/ */
protected class VcloudHttpRequestPrimer { protected class VcloudHttpRequestPrimer {
private Multimap<String, String> headers = ArrayListMultimap.create(); private Multimap<String, String> headers = LinkedListMultimap.create();
private HttpRequest.Builder builder = HttpRequest.builder(); private HttpRequest.Builder builder = HttpRequest.builder();
public VcloudHttpRequestPrimer() { public VcloudHttpRequestPrimer() {

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Task xmlns="http://www.vmware.com/vcloud/v1.5" status="running" startTime="2012-02-13T06:35:08.011-05:00" operationName="mediaDelete" operation="Deleting Media (794eb334-754e-4917-b5a0-5df85cbd61d1)" expiryTime="2012-05-13T06:35:08.011-04:00" name="task" id="urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c" type="application/vnd.vmware.vcloud.task+xml" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="task:cancel" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"/>
<Owner type="application/vnd.vmware.vcloud.media+xml" name="" href="https://vcloudbeta.bluelock.com/api/media794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<User type="application/vnd.vmware.admin.user+xml" name="adk@cloudsoftcorp.com" href="https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"/>
<Organization type="application/vnd.vmware.vcloud.org+xml" name="JClouds" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
</Task>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Task xmlns="http://www.vmware.com/vcloud/v1.5" status="running" startTime="2012-02-13T06:35:08.011-05:00" operationName="metadataDelete" operation="Deleting metadata for Media (794eb334-754e-4917-b5a0-5df85cbd61d1)" expiryTime="2012-05-13T06:35:08.011-04:00" name="task" id="urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c" type="application/vnd.vmware.vcloud.task+xml" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="task:cancel" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"/>
<Owner type="application/vnd.vmware.vcloud.media+xml" name="" href="https://vcloudbeta.bluelock.com/api/media794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<User type="application/vnd.vmware.admin.user+xml" name="adk@cloudsoftcorp.com" href="https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"/>
<Organization type="application/vnd.vmware.vcloud.org+xml" name="JClouds" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
</Task>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="BAD_REQUEST" message="validation error on field 'id': String value has invalid format or length" majorErrorCode="400" 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"></Error>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="ACCESS_TO_RESOURCE_IS_FORBIDDEN" message="No access to entity &quot;(com.vmware.vcloud.entity.media:e9cd3387-ac57-4d27-a481-9bee75e0690f)&quot;." majorErrorCode="403" 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"></Error>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="ACCESS_TO_RESOURCE_IS_FORBIDDEN" message="No access to entity &quot;(com.vmware.vcloud.entity.media:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee)&quot;." majorErrorCode="403" 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"></Error>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Media xmlns="http://www.vmware.com/vcloud/v1.5" size="175163392" imageType="iso" status="1" name="DansTestMedia" id="urn:vcloud:media:794eb334-754e-4917-b5a0-5df85cbd61d1" type="application/vnd.vmware.vcloud.media+xml" href="https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1" 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="catalogItem" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://mycloud.greenhousedata.com/api/catalogItem/1979d680-304e-4118-9283-9210c3b3ed8d"/>
<Link rel="remove" href="https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<Link rel="edit" type="application/vnd.vmware.vcloud.media+xml" href="https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<Link rel="down" type="application/vnd.vmware.vcloud.owner+xml" href="https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/owner"/>
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata"/>
<Description>Windows 2003 R2 Disk2 Standard 32bit &amp; 64bit</Description>
<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,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Task xmlns="http://www.vmware.com/vcloud/v1.5" status="running" startTime="2012-02-13T06:35:08.011-05:00" operationName="metadataMerge" operation="Merging metadata for Media (794eb334-754e-4917-b5a0-5df85cbd61d1)" expiryTime="2012-05-13T06:35:08.011-04:00" name="task" id="urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c" type="application/vnd.vmware.vcloud.task+xml" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="task:cancel" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"/>
<Owner type="application/vnd.vmware.vcloud.media+xml" name="" href="https://vcloudbeta.bluelock.com/api/media794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<User type="application/vnd.vmware.admin.user+xml" name="adk@cloudsoftcorp.com" href="https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"/>
<Organization type="application/vnd.vmware.vcloud.org+xml" name="JClouds" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
</Task>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Metadata type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata" xmlns="http://www.vmware.com/vcloud/v1.5">
<Link rel="up" type="application/vnd.vmware.vcloud.media+xml" href="https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<MetadataEntry>
<Key>key</Key>
<Value>value</Value>
</MetadataEntry>
</Metadata>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<MetadataEntry xmlns="http://www.vmware.com/vcloud/v1.5" href="https://vcloudbeta.bluelock.com/api/cmedia/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata/key" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="up" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1/metadata"/>
<Key>key</Key>
<Value>value</Value>
</MetadataEntry>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Owner xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.owner+xml" 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.media+xml" href="https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<User type="application/vnd.vmware.admin.user+xml" name="acole" href="https://mycloud.greenhousedata.com/api/admin/user/c090335b-708c-4c1c-9e3d-89560d002120"/>
</Owner>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MetadataValue xmlns="http://www.vmware.com/vcloud/v1.5">
<Value>value</Value>
</MetadataValue>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Task xmlns="http://www.vmware.com/vcloud/v1.5" status="running" startTime="2012-02-13T06:35:08.011-05:00" operationName="metadataSet" operation="Setting metadata for Media (794eb334-754e-4917-b5a0-5df85cbd61d1)" expiryTime="2012-05-13T06:35:08.011-04:00" name="task" id="urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c" type="application/vnd.vmware.vcloud.task+xml" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="task:cancel" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"/>
<Owner type="application/vnd.vmware.vcloud.media+xml" name="" href="https://vcloudbeta.bluelock.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<User type="application/vnd.vmware.admin.user+xml" name="dan@cloudsoftcorp.com" href="https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"/>
<Organization type="application/vnd.vmware.vcloud.org+xml" name="JClouds" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
</Task>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Media size="175163392" imageType="iso" xmlns="http://www.vmware.com/vcloud/v1.5">
<Owner>
<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,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Task xmlns="http://www.vmware.com/vcloud/v1.5" status="running" startTime="2012-02-13T06:35:08.011-05:00" operationName="mediaUpdate" operation="Updating Media (794eb334-754e-4917-b5a0-5df85cbd61d1)" expiryTime="2012-05-13T06:35:08.011-04:00" name="task" id="urn:vcloud:task:c6dca927-eab4-41fa-ad6a-3ac58602541c" type="application/vnd.vmware.vcloud.task+xml" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="task:cancel" href="https://vcloudbeta.bluelock.com/api/task/c6dca927-eab4-41fa-ad6a-3ac58602541c/action/cancel"/>
<Owner type="application/vnd.vmware.vcloud.media+xml" name="" href="https://vcloudbeta.bluelock.com/api/media794eb334-754e-4917-b5a0-5df85cbd61d1"/>
<User type="application/vnd.vmware.admin.user+xml" name="adk@cloudsoftcorp.com" href="https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"/>
<Organization type="application/vnd.vmware.vcloud.org+xml" name="JClouds" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
</Task>