diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java index 909d347cb6..d4d7386d81 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java @@ -75,10 +75,15 @@ public class VCloudDirectorMediaType { public static final String QUERY_RESULT_RECORDS = "application/vnd.vmware.vcloud.query.records+xml"; + public static final String QUERY_RESULT_REFERENCES = "application/vnd.vmware.vcloud.query.references+xml"; + + public static final String QUERY_RESULT_ID_RECORDS = "application/vnd.vmware.vcloud.query.idrecords+xml"; + public static final List ALL = Arrays.asList( - SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, - METADATA_VALUE, ORG, TASKS_LIST, TASK, ORG_NETWORK, - CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY, - MEDIA, OWNER, VDC, ADMIN_USER, QUERY_RESULT_RECORDS - ); + SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, + METADATA_VALUE, ORG, TASKS_LIST, TASK, ORG_NETWORK, + CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY, + MEDIA, OWNER, VDC, ADMIN_USER, QUERY_RESULT_RECORDS, + QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS + ); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogReference.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogReference.java new file mode 100644 index 0000000000..bb7ec86e9d --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CatalogReference.java @@ -0,0 +1,97 @@ +package org.jclouds.vcloud.director.v1_5.domain; + +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; + +import java.net.URI; + +import javax.xml.bind.annotation.XmlRootElement; + + +@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "catalogReference") +public class CatalogReference extends ReferenceType { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromCatalogReference(this); + } + + public static class Builder extends ReferenceType.Builder { + + @Override + public CatalogReference build() { + CatalogReference reference = new CatalogReference(href); + reference.setId(id); + reference.setName(name); + reference.setType(type); + return reference; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + @Override + protected Builder fromReferenceType(ReferenceType in) { + return Builder.class.cast(super.fromReferenceType(in)); + } + + protected Builder fromCatalogReference(CatalogReference in) { + return fromReferenceType(in); + } + } + + protected CatalogReference(URI href) { + super(href); + } + + protected CatalogReference() { + // For JAXB + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Reference that = Reference.class.cast(o); + return super.equals(that); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java index c56c8ed202..61c52d73b7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Link.java @@ -51,9 +51,15 @@ public class Link extends ReferenceType { public static final String REMOVE = "remove"; public static final String CATALOG_ITEM = "catalogItem"; public static final String TASK_CANCEL = "task:cancel"; + public static final String ALTERNATE = "alternate"; + public static final String NEXT_PAGE = "nextPage"; + public static final String PREVIOUS_PAGE = "previousPage"; + public static final String LAST_PAGE = "lastPage"; + public static final String FIRST_PAGE = "firstPage"; public static final List ALL = Arrays.asList( - UP, DOWN, EDIT, DELETE, ADD, REMOVE, CATALOG_ITEM, TASK_CANCEL + UP, DOWN, EDIT, DELETE, ADD, REMOVE, CATALOG_ITEM, TASK_CANCEL, + ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE ); } @@ -193,4 +199,4 @@ public class Link extends ReferenceType { public ToStringHelper string() { return super.string().add("rel", rel); } -} \ No newline at end of file +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntity.java index 5d339e20ab..934f955c39 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntity.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntity.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to jclouds, Inc. (jclouds) under one or more * contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,16 +16,22 @@ * specific language governing permissions and limitations * under the License. */ - package org.jclouds.vcloud.director.v1_5.domain; +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; + +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.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; +import com.google.common.base.Objects; +import com.google.common.collect.Sets; /** * @@ -57,16 +63,8 @@ import javax.xml.bind.annotation.XmlType; @XmlType(name = "ResourceEntity", propOrder = { "files" }) -@XmlSeeAlso({ - MediaType.class, - VAppTemplateType.class, - AbstractVAppType.class, - NetworkPoolType.class -}) -public class ResourceEntity - extends EntityType +public class ResourceEntity extends EntityType { -{ @SuppressWarnings("unchecked") public static Builder builder() { return new Builder(); @@ -78,13 +76,13 @@ public class ResourceEntity public static class Builder extends EntityType.Builder { - private FilesList files; + private Object /* FilesList */ files; private Integer status; /** * @see ResourceEntity#getFiles() */ - public Builder files(FilesList files) { + public Builder files(Object /* FilesList */ files) { this.files = files; return this; } @@ -172,14 +170,14 @@ public class ResourceEntity } } - private ResourceEntity() { + protected ResourceEntity() { // For JAXB and builder use } @XmlElement(name = "Files") - protected FilesList files; + protected Object /* FilesList */ files; @XmlAttribute protected Integer status; @@ -191,7 +189,7 @@ public class ResourceEntity * {@link FilesList } * */ - public FilesList getFiles() { + public Object /* FilesList */ getFiles() { return files; } @@ -203,7 +201,7 @@ public class ResourceEntity * {@link FilesList } * */ - public void setFiles(FilesList value) { + public void setFiles(Object /* FilesList */ value) { this.files = value; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java index 332841b59c..95ea0c61a8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/User.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to jclouds, Inc. (jclouds) under one or more * contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,14 +16,21 @@ * specific language governing permissions and limitations * under the License. */ - package org.jclouds.vcloud.director.v1_5.domain; +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; + +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.XmlType; +import com.google.common.base.Objects; +import com.google.common.collect.Sets; /** * @@ -119,7 +126,7 @@ public class User private Integer deployedVmQuota; private Reference role; private String password; - private GroupsList groupReferences; + private Object /* GroupsList */ groupReferences; /** * @see User#getFullName() @@ -260,7 +267,7 @@ public class User /** * @see User#getGroupReferences() */ - public Builder groupReferences(GroupsList groupReferences) { + public Builder groupReferences(Object /* GroupsList */ groupReferences) { this.groupReferences = groupReferences; return this; } @@ -353,16 +360,16 @@ public class User .fullName(in.getFullName()) .emailAddress(in.getEmailAddress()) .telephone(in.getTelephone()) - .isEnabled(in.getIsEnabled()) - .isLocked(in.getIsLocked()) - .im(in.getIm()) + .isEnabled(in.isEnabled()) + .isLocked(in.isLocked()) + .im(in.getIM()) .nameInSource(in.getNameInSource()) - .isAlertEnabled(in.getIsAlertEnabled()) + .isAlertEnabled(in.isAlertEnabled()) .alertEmailPrefix(in.getAlertEmailPrefix()) .alertEmail(in.getAlertEmail()) - .isExternal(in.getIsExternal()) - .isDefaultCached(in.getIsDefaultCached()) - .isGroupRole(in.getIsGroupRole()) + .isExternal(in.isExternal()) + .isDefaultCached(in.isDefaultCached()) + .isGroupRole(in.isGroupRole()) .storedVmQuota(in.getStoredVmQuota()) .deployedVmQuota(in.getDeployedVmQuota()) .role(in.getRole()) @@ -415,7 +422,7 @@ public class User @XmlElement(name = "Password") protected String password; @XmlElement(name = "GroupReferences") - protected GroupsList groupReferences; + protected Object /* GroupsList */ groupReferences; /** * Gets the value of the fullName property. @@ -497,7 +504,7 @@ public class User * {@link Boolean } * */ - public Boolean isIsEnabled() { + public Boolean isEnabled() { return isEnabled; } @@ -521,7 +528,7 @@ public class User * {@link Boolean } * */ - public Boolean isIsLocked() { + public Boolean isLocked() { return isLocked; } @@ -593,7 +600,7 @@ public class User * {@link Boolean } * */ - public Boolean isIsAlertEnabled() { + public Boolean isAlertEnabled() { return isAlertEnabled; } @@ -665,7 +672,7 @@ public class User * {@link Boolean } * */ - public Boolean isIsExternal() { + public Boolean isExternal() { return isExternal; } @@ -689,7 +696,7 @@ public class User * {@link Boolean } * */ - public Boolean isIsDefaultCached() { + public Boolean isDefaultCached() { return isDefaultCached; } @@ -713,7 +720,7 @@ public class User * {@link Boolean } * */ - public Boolean isIsGroupRole() { + public Boolean isGroupRole() { return isGroupRole; } @@ -833,7 +840,7 @@ public class User * {@link GroupsList } * */ - public GroupsList getGroupReferences() { + public Object /* GroupsList */ getGroupReferences() { return groupReferences; } @@ -845,7 +852,7 @@ public class User * {@link GroupsList } * */ - public void setGroupReferences(GroupsList value) { + public void setGroupReferences(Object /* GroupsList */ value) { this.groupReferences = value; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/CatalogReferences.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/CatalogReferences.java new file mode 100644 index 0000000000..df3782c805 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/CatalogReferences.java @@ -0,0 +1,152 @@ +/** + * 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.query; + +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.vcloud.director.v1_5.domain.CatalogReference; +import org.jclouds.vcloud.director.v1_5.domain.Link; + +import com.google.common.collect.Sets; + +/** + * Represents the results from a vCloud query as references. + * + *
+ * <complexType name="QueryResultReferences" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "CatalogReferences") +public class CatalogReferences extends QueryResultReferences { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromQueryResultReferences(this); + } + + public static class Builder extends QueryResultReferences.Builder { + + @Override + public CatalogReferences build() { + CatalogReferences queryResultReferences = new CatalogReferences(href); + queryResultReferences.setReferences(references); + queryResultReferences.setName(name); + queryResultReferences.setPage(page); + queryResultReferences.setPageSize(pageSize); + queryResultReferences.setTotal(total); + queryResultReferences.setType(type); + queryResultReferences.setLinks(links); + return queryResultReferences; + } + + /** + * @see Container#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see Container#getPage() + */ + @Override + public Builder page(Integer page) { + this.page = page; + return this; + } + + /** + * @see Container#getPageSize() + */ + @Override + public Builder pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * @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 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 fromQueryResultReferences(QueryResultReferences in) { + return Builder.class.cast(super.fromContainerType(in)); + } + + public Builder fromCatalogReferences(CatalogReferences in) { + return Builder.class.cast(fromQueryResultReferences(in).references(in.getReferences())); + } + } + + protected CatalogReferences() { + // For JAXB and builder use + } + + protected CatalogReferences(URI href) { + super(href); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryList.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryList.java new file mode 100644 index 0000000000..b40238e019 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryList.java @@ -0,0 +1,98 @@ +/* + * 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.query; + +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects.ToStringHelper; + +/** + * + * Container for the list of typed queries available to the + * requesting user. + * + * + *

Java class for QueryList complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="QueryList">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ContainerType">
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlType(name = "QueryList") +public class QueryList extends ContainerType { + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromQueryList(this); + } + + public static class Builder extends ContainerType.Builder { + + public QueryList build() { + QueryList queryList = new QueryList(); + return queryList; + } + + @Override + public Builder fromContainerType(ContainerType in) { + return Builder.class.cast(super.fromContainerType(in)); + } + public Builder fromQueryList(QueryList in) { + return fromContainerType(in); + } + } + + private QueryList() { + // For JAXB and builder use + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + QueryList that = QueryList.class.cast(o); + return super.equals(that) ; + } + + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public ToStringHelper string() { + return super.string(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultCatalogRecord.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultCatalogRecord.java index 5e9ad67287..225c762f2a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultCatalogRecord.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultCatalogRecord.java @@ -21,12 +21,14 @@ package org.jclouds.vcloud.director.v1_5.domain.query; import static com.google.common.base.Objects.*; import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; import java.net.URI; import java.util.Date; import java.util.Set; import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import org.jclouds.vcloud.director.v1_5.domain.Link; @@ -44,6 +46,7 @@ import com.google.common.collect.Sets; * * @author grkvlt@apache.org */ +@XmlRootElement(name = "CatalogRecord", namespace = VCLOUD_1_5_NS) public class QueryResultCatalogRecord extends QueryResultRecordType { @SuppressWarnings("unchecked") @@ -66,7 +69,7 @@ public class QueryResultCatalogRecord extends QueryResultRecordType> { public static > Builder builder() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultRecords.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultRecords.java index 33cdd6fcc7..fdbf3e6d13 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultRecords.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultRecords.java @@ -28,10 +28,10 @@ import java.util.List; import java.util.Set; import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlRootElement; 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.query.ContainerType.Builder; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -47,28 +47,28 @@ import com.google.common.collect.Sets; * * @author grkvlt@apache.org */ -public class QueryResultRecords extends ContainerType { +@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "QueryResultRecords") +public class QueryResultRecords> extends ContainerType> { public static final String MEDIA_TYPE = VCloudDirectorMediaType.QUERY_RESULT_RECORDS; - @SuppressWarnings("unchecked") - public static Builder builder() { - return new Builder(); + public static > Builder builder() { + return new Builder(); } @Override - public Builder toBuilder() { - return new Builder().fromQueryResultRecords(this); + public Builder toBuilder() { + return new Builder().fromQueryResultRecords(this); } - public static class Builder extends ContainerType.Builder { + public static class Builder> extends ContainerType.Builder> { - private List> records = Lists.newArrayList(); + private List records = Lists.newArrayList(); /** * @see QueryResultRecords#getRecords() */ - public Builder records(List> records) { + public Builder records(List records) { this.records = records; return this; } @@ -76,14 +76,14 @@ public class QueryResultRecords extends ContainerType { /** * @see QueryResultRecords#getRecords() */ - public Builder record(QueryResultRecordType record) { + public Builder record(T record) { this.records.add(record); return this; } @Override - public QueryResultRecords build() { - QueryResultRecords queryResultRecords = new QueryResultRecords(href); + public QueryResultRecords build() { + QueryResultRecords queryResultRecords = new QueryResultRecords(href); queryResultRecords.setRecords(records); queryResultRecords.setName(name); queryResultRecords.setPage(page); @@ -95,37 +95,46 @@ public class QueryResultRecords extends ContainerType { } /** - * @see Container#getName() + * @see ContainerType#getName() */ @Override - public Builder name(String name) { + public Builder name(String name) { this.name = name; return this; } /** - * @see Container#getPage() + * @see ContainerType#getPage() */ @Override - public Builder page(Integer page) { + public Builder page(Integer page) { this.page = page; return this; } /** - * @see Container#getPageSize() + * @see ContainerType#getPageSize() */ @Override - public Builder pageSize(Integer pageSize) { + public Builder pageSize(Integer pageSize) { this.pageSize = pageSize; return this; } + /** + * @see ContainerType#getTotal() + */ + @Override + public Builder total(Long total) { + this.total = total; + return this; + } + /** * @see ResourceType#getHref() */ @Override - public Builder href(URI href) { + public Builder href(URI href) { super.href(href); return this; } @@ -134,7 +143,7 @@ public class QueryResultRecords extends ContainerType { * @see ResourceType#getType() */ @Override - public Builder type(String type) { + public Builder type(String type) { super.type(type); return this; } @@ -143,7 +152,7 @@ public class QueryResultRecords extends ContainerType { * @see ResourceType#getLinks() */ @Override - public Builder links(Set links) { + public Builder links(Set links) { super.links(Sets.newLinkedHashSet(checkNotNull(links, "links"))); return this; } @@ -152,40 +161,44 @@ public class QueryResultRecords extends ContainerType { * @see ResourceType#getLinks() */ @Override - public Builder link(Link link) { + public Builder link(Link link) { super.link(link); return this; } @Override - public Builder fromContainerType(ContainerType in) { + public Builder fromContainerType(ContainerType> in) { return Builder.class.cast(super.fromContainerType(in)); } - public Builder fromQueryResultRecords(QueryResultRecords in) { + public Builder fromQueryResultRecords(QueryResultRecords in) { return fromContainerType(in).records(in.getRecords()); } } - private QueryResultRecords() { + protected QueryResultRecords() { // For JAXB and builder use } - @XmlElementRef(name = "Record", namespace = VCLOUD_1_5_NS) - protected List> records; + protected QueryResultRecords(URI href) { + super(href); + } + + @XmlElementRef + protected List records; /** * Set of records representing query results. */ - public List> getRecords() { + public List getRecords() { return records; } - public void setRecords(List> links) { - this.records = Lists.newArrayList(checkNotNull(links, "links")); + public void setRecords(List records) { + this.records = Lists.newArrayList(checkNotNull(records, "records")); } - public void addRecords(QueryResultRecordType record) { + public void addRecords(T record) { this.records.add(checkNotNull(record, "record")); } @@ -195,7 +208,7 @@ public class QueryResultRecords extends ContainerType { return true; if (o == null || getClass() != o.getClass()) return false; - QueryResultRecords that = QueryResultRecords.class.cast(o); + QueryResultRecords that = QueryResultRecords.class.cast(o); return super.equals(that) && equal(this.records, that.records); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultReferences.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultReferences.java new file mode 100644 index 0000000000..af482325ea --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultReferences.java @@ -0,0 +1,215 @@ +/** + * 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.query; + +import static com.google.common.base.Objects.*; +import static com.google.common.base.Preconditions.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; + +import java.net.URI; +import java.util.List; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElementRef; + +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.ReferenceType; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +/** + * Represents the results from a vCloud query as references. + * + *
+ * <complexType name="QueryResultReferences" />
+ * 
+ * + * @author grkvlt@apache.org + */ +public class QueryResultReferences> extends ContainerType> { + + public static final String MEDIA_TYPE = VCloudDirectorMediaType.QUERY_RESULT_REFERENCES; + + public static > Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromQueryResultReferences(this); + } + + public static class Builder> extends ContainerType.Builder> { + + protected List references = Lists.newArrayList(); + + /** + * @see QueryResultReferences#getReferences() + */ + public Builder references(List references) { + this.references = references; + return this; + } + + /** + * @see QueryResultReferences#getReferences() + */ + public Builder reference(T reference) { + this.references.add(reference); + return this; + } + + @Override + public QueryResultReferences build() { + QueryResultReferences queryResultReferences = new QueryResultReferences(href); + queryResultReferences.setReferences(references); + queryResultReferences.setName(name); + queryResultReferences.setPage(page); + queryResultReferences.setPageSize(pageSize); + queryResultReferences.setTotal(total); + queryResultReferences.setType(type); + queryResultReferences.setLinks(links); + return queryResultReferences; + } + + /** + * @see Container#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see Container#getPage() + */ + @Override + public Builder page(Integer page) { + this.page = page; + return this; + } + + /** + * @see Container#getPageSize() + */ + @Override + public Builder pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * @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 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 fromContainerType(ContainerType> in) { + return Builder.class.cast(super.fromContainerType(in)); + } + + public Builder fromQueryResultReferences(QueryResultReferences in) { + return fromContainerType(in).references(in.getReferences()); + } + } + + protected QueryResultReferences() { + // For JAXB and builder use + } + + protected QueryResultReferences(URI href) { + super(href); + } + + @XmlElementRef(name = "Reference", namespace = VCLOUD_1_5_NS) + protected List references; + + /** + * Set of references representing query results. + */ + public List getReferences() { + return references; + } + + public void setReferences(List references) { + this.references = Lists.newArrayList(checkNotNull(references, "references")); + } + + public void addReference(T reference) { + this.references.add(checkNotNull(reference, "reference")); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + QueryResultReferences that = QueryResultReferences.class.cast(o); + return super.equals(that) && equal(this.references, that.references); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(references); + } + + @Override + public ToStringHelper string() { + return super.string().add("references", references); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/vapp/AbstractVAppType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/vapp/AbstractVAppType.java index 1b353bc825..eba27db878 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/vapp/AbstractVAppType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/vapp/AbstractVAppType.java @@ -1,15 +1,26 @@ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6 -// See http://java.sun.com/xml/jaxb -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2012.02.08 at 02:47:44 PM GMT -// - - +/* + * 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.vapp; import java.util.ArrayList; import java.util.List; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -18,18 +29,9 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementRef; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; -import com.vmware.vcloud.api.rest.schema.ovf.AnnotationSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.DeploymentOptionSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.DiskSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.EulaSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.InstallSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.NetworkSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.OperatingSystemSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.ProductSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.ResourceAllocationSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.SectionType; -import com.vmware.vcloud.api.rest.schema.ovf.StartupSectionType; -import com.vmware.vcloud.api.rest.schema.ovf.VirtualHardwareSectionType; + +import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; +import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity; /** @@ -63,115 +65,109 @@ import com.vmware.vcloud.api.rest.schema.ovf.VirtualHardwareSectionType; "vAppParent", "section" }) -@XmlSeeAlso({ - VmType.class, - VAppType.class -}) -public abstract class AbstractVAppType - extends ResourceEntityType -{ +public abstract class AbstractVAppType extends ResourceEntity { - @XmlElement(name = "VAppParent") - protected ReferenceType vAppParent; - @XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class) - protected List> section; - @XmlAttribute - protected Boolean deployed; - - /** - * Gets the value of the vAppParent property. - * - * @return - * possible object is - * {@link ReferenceType } - * - */ - public ReferenceType getVAppParent() { - return vAppParent; - } - - /** - * Sets the value of the vAppParent property. - * - * @param value - * allowed object is - * {@link ReferenceType } - * - */ - public void setVAppParent(ReferenceType value) { - this.vAppParent = value; - } - - /** - * - * Specific ovf:Section with additional information for the vApp. - * Gets the value of the section property. - * - *

- * 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 set method for the section property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getSection().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link SectionType }{@code >} - * {@link JAXBElement }{@code <}{@link VirtualHardwareSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link LeaseSettingsSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link EulaSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link RuntimeInfoSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link AnnotationSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link DeploymentOptionSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link StartupSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link ResourceAllocationSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link NetworkConnectionSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link CustomizationSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link ProductSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link GuestCustomizationSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link OperatingSystemSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link NetworkConfigSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link NetworkSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link DiskSectionType }{@code >} - * {@link JAXBElement }{@code <}{@link InstallSectionType }{@code >} - * - * - */ - public List> getSection() { - if (section == null) { - section = new ArrayList>(); - } - return this.section; - } - - /** - * Gets the value of the deployed property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isDeployed() { - return deployed; - } - - /** - * Sets the value of the deployed property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setDeployed(Boolean value) { - this.deployed = value; - } +// @XmlElement(name = "VAppParent") +// protected ReferenceType vAppParent; +// @XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class) +// protected List> section; +// @XmlAttribute +// protected Boolean deployed; +// +// /** +// * Gets the value of the vAppParent property. +// * +// * @return +// * possible object is +// * {@link ReferenceType } +// * +// */ +// public ReferenceType getVAppParent() { +// return vAppParent; +// } +// +// /** +// * Sets the value of the vAppParent property. +// * +// * @param value +// * allowed object is +// * {@link ReferenceType } +// * +// */ +// public void setVAppParent(ReferenceType value) { +// this.vAppParent = value; +// } +// +// /** +// * +// * Specific ovf:Section with additional information for the vApp. +// * Gets the value of the section property. +// * +// *

+// * 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 set method for the section property. +// * +// *

+// * For example, to add a new item, do as follows: +// *

+//     *    getSection().add(newItem);
+//     * 
+// * +// * +// *

+// * Objects of the following type(s) are allowed in the list +// * {@link JAXBElement }{@code <}{@link SectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link VirtualHardwareSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link LeaseSettingsSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link EulaSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link RuntimeInfoSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link AnnotationSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link DeploymentOptionSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link StartupSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link ResourceAllocationSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link NetworkConnectionSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link CustomizationSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link ProductSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link GuestCustomizationSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link OperatingSystemSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link NetworkConfigSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link NetworkSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link DiskSectionType }{@code >} +// * {@link JAXBElement }{@code <}{@link InstallSectionType }{@code >} +// * +// * +// */ +// public List> getSection() { +// if (section == null) { +// section = new ArrayList>(); +// } +// return this.section; +// } +// +// /** +// * Gets the value of the deployed property. +// * +// * @return +// * possible object is +// * {@link Boolean } +// * +// */ +// public Boolean isDeployed() { +// return deployed; +// } +// +// /** +// * Sets the value of the deployed property. +// * +// * @param value +// * allowed object is +// * {@link Boolean } +// * +// */ +// public void setDeployed(Boolean value) { +// this.deployed = value; +// } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/vapp/VApp.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/vapp/VApp.java index 78654802ca..5e02670dd5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/vapp/VApp.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/vapp/VApp.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to jclouds, Inc. (jclouds) under one or more * contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -16,15 +16,19 @@ * specific language governing permissions and limitations * under the License. */ - package org.jclouds.vcloud.director.v1_5.domain.vapp; +import static com.google.common.base.Objects.*; + 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 org.jclouds.vcloud.director.v1_5.domain.Owner; + +import com.google.common.base.Objects; /** * @@ -59,221 +63,219 @@ import javax.xml.bind.annotation.XmlType; "inMaintenanceMode", "children" }) -public class VApp - extends AbstractVAppType - -{ - @SuppressWarnings("unchecked") - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromVApp(this); - } - - public static class Builder extends AbstractVAppType.Builder { - - private Owner owner; - private Boolean inMaintenanceMode; - private VAppChildren children; - private Boolean ovfDescriptorUploaded; - - /** - * @see VApp#getOwner() - */ - public Builder owner(Owner owner) { - this.owner = owner; - return this; - } - - /** - * @see VApp#getInMaintenanceMode() - */ - public Builder inMaintenanceMode(Boolean inMaintenanceMode) { - this.inMaintenanceMode = inMaintenanceMode; - return this; - } - - /** - * @see VApp#getChildren() - */ - public Builder children(VAppChildren children) { - this.children = children; - return this; - } - - /** - * @see VApp#getOvfDescriptorUploaded() - */ - public Builder ovfDescriptorUploaded(Boolean ovfDescriptorUploaded) { - this.ovfDescriptorUploaded = ovfDescriptorUploaded; - return this; - } - - - public VApp build() { - VApp vApp = new VApp(); - vApp.setOwner(owner); - vApp.setInMaintenanceMode(inMaintenanceMode); - vApp.setChildren(children); - vApp.setOvfDescriptorUploaded(ovfDescriptorUploaded); - return vApp; - } - - - @Override - public Builder fromAbstractVAppType(AbstractVAppType in) { - return Builder.class.cast(super.fromAbstractVAppType(in)); - } - public Builder fromVApp(VApp in) { - return fromAbstractVAppType(in) - .owner(in.getOwner()) - .inMaintenanceMode(in.getInMaintenanceMode()) - .children(in.getChildren()) - .ovfDescriptorUploaded(in.getOvfDescriptorUploaded()); - } - } - - private VApp() { - // For JAXB and builder use - } - - - - @XmlElement(name = "Owner") - protected Owner owner; - @XmlElement(name = "InMaintenanceMode") - protected Boolean inMaintenanceMode; - @XmlElement(name = "Children") - protected VAppChildren children; - @XmlAttribute - protected Boolean ovfDescriptorUploaded; - - /** - * 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 inMaintenanceMode property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isInMaintenanceMode() { - return inMaintenanceMode; - } - - /** - * Sets the value of the inMaintenanceMode property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setInMaintenanceMode(Boolean value) { - this.inMaintenanceMode = value; - } - - /** - * Gets the value of the children property. - * - * @return - * possible object is - * {@link VAppChildren } - * - */ - public VAppChildren getChildren() { - return children; - } - - /** - * Sets the value of the children property. - * - * @param value - * allowed object is - * {@link VAppChildren } - * - */ - public void setChildren(VAppChildren value) { - this.children = value; - } - - /** - * Gets the value of the ovfDescriptorUploaded property. - * - * @return - * possible object is - * {@link Boolean } - * - */ - public Boolean isOvfDescriptorUploaded() { - return ovfDescriptorUploaded; - } - - /** - * Sets the value of the ovfDescriptorUploaded property. - * - * @param value - * allowed object is - * {@link Boolean } - * - */ - public void setOvfDescriptorUploaded(Boolean value) { - this.ovfDescriptorUploaded = value; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - VApp that = VApp.class.cast(o); - return equal(owner, that.owner) && - equal(inMaintenanceMode, that.inMaintenanceMode) && - equal(children, that.children) && - equal(ovfDescriptorUploaded, that.ovfDescriptorUploaded); - } - - @Override - public int hashCode() { - return Objects.hashCode(owner, - inMaintenanceMode, - children, - ovfDescriptorUploaded); - } - - @Override - public String toString() { - return Objects.toStringHelper("") - .add("owner", owner) - .add("inMaintenanceMode", inMaintenanceMode) - .add("children", children) - .add("ovfDescriptorUploaded", ovfDescriptorUploaded).toString(); - } +public class VApp extends AbstractVAppType { +// +// @SuppressWarnings("unchecked") +// public static Builder builder() { +// return new Builder(); +// } +// +// public Builder toBuilder() { +// return new Builder().fromVApp(this); +// } +// +// public static class Builder extends AbstractVAppType.Builder { +// +// private Owner owner; +// private Boolean inMaintenanceMode; +// private VAppChildren children; +// private Boolean ovfDescriptorUploaded; +// +// /** +// * @see VApp#getOwner() +// */ +// public Builder owner(Owner owner) { +// this.owner = owner; +// return this; +// } +// +// /** +// * @see VApp#getInMaintenanceMode() +// */ +// public Builder inMaintenanceMode(Boolean inMaintenanceMode) { +// this.inMaintenanceMode = inMaintenanceMode; +// return this; +// } +// +// /** +// * @see VApp#getChildren() +// */ +// public Builder children(VAppChildren children) { +// this.children = children; +// return this; +// } +// +// /** +// * @see VApp#getOvfDescriptorUploaded() +// */ +// public Builder ovfDescriptorUploaded(Boolean ovfDescriptorUploaded) { +// this.ovfDescriptorUploaded = ovfDescriptorUploaded; +// return this; +// } +// +// +// public VApp build() { +// VApp vApp = new VApp(); +// vApp.setOwner(owner); +// vApp.setInMaintenanceMode(inMaintenanceMode); +// vApp.setChildren(children); +// vApp.setOvfDescriptorUploaded(ovfDescriptorUploaded); +// return vApp; +// } +// +// +// @Override +// public Builder fromAbstractVAppType(AbstractVAppType in) { +// return Builder.class.cast(super.fromAbstractVAppType(in)); +// } +// public Builder fromVApp(VApp in) { +// return fromAbstractVAppType(in) +// .owner(in.getOwner()) +// .inMaintenanceMode(in.getInMaintenanceMode()) +// .children(in.getChildren()) +// .ovfDescriptorUploaded(in.getOvfDescriptorUploaded()); +// } +// } +// +// private VApp() { +// // For JAXB and builder use +// } +// +// +// +// @XmlElement(name = "Owner") +// protected Owner owner; +// @XmlElement(name = "InMaintenanceMode") +// protected Boolean inMaintenanceMode; +// @XmlElement(name = "Children") +// protected VAppChildren children; +// @XmlAttribute +// protected Boolean ovfDescriptorUploaded; +// +// /** +// * 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 inMaintenanceMode property. +// * +// * @return +// * possible object is +// * {@link Boolean } +// * +// */ +// public Boolean isInMaintenanceMode() { +// return inMaintenanceMode; +// } +// +// /** +// * Sets the value of the inMaintenanceMode property. +// * +// * @param value +// * allowed object is +// * {@link Boolean } +// * +// */ +// public void setInMaintenanceMode(Boolean value) { +// this.inMaintenanceMode = value; +// } +// +// /** +// * Gets the value of the children property. +// * +// * @return +// * possible object is +// * {@link VAppChildren } +// * +// */ +// public VAppChildren getChildren() { +// return children; +// } +// +// /** +// * Sets the value of the children property. +// * +// * @param value +// * allowed object is +// * {@link VAppChildren } +// * +// */ +// public void setChildren(VAppChildren value) { +// this.children = value; +// } +// +// /** +// * Gets the value of the ovfDescriptorUploaded property. +// * +// * @return +// * possible object is +// * {@link Boolean } +// * +// */ +// public Boolean isOvfDescriptorUploaded() { +// return ovfDescriptorUploaded; +// } +// +// /** +// * Sets the value of the ovfDescriptorUploaded property. +// * +// * @param value +// * allowed object is +// * {@link Boolean } +// * +// */ +// public void setOvfDescriptorUploaded(Boolean value) { +// this.ovfDescriptorUploaded = value; +// } +// +// @Override +// public boolean equals(Object o) { +// if (this == o) +// return true; +// if (o == null || getClass() != o.getClass()) +// return false; +// VApp that = VApp.class.cast(o); +// return equal(owner, that.owner) && +// equal(inMaintenanceMode, that.inMaintenanceMode) && +// equal(children, that.children) && +// equal(ovfDescriptorUploaded, that.ovfDescriptorUploaded); +// } +// +// @Override +// public int hashCode() { +// return Objects.hashCode(owner, +// inMaintenanceMode, +// children, +// ovfDescriptorUploaded); +// } +// +// @Override +// public String toString() { +// return Objects.toStringHelper("") +// .add("owner", owner) +// .add("inMaintenanceMode", inMaintenanceMode) +// .add("children", children) +// .add("ovfDescriptorUploaded", ovfDescriptorUploaded).toString(); +// } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryAsyncClient.java index be09637d06..8b99bf4701 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryAsyncClient.java @@ -18,59 +18,81 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import java.net.URI; - import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; -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.vcloud.director.v1_5.domain.ReferenceType; -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.query.CatalogReferences; +import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; 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.ReferenceToEndpoint; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import com.google.common.util.concurrent.ListenableFuture; /** - * @see TaskClient + * @see QueryClient * @author grkvlt@apache.org */ @RequestFilters(AddVCloudAuthorizationToRequest.class) public interface QueryAsyncClient { /** - * @see TaskClient#getTaskList(ReferenceType) + * REST API General queries handler. */ @GET + @Path("/query") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getTaskList(@EndpointParam(parser = OrgReferenceToTaskListEndpoint.class) ReferenceType orgRef); + ListenableFuture query(@QueryParam("type") String type, @QueryParam("filter") String filter); + + @GET + @Path("/query") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture query(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize, + @QueryParam("format") String format, @QueryParam("type") String type, @QueryParam("filter") String filter); /** - * @see TaskClient#getTask(URI) + * Retrieves a list of Catalogs by using REST API general QueryHandler. */ @GET + @Path("/catalogs/query") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getTask(@EndpointParam URI taskUri); + ListenableFuture catalogsQuery(@QueryParam("filter") String filter); - /** - * @see TaskClient#cancelTask(URI) - */ - @POST - @Path("/action/cancel") + @GET + @Path("/catalogs/query") @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture cancelTask(@EndpointParam URI taskUri); + ListenableFuture catalogsQuery(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize, + @QueryParam("format") String format, @QueryParam("filter") String filter); + + @GET + @Path("/catalogs/query") + @Consumes + @DefaultValue("references") + @QueryParam("format") + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture catalogReferencesQuery(@QueryParam("filter") String filter); + + @GET + @Path("/catalogs/query") + @Consumes + @DefaultValue("references") + @QueryParam("format") + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture catalogReferencesQuery(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize, + @QueryParam("filter") String filter); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryClient.java index 188f5b7f7e..39bca1b3f0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/QueryClient.java @@ -18,13 +18,11 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -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.domain.TasksList; +import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences; +import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; /** * Provides synchronous access to The REST API query interface. @@ -39,10 +37,12 @@ public interface QueryClient { * REST API General queries handler. * *

-    * GET /query/
+    * GET /query
     * 
*/ - ContainerType query(String queryParams); + QueryResultRecords query(String type, String filter); + + QueryResultRecords query(Integer page, Integer pageSize, String format, String type, String filter); /** * Retrieves a list of Catalogs by using REST API general QueryHandler. @@ -52,11 +52,15 @@ public interface QueryClient { * Default format is references. * *
-    * GET /catalogs/query/
+    * GET /catalogs/query
     * 
- * - * @param orgId the unique id for the organization - * @return a list of tasks */ - ContainerType catalogsQuery(ReferenceType orgRef); + QueryResultRecords catalogsQuery(String filter); + + QueryResultRecords catalogsQuery(Integer page, Integer pageSize, String format, String filter); + + CatalogReferences catalogReferencesQuery(String filter); + + CatalogReferences catalogReferencesQuery(Integer page, Integer pageSize, String filter); + } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java index 5bba119b06..50f1b0cf8c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryClientExpectTest.java @@ -25,12 +25,10 @@ import java.net.URI; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; 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.Reference; -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.Link; +import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultCatalogRecord; +import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.testng.annotations.Test; @@ -46,7 +44,78 @@ public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTes @Test public void testQueryCatalogNoParam() { - assertTrue(true); + HttpRequest queryRequest = HttpRequest.builder() + .method("GET") + .endpoint(URI.create(endpoint + "/catalogs/query?filter=")) + .headers(ImmutableMultimap. builder() + .put("Accept", "*/*") + .put("x-vcloud-authorization", token) + .build()) + .build(); + + HttpResponse queryResponse= HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResourceWithContentType("/query/allCatalogs.xml", VCloudDirectorMediaType.QUERY_RESULT_RECORDS + ";version=1.5")) + .build(); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse); + + QueryResultRecords expected = QueryResultRecords.builder() + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=records")) + .type("application/vnd.vmware.vcloud.query.records+xml") + .name("catalog") + .page(1) + .pageSize(25) + .total(3L) + .link(Link.builder() + .rel("alternate") + .type("application/vnd.vmware.vcloud.query.references+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=references")) + .build()) + .link(Link.builder() + .rel("alternate") + .type("application/vnd.vmware.vcloud.query.idrecords+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=idrecords")) + .build()) + .record(QueryResultCatalogRecord.builder() + .ownerName("qunying.huang@enstratus.com") + .owner(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69")) + .orgName("JClouds") + .numberOfVAppTemplates(0) + .numberOfMedia(0) + .name("QunyingTestCatalog") + .shared() + .notPublished() + .creationDate(dateService.iso8601DateParse("2012-02-07T00:16:28.323-05:00")) + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4")) + .build()) + .record(QueryResultCatalogRecord.builder() + .ownerName("system") + .owner(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/0ebf2453-5e95-48ab-b223-02671965ee91")) + .orgName("Bluelock") + .numberOfVAppTemplates(0) + .numberOfMedia(0) + .name("Public") + .notShared() + .published() + .creationDate(dateService.iso8601DateParse("2011-09-28T13:45:44.207-04:00")) + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/9e08c2f6-077a-42ce-bece-d5332e2ebb5c")) + .build()) + .record(QueryResultCatalogRecord.builder() + .ownerName("adk@cloudsoftcorp.com") + .owner(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9")) + .orgName("JClouds") + .numberOfVAppTemplates(0) + .numberOfMedia(0) + .name("test") + .shared() + .notPublished() + .creationDate(dateService.iso8601DateParse("2012-02-09T12:32:17.723-05:00")) + .href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/b7289d54-4ca4-497f-9a93-2d4afc97e3da")) + .build()) + .build(); + + assertEquals(client.getQueryClient().catalogsQuery(""), expected); } } - \ No newline at end of file +