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 index 8f5dac90f7..acfffcb591 100644 --- 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 @@ -1,3 +1,21 @@ +/* + * 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 java.net.URI; @@ -11,6 +29,7 @@ public class CatalogReference extends Reference { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromCatalogReference(this); } @@ -52,5 +71,5 @@ public class CatalogReference extends Reference { return super.equals(that); } - // Note: hashcode inheritted from ReferenceType + // NOTE hashcode inheritted from Reference } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppReference.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppReference.java new file mode 100644 index 0000000000..6833ffff01 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppReference.java @@ -0,0 +1,75 @@ +/* + * 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 java.net.URI; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "VAppReference") +public class VAppReference extends Reference { + + public static Builder builder() { + return new ConcreteBuilder(); + } + + @Override + public Builder toBuilder() { + return builder().fromVAppReference(this); + } + + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> extends Reference.Builder { + + @Override + public VAppReference build() { + return new VAppReference(this); + } + + protected B fromVAppReference(VAppReference in) { + return fromReference(in); + } + } + + public VAppReference(Builder builder) { + super(builder); + } + + public VAppReference(URI href, String id, String name, String type) { + super(href, id, name, type); + } + + protected VAppReference() { + // For JAXB + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + VAppReference that = VAppReference.class.cast(o); + return super.equals(that); + } + + // NOTE hashcode inheritted from Reference +} 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 index 0f9f4c1931..b6e08357b4 100644 --- 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 @@ -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,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.jclouds.vcloud.director.v1_5.domain.query; import javax.xml.bind.annotation.XmlRootElement; @@ -37,6 +36,7 @@ public class CatalogReferences extends QueryResultReferences { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromCatalogReferences(this); } @@ -63,4 +63,16 @@ public class CatalogReferences extends QueryResultReferences { protected CatalogReferences() { // for JAXB } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CatalogReferences that = CatalogReferences.class.cast(o); + return super.equals(that); + } + + // NOTE hashcode inheritted from QueryResultReferences } 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 837c179bf2..0372421e06 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 @@ -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,7 +16,6 @@ * 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.equal; @@ -27,6 +26,7 @@ import java.util.Date; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -35,18 +35,20 @@ import com.google.common.base.Objects.ToStringHelper; * Represents the results from a Catalog vCloud query as a record. * *
- * <complexType name="QueryResultCatalogRecord" />
+ * <complexType name="QueryResultCatalogRecordType" />
  * 
* * @author grkvlt@apache.org */ @XmlRootElement(name = "CatalogRecord") +@XmlType(name = "QueryResultCatalogRecordType") public class QueryResultCatalogRecord extends QueryResultRecordType { public static Builder builder() { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromQueryResultCatalogRecord(this); } @@ -184,8 +186,8 @@ public class QueryResultCatalogRecord extends QueryResultRecordType { private QueryResultCatalogRecord(Builder builder) { super(builder); this.name = builder.name; - isPublished = builder.isPublished; - isShared = builder.isShared; + this.isPublished = builder.isPublished; + this.isShared = builder.isShared; this.creationDate = builder.creationDate; this.orgName = builder.orgName; this.ownerName = builder.ownerName; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultDatastoreRecord.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultDatastoreRecord.java new file mode 100644 index 0000000000..3a142cd695 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultDatastoreRecord.java @@ -0,0 +1,518 @@ +/** + * 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.equal; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; + +/** + * Represents the results from a Datastore vCloud query as a record. + * + *
+ * <complexType name="QueryResultDatastoreRecordType" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlRootElement(name = "DatastoreRecord") +@XmlType(name = "QueryResultDatastoreRecordType") +public class QueryResultDatastoreRecord extends QueryResultRecordType { + + public static Builder builder() { + return new ConcreteBuilder(); + } + + @Override + public Builder toBuilder() { + return builder().fromQueryResultDatastoreRecord(this); + } + + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> extends QueryResultRecordType.Builder { + + private String name; + private String datastoreType; + private Boolean isEnabled; + private Boolean isDeleted; + private Long storageUsedMB; + private Long storageMB; + private Long provisionedStorageMB; + private Long requestedStorageMB; + private String vc; + private String vcName; + private String moref; + private Integer numberOfProviderVdcs; + + /** + * @see QueryResultDatastoreRecord#getName() + */ + public B name(String name) { + this.name = name; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getDatastoreType() + */ + public B datastoreType(String datastoreType) { + this.datastoreType = datastoreType; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#isEnabled() + */ + public B isEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#isEnabled() + */ + public B enabled() { + this.isEnabled = Boolean.TRUE; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#isEnabled() + */ + public B disabled() { + this.isEnabled = Boolean.FALSE; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#isDeleted() + */ + public B isDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#isDeleted() + */ + public B deleted() { + this.isDeleted = Boolean.TRUE; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#isDeleted() + */ + public B notDeleted() { + this.isDeleted = Boolean.FALSE; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getStorageUsedMB() + */ + public B storageUsedMB(Long storageUsedMB) { + this.storageUsedMB = storageUsedMB; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getStorageMB() + */ + public B storageMB(Long storageMB) { + this.storageMB = storageMB; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getProvisionedStorageMB() + */ + public B provisionedStorageMB(Long provisionedStorageMB) { + this.provisionedStorageMB = provisionedStorageMB; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getRequestedStorageMB() + */ + public B requestedStorageMB(Long requestedStorageMB) { + this.requestedStorageMB = requestedStorageMB; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getVc() + */ + public B vc(String vc) { + this.vc = vc; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getVcName() + */ + public B vcName(String vcName) { + this.vcName = vcName; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getMoref() + */ + public B moref(String moref) { + this.moref = moref; + return self(); + } + + /** + * @see QueryResultDatastoreRecord#getNumberOfProviderVdcs() + */ + public B numberOfProviderVdcs(Integer numberOfProviderVdcs) { + this.numberOfProviderVdcs = numberOfProviderVdcs; + return self(); + } + + @Override + public QueryResultDatastoreRecord build() { + return new QueryResultDatastoreRecord(this); + } + + public B fromQueryResultDatastoreRecord(QueryResultDatastoreRecord in) { + return fromQueryResultRecordType(in) + .name(in.getName()) + .datastoreType(in.getDatastoreType()) + .isEnabled(in.isEnabled()) + .isDeleted(in.isDeleted()) + .storageUsedMB(in.getStorageUsedMB()) + .storageMB(in.getStorageMB()) + .provisionedStorageMB(in.getProvisionedStorageMB()) + .requestedStorageMB(in.getRequestedStorageMB()) + .vc(in.getVc()) + .vcName(in.getVcName()) + .moref(in.getMoref()) + .numberOfProviderVdcs(in.getNumberOfProviderVdcs()); + } + } + + private QueryResultDatastoreRecord(Builder builder) { + super(builder); + this.name = builder.name; + this.datastoreType = builder.datastoreType; + this.isEnabled = builder.isEnabled; + this.isDeleted = builder.isDeleted; + this.storageUsedMB = builder.storageUsedMB; + this.storageMB = builder.storageMB; + this.provisionedStorageMB = builder.provisionedStorageMB; + this.requestedStorageMB = builder.requestedStorageMB; + this.vc = builder.vc; + this.vcName = builder.vcName; + this.moref = builder.moref; + this.numberOfProviderVdcs = builder.numberOfProviderVdcs; + } + + private QueryResultDatastoreRecord() { + // for JAXB + } + + @XmlAttribute + protected String name; + @XmlAttribute + protected String datastoreType; + @XmlAttribute + protected Boolean isEnabled; + @XmlAttribute + protected Boolean isDeleted; + @XmlAttribute + protected Long storageUsedMB; + @XmlAttribute + protected Long storageMB; + @XmlAttribute + protected Long provisionedStorageMB; + @XmlAttribute + protected Long requestedStorageMB; + @XmlAttribute + protected String vc; + @XmlAttribute + protected String vcName; + @XmlAttribute + protected String moref; + @XmlAttribute + protected Integer numberOfProviderVdcs; + + /** + * Gets the value of the name property. + * + * @return possible object is {@link String } + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is {@link String } + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the datastoreType property. + * + * @return possible object is {@link String } + */ + public String getDatastoreType() { + return datastoreType; + } + + /** + * Sets the value of the datastoreType property. + * + * @param value + * allowed object is {@link String } + */ + public void setDatastoreType(String value) { + this.datastoreType = value; + } + + /** + * Gets the value of the isEnabled property. + * + * @return possible object is {@link Boolean } + */ + public Boolean isEnabled() { + return isEnabled; + } + + /** + * Sets the value of the isEnabled property. + * + * @param value + * allowed object is {@link Boolean } + */ + public void setIsEnabled(Boolean value) { + this.isEnabled = value; + } + + /** + * Gets the value of the isDeleted property. + * + * @return possible object is {@link Boolean } + */ + public Boolean isDeleted() { + return isDeleted; + } + + /** + * Sets the value of the isDeleted property. + * + * @param value + * allowed object is {@link Boolean } + */ + public void setIsDeleted(Boolean value) { + this.isDeleted = value; + } + + /** + * Gets the value of the storageUsedMB property. + * + * @return possible object is {@link Long } + */ + public Long getStorageUsedMB() { + return storageUsedMB; + } + + /** + * Sets the value of the storageUsedMB property. + * + * @param value + * allowed object is {@link Long } + */ + public void setStorageUsedMB(Long value) { + this.storageUsedMB = value; + } + + /** + * Gets the value of the storageMB property. + * + * @return possible object is {@link Long } + */ + public Long getStorageMB() { + return storageMB; + } + + /** + * Sets the value of the storageMB property. + * + * @param value + * allowed object is {@link Long } + */ + public void setStorageMB(Long value) { + this.storageMB = value; + } + + /** + * Gets the value of the provisionedStorageMB property. + * + * @return possible object is {@link Long } + */ + public Long getProvisionedStorageMB() { + return provisionedStorageMB; + } + + /** + * Sets the value of the provisionedStorageMB property. + * + * @param value + * allowed object is {@link Long } + */ + public void setProvisionedStorageMB(Long value) { + this.provisionedStorageMB = value; + } + + /** + * Gets the value of the requestedStorageMB property. + * + * @return possible object is {@link Long } + */ + public Long getRequestedStorageMB() { + return requestedStorageMB; + } + + /** + * Sets the value of the requestedStorageMB property. + * + * @param value + * allowed object is {@link Long } + */ + public void setRequestedStorageMB(Long value) { + this.requestedStorageMB = value; + } + + /** + * Gets the value of the vc property. + * + * @return possible object is {@link String } + */ + public String getVc() { + return vc; + } + + /** + * Sets the value of the vc property. + * + * @param value + * allowed object is {@link String } + */ + public void setVc(String value) { + this.vc = value; + } + + /** + * Gets the value of the vcName property. + * + * @return possible object is {@link String } + */ + public String getVcName() { + return vcName; + } + + /** + * Sets the value of the vcName property. + * + * @param value + * allowed object is {@link String } + */ + public void setVcName(String value) { + this.vcName = value; + } + + /** + * Gets the value of the moref property. + * + * @return possible object is {@link String } + */ + public String getMoref() { + return moref; + } + + /** + * Sets the value of the moref property. + * + * @param value + * allowed object is {@link String } + */ + public void setMoref(String value) { + this.moref = value; + } + + /** + * Gets the value of the numberOfProviderVdcs property. + * + * @return possible object is {@link Integer } + */ + public Integer getNumberOfProviderVdcs() { + return numberOfProviderVdcs; + } + + /** + * Sets the value of the numberOfProviderVdcs property. + * + * @param value + * allowed object is {@link Integer } + */ + public void setNumberOfProviderVdcs(Integer value) { + this.numberOfProviderVdcs = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + QueryResultDatastoreRecord that = QueryResultDatastoreRecord.class.cast(o); + return super.equals(that) && equal(name, that.name) && equal(datastoreType, that.datastoreType) && equal(isEnabled, that.isEnabled) && equal(isDeleted, that.isDeleted) + && equal(storageUsedMB, that.storageUsedMB) && equal(storageMB, that.storageMB) && equal(provisionedStorageMB, that.provisionedStorageMB) + && equal(requestedStorageMB, that.requestedStorageMB) && equal(vc, that.vc) && equal(vcName, that.vcName) && equal(moref, that.moref) + && equal(numberOfProviderVdcs, that.numberOfProviderVdcs); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), name, datastoreType, isEnabled, isDeleted, storageUsedMB, storageMB, provisionedStorageMB, requestedStorageMB, vc, vcName, moref, numberOfProviderVdcs); + } + + @Override + public ToStringHelper string() { + return super.string().add("name", name).add("datastoreType", datastoreType).add("isEnabled", isEnabled).add("isDeleted", isDeleted).add("storageUsedMB", storageUsedMB).add("storageMB", + storageMB).add("provisionedStorageMB", provisionedStorageMB).add("requestedStorageMB", requestedStorageMB).add("vc", vc).add("vcName", vcName).add("moref", moref).add( + "numberOfProviderVdcs", numberOfProviderVdcs); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultNetworkRecord.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultNetworkRecord.java index 40f5081b19..ad974f3949 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultNetworkRecord.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultNetworkRecord.java @@ -16,12 +16,13 @@ * 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.equal; import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; @@ -30,17 +31,20 @@ import com.google.common.base.Objects.ToStringHelper; * Represents the results from a Network vCloud query as a record. * *
- * <complexType name="QueryResultNetworkRecord" />
+ * <complexType name="QueryResultNetworkRecordType" />
  * 
* * @author grkvlt@apache.org */ +@XmlRootElement(name = "OrgNetworkRecord") +@XmlType(name = "QueryResultNetworkRecordType") public class QueryResultNetworkRecord extends QueryResultRecordType { public static Builder builder() { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromQueryResultNetworkRecord(this); } 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 adb22a66a1..469e9a58da 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 @@ -53,6 +53,7 @@ public class QueryResultRecords extends ContainerType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromQueryResultRecords(this); } 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 index 863a591f8e..75df451567 100644 --- 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 @@ -51,6 +51,7 @@ public class QueryResultReferences extends ContainerType { return new ConcreteBuilder(); } + @Override public Builder toBuilder() { return builder().fromQueryResultReferences(this); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultVAppRecord.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultVAppRecord.java new file mode 100644 index 0000000000..176b65049b --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/QueryResultVAppRecord.java @@ -0,0 +1,343 @@ +/* + * 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.equal; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; + +/** + * Represents the results from a VApp vCloud query as a record. + * + *
+ * <complexType name="QueryResultVAppRecordType" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlRootElement(name = "VAppRecord") +@XmlType(name = "QueryResultVAppRecordType") +public class QueryResultVAppRecord extends QueryResultRecordType { + + public static Builder builder() { + return new ConcreteBuilder(); + } + + @Override + public Builder toBuilder() { + return builder().fromQueryResultVAppRecord(this); + } + + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> extends QueryResultRecordType.Builder { + + private String name; + private String vdc; + private String vdcName; + private Boolean isPublic; + private Boolean isEnabled; + private Boolean isBusy; + private Date creationDate; + private String status; + private String ownerName; + private Boolean isDeployed; + private Boolean isInMaintenanceMode; + + /** + * @see QueryResultVAppRecord#getName() + */ + public B name(String name) { + this.name = name; + return self(); + } + + /** + * @see QueryResultVAppRecord#getVdc() + */ + public B vdc(String vdc) { + this.vdc = vdc; + return self(); + } + + /** + * @see QueryResultVAppRecord#getVdcName() + */ + public B vdcName(String vdcName) { + this.vdcName = vdcName; + return self(); + } + + /** + * @see QueryResultVAppRecord#getIsPublic() + */ + public B isPublic(Boolean isPublic) { + this.isPublic = isPublic; + return self(); + } + + /** + * @see QueryResultVAppRecord#getIsEnabled() + */ + public B isEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + return self(); + } + + /** + * @see QueryResultVAppRecord#getIsBusy() + */ + public B isBusy(Boolean isBusy) { + this.isBusy = isBusy; + return self(); + } + + /** + * @see QueryResultVAppRecord#getCreationDate() + */ + public B creationDate(Date creationDate) { + this.creationDate = creationDate; + return self(); + } + + /** + * @see QueryResultVAppRecord#getStatus() + */ + public B status(String status) { + this.status = status; + return self(); + } + + /** + * @see QueryResultVAppRecord#getOwnerName() + */ + public B ownerName(String ownerName) { + this.ownerName = ownerName; + return self(); + } + + /** + * @see QueryResultVAppRecord#getIsDeployed() + */ + public B isDeployed(Boolean isDeployed) { + this.isDeployed = isDeployed; + return self(); + } + + /** + * @see QueryResultVAppRecord#getIsInMaintenanceMode() + */ + public B isInMaintenanceMode(Boolean isInMaintenanceMode) { + this.isInMaintenanceMode = isInMaintenanceMode; + return self(); + } + + @Override + public QueryResultVAppRecord build() { + return new QueryResultVAppRecord(this); + } + + public B fromQueryResultVAppRecord(QueryResultVAppRecord in) { + return fromQueryResultRecordType(in) + .name(in.getName()) + .vdc(in.getVdc()) + .vdcName(in.getVdcName()) + .isPublic(in.isIsPublic()) + .isEnabled(in.isIsEnabled()) + .isBusy(in.isIsBusy()) + .creationDate(in.getCreationDate()) + .status(in.getStatus()) + .ownerName(in.getOwnerName()) + .isDeployed(in.isIsDeployed()) + .isInMaintenanceMode(in.isIsInMaintenanceMode()); + } + } + + private QueryResultVAppRecord() { + // For JAXB and builder use + } + + private QueryResultVAppRecord(Builder builder) { + super(builder); + this.name = builder.name; + this.vdc = builder.vdc; + this.vdcName = builder.vdcName; + this.isPublic = builder.isPublic; + this.isEnabled = builder.isEnabled; + this.isBusy = builder.isBusy; + this.creationDate = builder.creationDate; + this.status = builder.status; + this.ownerName = builder.ownerName; + this.isDeployed = builder.isDeployed; + this.isInMaintenanceMode = builder.isInMaintenanceMode; + } + + @XmlAttribute + protected String name; + @XmlAttribute + protected String vdc; + @XmlAttribute + protected String vdcName; + @XmlAttribute + protected Boolean isPublic; + @XmlAttribute + protected Boolean isEnabled; + @XmlAttribute + protected Boolean isBusy; + @XmlAttribute + @XmlSchemaType(name = "dateTime") + protected Date creationDate; + @XmlAttribute + protected String status; + @XmlAttribute + protected String ownerName; + @XmlAttribute + protected Boolean isDeployed; + @XmlAttribute + protected Boolean isInMaintenanceMode; + + /** + * Gets the value of the name property. + */ + public String getName() { + return name; + } + + /** + * Gets the value of the vdc property. + */ + public String getVdc() { + return vdc; + } + + /** + * Gets the value of the vdcName property. + */ + public String getVdcName() { + return vdcName; + } + + /** + * Gets the value of the isPublic property. + */ + public Boolean isIsPublic() { + return isPublic; + } + + /** + * Gets the value of the isEnabled property. + */ + public Boolean isIsEnabled() { + return isEnabled; + } + + /** + * Gets the value of the isBusy property. + */ + public Boolean isIsBusy() { + return isBusy; + } + + /** + * Gets the value of the creationDate property. + */ + public Date getCreationDate() { + return creationDate; + } + + /** + * Gets the value of the status property. + */ + public String getStatus() { + return status; + } + + /** + * Gets the value of the ownerName property. + */ + public String getOwnerName() { + return ownerName; + } + + /** + * Gets the value of the isDeployed property. + */ + public Boolean isIsDeployed() { + return isDeployed; + } + + /** + * Gets the value of the isInMaintenanceMode property. + */ + public Boolean isIsInMaintenanceMode() { + return isInMaintenanceMode; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + QueryResultVAppRecord that = QueryResultVAppRecord.class.cast(o); + return super.equals(that) && + equal(this.name, that.name) && + equal(this.vdc, that.vdc) && + equal(this.vdcName, that.vdcName) && + equal(this.isPublic, that.isPublic) && + equal(this.isEnabled, that.isEnabled) && + equal(this.isBusy, that.isBusy) && + equal(this.creationDate, that.creationDate) && + equal(this.status, that.status) && + equal(this.ownerName, that.ownerName) && + equal(this.isDeployed, that.isDeployed) && + equal(this.isInMaintenanceMode, that.isInMaintenanceMode); + } + + @Override + public int hashCode() { + return Objects.hashCode(super.hashCode(), name, vdc, vdcName, isPublic, isEnabled, isBusy, creationDate, status, ownerName, isDeployed, isInMaintenanceMode); + } + + @Override + public ToStringHelper string() { + return super.string() + .add("name", name) + .add("vdc", vdc) + .add("vdcName", vdcName) + .add("isPublic", isPublic) + .add("isEnabled", isEnabled) + .add("isBusy", isBusy) + .add("creationDate", creationDate) + .add("status", status) + .add("ownerName", ownerName) + .add("isDeployed", isDeployed) + .add("isInMaintenanceMode", isInMaintenanceMode); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/VAppReferences.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/VAppReferences.java new file mode 100644 index 0000000000..c911b09935 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/query/VAppReferences.java @@ -0,0 +1,78 @@ +/* + * 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.XmlRootElement; + +/** + * Represents the results from a vCloud query as references. + * + *
+ * <complexType name="QueryResultReferences" />
+ * 
+ * + * @author grkvlt@apache.org + */ +@XmlRootElement(name = "VAppReferences") +public class VAppReferences extends QueryResultReferences { + + public static Builder builder() { + return new ConcreteBuilder(); + } + + @Override + public Builder toBuilder() { + return builder().fromVAppReferences(this); + } + + private static class ConcreteBuilder extends Builder { + } + + public static class Builder> extends QueryResultReferences.Builder { + + @Override + public VAppReferences build() { + return new VAppReferences(this); + } + + public B fromVAppReferences(VAppReferences in) { + return fromQueryResultReferences(in); + } + } + + protected VAppReferences(Builder builder) { + super(builder); + } + + protected VAppReferences() { + // for JAXB + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + VAppReferences that = VAppReferences.class.cast(o); + return super.equals(that); + } + + // NOTE hashcode inheritted from QueryResultReferences +} 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 cebd6eac94..8685f20c85 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 @@ -31,6 +31,7 @@ import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences; import org.jclouds.vcloud.director.v1_5.domain.query.QueryList; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; +import org.jclouds.vcloud.director.v1_5.domain.query.VAppReferences; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; @@ -42,7 +43,6 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(AddVCloudAuthorizationToRequest.class) @SkipEncoding({ '=' }) -@SuppressWarnings("rawtypes") public interface QueryAsyncClient { /** @@ -78,7 +78,7 @@ public interface QueryAsyncClient { @QueryParam("format") String format, @QueryParam("type") String type, @QueryParam("filter") String filter); /** - * Retrieves a list of Catalogs by using REST API general QueryHandler. + * Retrieves a list of {@link Catalog}s by using REST API general QueryHandler. */ @GET @Path("/catalogs/query") @@ -126,4 +126,54 @@ public interface QueryAsyncClient { @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture catalogReferencesQuery(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize, @QueryParam("filter") String filter); + + /** + * Retrieves a list of {@link VApp}s by using REST API general QueryHandler. + */ + @GET + @Path("/vApps/query") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture vAppsQueryAll(); + + @GET + @Path("/vApps/query") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture vAppsQuery(@QueryParam("filter") String filter); + + @GET + @Path("/vApps/query") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture vAppsQuery(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize, + @QueryParam("filter") String filter); + + @GET + @Path("/vApps/query") + @Consumes + @QueryParams(keys = { "format" }, values = { "references" }) + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture vAppReferencesQueryAll(); + + @GET + @Path("/vApps/query") + @Consumes + @QueryParams(keys = { "format" }, values = { "references" }) + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture vAppReferencesQuery(@QueryParam("filter") String filter); + + @GET + @Path("/vApps/query") + @Consumes + @QueryParams(keys = { "format" }, values = { "references" }) + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture vAppReferencesQuery(@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 9df4ffa54a..e6e29931d4 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 @@ -24,52 +24,117 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences; import org.jclouds.vcloud.director.v1_5.domain.query.QueryList; import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords; +import org.jclouds.vcloud.director.v1_5.domain.query.VAppReferences; /** * Provides synchronous access to The REST API query interface. * - * @see TaskAsyncClient + * @see QueryAsyncClient * @author grkvlt@apache.org */ @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) public interface QueryClient { /** - * REST API General queries handler. + * REST API query {@link Link} list. * *
     * GET /query
     * 
*/ QueryList queryList(); - - QueryResultRecords queryAll(String type); - - 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. + * Retrieves a list of entities by using REST API general QueryHandler. * * If filter is provided it will be applied to the corresponding result set. * Format determines the elements representation - references or records. * Default format is references. * *
+    * GET /query
+    * 
+ * + * @see #queryList() + * @see #query(String, String) + * @see #query(Integer, Integer, String, String, String) + */ + QueryResultRecords queryAll(String type); + + /** @see #queryAll() */ + QueryResultRecords query(String type, String filter); + + /** @see #queryAll() */ + QueryResultRecords query(Integer page, Integer pageSize, String format, String type, String filter); + + /** + * Retrieves a list of {@link Catalog}s by using REST API general QueryHandler. + * + *
     * GET /catalogs/query
     * 
+ * + * @see #queryAll(String) */ QueryResultRecords catalogsQueryAll(); + /** @see #queryAll() */ QueryResultRecords catalogsQuery(String filter); + /** @see #queryAll() */ QueryResultRecords catalogsQuery(Integer page, Integer pageSize, String filter); + + /** + * Retrieves a list of {@link CatalogReference}s by using REST API general QueryHandler. + * + *
+    * GET /catalogs/query?format=references
+    * 
+ * + * @see #queryAll(String) + */ CatalogReferences catalogReferencesQueryAll(); + /** @see #catalogReferencesQueryAll() */ CatalogReferences catalogReferencesQuery(String filter); + /** @see #catalogReferencesQueryAll() */ CatalogReferences catalogReferencesQuery(Integer page, Integer pageSize, String filter); + + /** + * Retrieves a list of {@link VApp}s by using REST API general QueryHandler. + * + *
+    * GET /vApps/query
+    * 
+ * + * @see #queryAll(String) + */ + QueryResultRecords vAppsQueryAll(); + + /** @see #queryAll() */ + QueryResultRecords vAppsQuery(String filter); + + /** @see #queryAll() */ + QueryResultRecords vAppsQuery(Integer page, Integer pageSize, String filter); + + /** + * Retrieves a list of {@link VAppReference}s by using REST API general QueryHandler. + * + *
+    * GET /vApps/query?format=references
+    * 
+ * + * @see #queryAll(String) + */ + /** @see #queryAll() */ + VAppReferences vAppReferencesQueryAll(); + + /** @see #queryAll() */ + VAppReferences vAppReferencesQuery(String filter); + + /** @see #queryAll() */ + VAppReferences vAppReferencesQuery(Integer page, Integer pageSize, String filter); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java index 6d6ca59a26..b8511766e3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppClientLiveTest.java @@ -435,11 +435,12 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest { assertTrue(retryTaskSuccess.apply(recomposeVApp), String.format(TASK_COMPLETE_TIMELY, "recomposeVApp")); } - @Test(testName = "POST /vApp/{id}/action/relocate", dependsOnMethods = { "testGetVApp" }) + // NOTE This test is disabled, as it is not possible to look up datastores using the User API + @Test(enabled = false, testName = "POST /vApp/{id}/action/relocate", dependsOnMethods = { "testGetVApp" }) public void testRelocate() { - // Relocate to the first available datastore - QueryResultRecords records = context.getApi().getQueryClient().query("datastore", "fields==name"); - QueryResultRecordType datastore = Iterables.get(records.getRecords(), 0); + // Relocate to the last of the available datastores + QueryResultRecords records = context.getApi().getQueryClient().queryAll("datastore"); + QueryResultRecordType datastore = Iterables.getLast(records.getRecords()); RelocateParams params = RelocateParams.builder().datastore(Reference.builder().href(datastore.getHref()).build()).build(); // The method under test