From 413654b66ecc20c5416eb180fc5f9b9d13ed322a Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 9 Feb 2012 20:24:32 +0000 Subject: [PATCH 01/27] domain objects --- .../v1_5/domain/AvailableNetworks.java | 158 +++++ .../director/v1_5/domain/Capabilities.java | 148 +++++ .../director/v1_5/domain/CapacityType.java | 233 +++++++ .../v1_5/domain/CapacityWithUsage.java | 227 +++++++ .../v1_5/domain/CaptureVAppParams.java | 232 +++++++ .../v1_5/domain/CloneMediaParams.java | 200 ++++++ .../director/v1_5/domain/CloneVAppParams.java | 107 +++ .../v1_5/domain/CloneVAppTemplateParams.java | 200 ++++++ .../v1_5/domain/ComposeVAppParams.java | 261 ++++++++ .../director/v1_5/domain/ComputeCapacity.java | 190 ++++++ .../domain/InstantiateVAppParamsType.java | 248 +++++++ .../InstantiateVAppTemplateParamsType.java | 165 +++++ .../v1_5/domain/InstantiationParams.java | 180 +++++ .../v1_5/domain/NetworkAssignment.java | 188 ++++++ .../director/v1_5/domain/ParamsType.java | 201 ++++++ .../v1_5/domain/ResourceEntities.java | 158 +++++ .../domain/SourcedCompositionItemParam.java | 326 +++++++++ .../domain/SupportedHardwareVersions.java | 158 +++++ .../v1_5/domain/UploadVAppTemplateParams.java | 194 ++++++ .../v1_5/domain/VAppCreationParamsType.java | 289 ++++++++ .../director/v1_5/domain/VAppTemplate.java | 403 +++++++++++ .../v1_5/domain/VAppTemplateChildren.java | 158 +++++ .../vcloud/director/v1_5/domain/Vdc.java | 624 ++++++++++++++++++ 23 files changed, 5248 insertions(+) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Capabilities.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComputeCapacity.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParamsType.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplateChildren.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java new file mode 100644 index 0000000000..08d398e356 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java @@ -0,0 +1,158 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents a list of references to available networks. + * + * + *

Java class for AvailableNetworks complex type. + * + *

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

+ * <complexType name="AvailableNetworks">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Network" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "AvailableNetworks", propOrder = { + "network" +}) +public class AvailableNetworks { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromAvailableNetworks(this); + } + + public static class Builder { + + private List network; + + /** + * @see AvailableNetworks#getNetwork() + */ + public Builder network(List network) { + this.network = network; + return this; + } + + + public AvailableNetworks build() { + AvailableNetworks availableNetworks = new AvailableNetworks(network); + return availableNetworks; + } + + + public Builder fromAvailableNetworks(AvailableNetworks in) { + return network(in.getNetwork()); + } + } + + private AvailableNetworks() { + // For JAXB and builder use + } + + private AvailableNetworks(List network) { + this.network = network; + } + + + @XmlElement(name = "Network") + protected List network; + + /** + * Gets the value of the network 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 network property. + * + *

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

+     *    getNetwork().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ReferenceType } + * + * + */ + public List getNetwork() { + if (network == null) { + network = new ArrayList(); + } + return this.network; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + AvailableNetworks that = AvailableNetworks.class.cast(o); + return equal(network, that.network); + } + + @Override + public int hashCode() { + return Objects.hashCode(network); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("network", network).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Capabilities.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Capabilities.java new file mode 100644 index 0000000000..7c8c8b6770 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Capabilities.java @@ -0,0 +1,148 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import 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; + + +/** + * + * Collection of supported hardware capabilities. + * + * + *

Java class for Capabilities complex type. + * + *

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

+ * <complexType name="Capabilities">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="SupportedHardwareVersions" type="{http://www.vmware.com/vcloud/v1.5}SupportedHardwareVersionsType" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Capabilities", propOrder = { + "supportedHardwareVersions" +}) +public class Capabilities { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCapabilities(this); + } + + public static class Builder { + + private SupportedHardwareVersions supportedHardwareVersions; + + /** + * @see Capabilities#getSupportedHardwareVersions() + */ + public Builder supportedHardwareVersions(SupportedHardwareVersions supportedHardwareVersions) { + this.supportedHardwareVersions = supportedHardwareVersions; + return this; + } + + + public Capabilities build() { + Capabilities capabilities = new Capabilities(); + capabilities.setSupportedHardwareVersions(supportedHardwareVersions); + return capabilities; + } + + + public Builder fromCapabilities(Capabilities in) { + return supportedHardwareVersions(in.getSupportedHardwareVersions()); + } + } + + private Capabilities() { + // For JAXB and builder use + } + + + + @XmlElement(name = "SupportedHardwareVersions") + protected SupportedHardwareVersions supportedHardwareVersions; + + /** + * Gets the value of the supportedHardwareVersions property. + * + * @return + * possible object is + * {@link SupportedHardwareVersions } + * + */ + public SupportedHardwareVersions getSupportedHardwareVersions() { + return supportedHardwareVersions; + } + + /** + * Sets the value of the supportedHardwareVersions property. + * + * @param value + * allowed object is + * {@link SupportedHardwareVersions } + * + */ + public void setSupportedHardwareVersions(SupportedHardwareVersions value) { + this.supportedHardwareVersions = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Capabilities that = Capabilities.class.cast(o); + return equal(supportedHardwareVersions, that.supportedHardwareVersions); + } + + @Override + public int hashCode() { + return Objects.hashCode(supportedHardwareVersions); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("supportedHardwareVersions", supportedHardwareVersions).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java new file mode 100644 index 0000000000..b56e9691c1 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java @@ -0,0 +1,233 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents a capacity of a given resource. + * + * + *

Java class for Capacity complex type. + * + *

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

+ * <complexType name="Capacity">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Units" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="Allocated" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
+ *         <element name="Limit" type="{http://www.w3.org/2001/XMLSchema}long"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Capacity", propOrder = { + "units", + "allocated", + "limit" +}) +@XmlSeeAlso({ +// CapacityWithUsageType.class +}) +public class CapacityType> { + + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCapacityType(this); + } + + public static class Builder> { + + protected String units; + protected Long allocated; + protected long limit; + + /** + * @see CapacityType#getUnits() + */ + public Builder units(String units) { + this.units = units; + return this; + } + + /** + * @see CapacityType#getAllocated() + */ + public Builder allocated(Long allocated) { + this.allocated = allocated; + return this; + } + + /** + * @see CapacityType#getLimit() + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + + public CapacityType build() { + CapacityType capacity = new CapacityType(); + capacity.setUnits(units); + capacity.setAllocated(allocated); + capacity.setLimit(limit); + return capacity; + } + + + public Builder fromCapacityType(CapacityType in) { + return units(in.getUnits()) + .allocated(in.getAllocated()) + .limit(in.getLimit()); + } + } + + protected CapacityType() { + // For JAXB and builder use + } + + protected CapacityType(String units) { + this.units = units; + } + + + + @XmlElement(name = "Units", required = true) + protected String units; + @XmlElement(name = "Allocated") + protected Long allocated; + @XmlElement(name = "Limit") + protected long limit; + + /** + * Gets the value of the units property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUnits() { + return units; + } + + /** + * Sets the value of the units property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUnits(String value) { + this.units = value; + } + + /** + * Gets the value of the allocated property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getAllocated() { + return allocated; + } + + /** + * Sets the value of the allocated property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setAllocated(Long value) { + this.allocated = value; + } + + /** + * Gets the value of the limit property. + * + */ + public long getLimit() { + return limit; + } + + /** + * Sets the value of the limit property. + * + */ + public void setLimit(long value) { + this.limit = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CapacityType that = CapacityType.class.cast(o); + return equal(units, that.units) && + equal(allocated, that.allocated) && + equal(limit, that.limit); + } + + @Override + public int hashCode() { + return Objects.hashCode(units, + allocated, + limit); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("units", units) + .add("allocated", allocated) + .add("limit", limit).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java new file mode 100644 index 0000000000..7079374b97 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java @@ -0,0 +1,227 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents a capacity and usage of a given resource. + * + * + *

Java class for CapacityWithUsage complex type. + * + *

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

+ * <complexType name="CapacityWithUsage">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}CapacityType">
+ *       <sequence>
+ *         <element name="Used" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
+ *         <element name="Overhead" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CapacityWithUsage", propOrder = { + "used", + "overhead" +}) +public class CapacityWithUsage extends CapacityType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCapacityWithUsage(this); + } + + public static class Builder extends CapacityType.Builder { + + private Long used; + private Long overhead; + + /** + * @see CapacityWithUsage#getUsed() + */ + public Builder used(Long used) { + this.used = used; + return this; + } + + /** + * @see CapacityWithUsage#getOverhead() + */ + public Builder overhead(Long overhead) { + this.overhead = overhead; + return this; + } + + + public CapacityWithUsage build() { + CapacityWithUsage capacityWithUsage = new CapacityWithUsage(units); + capacityWithUsage.setUsed(used); + capacityWithUsage.setOverhead(overhead); + capacityWithUsage.setAllocated(allocated); + capacityWithUsage.setLimit(limit); + return capacityWithUsage; + } + + /** + * @see CapacityType#getUnits() + */ + public Builder units(String units) { + this.units = units; + return this; + } + + /** + * @see CapacityType#getAllocated() + */ + public Builder allocated(Long allocated) { + this.allocated = allocated; + return this; + } + + /** + * @see CapacityType#getLimit() + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + + @Override + public Builder fromCapacityType(CapacityType in) { + return Builder.class.cast(super.fromCapacityType(in)); + } + public Builder fromCapacityWithUsage(CapacityWithUsage in) { + return fromCapacityType(in) + .used(in.getUsed()) + .overhead(in.getOverhead()); + } + } + + protected CapacityWithUsage() { + // For JAXB and builder use + } + + public CapacityWithUsage(String units) { + super(units); + } + + + @XmlElement(name = "Used") + protected Long used; + @XmlElement(name = "Overhead") + protected Long overhead; + + /** + * Gets the value of the used property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getUsed() { + return used; + } + + /** + * Sets the value of the used property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setUsed(Long value) { + this.used = value; + } + + /** + * Gets the value of the overhead property. + * + * @return + * possible object is + * {@link Long } + * + */ + public Long getOverhead() { + return overhead; + } + + /** + * Sets the value of the overhead property. + * + * @param value + * allowed object is + * {@link Long } + * + */ + public void setOverhead(Long value) { + this.overhead = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CapacityWithUsage that = CapacityWithUsage.class.cast(o); + return equal(used, that.used) && + equal(overhead, that.overhead); + } + + @Override + public int hashCode() { + return Objects.hashCode(used, + overhead); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("used", used) + .add("overhead", overhead).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java new file mode 100644 index 0000000000..a762cdb3ca --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CaptureVAppParams.java @@ -0,0 +1,232 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.ovf.Section; + +import com.google.common.base.Objects; + + +/** + * + * Represents the parameters for capturing a vApp to a vApp template. + * + * + *

Java class for CaptureVAppParams complex type. + * + *

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

+ * <complexType name="CaptureVAppParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element ref="{http://schemas.dmtf.org/ovf/envelope/1}Section" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CaptureVAppParams", propOrder = { + "source", + "section" +}) +public class CaptureVAppParams + extends ParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCaptureVAppParams(this); + } + + public static class Builder extends ParamsType.Builder { + + private Reference source; + private List>> sections; + + /** + * @see CaptureVAppParams#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see CaptureVAppParams#getExtend() + */ + public Builder sections(List>> sections) { + this.sections = sections; + return this; + } + + + public CaptureVAppParams build() { + CaptureVAppParams captureVAppParams = new CaptureVAppParams(sections); + captureVAppParams.setSource(source); + return captureVAppParams; + } + + + @Override + public Builder fromParamsType(ParamsType in) { + return Builder.class.cast(super.fromParamsType(in)); + } + public Builder fromCaptureVAppParams(CaptureVAppParams in) { + return fromParamsType(in) + .source(in.getSource()) + .sections(in.getSections()); + } + } + + private CaptureVAppParams() { + // For JAXB and builder use + } + + private CaptureVAppParams(List>> sections) { + this.sections = sections; + } + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class) + protected List>> sections; + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link Reference } + * + */ + public Reference getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link Reference } + * + */ + public void setSource(Reference value) { + this.source = value; + } + + /** + * + * An ovf:Section to configure the captured vAppTemplate. + * 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 Section> }{@code >} + * {@link JAXBElement }{@code <}{@link VirtualHardwareSection> }{@code >} + * {@link JAXBElement }{@code <}{@link LeaseSettingsSection> }{@code >} + * {@link JAXBElement }{@code <}{@link EulaSection> }{@code >} + * {@link JAXBElement }{@code <}{@link RuntimeInfoSection> }{@code >} + * {@link JAXBElement }{@code <}{@link AnnotationSection> }{@code >} + * {@link JAXBElement }{@code <}{@link DeploymentOptionSection> }{@code >} + * {@link JAXBElement }{@code <}{@link StartupSection> }{@code >} + * {@link JAXBElement }{@code <}{@link ResourceAllocationSection> }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkConnectionSection> }{@code >} + * {@link JAXBElement }{@code <}{@link CustomizationSection> }{@code >} + * {@link JAXBElement }{@code <}{@link ProductSection> }{@code >} + * {@link JAXBElement }{@code <}{@link GuestCustomizationSection> }{@code >} + * {@link JAXBElement }{@code <}{@link OperatingSystemSection> }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkConfigSection> }{@code >} + * {@link JAXBElement }{@code <}{@link NetworkSection> }{@code >} + * {@link JAXBElement }{@code <}{@link DiskSection> }{@code >} + * {@link JAXBElement }{@code <}{@link InstallSection> }{@code >} + * + * + */ + public List>> getSections() { + if (sections == null) { + sections = new ArrayList>>(); + } + return this.sections; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CaptureVAppParams that = CaptureVAppParams.class.cast(o); + return equal(source, that.source) && + equal(sections, that.sections); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + sections); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("sections", sections).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java new file mode 100644 index 0000000000..f0434a1a42 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneMediaParams.java @@ -0,0 +1,200 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents parameters for copying a media resource and optionally + * deleting the source. + * + * + *

Java class for CloneMediaParams complex type. + * + *

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

+ * <complexType name="CloneMediaParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element name="IsSourceDelete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CloneMediaParams", propOrder = { + "source", + "isSourceDelete" +}) +public class CloneMediaParams + extends ParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCloneMediaParams(this); + } + + public static class Builder extends ParamsType.Builder { + + private Reference source; + private Boolean isSourceDelete; + + /** + * @see CloneMediaParams#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see CloneMediaParams#getIsSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + this.isSourceDelete = isSourceDelete; + return this; + } + + + public CloneMediaParams build() { + CloneMediaParams cloneMediaParams = new CloneMediaParams(); + cloneMediaParams.setSource(source); + cloneMediaParams.setIsSourceDelete(isSourceDelete); + return cloneMediaParams; + } + + + @Override + public Builder fromParamsType(ParamsType in) { + return Builder.class.cast(super.fromParamsType(in)); + } + public Builder fromCloneMediaParams(CloneMediaParams in) { + return fromParamsType(in) + .source(in.getSource()) + .isSourceDelete(in.isSourceDelete()); + } + } + + private CloneMediaParams() { + // For JAXB and builder use + } + + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElement(name = "IsSourceDelete") + protected Boolean isSourceDelete; + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link Reference } + * + */ + public Reference getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link Reference } + * + */ + public void setSource(Reference value) { + this.source = value; + } + + /** + * Gets the value of the isSourceDelete property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isSourceDelete() { + return isSourceDelete; + } + + /** + * Sets the value of the isSourceDelete property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setIsSourceDelete(Boolean value) { + this.isSourceDelete = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CloneMediaParams that = CloneMediaParams.class.cast(o); + return equal(source, that.source) && + equal(isSourceDelete, that.isSourceDelete); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + isSourceDelete); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("isSourceDelete", isSourceDelete).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java new file mode 100644 index 0000000000..1c3f3786f2 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java @@ -0,0 +1,107 @@ +/** + * 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 javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents parameters for copying a vApp and optionally deleting the source. + * + * + *

Java class for CloneVAppParams complex type. + * + *

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

+ * <complexType name="CloneVAppParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}InstantiateVAppParamsType">
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CloneVAppParams") +public class CloneVAppParams + extends InstantiateVAppParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCloneVAppParams(this); + } + + public static class Builder extends InstantiateVAppParamsType.Builder { + + + public CloneVAppParams build() { + CloneVAppParams cloneVAppParams = new CloneVAppParams(); + return cloneVAppParams; + } + + + @Override + public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { + return Builder.class.cast(super.fromInstantiateVAppParamsType(in)); + } + public Builder fromCloneVAppParams(CloneVAppParams in) { + return fromInstantiateVAppParamsType(in); + } + } + + private CloneVAppParams() { + // For JAXB and builder use + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CloneVAppParams that = CloneVAppParams.class.cast(o); + return super.equals(that); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(""); + } + + @Override + public String toString() { + return Objects.toStringHelper("").toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java new file mode 100644 index 0000000000..36d4b1de62 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppTemplateParams.java @@ -0,0 +1,200 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents parameters for copying a vApp template and optionally + * deleting the source. + * + * + *

Java class for CloneVAppTemplateParams complex type. + * + *

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

+ * <complexType name="CloneVAppTemplateParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element name="IsSourceDelete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "CloneVAppTemplateParams", propOrder = { + "source", + "isSourceDelete" +}) +public class CloneVAppTemplateParams + extends ParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromCloneVAppTemplateParams(this); + } + + public static class Builder extends ParamsType.Builder { + + private Reference source; + private Boolean isSourceDelete; + + /** + * @see CloneVAppTemplateParams#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see CloneVAppTemplateParams#getIsSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + this.isSourceDelete = isSourceDelete; + return this; + } + + + public CloneVAppTemplateParams build() { + CloneVAppTemplateParams cloneVAppTemplateParams = new CloneVAppTemplateParams(); + cloneVAppTemplateParams.setSource(source); + cloneVAppTemplateParams.setIsSourceDelete(isSourceDelete); + return cloneVAppTemplateParams; + } + + + @Override + public Builder fromParamsType(ParamsType in) { + return Builder.class.cast(super.fromParamsType(in)); + } + public Builder fromCloneVAppTemplateParams(CloneVAppTemplateParams in) { + return fromParamsType(in) + .source(in.getSource()) + .isSourceDelete(in.isSourceDelete()); + } + } + + private CloneVAppTemplateParams() { + // For JAXB and builder use + } + + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElement(name = "IsSourceDelete") + protected Boolean isSourceDelete; + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link Reference } + * + */ + public Reference getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link Reference } + * + */ + public void setSource(Reference value) { + this.source = value; + } + + /** + * Gets the value of the isSourceDelete property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isSourceDelete() { + return isSourceDelete; + } + + /** + * Sets the value of the isSourceDelete property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setIsSourceDelete(Boolean value) { + this.isSourceDelete = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + CloneVAppTemplateParams that = CloneVAppTemplateParams.class.cast(o); + return equal(source, that.source) && + equal(isSourceDelete, that.isSourceDelete); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + isSourceDelete); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("isSourceDelete", isSourceDelete).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java new file mode 100644 index 0000000000..de601f35c3 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComposeVAppParams.java @@ -0,0 +1,261 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.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; + + +/** + * + * Represents vApp composition parameters. + * + * + *

Java class for ComposeVAppParams complex type. + * + *

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

+ * <complexType name="ComposeVAppParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VAppCreationParamsType">
+ *       <sequence>
+ *         <element name="SourcedItem" type="{http://www.vmware.com/vcloud/v1.5}SourcedCompositionItemParamType" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element ref="{http://www.vmware.com/vcloud/v1.5}AllEULAsAccepted" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="linkedClone" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ComposeVAppParams", propOrder = { + "sourcedItem", + "allEULAsAccepted" +}) +@XmlSeeAlso({ +// RecomposeVAppParamsType.class +}) +public class ComposeVAppParams + extends VAppCreationParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromComposeVAppParams(this); + } + + public static class Builder extends VAppCreationParamsType.Builder { + + private List sourcedItem; + private Boolean allEULAsAccepted; + private Boolean linkedClone; + + /** + * @see ComposeVAppParams#getSourcedItem() + */ + public Builder sourcedItem(List sourcedItem) { + this.sourcedItem = sourcedItem; + return this; + } + + /** + * @see ComposeVAppParams#getAllEULAsAccepted() + */ + public Builder allEULAsAccepted(Boolean allEULAsAccepted) { + this.allEULAsAccepted = allEULAsAccepted; + return this; + } + + /** + * @see ComposeVAppParams#getLinkedClone() + */ + public Builder linkedClone(Boolean linkedClone) { + this.linkedClone = linkedClone; + return this; + } + + + public ComposeVAppParams build() { + ComposeVAppParams composeVAppParams = new ComposeVAppParams(sourcedItem); + composeVAppParams.setAllEULAsAccepted(allEULAsAccepted); + composeVAppParams.setLinkedClone(linkedClone); + return composeVAppParams; + } + + + @Override + public Builder fromVAppCreationParamsType(VAppCreationParamsType in) { + return Builder.class.cast(super.fromVAppCreationParamsType(in)); + } + public Builder fromComposeVAppParams(ComposeVAppParams in) { + return fromVAppCreationParamsType(in) + .sourcedItem(in.getSourcedItem()) + .allEULAsAccepted(in.isAllEULAsAccepted()) + .linkedClone(in.isLinkedClone()); + } + } + + private ComposeVAppParams() { + // For JAXB and builder use + } + + private ComposeVAppParams(List sourcedItem) { + this.sourcedItem = sourcedItem; + } + + + @XmlElement(name = "SourcedItem") + protected List sourcedItem; + @XmlElement(name = "AllEULAsAccepted") + protected Boolean allEULAsAccepted; + @XmlAttribute + protected Boolean linkedClone; + + /** + * Gets the value of the sourcedItem 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 sourcedItem property. + * + *

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

+     *    getSourcedItem().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link SourcedCompositionItemParamType } + * + * + */ + public List getSourcedItem() { + if (sourcedItem == null) { + sourcedItem = new ArrayList(); + } + return this.sourcedItem; + } + + /** + * + * Used to confirm acceptance of all EULAs in a + * vApp template. Instantiation fails if this + * element is missing, empty, or set to false + * and one or more EulaSection elements are + * present. + * + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isAllEULAsAccepted() { + return allEULAsAccepted; + } + + /** + * Sets the value of the allEULAsAccepted property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setAllEULAsAccepted(Boolean value) { + this.allEULAsAccepted = value; + } + + /** + * Gets the value of the linkedClone property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isLinkedClone() { + return linkedClone; + } + + /** + * Sets the value of the linkedClone property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setLinkedClone(Boolean value) { + this.linkedClone = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ComposeVAppParams that = ComposeVAppParams.class.cast(o); + return equal(sourcedItem, that.sourcedItem) && + equal(allEULAsAccepted, that.allEULAsAccepted) && + equal(linkedClone, that.linkedClone); + } + + @Override + public int hashCode() { + return Objects.hashCode(sourcedItem, + allEULAsAccepted, + linkedClone); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("sourcedItem", sourcedItem) + .add("allEULAsAccepted", allEULAsAccepted) + .add("linkedClone", linkedClone).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComputeCapacity.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComputeCapacity.java new file mode 100644 index 0000000000..0de0b3376c --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ComputeCapacity.java @@ -0,0 +1,190 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents a compute capacity with units. + * + * + *

Java class for ComputeCapacity complex type. + * + *

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

+ * <complexType name="ComputeCapacity">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Cpu" type="{http://www.vmware.com/vcloud/v1.5}CapacityWithUsageType"/>
+ *         <element name="Memory" type="{http://www.vmware.com/vcloud/v1.5}CapacityWithUsageType"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ComputeCapacity", propOrder = { + "cpu", + "memory" +}) +public class ComputeCapacity { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromComputeCapacity(this); + } + + public static class Builder { + + private CapacityWithUsage cpu; + private CapacityWithUsage memory; + + /** + * @see ComputeCapacity#getCpu() + */ + public Builder cpu(CapacityWithUsage cpu) { + this.cpu = cpu; + return this; + } + + /** + * @see ComputeCapacity#getMemory() + */ + public Builder memory(CapacityWithUsage memory) { + this.memory = memory; + return this; + } + + + public ComputeCapacity build() { + ComputeCapacity computeCapacity = new ComputeCapacity(); + computeCapacity.setCpu(cpu); + computeCapacity.setMemory(memory); + return computeCapacity; + } + + + public Builder fromComputeCapacity(ComputeCapacity in) { + return cpu(in.getCpu()) + .memory(in.getMemory()); + } + } + + private ComputeCapacity() { + // For JAXB and builder use + } + + + + @XmlElement(name = "Cpu", required = true) + protected CapacityWithUsage cpu; + @XmlElement(name = "Memory", required = true) + protected CapacityWithUsage memory; + + /** + * Gets the value of the cpu property. + * + * @return + * possible object is + * {@link CapacityWithUsage } + * + */ + public CapacityWithUsage getCpu() { + return cpu; + } + + /** + * Sets the value of the cpu property. + * + * @param value + * allowed object is + * {@link CapacityWithUsage } + * + */ + public void setCpu(CapacityWithUsage value) { + this.cpu = value; + } + + /** + * Gets the value of the memory property. + * + * @return + * possible object is + * {@link CapacityWithUsage } + * + */ + public CapacityWithUsage getMemory() { + return memory; + } + + /** + * Sets the value of the memory property. + * + * @param value + * allowed object is + * {@link CapacityWithUsage } + * + */ + public void setMemory(CapacityWithUsage value) { + this.memory = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ComputeCapacity that = ComputeCapacity.class.cast(o); + return equal(cpu, that.cpu) && + equal(memory, that.memory); + } + + @Override + public int hashCode() { + return Objects.hashCode(cpu, + memory); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("cpu", cpu) + .add("memory", memory).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java new file mode 100644 index 0000000000..a7db8f5db4 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java @@ -0,0 +1,248 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import 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; + + +/** + * + * Represents vApp instantiation parameters. + * + * + *

Java class for InstantiateVAppParams complex type. + * + *

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

+ * <complexType name="InstantiateVAppParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VAppCreationParamsType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element name="IsSourceDelete" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="linkedClone" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "InstantiateVAppParams", propOrder = { + "source", + "isSourceDelete" +}) +@XmlSeeAlso({ +// InstantiateVAppTemplateParamsType.class, +// CloneVAppParamsType.class +}) +public class InstantiateVAppParamsType> + extends VAppCreationParamsType + +{ + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromInstantiateVAppParamsType(this); + } + + public static class Builder> extends VAppCreationParamsType.Builder { + + private Reference source; + private Boolean isSourceDelete; + private Boolean linkedClone; + + /** + * @see InstantiateVAppParamsType#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see InstantiateVAppParamsType#getIsSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + this.isSourceDelete = isSourceDelete; + return this; + } + + /** + * @see InstantiateVAppParamsType#getLinkedClone() + */ + public Builder linkedClone(Boolean linkedClone) { + this.linkedClone = linkedClone; + return this; + } + + + public InstantiateVAppParamsType build() { + InstantiateVAppParamsType instantiateVAppParams = new InstantiateVAppParamsType(); + instantiateVAppParams.setSource(source); + instantiateVAppParams.setIsSourceDelete(isSourceDelete); + instantiateVAppParams.setLinkedClone(linkedClone); + return instantiateVAppParams; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public Builder fromVAppCreationParamsType(VAppCreationParamsType in) { + return Builder.class.cast(super.fromVAppCreationParamsType(in)); + } + public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { + return fromVAppCreationParamsType(in) + .source(in.getSource()) + .isSourceDelete(in.isSourceDelete()) + .linkedClone(in.isLinkedClone()); + } + } + + protected InstantiateVAppParamsType() { + // For JAXB and builder use + } + + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElement(name = "IsSourceDelete") + protected Boolean isSourceDelete; + @XmlAttribute + protected Boolean linkedClone; + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link Reference } + * + */ + public Reference getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link Reference } + * + */ + public void setSource(Reference value) { + this.source = value; + } + + /** + * Gets the value of the isSourceDelete property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isSourceDelete() { + return isSourceDelete; + } + + /** + * Sets the value of the isSourceDelete property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setIsSourceDelete(Boolean value) { + this.isSourceDelete = value; + } + + /** + * Gets the value of the linkedClone property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isLinkedClone() { + return linkedClone; + } + + /** + * Sets the value of the linkedClone property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setLinkedClone(Boolean value) { + this.linkedClone = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InstantiateVAppParamsType that = InstantiateVAppParamsType.class.cast(o); + return equal(source, that.source) && + equal(isSourceDelete, that.isSourceDelete) && + equal(linkedClone, that.linkedClone); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + isSourceDelete, + linkedClone); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("isSourceDelete", isSourceDelete) + .add("linkedClone", linkedClone).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParamsType.java new file mode 100644 index 0000000000..9849c47f60 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParamsType.java @@ -0,0 +1,165 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents vApp template instantiation parameters. + * + * + *

Java class for InstantiateVAppTemplateParams complex type. + * + *

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

+ * <complexType name="InstantiateVAppTemplateParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}InstantiateVAppParamsType">
+ *       <sequence>
+ *         <element ref="{http://www.vmware.com/vcloud/v1.5}AllEULAsAccepted" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "InstantiateVAppTemplateParams", propOrder = { + "allEULAsAccepted" +}) +public class InstantiateVAppTemplateParamsType> + extends InstantiateVAppParamsType + +{ + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromInstantiateVAppTemplateParams(this); + } + + public static class Builder> extends InstantiateVAppParamsType.Builder { + + private Boolean allEULAsAccepted; + + /** + * @see InstantiateVAppTemplateParamsType#getAllEULAsAccepted() + */ + public Builder allEULAsAccepted(Boolean allEULAsAccepted) { + this.allEULAsAccepted = allEULAsAccepted; + return this; + } + + + public InstantiateVAppTemplateParamsType build() { + InstantiateVAppTemplateParamsType instantiateVAppTemplateParams = new InstantiateVAppTemplateParamsType(); + instantiateVAppTemplateParams.setAllEULAsAccepted(allEULAsAccepted); + return instantiateVAppTemplateParams; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { + return Builder.class.cast(super.fromInstantiateVAppParamsType(in)); + } + public Builder fromInstantiateVAppTemplateParams(InstantiateVAppTemplateParamsType in) { + return fromInstantiateVAppParamsType(in) + .allEULAsAccepted(in.isAllEULAsAccepted()); + } + } + + private InstantiateVAppTemplateParamsType() { + // For JAXB and builder use + } + + + + @XmlElement(name = "AllEULAsAccepted") + protected Boolean allEULAsAccepted; + + /** + * + * Used to confirm acceptance of all EULAs in a + * vApp template. Instantiation fails if this + * element is missing, empty, or set to false + * and one or more EulaSection elements are + * present. + * + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isAllEULAsAccepted() { + return allEULAsAccepted; + } + + /** + * Sets the value of the allEULAsAccepted property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setAllEULAsAccepted(Boolean value) { + this.allEULAsAccepted = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InstantiateVAppTemplateParamsType that = InstantiateVAppTemplateParamsType.class.cast(o); + return equal(allEULAsAccepted, that.allEULAsAccepted); + } + + @Override + public int hashCode() { + return Objects.hashCode(allEULAsAccepted); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("allEULAsAccepted", allEULAsAccepted).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java new file mode 100644 index 0000000000..af0ab6754b --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiationParams.java @@ -0,0 +1,180 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.ovf.Section; + +import com.google.common.base.Objects; + + +/** + * + * Represents a list of ovf:Section to configure for instantiating a VApp. + * + * + *

Java class for InstantiationParams complex type. + * + *

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

+ * <complexType name="InstantiationParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element ref="{http://schemas.dmtf.org/ovf/envelope/1}Section" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "InstantiationParams", propOrder = { + "section" +}) +public class InstantiationParams { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromInstantiationParams(this); + } + + public static class Builder { + + private List>> sections; + + /** + * @see InstantiationParams#getExtend() + */ + public Builder sections(List>> sections) { + this.sections = sections; + return this; + } + + + public InstantiationParams build() { + InstantiationParams instantiationParams = new InstantiationParams(sections); + return instantiationParams; + } + + + public Builder fromInstantiationParams(InstantiationParams in) { + return sections(in.getSections()); + } + } + + private InstantiationParams() { + // For JAXB and builder use + } + + private InstantiationParams(List>> sections) { + this.sections = sections; + } + + + @XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class) + protected List>> sections; + + /** + * + * An ovf:Section to configure for instantiation. + * 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>> getSections() { + if (sections == null) { + sections = new ArrayList>>(); + } + return this.sections; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InstantiationParams that = InstantiationParams.class.cast(o); + return equal(sections, that.sections); + } + + @Override + public int hashCode() { + return Objects.hashCode(sections); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("sections", sections).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java new file mode 100644 index 0000000000..77eec2e6e6 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkAssignment.java @@ -0,0 +1,188 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents mapping between a VM and vApp network. + * + * + *

Java class for NetworkAssignment complex type. + * + *

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

+ * <complexType name="NetworkAssignment">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <attribute name="innerNetwork" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="containerNetwork" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "NetworkAssignment") +public class NetworkAssignment + + +{ + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkAssignment(this); + } + + public static class Builder { + + private String innerNetwork; + private String containerNetwork; + + /** + * @see NetworkAssignment#getInnerNetwork() + */ + public Builder innerNetwork(String innerNetwork) { + this.innerNetwork = innerNetwork; + return this; + } + + /** + * @see NetworkAssignment#getContainerNetwork() + */ + public Builder containerNetwork(String containerNetwork) { + this.containerNetwork = containerNetwork; + return this; + } + + + public NetworkAssignment build() { + NetworkAssignment networkAssignment = new NetworkAssignment(); + networkAssignment.setInnerNetwork(innerNetwork); + networkAssignment.setContainerNetwork(containerNetwork); + return networkAssignment; + } + + + public Builder fromNetworkAssignment(NetworkAssignment in) { + return innerNetwork(in.getInnerNetwork()) + .containerNetwork(in.getContainerNetwork()); + } + } + + private NetworkAssignment() { + // For JAXB and builder use + } + + + + @XmlAttribute(required = true) + protected String innerNetwork; + @XmlAttribute(required = true) + protected String containerNetwork; + + /** + * Gets the value of the innerNetwork property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getInnerNetwork() { + return innerNetwork; + } + + /** + * Sets the value of the innerNetwork property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setInnerNetwork(String value) { + this.innerNetwork = value; + } + + /** + * Gets the value of the containerNetwork property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getContainerNetwork() { + return containerNetwork; + } + + /** + * Sets the value of the containerNetwork property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setContainerNetwork(String value) { + this.containerNetwork = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + NetworkAssignment that = NetworkAssignment.class.cast(o); + return equal(innerNetwork, that.innerNetwork) && + equal(containerNetwork, that.containerNetwork); + } + + @Override + public int hashCode() { + return Objects.hashCode(innerNetwork, + containerNetwork); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("innerNetwork", innerNetwork) + .add("containerNetwork", containerNetwork).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java new file mode 100644 index 0000000000..83542c3017 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java @@ -0,0 +1,201 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import 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; + + +/** + * + * A basic type used to specify parameters for operations. + * + * + *

Java class for Params complex type. + * + *

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

+ * <complexType name="Params">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Params", propOrder = { + "description" +}) +@XmlSeeAlso({ +// CaptureVAppParams.class, +// CloneVAppTemplateParams.class, +// CloneMediaParams.class, +// UploadVAppTemplateParams.class, +// ImportVmAsVAppTemplateParams.class, +// ImportMediaParams.class, +// UpdateResourcePoolSetParams.class, +// VAppCreationParams.class +}) +public class ParamsType> { + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromParamsType(this); + } + + public static class Builder>{ + + private String description; + private String name; + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + + public ParamsType build() { + ParamsType params = new ParamsType(); + params.setDescription(description); + params.setName(name); + return params; + } + + + public Builder fromParamsType(ParamsType in) { + return description(in.getDescription()) + .name(in.getName()); + } + } + + protected ParamsType() { + // For JAXB and builder use + } + + + + @XmlElement(name = "Description") + protected String description; + @XmlAttribute + protected String name; + + /** + * Gets the value of the description property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDescription() { + return description; + } + + /** + * Sets the value of the description property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDescription(String value) { + this.description = value; + } + + /** + * 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; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ParamsType that = ParamsType.class.cast(o); + return equal(description, that.description) && + equal(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hashCode(description, + name); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("description", description) + .add("name", name).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java new file mode 100644 index 0000000000..e16805bfa6 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java @@ -0,0 +1,158 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents a list of references to resource entities. + * + * + *

Java class for ResourceEntities complex type. + * + *

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

+ * <complexType name="ResourceEntities">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="ResourceEntity" type="{http://www.vmware.com/vcloud/v1.5}ReferenceTypeType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ResourceEntities", propOrder = { + "resourceEntity" +}) +public class ResourceEntities { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromResourceEntities(this); + } + + public static class Builder { + + private List> resourceEntity; + + /** + * @see ResourceEntities#getResourceEntity() + */ + public Builder resourceEntity(List> resourceEntity) { + this.resourceEntity = resourceEntity; + return this; + } + + + public ResourceEntities build() { + ResourceEntities resourceEntities = new ResourceEntities(resourceEntity); + return resourceEntities; + } + + + public Builder fromResourceEntities(ResourceEntities in) { + return resourceEntity(in.getResourceEntity()); + } + } + + private ResourceEntities() { + // For JAXB and builder use + } + + private ResourceEntities(List> resourceEntity) { + this.resourceEntity = resourceEntity; + } + + + @XmlElement(name = "ResourceEntity") + protected List> resourceEntity; + + /** + * Gets the value of the resourceEntity 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 resourceEntity property. + * + *

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

+     *    getResourceEntity().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link ReferenceTypeType } + * + * + */ + public List> getResourceEntity() { + if (resourceEntity == null) { + resourceEntity = new ArrayList>(); + } + return this.resourceEntity; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ResourceEntities that = ResourceEntities.class.cast(o); + return equal(resourceEntity, that.resourceEntity); + } + + @Override + public int hashCode() { + return Objects.hashCode(resourceEntity); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("resourceEntity", resourceEntity).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java new file mode 100644 index 0000000000..c52936f972 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SourcedCompositionItemParam.java @@ -0,0 +1,326 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents a composition item. + * + * + *

Java class for SourcedCompositionItemParam complex type. + * + *

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

+ * <complexType name="SourcedCompositionItemParam">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Source" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
+ *         <element name="VAppScopedLocalId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="InstantiationParams" type="{http://www.vmware.com/vcloud/v1.5}InstantiationParamsType" minOccurs="0"/>
+ *         <element name="NetworkAssignment" type="{http://www.vmware.com/vcloud/v1.5}NetworkAssignmentType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="sourceDelete" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SourcedCompositionItemParam", propOrder = { + "source", + "vAppScopedLocalId", + "instantiationParams", + "networkAssignment" +}) +public class SourcedCompositionItemParam { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromSourcedCompositionItemParam(this); + } + + public static class Builder { + + private Reference source; + private String vAppScopedLocalId; + private InstantiationParams instantiationParams; + private List networkAssignment; + private Boolean sourceDelete; + + /** + * @see SourcedCompositionItemParam#getSource() + */ + public Builder source(Reference source) { + this.source = source; + return this; + } + + /** + * @see SourcedCompositionItemParam#getVAppScopedLocalId() + */ + public Builder vAppScopedLocalId(String vAppScopedLocalId) { + this.vAppScopedLocalId = vAppScopedLocalId; + return this; + } + + /** + * @see SourcedCompositionItemParam#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + this.instantiationParams = instantiationParams; + return this; + } + + /** + * @see SourcedCompositionItemParam#getNetworkAssignment() + */ + public Builder networkAssignment(List networkAssignment) { + this.networkAssignment = networkAssignment; + return this; + } + + /** + * @see SourcedCompositionItemParam#getSourceDelete() + */ + public Builder sourceDelete(Boolean sourceDelete) { + this.sourceDelete = sourceDelete; + return this; + } + + + public SourcedCompositionItemParam build() { + SourcedCompositionItemParam sourcedCompositionItemParam = new SourcedCompositionItemParam(networkAssignment); + sourcedCompositionItemParam.setSource(source); + sourcedCompositionItemParam.setVAppScopedLocalId(vAppScopedLocalId); + sourcedCompositionItemParam.setInstantiationParams(instantiationParams); + sourcedCompositionItemParam.setSourceDelete(sourceDelete); + return sourcedCompositionItemParam; + } + + + public Builder fromSourcedCompositionItemParam(SourcedCompositionItemParam in) { + return source(in.getSource()) + .vAppScopedLocalId(in.getVAppScopedLocalId()) + .instantiationParams(in.getInstantiationParams()) + .networkAssignment(in.getNetworkAssignment()) + .sourceDelete(in.isSourceDelete()); + } + } + + private SourcedCompositionItemParam() { + // For JAXB and builder use + } + + private SourcedCompositionItemParam(List networkAssignment) { + this.networkAssignment = networkAssignment; + } + + + @XmlElement(name = "Source", required = true) + protected Reference source; + @XmlElement(name = "VAppScopedLocalId") + protected String vAppScopedLocalId; + @XmlElement(name = "InstantiationParams") + protected InstantiationParams instantiationParams; + @XmlElement(name = "NetworkAssignment") + protected List networkAssignment; + @XmlAttribute + protected Boolean sourceDelete; + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link Reference } + * + */ + public Reference getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link Reference } + * + */ + public void setSource(Reference value) { + this.source = value; + } + + /** + * Gets the value of the vAppScopedLocalId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVAppScopedLocalId() { + return vAppScopedLocalId; + } + + /** + * Sets the value of the vAppScopedLocalId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVAppScopedLocalId(String value) { + this.vAppScopedLocalId = value; + } + + /** + * Gets the value of the instantiationParams property. + * + * @return + * possible object is + * {@link InstantiationParams } + * + */ + public InstantiationParams getInstantiationParams() { + return instantiationParams; + } + + /** + * Sets the value of the instantiationParams property. + * + * @param value + * allowed object is + * {@link InstantiationParams } + * + */ + public void setInstantiationParams(InstantiationParams value) { + this.instantiationParams = value; + } + + /** + * Gets the value of the networkAssignment 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 networkAssignment property. + * + *

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

+     *    getNetworkAssignment().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link NetworkAssignmentType } + * + * + */ + public List getNetworkAssignment() { + if (networkAssignment == null) { + networkAssignment = new ArrayList(); + } + return this.networkAssignment; + } + + /** + * Gets the value of the sourceDelete property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isSourceDelete() { + return sourceDelete; + } + + /** + * Sets the value of the sourceDelete property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setSourceDelete(Boolean value) { + this.sourceDelete = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + SourcedCompositionItemParam that = SourcedCompositionItemParam.class.cast(o); + return equal(source, that.source) && + equal(vAppScopedLocalId, that.vAppScopedLocalId) && + equal(instantiationParams, that.instantiationParams) && + equal(networkAssignment, that.networkAssignment) && + equal(sourceDelete, that.sourceDelete); + } + + @Override + public int hashCode() { + return Objects.hashCode(source, + vAppScopedLocalId, + instantiationParams, + networkAssignment, + sourceDelete); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("source", source) + .add("vAppScopedLocalId", vAppScopedLocalId) + .add("instantiationParams", instantiationParams) + .add("networkAssignment", networkAssignment) + .add("sourceDelete", sourceDelete).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java new file mode 100644 index 0000000000..8dc1a6fadf --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java @@ -0,0 +1,158 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents a list of supported VM hardware versions. + * + * + *

Java class for SupportedHardwareVersions complex type. + * + *

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

+ * <complexType name="SupportedHardwareVersions">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="SupportedHardwareVersion" type="{http://www.vmware.com/vcloud/v1.5}SupportedHardwareVersionType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "SupportedHardwareVersions", propOrder = { + "supportedHardwareVersion" +}) +public class SupportedHardwareVersions { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromSupportedHardwareVersions(this); + } + + public static class Builder { + + private List supportedHardwareVersion; + + /** + * @see SupportedHardwareVersions#getSupportedHardwareVersion() + */ + public Builder supportedHardwareVersion(List supportedHardwareVersion) { + this.supportedHardwareVersion = supportedHardwareVersion; + return this; + } + + + public SupportedHardwareVersions build() { + SupportedHardwareVersions supportedHardwareVersions = new SupportedHardwareVersions(supportedHardwareVersion); + return supportedHardwareVersions; + } + + + public Builder fromSupportedHardwareVersions(SupportedHardwareVersions in) { + return supportedHardwareVersion(in.getSupportedHardwareVersion()); + } + } + + private SupportedHardwareVersions() { + // For JAXB and builder use + } + + private SupportedHardwareVersions(List supportedHardwareVersion) { + this.supportedHardwareVersion = supportedHardwareVersion; + } + + + @XmlElement(name = "SupportedHardwareVersion") + protected List supportedHardwareVersion; + + /** + * Gets the value of the supportedHardwareVersion 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 supportedHardwareVersion property. + * + *

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

+     *    getSupportedHardwareVersion().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getSupportedHardwareVersion() { + if (supportedHardwareVersion == null) { + supportedHardwareVersion = new ArrayList(); + } + return this.supportedHardwareVersion; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + SupportedHardwareVersions that = SupportedHardwareVersions.class.cast(o); + return equal(supportedHardwareVersion, that.supportedHardwareVersion); + } + + @Override + public int hashCode() { + return Objects.hashCode(supportedHardwareVersion); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("supportedHardwareVersion", supportedHardwareVersion).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java new file mode 100644 index 0000000000..9ec25e2d77 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/UploadVAppTemplateParams.java @@ -0,0 +1,194 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents vApp Template upload parameters. + * + * + *

Java class for UploadVAppTemplateParams complex type. + * + *

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

+ * <complexType name="UploadVAppTemplateParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
+ *       <attribute name="transferFormat" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="manifestRequired" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "UploadVAppTemplateParams") +public class UploadVAppTemplateParams + extends ParamsType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromUploadVAppTemplateParams(this); + } + + public static class Builder extends ParamsType.Builder { + + private String transferFormat; + private Boolean manifestRequired; + + /** + * @see UploadVAppTemplateParams#getTransferFormat() + */ + public Builder transferFormat(String transferFormat) { + this.transferFormat = transferFormat; + return this; + } + + /** + * @see UploadVAppTemplateParams#getManifestRequired() + */ + public Builder manifestRequired(Boolean manifestRequired) { + this.manifestRequired = manifestRequired; + return this; + } + + + public UploadVAppTemplateParams build() { + UploadVAppTemplateParams uploadVAppTemplateParams = new UploadVAppTemplateParams(); + uploadVAppTemplateParams.setTransferFormat(transferFormat); + uploadVAppTemplateParams.setManifestRequired(manifestRequired); + return uploadVAppTemplateParams; + } + + + @Override + public Builder fromParamsType(ParamsType in) { + return Builder.class.cast(super.fromParamsType(in)); + } + public Builder fromUploadVAppTemplateParams(UploadVAppTemplateParams in) { + return fromParamsType(in) + .transferFormat(in.getTransferFormat()) + .manifestRequired(in.isManifestRequired()); + } + } + + private UploadVAppTemplateParams() { + // For JAXB and builder use + } + + + + @XmlAttribute + protected String transferFormat; + @XmlAttribute + protected Boolean manifestRequired; + + /** + * Gets the value of the transferFormat property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTransferFormat() { + return transferFormat; + } + + /** + * Sets the value of the transferFormat property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTransferFormat(String value) { + this.transferFormat = value; + } + + /** + * Gets the value of the manifestRequired property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isManifestRequired() { + return manifestRequired; + } + + /** + * Sets the value of the manifestRequired property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setManifestRequired(Boolean value) { + this.manifestRequired = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + UploadVAppTemplateParams that = UploadVAppTemplateParams.class.cast(o); + return equal(transferFormat, that.transferFormat) && + equal(manifestRequired, that.manifestRequired); + } + + @Override + public int hashCode() { + return Objects.hashCode(transferFormat, + manifestRequired); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("transferFormat", transferFormat) + .add("manifestRequired", manifestRequired).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java new file mode 100644 index 0000000000..5f5b97518d --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java @@ -0,0 +1,289 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import 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; + + +/** + * + * Represents vApp creation parameters. + * + * + *

Java class for VAppCreationParams complex type. + * + *

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

+ * <complexType name="VAppCreationParams">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ParamsType">
+ *       <sequence>
+ *         <element name="VAppParent" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" minOccurs="0"/>
+ *         <element name="InstantiationParams" type="{http://www.vmware.com/vcloud/v1.5}InstantiationParamsType" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="deploy" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <attribute name="powerOn" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "VAppCreationParams", propOrder = { + "vAppParent", + "instantiationParams" +}) +@XmlSeeAlso({ +// InstantiateOvfParamsType.class, +// ComposeVAppParamsType.class, +// InstantiateVAppParamsType.class, +// ImportVmAsVAppParamsType.class +}) +public class VAppCreationParamsType> + extends ParamsType + +{ + public static > Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromVAppCreationParamsType(this); + } + + public static class Builder> extends ParamsType.Builder { + + private Reference vAppParent; + private InstantiationParams instantiationParams; + private Boolean deploy; + private Boolean powerOn; + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + this.vAppParent = vAppParent; + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + this.instantiationParams = instantiationParams; + return this; + } + + /** + * @see VAppCreationParamsType#getDeploy() + */ + public Builder deploy(Boolean deploy) { + this.deploy = deploy; + return this; + } + + /** + * @see VAppCreationParamsType#getPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + this.powerOn = powerOn; + return this; + } + + + public VAppCreationParamsType build() { + VAppCreationParamsType vAppCreationParams = new VAppCreationParamsType(); + vAppCreationParams.setVAppParent(vAppParent); + vAppCreationParams.setInstantiationParams(instantiationParams); + vAppCreationParams.setDeploy(deploy); + vAppCreationParams.setPowerOn(powerOn); + return vAppCreationParams; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public Builder fromParamsType(ParamsType in) { + return Builder.class.cast(super.fromParamsType(in)); + } + public Builder fromVAppCreationParamsType(VAppCreationParamsType in) { + return fromParamsType(in) + .vAppParent(in.getVAppParent()) + .instantiationParams(in.getInstantiationParams()) + .deploy(in.isDeploy()) + .powerOn(in.isPowerOn()); + } + } + + protected VAppCreationParamsType() { + // For JAXB and builder use + } + + @XmlElement(name = "VAppParent") + protected Reference vAppParent; + @XmlElement(name = "InstantiationParams") + protected InstantiationParams instantiationParams; + @XmlAttribute + protected Boolean deploy; + @XmlAttribute + protected Boolean powerOn; + + /** + * Gets the value of the vAppParent property. + * + * @return + * possible object is + * {@link Reference } + * + */ + public Reference getVAppParent() { + return vAppParent; + } + + /** + * Sets the value of the vAppParent property. + * + * @param value + * allowed object is + * {@link Reference } + * + */ + public void setVAppParent(Reference value) { + this.vAppParent = value; + } + + /** + * Gets the value of the instantiationParams property. + * + * @return + * possible object is + * {@link InstantiationParams } + * + */ + public InstantiationParams getInstantiationParams() { + return instantiationParams; + } + + /** + * Sets the value of the instantiationParams property. + * + * @param value + * allowed object is + * {@link InstantiationParams } + * + */ + public void setInstantiationParams(InstantiationParams value) { + this.instantiationParams = value; + } + + /** + * Gets the value of the deploy property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isDeploy() { + return deploy; + } + + /** + * Sets the value of the deploy property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setDeploy(Boolean value) { + this.deploy = value; + } + + /** + * Gets the value of the powerOn property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isPowerOn() { + return powerOn; + } + + /** + * Sets the value of the powerOn property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setPowerOn(Boolean value) { + this.powerOn = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + VAppCreationParamsType that = VAppCreationParamsType.class.cast(o); + return equal(vAppParent, that.vAppParent) && + equal(instantiationParams, that.instantiationParams) && + equal(deploy, that.deploy) && + equal(powerOn, that.powerOn); + } + + @Override + public int hashCode() { + return Objects.hashCode(vAppParent, + instantiationParams, + deploy, + powerOn); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("vAppParent", vAppParent) + .add("instantiationParams", instantiationParams) + .add("deploy", deploy) + .add("powerOn", powerOn).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java new file mode 100644 index 0000000000..249e17c3d0 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplate.java @@ -0,0 +1,403 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXBElement; +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.XmlElementRef; +import javax.xml.bind.annotation.XmlType; + +import org.jclouds.ovf.Section; + +import com.google.common.base.Objects; + + +/** + * + * Represents a vApp template. + * + * + *

Java class for VAppTemplate complex type. + * + *

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

+ * <complexType name="VAppTemplate">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}ResourceEntityType">
+ *       <sequence>
+ *         <element name="Owner" type="{http://www.vmware.com/vcloud/v1.5}OwnerType" minOccurs="0"/>
+ *         <element name="Children" type="{http://www.vmware.com/vcloud/v1.5}VAppTemplateChildrenType" minOccurs="0"/>
+ *         <element ref="{http://schemas.dmtf.org/ovf/envelope/1}Section" maxOccurs="unbounded" minOccurs="0"/>
+ *         <element name="VAppScopedLocalId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="ovfDescriptorUploaded" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <attribute name="goldMaster" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "VAppTemplate", propOrder = { + "owner", + "children", + "section", + "vAppScopedLocalId" +}) +public class VAppTemplate + extends ResourceEntityType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromVAppTemplate(this); + } + + public static class Builder extends ResourceEntityType.Builder { + + private Owner owner; + private VAppTemplateChildren children; + private List>> sections; + private String vAppScopedLocalId; + private Boolean ovfDescriptorUploaded; + private Boolean goldMaster; + + /** + * @see VAppTemplate#getOwner() + */ + public Builder owner(Owner owner) { + this.owner = owner; + return this; + } + + /** + * @see VAppTemplate#getChildren() + */ + public Builder children(VAppTemplateChildren children) { + this.children = children; + return this; + } + + /** + * @see VAppTemplate#getExtend() + */ + public Builder extend(List>> sections) { + this.sections = sections; + return this; + } + + /** + * @see VAppTemplate#getVAppScopedLocalId() + */ + public Builder vAppScopedLocalId(String vAppScopedLocalId) { + this.vAppScopedLocalId = vAppScopedLocalId; + return this; + } + + /** + * @see VAppTemplate#getOvfDescriptorUploaded() + */ + public Builder ovfDescriptorUploaded(Boolean ovfDescriptorUploaded) { + this.ovfDescriptorUploaded = ovfDescriptorUploaded; + return this; + } + + /** + * @see VAppTemplate#getGoldMaster() + */ + public Builder goldMaster(Boolean goldMaster) { + this.goldMaster = goldMaster; + return this; + } + + + public VAppTemplate build() { + VAppTemplate vAppTemplate = new VAppTemplate(sections); + vAppTemplate.setOwner(owner); + vAppTemplate.setChildren(children); + vAppTemplate.setVAppScopedLocalId(vAppScopedLocalId); + vAppTemplate.setOvfDescriptorUploaded(ovfDescriptorUploaded); + vAppTemplate.setGoldMaster(goldMaster); + return vAppTemplate; + } + + + @Override + public Builder fromResourceEntityType(ResourceEntityType in) { + return Builder.class.cast(super.fromResourceEntityType(in)); + } + public Builder fromVAppTemplate(VAppTemplate in) { + return fromResourceEntityType(in) + .owner(in.getOwner()) + .children(in.getChildren()) + .extend(in.getSections()) + .vAppScopedLocalId(in.getVAppScopedLocalId()) + .ovfDescriptorUploaded(in.isOvfDescriptorUploaded()) + .goldMaster(in.isGoldMaster()); + } + } + + private VAppTemplate() { + // For JAXB and builder use + } + + private VAppTemplate(List>> sections) { + this.sections = sections; + } + + + @XmlElement(name = "Owner") + protected Owner owner; + @XmlElement(name = "Children") + protected VAppTemplateChildren children; + @XmlElementRef(name = "Section", namespace = "http://schemas.dmtf.org/ovf/envelope/1", type = JAXBElement.class) + protected List>> sections; + @XmlElement(name = "VAppScopedLocalId") + protected String vAppScopedLocalId; + @XmlAttribute + protected Boolean ovfDescriptorUploaded; + @XmlAttribute + protected Boolean goldMaster; + + /** + * 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 children property. + * + * @return + * possible object is + * {@link VAppTemplateChildren } + * + */ + public VAppTemplateChildren getChildren() { + return children; + } + + /** + * Sets the value of the children property. + * + * @param value + * allowed object is + * {@link VAppTemplateChildren } + * + */ + public void setChildren(VAppTemplateChildren value) { + this.children = value; + } + + /** + * + * Contains ovf sections for vApp template. + * 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>> getSections() { + if (sections == null) { + sections = new ArrayList>>(); + } + return this.sections; + } + + /** + * Gets the value of the vAppScopedLocalId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVAppScopedLocalId() { + return vAppScopedLocalId; + } + + /** + * Sets the value of the vAppScopedLocalId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVAppScopedLocalId(String value) { + this.vAppScopedLocalId = 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; + } + + /** + * Gets the value of the goldMaster property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public boolean isGoldMaster() { + if (goldMaster == null) { + return false; + } else { + return goldMaster; + } + } + + /** + * Sets the value of the goldMaster property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setGoldMaster(Boolean value) { + this.goldMaster = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + VAppTemplate that = VAppTemplate.class.cast(o); + return equal(owner, that.owner) && + equal(children, that.children) && + equal(sections, that.sections) && + equal(vAppScopedLocalId, that.vAppScopedLocalId) && + equal(ovfDescriptorUploaded, that.ovfDescriptorUploaded) && + equal(goldMaster, that.goldMaster); + } + + @Override + public int hashCode() { + return Objects.hashCode(owner, + children, + sections, + vAppScopedLocalId, + ovfDescriptorUploaded, + goldMaster); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("owner", owner) + .add("children", children) + .add("sections", sections) + .add("vAppScopedLocalId", vAppScopedLocalId) + .add("ovfDescriptorUploaded", ovfDescriptorUploaded) + .add("goldMaster", goldMaster).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplateChildren.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplateChildren.java new file mode 100644 index 0000000000..3adf7a0054 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppTemplateChildren.java @@ -0,0 +1,158 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; + + +/** + * + * Represents vApp template children. + * + * + *

Java class for VAppTemplateChildren complex type. + * + *

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

+ * <complexType name="VAppTemplateChildren">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
+ *       <sequence>
+ *         <element name="Vm" type="{http://www.vmware.com/vcloud/v1.5}VAppTemplateType" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "VAppTemplateChildren", propOrder = { + "vm" +}) +public class VAppTemplateChildren { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromVAppTemplateChildren(this); + } + + public static class Builder { + + private List vm; + + /** + * @see VAppTemplateChildren#getVm() + */ + public Builder vm(List vm) { + this.vm = vm; + return this; + } + + + public VAppTemplateChildren build() { + VAppTemplateChildren vAppTemplateChildren = new VAppTemplateChildren(vm); + return vAppTemplateChildren; + } + + + public Builder fromVAppTemplateChildren(VAppTemplateChildren in) { + return vm(in.getVm()); + } + } + + private VAppTemplateChildren() { + // For JAXB and builder use + } + + private VAppTemplateChildren(List vm) { + this.vm = vm; + } + + + @XmlElement(name = "Vm") + protected List vm; + + /** + * Gets the value of the vm 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 vm property. + * + *

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

+     *    getVm().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link VAppTemplateType } + * + * + */ + public List getVm() { + if (vm == null) { + vm = new ArrayList(); + } + return this.vm; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + VAppTemplateChildren that = VAppTemplateChildren.class.cast(o); + return equal(vm, that.vm); + } + + @Override + public int hashCode() { + return Objects.hashCode(vm); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("vm", vm).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java new file mode 100644 index 0000000000..8dc3910417 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java @@ -0,0 +1,624 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; + +import com.google.common.base.Objects; +import com.google.common.collect.Sets; + + +/** + * + * Represents a virtual data center (vDC). + * + * + *

Java class for Vdc complex type. + * + *

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

+ * <complexType name="Vdc">
+ *   <complexContent>
+ *     <extension base="{http://www.vmware.com/vcloud/v1.5}EntityType">
+ *       <sequence>
+ *         <element name="AllocationModel" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="StorageCapacity" type="{http://www.vmware.com/vcloud/v1.5}CapacityWithUsageType"/>
+ *         <element name="ComputeCapacity" type="{http://www.vmware.com/vcloud/v1.5}ComputeCapacityType"/>
+ *         <element name="ResourceEntities" type="{http://www.vmware.com/vcloud/v1.5}ResourceEntitiesType" minOccurs="0"/>
+ *         <element name="AvailableNetworks" type="{http://www.vmware.com/vcloud/v1.5}AvailableNetworksType" minOccurs="0"/>
+ *         <element name="Capabilities" type="{http://www.vmware.com/vcloud/v1.5}CapabilitiesType" minOccurs="0"/>
+ *         <element name="NicQuota" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="NetworkQuota" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="VmQuota" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
+ *         <element name="IsEnabled" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *       </sequence>
+ *       <attribute name="status" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <anyAttribute processContents='lax' namespace='##other'/>
+ *     </extension>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "Vdc", propOrder = { + "allocationModel", + "storageCapacity", + "computeCapacity", + "resourceEntities", + "availableNetworks", + "capabilities", + "nicQuota", + "networkQuota", + "vmQuota", + "isEnabled" +}) +@XmlSeeAlso({ +// AdminVdc.class +}) +public class Vdc + extends EntityType + +{ + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromVdc(this); + } + + public static class Builder extends EntityType.Builder { + + private String allocationModel; + private CapacityWithUsage storageCapacity; + private ComputeCapacity computeCapacity; + private ResourceEntities resourceEntities; + private AvailableNetworks availableNetworks; + private Capabilities capabilities; + private int nicQuota; + private int networkQuota; + private Integer vmQuota; + private Boolean isEnabled; + private Integer status; + + /** + * @see Vdc#getAllocationModel() + */ + public Builder allocationModel(String allocationModel) { + this.allocationModel = allocationModel; + return this; + } + + /** + * @see Vdc#getStorageCapacity() + */ + public Builder storageCapacity(CapacityWithUsage storageCapacity) { + this.storageCapacity = storageCapacity; + return this; + } + + /** + * @see Vdc#getComputeCapacity() + */ + public Builder computeCapacity(ComputeCapacity computeCapacity) { + this.computeCapacity = computeCapacity; + return this; + } + + /** + * @see Vdc#getResourceEntities() + */ + public Builder resourceEntities(ResourceEntities resourceEntities) { + this.resourceEntities = resourceEntities; + return this; + } + + /** + * @see Vdc#getAvailableNetworks() + */ + public Builder availableNetworks(AvailableNetworks availableNetworks) { + this.availableNetworks = availableNetworks; + return this; + } + + /** + * @see Vdc#getCapabilities() + */ + public Builder capabilities(Capabilities capabilities) { + this.capabilities = capabilities; + return this; + } + + /** + * @see Vdc#getNicQuota() + */ + public Builder nicQuota(int nicQuota) { + this.nicQuota = nicQuota; + return this; + } + + /** + * @see Vdc#getNetworkQuota() + */ + public Builder networkQuota(int networkQuota) { + this.networkQuota = networkQuota; + return this; + } + + /** + * @see Vdc#getVmQuota() + */ + public Builder vmQuota(Integer vmQuota) { + this.vmQuota = vmQuota; + return this; + } + + /** + * @see Vdc#isEnabled() + */ + public Builder isEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + return this; + } + + /** + * @see Vdc#getStatus() + */ + public Builder status(Integer status) { + this.status = status; + return this; + } + + + public Vdc build() { + Vdc vdc = new Vdc(); + vdc.setAllocationModel(allocationModel); + vdc.setStorageCapacity(storageCapacity); + vdc.setComputeCapacity(computeCapacity); + vdc.setResourceEntities(resourceEntities); + vdc.setAvailableNetworks(availableNetworks); + vdc.setCapabilities(capabilities); + vdc.setNicQuota(nicQuota); + vdc.setNetworkQuota(networkQuota); + vdc.setVmQuota(vmQuota); + vdc.setIsEnabled(isEnabled); + vdc.setStatus(status); + return vdc; + } + + + /** + * @see EntityType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasksInProgress() + */ + @Override + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; + return this; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + + @Override + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); + } + public Builder fromVdc(Vdc in) { + return fromEntityType(in) + .allocationModel(in.getAllocationModel()) + .storageCapacity(in.getStorageCapacity()) + .computeCapacity(in.getComputeCapacity()) + .resourceEntities(in.getResourceEntities()) + .availableNetworks(in.getAvailableNetworks()) + .capabilities(in.getCapabilities()) + .nicQuota(in.getNicQuota()) + .networkQuota(in.getNetworkQuota()) + .vmQuota(in.getVmQuota()) + .isEnabled(in.isEnabled()) + .status(in.getStatus()); + } + } + + private Vdc() { + // For JAXB and builder use + } + + + @XmlElement(name = "AllocationModel", required = true) + protected String allocationModel; + @XmlElement(name = "StorageCapacity", required = true) + protected CapacityWithUsage storageCapacity; + @XmlElement(name = "ComputeCapacity", required = true) + protected ComputeCapacity computeCapacity; + @XmlElement(name = "ResourceEntities") + protected ResourceEntities resourceEntities; + @XmlElement(name = "AvailableNetworks") + protected AvailableNetworks availableNetworks; + @XmlElement(name = "Capabilities") + protected Capabilities capabilities; + @XmlElement(name = "NicQuota") + protected int nicQuota; + @XmlElement(name = "NetworkQuota") + protected int networkQuota; + @XmlElement(name = "VmQuota") + protected Integer vmQuota; + @XmlElement(name = "IsEnabled") + protected Boolean isEnabled; + @XmlAttribute + protected Integer status; + + /** + * Gets the value of the allocationModel property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAllocationModel() { + return allocationModel; + } + + /** + * Sets the value of the allocationModel property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAllocationModel(String value) { + this.allocationModel = value; + } + + /** + * Gets the value of the storageCapacity property. + * + * @return + * possible object is + * {@link CapacityWithUsage } + * + */ + public CapacityWithUsage getStorageCapacity() { + return storageCapacity; + } + + /** + * Sets the value of the storageCapacity property. + * + * @param value + * allowed object is + * {@link CapacityWithUsage } + * + */ + public void setStorageCapacity(CapacityWithUsage value) { + this.storageCapacity = value; + } + + /** + * Gets the value of the computeCapacity property. + * + * @return + * possible object is + * {@link ComputeCapacity } + * + */ + public ComputeCapacity getComputeCapacity() { + return computeCapacity; + } + + /** + * Sets the value of the computeCapacity property. + * + * @param value + * allowed object is + * {@link ComputeCapacity } + * + */ + public void setComputeCapacity(ComputeCapacity value) { + this.computeCapacity = value; + } + + /** + * Gets the value of the resourceEntities property. + * + * @return + * possible object is + * {@link ResourceEntities } + * + */ + public ResourceEntities getResourceEntities() { + return resourceEntities; + } + + /** + * Sets the value of the resourceEntities property. + * + * @param value + * allowed object is + * {@link ResourceEntities } + * + */ + public void setResourceEntities(ResourceEntities value) { + this.resourceEntities = value; + } + + /** + * Gets the value of the availableNetworks property. + * + * @return + * possible object is + * {@link AvailableNetworks } + * + */ + public AvailableNetworks getAvailableNetworks() { + return availableNetworks; + } + + /** + * Sets the value of the availableNetworks property. + * + * @param value + * allowed object is + * {@link AvailableNetworks } + * + */ + public void setAvailableNetworks(AvailableNetworks value) { + this.availableNetworks = value; + } + + /** + * Gets the value of the capabilities property. + * + * @return + * possible object is + * {@link Capabilities } + * + */ + public Capabilities getCapabilities() { + return capabilities; + } + + /** + * Sets the value of the capabilities property. + * + * @param value + * allowed object is + * {@link Capabilities } + * + */ + public void setCapabilities(Capabilities value) { + this.capabilities = value; + } + + /** + * Gets the value of the nicQuota property. + * + */ + public int getNicQuota() { + return nicQuota; + } + + /** + * Sets the value of the nicQuota property. + * + */ + public void setNicQuota(int value) { + this.nicQuota = value; + } + + /** + * Gets the value of the networkQuota property. + * + */ + public int getNetworkQuota() { + return networkQuota; + } + + /** + * Sets the value of the networkQuota property. + * + */ + public void setNetworkQuota(int value) { + this.networkQuota = value; + } + + /** + * Gets the value of the vmQuota property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getVmQuota() { + return vmQuota; + } + + /** + * Sets the value of the vmQuota property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setVmQuota(Integer value) { + this.vmQuota = 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 status property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getStatus() { + return status; + } + + /** + * Sets the value of the status property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setStatus(Integer value) { + this.status = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Vdc that = Vdc.class.cast(o); + return equal(allocationModel, that.allocationModel) && + equal(storageCapacity, that.storageCapacity) && + equal(computeCapacity, that.computeCapacity) && + equal(resourceEntities, that.resourceEntities) && + equal(availableNetworks, that.availableNetworks) && + equal(capabilities, that.capabilities) && + equal(nicQuota, that.nicQuota) && + equal(networkQuota, that.networkQuota) && + equal(vmQuota, that.vmQuota) && + equal(isEnabled, that.isEnabled) && + equal(status, that.status); + } + + @Override + public int hashCode() { + return Objects.hashCode(allocationModel, + storageCapacity, + computeCapacity, + resourceEntities, + availableNetworks, + capabilities, + nicQuota, + networkQuota, + vmQuota, + isEnabled, + status); + } + + @Override + public String toString() { + return Objects.toStringHelper("") + .add("allocationModel", allocationModel) + .add("storageCapacity", storageCapacity) + .add("computeCapacity", computeCapacity) + .add("resourceEntities", resourceEntities) + .add("availableNetworks", availableNetworks) + .add("capabilities", capabilities) + .add("nicQuota", nicQuota) + .add("networkQuota", networkQuota) + .add("vmQuota", vmQuota) + .add("isEnabled", isEnabled) + .add("status", status).toString(); + } + +} From 454365e13168ac10c4522c556f920ccd64c5e9c3 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 14 Feb 2012 12:11:16 +0000 Subject: [PATCH 02/27] add basic expect test (no actions) --- .../v1_5/features/VdcClientExpectTest.java | 290 ++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java new file mode 100644 index 0000000000..acd6dd6734 --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -0,0 +1,290 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + *(Link.builder().regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless(Link.builder().required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.net.URI; + +import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.AvailableNetworks; +import org.jclouds.vcloud.director.v1_5.domain.Capabilities; +import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage; +import org.jclouds.vcloud.director.v1_5.domain.ComputeCapacity; +import org.jclouds.vcloud.director.v1_5.domain.Error; +import org.jclouds.vcloud.director.v1_5.domain.Link; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.ResourceEntities; +import org.jclouds.vcloud.director.v1_5.domain.SupportedHardwareVersions; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +/** + * Allows us to test a client via its side effects. + * + * @author danikov + */ +@Test(groups = "unit", singleThreaded = true, testName = "VdcClientExpectTest") +public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { + + @Test + public void testWhenResponseIs2xxLoginReturnsValidVdc() { + URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"), + getStandardPayloadResponse("/vdc/vdc.xml", VCloudDirectorMediaType.VDC)); + + Vdc expected = vdc(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + + assertEquals(client.getVdcClient().getVdc(vdcRef), expected); + } + + @Test + public void testWhenResponseIs400ForInvalidVdcId() { + URI vdcUri = URI.create(endpoint + "/vdc/NOTAUUID"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", "/vdc/NOTAUUID"), + getStandardPayloadResponse(400, "/vdc/error400.xml", VCloudDirectorMediaType.ERROR)); + + Error expected = Error.builder() + .message("validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.vdc.") + .majorErrorCode(400) + .minorErrorCode("BAD_REQUEST") + .build(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + try { + client.getVdcClient().getVdc(vdcRef); + fail("Should give HTTP 400 error"); + } catch (VCloudDirectorException vde) { + assertEquals(vde.getError(), expected); + } catch (Exception e) { + fail("Should have thrown a VCloudDirectorException"); + } + } + + @Test + public void testWhenResponseIs403ForFakeVdcId() { + URI vdcUri = URI.create(endpoint + "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), + getStandardPayloadResponse(403, "/vdc/error403-fake.xml", VCloudDirectorMediaType.ERROR)); + + Error expected = Error.builder() + .message("No access to entity \"com.vmware.vcloud.entity.vdc:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\".") + .majorErrorCode(403) + .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") + .build(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + + try { + client.getVdcClient().getVdc(vdcRef); + fail("Should give HTTP 403 error"); + } catch (VCloudDirectorException vde) { + assertEquals(vde.getError(), expected); + } catch (Exception e) { + fail("Should have thrown a VCloudDirectorException"); + } + } + + @Test + public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { + URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata"), + getStandardPayloadResponse("/vdc/metadata.xml", VCloudDirectorMediaType.METADATA)); + + Metadata expected = Metadata.builder() + .type("application/vnd.vmware.vcloud.metadata+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata")) + .link(Link.builder() + .rel("up") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f")) + .build()) + .metadata(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build())) + .build(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + + assertEquals(client.getVdcClient().getMetadata(vdcRef), expected); + } + + @Test(enabled=false) // No metadata in exemplar xml... + public void testWhenResponseIs2xxLoginReturnsValidMetadata() { + URI vdcUri = URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata/KEY"), + getStandardPayloadResponse("/vdc/metadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY)); + + MetadataEntry expected = MetadataEntry.builder() + .entry("key", "value") + .build(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + + assertEquals(client.getOrgClient().getMetadataEntry(vdcRef, "KEY"), expected); + } + + public static Vdc vdc() { + return Vdc.builder() + .status(1) + .name("orgVDC-cloudsoft-Tier1-PAYG") + .id("urn:vcloud:vdc:e9cd3387-ac57-4d27-a481-9bee75e0690f") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f")) + .link(Link.builder() + .rel("up") + .type("application/vnd.vmware.vcloud.org+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/org/c076f90a-397a-49fa-89b8-b294c1599cd0")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.metadata+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/uploadVAppTemplate")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.vcloud.media+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/media")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/instantiateVAppTemplate")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.vcloud.cloneVAppParams+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVApp")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVAppTemplate")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.vcloud.cloneMediaParams+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.vcloud.captureVAppParams+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp")) + .build()) + .link(Link.builder() + .rel("add") + .type("application/vnd.vmware.vcloud.composeVAppParams+xml") + .href(URI.create("https://mycloud.greenhousedata.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/composeVApp")) + .build()) + .description("Pay As You go resources for organization cloudsoft ") + .allocationModel("AllocationVApp") + .storageCapacity(CapacityWithUsage.builder() + .units("MB") + .allocated(0l) + .limit(0l) + .used(4519l) + .overhead(0l) + .build()) + .computeCapacity(ComputeCapacity.builder() + .cpu(CapacityWithUsage.builder() + .units("MHz") + .allocated(0l) + .limit(0l) + .used(0l) + .overhead(0l) + .build()) + .memory(CapacityWithUsage.builder() + .units("MB") + .allocated(0l) + .limit(0l) + .used(0l) + .overhead(0l) + .build()) + .build()) + .resourceEntities(ResourceEntities.builder() + .resourceEntity(Reference.builder() + .type("application/vnd.vmware.vcloud.vApp+xml") + .name("vcdcap-db9") + .href(URI.create("https://mycloud.greenhousedata.com/api/vApp/vapp-e2a4ab74-ea62-4afa-8bb7-0c11259044fb")) + .build()) + .resourceEntity(Reference.builder() + .type("application/vnd.vmware.vcloud.vAppTemplate+xml") + .name("adriancolecap") + .href(URI.create("https://mycloud.greenhousedata.com/api/vAppTemplate/vappTemplate-5571eb21-f532-4506-9737-01a4635a04cb")) + .build()) + .resourceEntity(Reference.builder() + .type("application/vnd.vmware.vcloud.media+xml") + .name("DansTestMedia") + .href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1")) + .build()) + .build()) + .availableNetworks(AvailableNetworks.builder() + .network(Reference.builder() + .type("application/vnd.vmware.vcloud.network+xml") + .name("orgNet-cloudsoft-Isolated") + .href(URI.create("https://mycloud.greenhousedata.com/api/network/a604f3c2-0343-453e-ae1f-cddac5b7bd94")) + .build()) + .network(Reference.builder() + .type("application/vnd.vmware.vcloud.network+xml") + .name("orgNet-cloudsoft-External") + .href(URI.create("https://mycloud.greenhousedata.com/api/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1")) + .build()) + .network(Reference.builder() + .type("application/vnd.vmware.vcloud.network+xml") + .name("orgNet-cloudsoft-Internal-Routed") + .href(URI.create("https://mycloud.greenhousedata.com/api/network/6d7392e2-c816-43fb-99be-f9ebcd70abf6")) + .build()) + .build()) + .capabilities(Capabilities.builder() + .supportedHardwareVersions(SupportedHardwareVersions.builder() + .supportedHardwareVersion("vmx-04") + .supportedHardwareVersion("vmx-07") + .supportedHardwareVersion("vmx-08") + .build()) + .build()) + .nicQuota(0) + .networkQuota(10) + .vmQuota(10) + .isEnabled(true) + .build(); + } +} From f73a5bcfa88a23c498ab41be59454b2def0e2c7a Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 14 Feb 2012 12:11:29 +0000 Subject: [PATCH 03/27] add exemplar xml --- .../src/test/resources/vdc/error400.xml | 2 + .../src/test/resources/vdc/error403-fake.xml | 2 + .../src/test/resources/vdc/metadata.xml | 8 +++ .../src/test/resources/vdc/vdc.xml | 59 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 labs/vcloud-director/src/test/resources/vdc/error400.xml create mode 100644 labs/vcloud-director/src/test/resources/vdc/error403-fake.xml create mode 100644 labs/vcloud-director/src/test/resources/vdc/metadata.xml create mode 100644 labs/vcloud-director/src/test/resources/vdc/vdc.xml diff --git a/labs/vcloud-director/src/test/resources/vdc/error400.xml b/labs/vcloud-director/src/test/resources/vdc/error400.xml new file mode 100644 index 0000000000..7d7c18b7f1 --- /dev/null +++ b/labs/vcloud-director/src/test/resources/vdc/error400.xml @@ -0,0 +1,2 @@ + + diff --git a/labs/vcloud-director/src/test/resources/vdc/error403-fake.xml b/labs/vcloud-director/src/test/resources/vdc/error403-fake.xml new file mode 100644 index 0000000000..a3f2be18c6 --- /dev/null +++ b/labs/vcloud-director/src/test/resources/vdc/error403-fake.xml @@ -0,0 +1,2 @@ + + diff --git a/labs/vcloud-director/src/test/resources/vdc/metadata.xml b/labs/vcloud-director/src/test/resources/vdc/metadata.xml new file mode 100644 index 0000000000..58682fae3d --- /dev/null +++ b/labs/vcloud-director/src/test/resources/vdc/metadata.xml @@ -0,0 +1,8 @@ + + + + + key + value + + diff --git a/labs/vcloud-director/src/test/resources/vdc/vdc.xml b/labs/vcloud-director/src/test/resources/vdc/vdc.xml new file mode 100644 index 0000000000..ac1e2f92ae --- /dev/null +++ b/labs/vcloud-director/src/test/resources/vdc/vdc.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + Pay As You go resources for organization cloudsoft + AllocationVApp + + MB + 0 + 0 + 4519 + 0 + + + + MHz + 0 + 0 + 0 + 0 + + + MB + 0 + 0 + 0 + 0 + + + + + + + + + + + + + + + vmx-04 + vmx-07 + vmx-08 + + + 0 + 10 + 10 + true + From 5aa69bbeafc8c2e15dec7ac769f4bb0f3131e3b7 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 14 Feb 2012 12:12:16 +0000 Subject: [PATCH 04/27] implement clients --- .../v1_5/features/VdcAsyncClient.java | 79 +++++++++++++++++++ .../director/v1_5/features/VdcClient.java | 61 ++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java new file mode 100644 index 0000000000..c17e9ebb59 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java @@ -0,0 +1,79 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.features; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +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.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; +import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint; +import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + + * @see VdcClient + * @author danikov + */ +@RequestFilters(AddVCloudAuthorizationToRequest.class) +public interface VdcAsyncClient { + + /** + * @see VdcClient#getVdc(ReferenceType) + */ + @GET + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getVdc(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef); + + /** + * @see VdcClient#getMetadata(ReferenceType) + */ + @GET + @Path("/metadata") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef); + + /** + * @see VdcClient#getMetadataEntry(ReferenceType, String) + */ + @GET + @Path("/metadata/{key}") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef , + @PathParam("key") String key); + +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java new file mode 100644 index 0000000000..c3d64f8141 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java @@ -0,0 +1,61 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.features; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; + +/** + * Provides synchronous access to a vDC. + *

+ * + * @see VdcAsyncClient + * @see + * @author danikov + */ +@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) +public interface VdcClient { + + /** + * Retrieves a vdc. + * + * @return the vdc or null if not found + */ + Vdc getVdc(Reference vdcRef); + + /** + * Retrieves an list of the vdc's metadata + * + * @return a list of metadata + */ + Metadata getMetadata(Reference vdcRef); + + /** + * Retrieves a metadata entry + * + * @return the metadata entry, or null if not found + */ + MetadataEntry getMetadataEntry(Reference vdcRef, String key); + +} From e50dd9f2eb8ec7fad502212553766249e7a61c5f Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 14 Feb 2012 12:12:33 +0000 Subject: [PATCH 05/27] wire up clients --- .../director/v1_5/VCloudDirectorAsyncClient.java | 12 ++++++++++++ .../vcloud/director/v1_5/VCloudDirectorClient.java | 12 ++++++++++++ .../director/v1_5/VCloudDirectorMediaType.java | 2 +- .../v1_5/config/VCloudDirectorRestClientModule.java | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java index cf1c90c09d..a66919ce12 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java @@ -21,12 +21,18 @@ package org.jclouds.vcloud.director.v1_5; import org.jclouds.ovf.Network; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Org; +import org.jclouds.vcloud.director.v1_5.domain.Catalog; +import org.jclouds.vcloud.director.v1_5.domain.Media; +import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; +import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient; import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient; import com.google.inject.Provides; @@ -80,4 +86,10 @@ public interface VCloudDirectorAsyncClient { */ @Delegate CatalogAsyncClient getMediaClient(); + + /** + * @return asynchronous access to {@link Vdc} features + */ + @Delegate + VdcAsyncClient getVdcClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java index 89c53a663b..7649998ed6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java @@ -24,13 +24,19 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.ovf.Network; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Org; +import org.jclouds.vcloud.director.v1_5.domain.Catalog; +import org.jclouds.vcloud.director.v1_5.domain.Media; +import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; +import org.jclouds.vcloud.director.v1_5.domain.Task; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.MediaClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.features.QueryClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient; +import org.jclouds.vcloud.director.v1_5.features.VdcClient; import com.google.inject.Provides; @@ -83,4 +89,10 @@ public interface VCloudDirectorClient { */ @Delegate MediaClient getMediaClient(); + + /** + * @return synchronous access to {@link Vdc} features + */ + @Delegate + VdcClient getVdcClient(); } 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 aca63b8e36..910ac1ab70 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 @@ -71,7 +71,7 @@ public class VCloudDirectorMediaType { public static final String OWNER = "application/vnd.vmware.vcloud.owner+xml"; public static final String VDC = "application/vnd.vmware.vcloud.vdc+xml"; - + public static final String ADMIN_USER = "application/vnd.vmware.admin.user+xml"; public static final String QUERY_RESULT_RECORDS = "application/vnd.vmware.vcloud.query.records+xml"; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index 6dd7be580f..ef9c121fd8 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -54,6 +54,8 @@ import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient; import org.jclouds.vcloud.director.v1_5.features.QueryClient; import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient; +import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.VdcClient; import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword; import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401AndLogoutOnClose; import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler; @@ -87,6 +89,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule Date: Tue, 14 Feb 2012 12:13:44 +0000 Subject: [PATCH 06/27] domain object tweaks --- .../v1_5/domain/AvailableNetworks.java | 45 +++++++++------- .../director/v1_5/domain/CapacityType.java | 14 ++--- .../v1_5/domain/CapacityWithUsage.java | 6 +-- .../v1_5/domain/ResourceEntities.java | 51 +++++++++++-------- .../domain/SupportedHardwareVersions.java | 47 ++++++++++------- .../vcloud/director/v1_5/domain/Vdc.java | 19 ++++++- 6 files changed, 113 insertions(+), 69 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java index 08d398e356..d0a523b7ed 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/AvailableNetworks.java @@ -20,8 +20,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; -import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; @@ -29,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; +import org.testng.collections.Lists; + import com.google.common.base.Objects; @@ -58,7 +60,7 @@ import com.google.common.base.Objects; */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "AvailableNetworks", propOrder = { - "network" + "networks" }) public class AvailableNetworks { public static Builder builder() { @@ -71,25 +73,32 @@ public class AvailableNetworks { public static class Builder { - private List network; + private List networks = Lists.newArrayList(); /** - * @see AvailableNetworks#getNetwork() + * @see AvailableNetworks#getNetworks() */ - public Builder network(List network) { - this.network = network; + public Builder networks(List networks) { + this.networks = Lists.newArrayList(checkNotNull(networks, "networks")); return this; } + /** + * @see AvailableNetworks#getNetworks() + */ + public Builder network(Reference network) { + networks.add(checkNotNull(network, "network")); + return this; + } public AvailableNetworks build() { - AvailableNetworks availableNetworks = new AvailableNetworks(network); + AvailableNetworks availableNetworks = new AvailableNetworks(networks); return availableNetworks; } public Builder fromAvailableNetworks(AvailableNetworks in) { - return network(in.getNetwork()); + return networks(in.getNetworks()); } } @@ -97,13 +106,13 @@ public class AvailableNetworks { // For JAXB and builder use } - private AvailableNetworks(List network) { - this.network = network; + private AvailableNetworks(List networks) { + this.networks = networks; } @XmlElement(name = "Network") - protected List network; + protected List networks; /** * Gets the value of the network property. @@ -127,11 +136,11 @@ public class AvailableNetworks { * * */ - public List getNetwork() { - if (network == null) { - network = new ArrayList(); + public List getNetworks() { + if (networks == null) { + networks = Lists.newArrayList(); } - return this.network; + return this.networks; } @Override @@ -141,18 +150,18 @@ public class AvailableNetworks { if (o == null || getClass() != o.getClass()) return false; AvailableNetworks that = AvailableNetworks.class.cast(o); - return equal(network, that.network); + return equal(networks, that.networks); } @Override public int hashCode() { - return Objects.hashCode(network); + return Objects.hashCode(networks); } @Override public String toString() { return Objects.toStringHelper("") - .add("network", network).toString(); + .add("network", networks).toString(); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java index b56e9691c1..b6e968103f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityType.java @@ -45,8 +45,8 @@ import com.google.common.base.Objects; * <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType"> * <sequence> * <element name="Units" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="Allocated" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/> - * <element name="Limit" type="{http://www.w3.org/2001/XMLSchema}long"/> + * <element name="Allocated" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/> + * <element name="Limit" type="{http://www.w3.org/2001/XMLSchema}Long"/> * </sequence> * <anyAttribute processContents='lax' namespace='##other'/> * </extension> @@ -79,7 +79,7 @@ public class CapacityType> { protected String units; protected Long allocated; - protected long limit; + protected Long limit; /** * @see CapacityType#getUnits() @@ -100,7 +100,7 @@ public class CapacityType> { /** * @see CapacityType#getLimit() */ - public Builder limit(long limit) { + public Builder limit(Long limit) { this.limit = limit; return this; } @@ -137,7 +137,7 @@ public class CapacityType> { @XmlElement(name = "Allocated") protected Long allocated; @XmlElement(name = "Limit") - protected long limit; + protected Long limit; /** * Gets the value of the units property. @@ -191,7 +191,7 @@ public class CapacityType> { * Gets the value of the limit property. * */ - public long getLimit() { + public Long getLimit() { return limit; } @@ -199,7 +199,7 @@ public class CapacityType> { * Sets the value of the limit property. * */ - public void setLimit(long value) { + public void setLimit(Long value) { this.limit = value; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java index 7079374b97..f80e445147 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CapacityWithUsage.java @@ -43,8 +43,8 @@ import com.google.common.base.Objects; * <complexContent> * <extension base="{http://www.vmware.com/vcloud/v1.5}CapacityType"> * <sequence> - * <element name="Used" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/> - * <element name="Overhead" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/> + * <element name="Used" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/> + * <element name="Overhead" type="{http://www.w3.org/2001/XMLSchema}Long" minOccurs="0"/> * </sequence> * <anyAttribute processContents='lax' namespace='##other'/> * </extension> @@ -121,7 +121,7 @@ public class CapacityWithUsage extends CapacityType /** * @see CapacityType#getLimit() */ - public Builder limit(long limit) { + public Builder limit(Long limit) { this.limit = limit; return this; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java index e16805bfa6..ee6a758f70 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ResourceEntities.java @@ -20,8 +20,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; -import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; @@ -29,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; +import org.testng.collections.Lists; + import com.google.common.base.Objects; @@ -46,7 +48,7 @@ import com.google.common.base.Objects; * <complexContent> * <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType"> * <sequence> - * <element name="ResourceEntity" type="{http://www.vmware.com/vcloud/v1.5}ReferenceTypeType" maxOccurs="unbounded" minOccurs="0"/> + * <element name="ResourceEntity" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/> * </sequence> * <anyAttribute processContents='lax' namespace='##other'/> * </extension> @@ -58,7 +60,7 @@ import com.google.common.base.Objects; */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "ResourceEntities", propOrder = { - "resourceEntity" + "resourceEntities" }) public class ResourceEntities { public static Builder builder() { @@ -71,25 +73,32 @@ public class ResourceEntities { public static class Builder { - private List> resourceEntity; - + private List resourceEntities = Lists.newArrayList(); + /** - * @see ResourceEntities#getResourceEntity() + * @see ResourceEntities#getResourceEntities() */ - public Builder resourceEntity(List> resourceEntity) { - this.resourceEntity = resourceEntity; + public Builder resourceEntities(List resourceEntities) { + this.resourceEntities = Lists.newArrayList(checkNotNull(resourceEntities, "resourceEntities")); return this; } + /** + * @see ResourceEntities#getResourceEntities() + */ + public Builder resourceEntity(Reference resourceEntity) { + resourceEntities.add(checkNotNull(resourceEntity, "resourceEntity")); + return this; + } public ResourceEntities build() { - ResourceEntities resourceEntities = new ResourceEntities(resourceEntity); + ResourceEntities resourceEntities = new ResourceEntities(this.resourceEntities); return resourceEntities; } public Builder fromResourceEntities(ResourceEntities in) { - return resourceEntity(in.getResourceEntity()); + return resourceEntities(in.getResourceEntities()); } } @@ -97,13 +106,13 @@ public class ResourceEntities { // For JAXB and builder use } - private ResourceEntities(List> resourceEntity) { - this.resourceEntity = resourceEntity; + private ResourceEntities(List resourceEntity) { + this.resourceEntities = resourceEntity; } @XmlElement(name = "ResourceEntity") - protected List> resourceEntity; + protected List resourceEntities; /** * Gets the value of the resourceEntity property. @@ -123,15 +132,15 @@ public class ResourceEntities { * *

* Objects of the following type(s) are allowed in the list - * {@link ReferenceTypeType } + * {@link ReferenceType } * * */ - public List> getResourceEntity() { - if (resourceEntity == null) { - resourceEntity = new ArrayList>(); + public List getResourceEntities() { + if (resourceEntities == null) { + resourceEntities = Lists.newArrayList(); } - return this.resourceEntity; + return this.resourceEntities; } @Override @@ -141,18 +150,18 @@ public class ResourceEntities { if (o == null || getClass() != o.getClass()) return false; ResourceEntities that = ResourceEntities.class.cast(o); - return equal(resourceEntity, that.resourceEntity); + return equal(resourceEntities, that.resourceEntities); } @Override public int hashCode() { - return Objects.hashCode(resourceEntity); + return Objects.hashCode(resourceEntities); } @Override public String toString() { return Objects.toStringHelper("") - .add("resourceEntity", resourceEntity).toString(); + .add("resourceEntity", resourceEntities).toString(); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java index 8dc1a6fadf..d8338d5809 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SupportedHardwareVersions.java @@ -20,8 +20,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; -import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; @@ -29,6 +29,8 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; +import org.testng.collections.Lists; + import com.google.common.base.Objects; @@ -58,7 +60,7 @@ import com.google.common.base.Objects; */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "SupportedHardwareVersions", propOrder = { - "supportedHardwareVersion" + "supportedHardwareVersions" }) public class SupportedHardwareVersions { public static Builder builder() { @@ -71,25 +73,32 @@ public class SupportedHardwareVersions { public static class Builder { - private List supportedHardwareVersion; + private List supportedHardwareVersions = Lists.newArrayList(); /** - * @see SupportedHardwareVersions#getSupportedHardwareVersion() + * @see SupportedHardwareVersions#getSupportedHardwareVersions() */ - public Builder supportedHardwareVersion(List supportedHardwareVersion) { - this.supportedHardwareVersion = supportedHardwareVersion; + public Builder supportedHardwareVersions(List supportedHardwareVersions) { + this.supportedHardwareVersions = Lists.newArrayList(checkNotNull(supportedHardwareVersions, "supportedHardwareVersions")); + return this; + } + + /** + * @see SupportedHardwareVersions#getSupportedHardwareVersions() + */ + public Builder supportedHardwareVersion(String supportedHardwareVersion) { + supportedHardwareVersions.add(checkNotNull(supportedHardwareVersion, "supportedHardwareVersion")); return this; } - public SupportedHardwareVersions build() { - SupportedHardwareVersions supportedHardwareVersions = new SupportedHardwareVersions(supportedHardwareVersion); + SupportedHardwareVersions supportedHardwareVersions = new SupportedHardwareVersions(this.supportedHardwareVersions); return supportedHardwareVersions; } public Builder fromSupportedHardwareVersions(SupportedHardwareVersions in) { - return supportedHardwareVersion(in.getSupportedHardwareVersion()); + return supportedHardwareVersions(in.getSupportedHardwareVersions()); } } @@ -97,13 +106,13 @@ public class SupportedHardwareVersions { // For JAXB and builder use } - private SupportedHardwareVersions(List supportedHardwareVersion) { - this.supportedHardwareVersion = supportedHardwareVersion; + private SupportedHardwareVersions(List supportedHardwareVersions) { + this.supportedHardwareVersions = supportedHardwareVersions; } @XmlElement(name = "SupportedHardwareVersion") - protected List supportedHardwareVersion; + protected List supportedHardwareVersions; /** * Gets the value of the supportedHardwareVersion property. @@ -127,11 +136,11 @@ public class SupportedHardwareVersions { * * */ - public List getSupportedHardwareVersion() { - if (supportedHardwareVersion == null) { - supportedHardwareVersion = new ArrayList(); + public List getSupportedHardwareVersions() { + if (supportedHardwareVersions == null) { + supportedHardwareVersions = Lists.newArrayList(); } - return this.supportedHardwareVersion; + return this.supportedHardwareVersions; } @Override @@ -141,18 +150,18 @@ public class SupportedHardwareVersions { if (o == null || getClass() != o.getClass()) return false; SupportedHardwareVersions that = SupportedHardwareVersions.class.cast(o); - return equal(supportedHardwareVersion, that.supportedHardwareVersion); + return equal(supportedHardwareVersions, that.supportedHardwareVersions); } @Override public int hashCode() { - return Objects.hashCode(supportedHardwareVersion); + return Objects.hashCode(supportedHardwareVersions); } @Override public String toString() { return Objects.toStringHelper("") - .add("supportedHardwareVersion", supportedHardwareVersion).toString(); + .add("supportedHardwareVersion", supportedHardwareVersions).toString(); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java index 8dc3910417..23cad56744 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/Vdc.java @@ -29,6 +29,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; @@ -71,7 +72,8 @@ import com.google.common.collect.Sets; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "Vdc", propOrder = { +@XmlRootElement(name = "Vdc") +@XmlType(propOrder = { "allocationModel", "storageCapacity", "computeCapacity", @@ -217,7 +219,22 @@ public class Vdc vdc.setStatus(status); return vdc; } + + /** + * @see EntityType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + /** + * @see EntityType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } /** * @see EntityType#getId() From b01a8888350598a3d643ed5bd7934f724b3b036e Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 14 Feb 2012 13:03:59 +0000 Subject: [PATCH 07/27] implement actions --- .../v1_5/features/VdcAsyncClient.java | 94 +++++++++++++++- .../director/v1_5/features/VdcClient.java | 101 ++++++++++++++++++ 2 files changed, 191 insertions(+), 4 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java index c17e9ebb59..34bd9febad 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java @@ -20,17 +20,26 @@ package org.jclouds.vcloud.director.v1_5.features; import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; +import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; +import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint; @@ -47,16 +56,93 @@ import com.google.common.util.concurrent.ListenableFuture; public interface VdcAsyncClient { /** - * @see VdcClient#getVdc(ReferenceType) + * @see VdcClient#getVdc(Reference) */ @GET @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture getVdc(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef); + + /** + * @see VdcClient#cloneMedia(Reference, CloneMediaParams) + */ + @POST + @Path("/action/cloneMedia") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture cloneMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @PayloadParam(value = "?") CloneMediaParams params); + + /** + * @see VdcClient#cloneVApp(Reference, CloneVAppParams) + */ + @POST + @Path("/action/cloneVApp") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture cloneVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @PayloadParam(value = "?") CloneVAppParams params); + + /** + * @see VdcClient#cloneVAppTemplate(Reference, CloneVAppTemplateParams) + */ + @POST + @Path("/action/cloneVAppTemplate") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture cloneVAppTemplate(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @PayloadParam(value = "?") CloneVAppTemplateParams params); + + /** + * @see VdcClient#composeVApp(Reference, ComposeVAppParams) + */ + @POST + @Path("/action/composeVApp") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture composeVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @PayloadParam(value = "?") ComposeVAppParams params); + + /** + * @see VdcClient#instantiateVApp(Reference, InstantiateVAppParamsType) + */ + @POST + @Path("/action/instantiateVApp") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture instantiateVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @PayloadParam(value = "?") InstantiateVAppParamsType params); + + /** + * @see VdcClient#uploadVAppTemplate(Reference, UploadVAppTemplateParams) + */ + @POST + @Path("/action/uploadVAppTemplate") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture uploadVAppTemplate(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @PayloadParam(value = "?") UploadVAppTemplateParams params); + + /** + * @see VdcClient#createMedia(Reference, Media) + */ + @POST + @Path("/media") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture createMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @PayloadParam(value = "?") Media media); /** - * @see VdcClient#getMetadata(ReferenceType) + * @see VdcClient#getMetadata(Reference) */ @GET @Path("/metadata") @@ -66,7 +152,7 @@ public interface VdcAsyncClient { ListenableFuture getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef); /** - * @see VdcClient#getMetadataEntry(ReferenceType, String) + * @see VdcClient#getMetadataEntry(Reference, String) */ @GET @Path("/metadata/{key}") diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java index c3d64f8141..6fefa33d1e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java @@ -20,11 +20,32 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; +import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; +import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint; +import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; + +import com.google.common.util.concurrent.ListenableFuture; /** * Provides synchronous access to a vDC. @@ -44,6 +65,86 @@ public interface VdcClient { */ Vdc getVdc(Reference vdcRef); + /** + * Clones a media into new one. + * The status of the returned media is UNRESOLVED(0) until the task for cloning finish. + * + * @return a Media resource which will contain a task. + * The user should monitor the contained task status in order to check when it is completed. + */ + Media cloneMedia(Reference vdcRef, CloneMediaParams params); + + /** + * Clones a vApp into new one. The status of vApp will be in UNRESOLVED(0) until the clone task is finished. + * + * @return a VApp resource which will contain a task. + * The user should should wait for this task to finish to be able to use the vApp. + */ + VApp cloneVApp(Reference vdcRef, CloneVAppParams params); + + /** + * Clones a vApp template into new one. + * The status of vApp template will be in UNRESOLVED(0) until the clone task is finished. + * + * @return a VAppTemplate resource which will contain a task. + * The user should should wait for this task to finish to be able to use the VAppTemplate. + */ + VAppTemplate cloneVAppTemplate(Reference vdcRef, CloneVAppTemplateParams params); + + /** + * Composes a new vApp using VMs from other vApps or vApp templates. The vCloud API supports + * composing a vApp from any combination of vApp templates, vApps, or virtual machines. + * When you compose a vApp, all children of each composition source become peers in the + * Children collection of the composed vApp. To compose a vApp, a client makes a compose + * vApp request whose body is a ComposeVAppParams element, includes the following information: + * - An InstantiationParams element that applies to the composed vApp itself and any vApp + * templates referenced in Item elements. - A SourcedItem element for each virtual machine, + * vApp, or vAppTemplate to include in the composition. Each SourcedItem can contain the + * following elements: - A required Source element whose href attribute value is a reference + * to a vApp template, vApp, or VM to include in the composition. If the Source element + * references a VM, the Item must also include an InstantiationParams element specific to + * that VM. - An optional NetworkAssignment element that specifies how the network connections + * of child VM elements are mapped to vApp networks in the parent. - If any of the composition + * items is subject to a EULA, the ComposeVAppParams element must include an AllEULAsAccepted + * element that has a value of true, indicating that you accept the EULA. Otherwise, composition + * fails. The composed vApp must be deployed and powered on before it can be used. The status + * of vApp will be UNRESOLVED(0) until the compose task is finished. + * + * @return a VApp resource which will contain a task. + * The user should should wait for this task to finish to be able to use the vApp. + */ + VApp composeVApp(Reference vdcRef, ComposeVAppParams params); + + /** + * Instantiate a vApp template into a new vApp. + * The status of vApp will be in UNRESOLVED(0) until the instantiate task is finished. + * + * @return a VApp resource which will contain a task. + * The user should should wait for this task to finish to be able to use the vApp. + */ + VApp instantiateVApp(Reference vdcRef, InstantiateVAppParamsType params); + + /** + * Uploading vApp template to a vDC. The operation is separate on several steps: + * 1. creating empty vApp template entity + * 2. uploading an OVF of vApp template + * 3. uploading disks described from the OVF + * 4. finishing task for uploading + * The status of vApp template will be NOT_READY(0) until the ovf and all disks are uploaded + * to the transfer site. After this a task will run on the vApp template uploading. + * + * @return a VAppTemplate resource which will contain a task. + * The user should should wait for this task to finish to be able to use the VAppTemplate. + */ + VAppTemplate uploadVAppTemplate(Reference vdcRef, UploadVAppTemplateParams params); + + /** + * Creates a media (and present upload link for the floppy/iso file). + * + * @return The response will return a link to transfer site to be able to continue with uploading the media. + */ + Media createMedia(Reference vdcRef, Media media); + /** * Retrieves an list of the vdc's metadata * From e0361ef1a1a3d6ca1ab2d927b0b48e764bac0cea Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 14 Feb 2012 13:33:35 +0000 Subject: [PATCH 08/27] add missing action --- .../director/v1_5/features/VdcAsyncClient.java | 12 ++++++++++++ .../vcloud/director/v1_5/features/VdcClient.java | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java index 34bd9febad..4d62bea509 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java @@ -29,6 +29,7 @@ import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; @@ -64,6 +65,17 @@ public interface VdcAsyncClient { @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture getVdc(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef); + /** + * @see VdcClient#captureVApp(Reference, CaptureVAppParams) + */ + @POST + @Path("/action/captureVApp") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture captureVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @PayloadParam(value = "?") CaptureVAppParams params); + /** * @see VdcClient#cloneMedia(Reference, CloneMediaParams) */ diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java index 6fefa33d1e..27391ce221 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java @@ -65,6 +65,15 @@ public interface VdcClient { */ Vdc getVdc(Reference vdcRef); + /** + * Captures a vApp into vApp template. + * The status of vApp template will be in UNRESOLVED(0) until the capture task is finished. + * + * @return a VApp resource which will contain a task. + * The user should should wait for this task to finish to be able to use the vApp. + */ + VAppTemplate captureVApp(Reference vdcRef, CloneMediaParams params); + /** * Clones a media into new one. * The status of the returned media is UNRESOLVED(0) until the task for cloning finish. From 32e4493f51ec502fcc9dc52eca78f323a3b5d5f6 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 14 Feb 2012 13:34:02 +0000 Subject: [PATCH 09/27] add parameter types --- .../v1_5/VCloudDirectorMediaType.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) 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 910ac1ab70..12a27d153d 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 @@ -44,7 +44,7 @@ public class VCloudDirectorMediaType { public static final String METADATA_ENTRY = "*/*"; // No media type (?) - public static final String METADATA_VALUE = "application/vnd.vmware.vcloud.metadata.value+xml";; + public static final String METADATA_VALUE = "application/vnd.vmware.vcloud.metadata.value+xml"; public static final String ORG = "application/vnd.vmware.vcloud.org+xml"; @@ -72,14 +72,31 @@ public class VCloudDirectorMediaType { public static final String VDC = "application/vnd.vmware.vcloud.vdc+xml"; + public static final String CAPTURE_VAPP_PARAMS = + "application/vnd.vmware.vcloud.captureVAppParams+xml"; + + public static final String CLONE_VPP_PARAMS = + "application/vnd.vmware.vcloud.cloneVAppParams+xml"; + + public static final String CLONE_VAPP_TEMPLATE_PARAMS = + "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml"; public static final String ADMIN_USER = "application/vnd.vmware.admin.user+xml"; - + + public static final String COMPOSE_VAPP_PARAMS = + "application/vnd.vmware.vcloud.composeVAppParams+xml"; + + public static final String INSTANTIATE_VAPP_TEMPLATE_PARAMS = + "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml"; + + public static final String UPLOAD_VAPP_TEMPLATE_PARAMS = + "application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml"; + 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 String QUERY_RESULT_ID_RECORDS = "application/vnd.vmware.vcloud.query.idrecords+xml"; + public static final String CONTROL_ACCESS = "application/vnd.vmware.vcloud.controlAccess+xml"; /** @@ -91,8 +108,12 @@ public class VCloudDirectorMediaType { SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, METADATA_VALUE, ORG, TASKS_LIST, TASK, NETWORK, 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, + MEDIA, OWNER, VDC, ADMIN_USER, + CAPTURE_VAPP_PARAMS, CLONE_VPP_PARAMS, CLONE_VAPP_TEMPLATE_PARAMS, + COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS, + UPLOAD_VAPP_TEMPLATE_PARAMS, + QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS, CONTROL_ACCESS ); + } From e34c0854550ee407b7f795bac65c73a68ed11eaa Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 14 Feb 2012 13:35:29 +0000 Subject: [PATCH 10/27] first attempt at reference POST action test --- .../v1_5/features/VdcClientExpectTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index acd6dd6734..67a35c15f6 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -29,6 +29,7 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.AvailableNetworks; import org.jclouds.vcloud.director.v1_5.domain.Capabilities; import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage; +import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.ComputeCapacity; import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.Link; @@ -117,6 +118,56 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } } + @Test + public void testWhenResponseIs2xxLoginCaptureVAppSucceeds() { + URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardPayloadRequest("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp", + "/vdc/params/captureVApp", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS), + getStandardPayloadResponse("/vdc/vdc.xml", VCloudDirectorMediaType.VDC)); + + Vdc expected = vdc(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + + assertEquals(client.getVdcClient().captureVApp(vdcRef, params), expected); + } + + @Test + public void testWhenResponseIs4xxForCaptureVAppNoParams() { + URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp"), + getStandardPayloadResponse(400, "/vdc/param/error400.xml", VCloudDirectorMediaType.ERROR)); + + Error expected = Error.builder() + .message("?") + .majorErrorCode(400) + .minorErrorCode("BAD_REQUEST") + .build(); + + Reference vdcRef = Reference.builder().href(vdcUri).build(); + try { + client.getVdcClient().captureVApp(vdcRef, null); + fail("Should give HTTP 400 error"); + } catch (VCloudDirectorException vde) { + assertEquals(vde.getError(), expected); + } catch (Exception e) { + fail("Should have thrown a VCloudDirectorException"); + } + } + +// POST /vdc/{id}/action/captureVApp +// POST /vdc/{id}/action/cloneMedia +// POST /vdc/{id}/action/cloneVApp +// POST /vdc/{id}/action/cloneVAppTemplate +// POST /vdc/{id}/action/composeVApp +// POST /vdc/{id}/action/instantiateVAppTemplate +// POST /vdc/{id}/action/uploadVAppTemplate +// POST /vdc/{id}/media + @Test public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); From 16309eaef19ed363c52342ae3aa7c04ed2c94412 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 16:02:59 +0000 Subject: [PATCH 11/27] flesh out expect test --- .../v1_5/features/VdcClientExpectTest.java | 325 +++++++++++++++--- 1 file changed, 278 insertions(+), 47 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index 67a35c15f6..da7ba2638e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -30,16 +30,27 @@ import org.jclouds.vcloud.director.v1_5.domain.AvailableNetworks; import org.jclouds.vcloud.director.v1_5.domain.Capabilities; import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.ComputeCapacity; import org.jclouds.vcloud.director.v1_5.domain.Error; +import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.Link; +import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.ResourceEntities; import org.jclouds.vcloud.director.v1_5.domain.SupportedHardwareVersions; +import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; +import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -49,31 +60,48 @@ import com.google.common.collect.ImmutableSet; * * @author danikov */ -@Test(groups = "unit", singleThreaded = true, testName = "VdcClientExpectTest") +@Test(groups = { "unit", "apitests", "user" }, singleThreaded = true, testName = "VdcClientExpectTest") public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { + private Reference vdcRef; + + @BeforeGroups(groups = { "unit" }, dependsOnMethods = { "setupClient" }) + public void before() { + String vdcId = "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"; // TODO: inject + vdcRef = Reference.builder() + .type("application/vnd.vmware.vcloud.vdc+xml") + .name("") + .href(URI.create(endpoint+"/vdc/"+vdcId)) + .id(vdcId) + .build(); + } + @Test - public void testWhenResponseIs2xxLoginReturnsValidVdc() { - URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); - + public void testGetVdc() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"), - getStandardPayloadResponse("/vdc/vdc.xml", VCloudDirectorMediaType.VDC)); + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/vdc.xml", VCloudDirectorMediaType.VDC) + .httpResponseBuilder().build()); - Vdc expected = vdc(); - - Reference vdcRef = Reference.builder().href(vdcUri).build(); + Vdc expected = getVdc(); assertEquals(client.getVdcClient().getVdc(vdcRef), expected); } @Test - public void testWhenResponseIs400ForInvalidVdcId() { - URI vdcUri = URI.create(endpoint + "/vdc/NOTAUUID"); - - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", "/vdc/NOTAUUID"), - getStandardPayloadResponse(400, "/vdc/error400.xml", VCloudDirectorMediaType.ERROR)); + public void testResponse400ForInvalidVdcId() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/vdc/NOTAUUID") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/error400.xml", VCloudDirectorMediaType.ERROR) + .httpResponseBuilder().statusCode(400).build()); Error expected = Error.builder() .message("validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.vdc.") @@ -81,7 +109,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .minorErrorCode("BAD_REQUEST") .build(); - Reference vdcRef = Reference.builder().href(vdcUri).build(); try { client.getVdcClient().getVdc(vdcRef); fail("Should give HTTP 400 error"); @@ -93,12 +120,15 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } @Test - public void testWhenResponseIs403ForFakeVdcId() { - URI vdcUri = URI.create(endpoint + "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); - - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), - getStandardPayloadResponse(403, "/vdc/error403-fake.xml", VCloudDirectorMediaType.ERROR)); + public void testResponse403ForFakeVdcId() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/error403-fake.xml", VCloudDirectorMediaType.ERROR) + .httpResponseBuilder().statusCode(403).build()); Error expected = Error.builder() .message("No access to entity \"com.vmware.vcloud.entity.vdc:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\".") @@ -106,8 +136,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN") .build(); - Reference vdcRef = Reference.builder().href(vdcUri).build(); - try { client.getVdcClient().getVdc(vdcRef); fail("Should give HTTP 403 error"); @@ -119,28 +147,38 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } @Test - public void testWhenResponseIs2xxLoginCaptureVAppSucceeds() { - URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp"); - + public void testCaptureVApp() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardPayloadRequest("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp", - "/vdc/params/captureVApp", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS), - getStandardPayloadResponse("/vdc/vdc.xml", VCloudDirectorMediaType.VDC)); + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp") + .xmlFilePayload("/vdc/params/captureVApp.xml", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/vdc.xml", VCloudDirectorMediaType.VDC) + .httpResponseBuilder().build()); - Vdc expected = vdc(); - - Reference vdcRef = Reference.builder().href(vdcUri).build(); + VAppTemplate expected = captureVApp(); + // TODO: configure params + CaptureVAppParams params = CaptureVAppParams.builder() + + .build(); + assertEquals(client.getVdcClient().captureVApp(vdcRef, params), expected); } @Test - public void testWhenResponseIs4xxForCaptureVAppNoParams() { - URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp"); - - VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp"), - getStandardPayloadResponse(400, "/vdc/param/error400.xml", VCloudDirectorMediaType.ERROR)); + public void testResponse4xxForCaptureVAppNoParams() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/captureVApp") + .xmlFilePayload("/vdc/params/captureVApp.xml", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/param/error400.xml", VCloudDirectorMediaType.ERROR) + .httpResponseBuilder().statusCode(400).build()); Error expected = Error.builder() .message("?") @@ -148,7 +186,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .minorErrorCode("BAD_REQUEST") .build(); - Reference vdcRef = Reference.builder().href(vdcUri).build(); try { client.getVdcClient().captureVApp(vdcRef, null); fail("Should give HTTP 400 error"); @@ -169,7 +206,161 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest // POST /vdc/{id}/media @Test - public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { + public void testCloneMedia() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia") + .xmlFilePayload("/vdc/params/cloneMedia.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/cloneMedia.xml", VCloudDirectorMediaType.MEDIA) + .httpResponseBuilder().build()); + + Media expected = cloneMedia(); + + // TODO: configure params + CloneMediaParams params = CloneMediaParams.builder() + + .build(); + + assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected); + } + + @Test + public void testCloneVApp() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVApp") + .xmlFilePayload("/vdc/params/cloneVApp.xml", VCloudDirectorMediaType.CLONE_V_APP_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/cloneVApp.xml", VCloudDirectorMediaType.V_APP) + .httpResponseBuilder().build()); + + VApp expected = cloneVApp(); + + // TODO: configure params + CloneVAppParams params = CloneVAppParams.builder() + + .build(); + + assertEquals(client.getVdcClient().cloneVApp(vdcRef, params), expected); + } + + @Test + public void testCloneVAppTemplate() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneVAppTemplate") + .xmlFilePayload("/vdc/params/cloneVAppTemplate.xml", VCloudDirectorMediaType.CLONE_V_APP_TEMPLATE_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/cloneVAppTemplate.xml", VCloudDirectorMediaType.V_APP_TEMPLATE) + .httpResponseBuilder().build()); + + VAppTemplate expected = cloneVAppTemplate(); + + // TODO: configure params + CloneVAppTemplateParams params = CloneVAppTemplateParams.builder() + + .build(); + + assertEquals(client.getVdcClient().cloneVAppTemplate(vdcRef, params), expected); + } + + @Test + public void testComposeVApp() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/composeVApp") + .xmlFilePayload("/vdc/params/composeVApp.xml", VCloudDirectorMediaType.COMPOSE_VAPP_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/composeVApp.xml", VCloudDirectorMediaType.V_APP) + .httpResponseBuilder().build()); + + VApp expected = composeVApp(); + + // TODO: configure params + ComposeVAppParams params = ComposeVAppParams.builder() + + .build(); + + assertEquals(client.getVdcClient().composeVApp(vdcRef, params), expected); + } + + @Test + public void testInstantiateVAppTemplate() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/instantiateVAppTemplate") + .xmlFilePayload("/vdc/params/instantiateVAppTemplate.xml", VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/instantiateVAppTemplate.xml", VCloudDirectorMediaType.V_APP) + .httpResponseBuilder().build()); + + VApp expected = instantiateVAppTemplate(); + + // TODO: configure params + InstantiateVAppTemplateParams params = InstantiateVAppTemplateParams.builder() + + .build(); + + assertEquals(client.getVdcClient().instantiateVApp(vdcRef, params), expected); + } + + @Test + public void testUploadVAppTemplate() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/uploadVAppTemplate") + .xmlFilePayload("/vdc/params/uploadVAppTemplate.xml", VCloudDirectorMediaType.UPLOAD_VAPP_TEMPLATE_PARAMS) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/uploadVAppTemplate.xml", VCloudDirectorMediaType.V_APP_TEMPLATE) + .httpResponseBuilder().build()); + + VAppTemplate expected = uploadVAppTemplate(); + + // TODO: configure params + UploadVAppTemplateParams params = UploadVAppTemplateParams.builder() + + .build(); + + assertEquals(client.getVdcClient().uploadVAppTemplate(vdcRef, params), expected); + } + + @Test + public void testCreateMedia() { + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + new VcloudHttpRequestPrimer() + .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/media") + .xmlFilePayload("/vdc/params/createMedia.xml", VCloudDirectorMediaType.MEDIA) + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/createMedia.xml", VCloudDirectorMediaType.MEDIA) + .httpResponseBuilder().build()); + + Media expected = createMedia(); + + // TODO: configure params + Media createMedia = Media.builder() + + .build(); + + assertEquals(client.getVdcClient().createMedia(vdcRef, createMedia), expected); + } + + @Test + public void testGetMetadata() { URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, @@ -184,7 +375,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .type("application/vnd.vmware.vcloud.vdc+xml") .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f")) .build()) - .metadata(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build())) + .entries(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build())) .build(); Reference vdcRef = Reference.builder().href(vdcUri).build(); @@ -193,23 +384,23 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } @Test(enabled=false) // No metadata in exemplar xml... - public void testWhenResponseIs2xxLoginReturnsValidMetadata() { + public void testGetMetadataValue() { URI vdcUri = URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata/KEY"), getStandardPayloadResponse("/vdc/metadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY)); - MetadataEntry expected = MetadataEntry.builder() - .entry("key", "value") + MetadataValue expected = MetadataValue.builder() + .value("value") .build(); Reference vdcRef = Reference.builder().href(vdcUri).build(); - assertEquals(client.getOrgClient().getMetadataEntry(vdcRef, "KEY"), expected); + assertEquals(client.getVdcClient().getMetadataValue(vdcRef, "KEY"), expected); } - public static Vdc vdc() { + public static Vdc getVdc() { return Vdc.builder() .status(1) .name("orgVDC-cloudsoft-Tier1-PAYG") @@ -338,4 +529,44 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest .isEnabled(true) .build(); } + + private VAppTemplate captureVApp() { + // TODO Auto-generated method stub + return null; + } + + private Media cloneMedia() { + // TODO Auto-generated method stub + return null; + } + + private VApp cloneVApp() { + // TODO Auto-generated method stub + return null; + } + + private VAppTemplate cloneVAppTemplate() { + // TODO Auto-generated method stub + return null; + } + + private VApp composeVApp() { + // TODO Auto-generated method stub + return null; + } + + private VApp instantiateVAppTemplate() { + // TODO Auto-generated method stub + return null; + } + + private VAppTemplate uploadVAppTemplate() { + // TODO Auto-generated method stub + return null; + } + + private Media createMedia() { + // TODO Auto-generated method stub + return null; + } } From 257503f4ddebeb019e18f6d114d6007e93b6504c Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 16:03:59 +0000 Subject: [PATCH 12/27] update client with the right param types and metadataValue getter --- .../v1_5/features/VdcAsyncClient.java | 52 ++++++++++++------- .../director/v1_5/features/VdcClient.java | 25 +++------ 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java index 4d62bea509..4fe5cda2ae 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java @@ -23,12 +23,15 @@ import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.binders.BindToXMLPayload; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; @@ -37,9 +40,10 @@ import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; @@ -70,88 +74,96 @@ public interface VdcAsyncClient { */ @POST @Path("/action/captureVApp") - @Consumes + @Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE) + @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture captureVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, - @PayloadParam(value = "?") CaptureVAppParams params); + ListenableFuture captureVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, + @BinderParam(BindToXMLPayload.class) CaptureVAppParams params); /** * @see VdcClient#cloneMedia(Reference, CloneMediaParams) */ @POST @Path("/action/cloneMedia") - @Consumes + @Consumes(VCloudDirectorMediaType.MEDIA) + @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture cloneMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, - @PayloadParam(value = "?") CloneMediaParams params); + @BinderParam(BindToXMLPayload.class) CloneMediaParams params); /** * @see VdcClient#cloneVApp(Reference, CloneVAppParams) */ @POST @Path("/action/cloneVApp") - @Consumes + @Consumes(VCloudDirectorMediaType.V_APP) + @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture cloneVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, - @PayloadParam(value = "?") CloneVAppParams params); + @BinderParam(BindToXMLPayload.class) CloneVAppParams params); /** * @see VdcClient#cloneVAppTemplate(Reference, CloneVAppTemplateParams) */ @POST @Path("/action/cloneVAppTemplate") - @Consumes + @Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE) + @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture cloneVAppTemplate(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, - @PayloadParam(value = "?") CloneVAppTemplateParams params); + @BinderParam(BindToXMLPayload.class) CloneVAppTemplateParams params); /** * @see VdcClient#composeVApp(Reference, ComposeVAppParams) */ @POST @Path("/action/composeVApp") - @Consumes + @Consumes(VCloudDirectorMediaType.V_APP) + @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture composeVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, - @PayloadParam(value = "?") ComposeVAppParams params); + @BinderParam(BindToXMLPayload.class) ComposeVAppParams params); /** * @see VdcClient#instantiateVApp(Reference, InstantiateVAppParamsType) */ @POST @Path("/action/instantiateVApp") - @Consumes + @Consumes(VCloudDirectorMediaType.V_APP) + @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture instantiateVApp(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, - @PayloadParam(value = "?") InstantiateVAppParamsType params); + @BinderParam(BindToXMLPayload.class) InstantiateVAppParamsType params); /** * @see VdcClient#uploadVAppTemplate(Reference, UploadVAppTemplateParams) */ @POST @Path("/action/uploadVAppTemplate") - @Consumes + @Consumes(VCloudDirectorMediaType.V_APP_TEMPLATE) + @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture uploadVAppTemplate(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, - @PayloadParam(value = "?") UploadVAppTemplateParams params); + @BinderParam(BindToXMLPayload.class) UploadVAppTemplateParams params); /** * @see VdcClient#createMedia(Reference, Media) */ @POST @Path("/media") - @Consumes + @Consumes(VCloudDirectorMediaType.MEDIA) + @Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture createMedia(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef, - @PayloadParam(value = "?") Media media); + @BinderParam(BindToXMLPayload.class) Media media); /** * @see VdcClient#getMetadata(Reference) @@ -171,7 +183,7 @@ public interface VdcAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef , + ListenableFuture getMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) Reference vdcRef , @PathParam("key") String key); } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java index 27391ce221..0b72a139c4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java @@ -20,15 +20,8 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - import org.jclouds.concurrent.Timeout; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.ExceptionParser; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; @@ -36,16 +29,12 @@ import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; -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; /** * Provides synchronous access to a vDC. @@ -72,7 +61,7 @@ public interface VdcClient { * @return a VApp resource which will contain a task. * The user should should wait for this task to finish to be able to use the vApp. */ - VAppTemplate captureVApp(Reference vdcRef, CloneMediaParams params); + VAppTemplate captureVApp(Reference vdcRef, CaptureVAppParams params); /** * Clones a media into new one. @@ -162,10 +151,10 @@ public interface VdcClient { Metadata getMetadata(Reference vdcRef); /** - * Retrieves a metadata entry + * Retrieves a metadata value * - * @return the metadata entry, or null if not found + * @return the metadata value, or null if not found */ - MetadataEntry getMetadataEntry(Reference vdcRef, String key); + MetadataValue getMetadataValue(Reference vdcRef, String key); } From 08c20366bc9cc301a6139a5d582240c782f5636f Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 16:04:25 +0000 Subject: [PATCH 13/27] add builder inheritance methods --- .../domain/InstantiateVAppParamsType.java | 48 +++++++++++++++++++ .../v1_5/domain/VAppCreationParamsType.java | 16 +++++++ 2 files changed, 64 insertions(+) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java index a7db8f5db4..0660a06a87 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java @@ -116,6 +116,54 @@ public class InstantiateVAppParamsType> instantiateVAppParams.setLinkedClone(linkedClone); return instantiateVAppParams; } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + super.vAppParent(vAppParent); + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + super.instantiationParams(instantiationParams); + return this; + } + + /** + * @see VAppCreationParamsType#getDeploy() + */ + public Builder deploy(Boolean deploy) { + super.deploy(deploy); + return this; + } + + /** + * @see VAppCreationParamsType#getPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + super.powerOn(powerOn); + return this; + } /** * {@inheritDoc} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java index 5f5b97518d..1fc316b172 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java @@ -129,6 +129,22 @@ public class VAppCreationParamsType> vAppCreationParams.setPowerOn(powerOn); return vAppCreationParams; } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } /** * {@inheritDoc} From 7f83356108e33b8cbd7f68124129da6b1e2abdb6 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 16:05:01 +0000 Subject: [PATCH 14/27] make params class concrete --- ...ava => InstantiateVAppTemplateParams.java} | 83 +++++++++++++++---- 1 file changed, 65 insertions(+), 18 deletions(-) rename labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/{InstantiateVAppTemplateParamsType.java => InstantiateVAppTemplateParams.java} (65%) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java similarity index 65% rename from labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParamsType.java rename to labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java index 9849c47f60..ce7e905f34 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParamsType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppTemplateParams.java @@ -57,52 +57,99 @@ import com.google.common.base.Objects; @XmlType(name = "InstantiateVAppTemplateParams", propOrder = { "allEULAsAccepted" }) -public class InstantiateVAppTemplateParamsType> - extends InstantiateVAppParamsType - -{ - public static > Builder builder() { - return new Builder(); +public class InstantiateVAppTemplateParams + extends InstantiateVAppParamsType { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); } - public Builder toBuilder() { - return new Builder().fromInstantiateVAppTemplateParams(this); + public Builder toBuilder() { + return new Builder().fromInstantiateVAppTemplateParams(this); } - public static class Builder> extends InstantiateVAppParamsType.Builder { + public static class Builder extends InstantiateVAppParamsType.Builder { private Boolean allEULAsAccepted; /** * @see InstantiateVAppTemplateParamsType#getAllEULAsAccepted() */ - public Builder allEULAsAccepted(Boolean allEULAsAccepted) { + public Builder allEULAsAccepted(Boolean allEULAsAccepted) { this.allEULAsAccepted = allEULAsAccepted; return this; } - - public InstantiateVAppTemplateParamsType build() { - InstantiateVAppTemplateParamsType instantiateVAppTemplateParams = new InstantiateVAppTemplateParamsType(); + public InstantiateVAppTemplateParams build() { + InstantiateVAppTemplateParams instantiateVAppTemplateParams = new InstantiateVAppTemplateParams(); instantiateVAppTemplateParams.setAllEULAsAccepted(allEULAsAccepted); return instantiateVAppTemplateParams; } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + super.vAppParent(vAppParent); + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + super.instantiationParams(instantiationParams); + return this; + } + + /** + * @see VAppCreationParamsType#getDeploy() + */ + public Builder deploy(Boolean deploy) { + super.deploy(deploy); + return this; + } + + /** + * @see VAppCreationParamsType#getPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + super.powerOn(powerOn); + return this; + } /** * {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override - public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { + public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { return Builder.class.cast(super.fromInstantiateVAppParamsType(in)); } - public Builder fromInstantiateVAppTemplateParams(InstantiateVAppTemplateParamsType in) { + + public Builder fromInstantiateVAppTemplateParams(InstantiateVAppTemplateParams in) { return fromInstantiateVAppParamsType(in) .allEULAsAccepted(in.isAllEULAsAccepted()); } } - private InstantiateVAppTemplateParamsType() { + private InstantiateVAppTemplateParams() { // For JAXB and builder use } @@ -147,7 +194,7 @@ public class InstantiateVAppTemplateParamsType that = InstantiateVAppTemplateParamsType.class.cast(o); + InstantiateVAppTemplateParams that = InstantiateVAppTemplateParams.class.cast(o); return equal(allEULAsAccepted, that.allEULAsAccepted); } From 57bd4f23af584936082c8c76d180f4366135088c Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 16:05:26 +0000 Subject: [PATCH 15/27] placeholder for merging with VApp branch --- .../java/org/jclouds/vcloud/director/v1_5/domain/VApp.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VApp.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VApp.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VApp.java new file mode 100644 index 0000000000..ea90248696 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VApp.java @@ -0,0 +1,5 @@ +package org.jclouds.vcloud.director.v1_5.domain; + +public class VApp { + // Placeholder for merge +} From 703c48b557656aca53cbfb06ba29c186c4c9718e Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 16:05:45 +0000 Subject: [PATCH 16/27] add + modify media types --- .../v1_5/VCloudDirectorMediaType.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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 12a27d153d..23cc523630 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 @@ -72,15 +72,23 @@ public class VCloudDirectorMediaType { public static final String VDC = "application/vnd.vmware.vcloud.vdc+xml"; + public static final String ADMIN_USER = "application/vnd.vmware.admin.user+xml"; + + public static final String V_APP = "application/vnd.vmware.vcloud.vApp+xml"; + + public static final String V_APP_TEMPLATE = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + public static final String CAPTURE_VAPP_PARAMS = "application/vnd.vmware.vcloud.captureVAppParams+xml"; - public static final String CLONE_VPP_PARAMS = + public static final String CLONE_MEDIA_PARAMS = + "application/vnd.vmware.vcloud.cloneMediaParams+xml"; + + public static final String CLONE_V_APP_PARAMS = "application/vnd.vmware.vcloud.cloneVAppParams+xml"; - public static final String CLONE_VAPP_TEMPLATE_PARAMS = + public static final String CLONE_V_APP_TEMPLATE_PARAMS = "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml"; - public static final String ADMIN_USER = "application/vnd.vmware.admin.user+xml"; public static final String COMPOSE_VAPP_PARAMS = "application/vnd.vmware.vcloud.composeVAppParams+xml"; @@ -108,12 +116,11 @@ public class VCloudDirectorMediaType { SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, METADATA_VALUE, ORG, TASKS_LIST, TASK, NETWORK, ORG_NETWORK, CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY, - MEDIA, OWNER, VDC, ADMIN_USER, - CAPTURE_VAPP_PARAMS, CLONE_VPP_PARAMS, CLONE_VAPP_TEMPLATE_PARAMS, + MEDIA, OWNER, VDC, ADMIN_USER, V_APP, V_APP_TEMPLATE, + CAPTURE_VAPP_PARAMS, CLONE_V_APP_PARAMS, CLONE_V_APP_TEMPLATE_PARAMS, COMPOSE_VAPP_PARAMS, INSTANTIATE_VAPP_TEMPLATE_PARAMS, UPLOAD_VAPP_TEMPLATE_PARAMS, QUERY_RESULT_RECORDS, QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS, CONTROL_ACCESS ); - } From f8900900f9e5ca3792c15b662ef7d895b5daff20 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 17:29:14 +0000 Subject: [PATCH 17/27] add live test --- .../v1_5/features/VdcClientLiveTest.java | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java new file mode 100644 index 0000000000..634dc7e49a --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -0,0 +1,145 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + *(Link.builder().regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless(Link.builder().required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.features; + +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; + +import org.jclouds.vcloud.director.v1_5.domain.Checks; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; + +import com.google.common.collect.Iterables; + +/** + * Tests behavior of {@code VdcClient} + * + * @author danikov + */ +@Test(groups = { "live", "apitests", "user" }, testName = "VdcClientLiveTest") +public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { + + public static final String VDC = "vdc"; + + /* + * Convenience reference to API client. + */ + protected VdcClient vdcClient; + + private Reference vdcRef; + + @BeforeGroups(groups = { "live" }, dependsOnMethods = { "setupClient" }) + public void before() { + String vdcId = ""; // TODO: inject + vdcRef = Reference.builder() + .type("application/vnd.vmware.vcloud.vdc+xml") + .name("") + .href(URI.create(endpoint+"/vdc/"+vdcId)) + .id(vdcId) + .build(); + vdcClient = context.getApi().getVdcClient(); + } + + @Test(testName = "GET /vdc/{id}") + public void testGetVdc() { + // required for testing + assertNotNull(vdcRef, String.format(REF_REQ_LIVE, VDC)); + + Vdc vdc = vdcClient.getVdc(vdcRef); + assertNotNull(vdc, String.format(OBJ_REQ_LIVE, VDC)); + assertTrue(!vdc.getDescription().equals("DO NOT USE"), "vDC isn't to be used for testing"); + + // parent type + Checks.checkEntityType(vdc); + + // required + assertNotNull(vdc.getAllocationModel(), String.format(OBJ_FIELD_REQ, VDC, "allocationModel")); + + assertNotNull(vdc.getStorageCapacity(), String.format(OBJ_FIELD_REQ, VDC, "storageCapacity")); + Checks.checkCapacityWithUsage(vdc.getStorageCapacity()); + + assertNotNull(vdc.getComputeCapacity(), String.format(OBJ_FIELD_REQ, VDC, "computeCapacity")); + Checks.checkComputeCapacity(vdc.getComputeCapacity()); + + assertNotNull(vdc.getNicQuota(), String.format(OBJ_FIELD_REQ, VDC, "nicQuota")); + assertTrue(vdc.getNicQuota() >= 0, String.format(OBJ_FIELD_GTE_0, VDC, "nicQuota", vdc.getNicQuota())); + + assertNotNull(vdc.getNetworkQuota(), String.format(OBJ_FIELD_REQ, VDC, "networkQuota")); + assertTrue(vdc.getNetworkQuota() >= 0, String.format(OBJ_FIELD_GTE_0, VDC, "networkQuota", vdc.getNetworkQuota())); + + + // optional + // NOTE isEnabled cannot be checked + if (vdc.getResourceEntities() != null) { + Checks.checkResourceEntities(vdc.getResourceEntities()); + } + if (vdc.getAvailableNetworks() != null) { + Checks.checkAvailableNetworks(vdc.getAvailableNetworks()); + } + if (vdc.getCapabilities() != null) { + Checks.checkCapabilities(vdc.getCapabilities()); + } + if(vdc.getVmQuota() != null) { + assertTrue(vdc.getVmQuota() >= 0, String.format(OBJ_FIELD_GTE_0, VDC, "vmQuota", vdc.getVmQuota())); + } + if(vdc.getVmQuota() != null) { + assertTrue(vdc.getVmQuota() >= 0, String.format(OBJ_FIELD_GTE_0, VDC, "vmQuota", vdc.getVmQuota())); + } + } + +// POST /vdc/{id}/action/captureVApp +// POST /vdc/{id}/action/cloneMedia +// POST /vdc/{id}/action/cloneVApp +// POST /vdc/{id}/action/cloneVAppTemplate +// POST /vdc/{id}/action/composeVApp +// POST /vdc/{id}/action/instantiateVAppTemplate +// POST /vdc/{id}/action/uploadVAppTemplate +// POST /vdc/{id}/media + + @Test(testName = "GET /network/{id}/metadata") + public void testGetMetadata() { + Metadata metadata = vdcClient.getMetadata(vdcRef); + // required for testing + assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), + String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries")); + + Checks.checkMetadataFor(VDC, metadata); + } + + @Test(testName = "GET /network/{id}/metadata/{key}") + public void testGetMetadataValue() { + MetadataValue metadataValue = vdcClient.getMetadataValue(vdcRef, "key"); + + Checks.checkMetadataValueFor(VDC, metadataValue); + } + +} From 95cb736a185c6df6580ad495c65ef66af4045e54 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 17:29:36 +0000 Subject: [PATCH 18/27] remove scratch comments --- .../director/v1_5/features/VdcClientExpectTest.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index da7ba2638e..fbfcd1412d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -196,15 +196,6 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } } -// POST /vdc/{id}/action/captureVApp -// POST /vdc/{id}/action/cloneMedia -// POST /vdc/{id}/action/cloneVApp -// POST /vdc/{id}/action/cloneVAppTemplate -// POST /vdc/{id}/action/composeVApp -// POST /vdc/{id}/action/instantiateVAppTemplate -// POST /vdc/{id}/action/uploadVAppTemplate -// POST /vdc/{id}/media - @Test public void testCloneMedia() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, From 52717c3135fb2f7077b39c95d3c79cfa9a3f3396 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 21 Feb 2012 17:31:22 +0000 Subject: [PATCH 19/27] add checks for: ComputeCapacity, CapacityWithUsage, CapacityType, ResourceEntities, AvailableNetworks, Capabilities, SupportedHardwareVersions, Metadata, MetadataValue --- .../vcloud/director/v1_5/domain/Checks.java | 96 ++++++++++++++++++- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java index 6308e7addf..fcf5d55f3d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/Checks.java @@ -20,6 +20,8 @@ package org.jclouds.vcloud.director.v1_5.domain; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CONDITION_FMT; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_BE_WELL_FORMED_FMT; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_ATTRB_REQ; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_CONTAIN_FMT; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJECT_FMT; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0; @@ -269,19 +271,15 @@ public class Checks { if (config.getIpScope() != null) { checkIpScope(config.getIpScope()); } - if (config.getParentNetwork() != null) { checkReferenceType(config.getParentNetwork()); } - if (config.getNetworkFeatures() != null) { checkNetworkFeatures(config.getNetworkFeatures()); } - if (config.getSyslogServerSettings() != null) { checkSyslogServerSettings(config.getSyslogServerSettings()); } - if (config.getRouterInfo() != null) { checkRouterInfo(config.getRouterInfo()); } @@ -327,7 +325,6 @@ public class Checks { if (settings.getSyslogServerIp1() != null) { checkIpAddress(settings.getSyslogServerIp1()); } - if (settings.getSyslogServerIp2() != null) { checkIpAddress(settings.getSyslogServerIp2()); } @@ -370,6 +367,95 @@ public class Checks { public static void checkIpAddress(String ip) { InetAddresses.isInetAddress(ip); } + + public static void checkComputeCapacity(ComputeCapacity computeCapacity) { + // Check required fields + assertNotNull(computeCapacity.getCpu(), "The cpu attribute of a ComputeCapacity must be set"); + checkCapacityWithUsage(computeCapacity.getCpu()); + + assertNotNull(computeCapacity.getMemory(), "The memory attribute of a ComputeCapacity must be set"); + checkCapacityWithUsage(computeCapacity.getMemory()); + } + + public static void checkCapacityWithUsage(CapacityWithUsage capacityWithUsage) { + // Check optional fields + if (capacityWithUsage.getUsed() != null) { + assertTrue(capacityWithUsage.getUsed() >= 0, "used must be greater than or equal to 0"); + } + if (capacityWithUsage.getOverhead() != null) { + assertTrue(capacityWithUsage.getOverhead() >= 0, "overhead must be greater than or equal to 0"); + } + + // Check parent type + checkCapacityType(capacityWithUsage); + } + + public static void checkCapacityType(CapacityType capacity) { + // Check required fields + assertNotNull(capacity.getUnits(), "The unit attribute of a CapacityWithUsage must be set"); + + assertNotNull(capacity.getLimit(), "The limit attribute of a CapacityWithUsage must be set"); + assertTrue(capacity.getLimit() >= 0, "Limit must be greater than or equal to 0"); + + + // Check optional fields + if (capacity.getAllocated() != null) { + assertTrue(capacity.getAllocated() >= 0, "allocated must be greater than or equal to 0"); + } + } + + public static void checkResourceEntities(ResourceEntities resourceEntities) { + for (Reference resourceEntity : resourceEntities.getResourceEntities()) { + checkReferenceType(resourceEntity); + } + } + + public static void checkAvailableNetworks(AvailableNetworks availableNetworks) { + for (Reference network : availableNetworks.getNetworks()) { + checkReferenceType(network); + } + } + + public static void checkCapabilities(Capabilities capabilities) { + // Check optional fields + if (capabilities.getSupportedHardwareVersions() != null) { + checkSupportedHardwareVersions(capabilities.getSupportedHardwareVersions()); + } + } + public static void checkSupportedHardwareVersions(SupportedHardwareVersions supportedHardwareVersions) { + for (String supportedHardwareVersion : supportedHardwareVersions.getSupportedHardwareVersions()) { + // NOTE supportedHardwareVersion cannot be checked? + } + } + + public static void checkMetadataFor(String client, Metadata metadata) { + for (MetadataEntry entry : metadata.getMetadataEntries()) { + // Check required fields + assertNotNull(entry.getKey(), + String.format(OBJ_FIELD_ATTRB_REQ, client, "MetadataEntry", entry.getKey(), "key")); + assertNotNull(entry.getValue(), + String.format(OBJ_FIELD_ATTRB_REQ, client, "MetadataEntry", entry.getValue(), "value")); + + // Check parent type + checkResourceType(entry); + } + + // Check parent type + checkResourceType(metadata); + } + + public static void checkMetadataValueFor(String client, MetadataValue metadataValue) { + // Check required fields + String value = metadataValue.getValue(); + assertNotNull(value, + String.format(OBJ_FIELD_ATTRB_REQ, client, "MetadataEntry", + metadataValue.toString(), "value")); + assertEquals(value, "value", + String.format(OBJ_FIELD_EQ, client, "metadataEntry.value", "value", value)); + + // Check parent type + checkResourceType(metadataValue); + } public static void checkVApp(VApp vApp) { // TODO Auto-generated method stub From 81dfd02935832f3036e8b9c5217f8e8bdc5aba93 Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 10:46:29 +0000 Subject: [PATCH 20/27] add missing builder inherited methods --- .../director/v1_5/domain/CloneVAppParams.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java index 1c3f3786f2..69559ff598 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/CloneVAppParams.java @@ -70,6 +70,77 @@ public class CloneVAppParams return cloneVAppParams; } + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + super.vAppParent(vAppParent); + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + super.instantiationParams(instantiationParams); + return this; + } + + /** + * @see VAppCreationParamsType#getDeploy() + */ + public Builder deploy(Boolean deploy) { + super.deploy(deploy); + return this; + } + + /** + * @see VAppCreationParamsType#getPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + super.powerOn(powerOn); + return this; + } + + /** + * @see InstantiateVAppParamsType#getSource() + */ + public Builder source(Reference source) { + super.source(source); + return this; + } + + /** + * @see InstantiateVAppParamsType#getIsSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + super.isSourceDelete(isSourceDelete); + return this; + } + + /** + * @see InstantiateVAppParamsType#getLinkedClone() + */ + public Builder linkedClone(Boolean linkedClone) { + super.linkedClone(linkedClone); + return this; + } @Override public Builder fromInstantiateVAppParamsType(InstantiateVAppParamsType in) { From 54b3c01377ce3af5b2bb8c5f7bbcf57a3531050c Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 10:46:53 +0000 Subject: [PATCH 21/27] remove shadowing networkId --- .../vcloud/director/v1_5/features/NetworkClientLiveTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 790198f5f7..d2ecac0bb3 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -65,7 +65,6 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { @BeforeClass(inheritGroups = true) @Override public void setupRequiredClients() { - String networkId = "a604f3c2-0343-453e-ae1f-cddac5b7bd94"; // TODO: inject networkRef = Reference.builder() .type("application/vnd.vmware.vcloud.orgNetwork+xml") .name("") From 7d5dbbef59c80a6f19ddca848991c0e01d1966d8 Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 11:04:01 +0000 Subject: [PATCH 22/27] flesh out/first pass live tests --- .../v1_5/features/VdcClientLiveTest.java | 188 ++++++++++++++++-- 1 file changed, 170 insertions(+), 18 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index 634dc7e49a..4b049d4dd6 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -29,13 +29,23 @@ import static org.testng.Assert.assertTrue; import java.net.URI; +import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.Checks; +import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParams; +import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.domain.VApp; +import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; -import org.testng.annotations.BeforeGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.Iterables; @@ -49,26 +59,26 @@ import com.google.common.collect.Iterables; public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { public static final String VDC = "vdc"; - + /* * Convenience reference to API client. */ protected VdcClient vdcClient; - + private Reference vdcRef; - @BeforeGroups(groups = { "live" }, dependsOnMethods = { "setupClient" }) - public void before() { - String vdcId = ""; // TODO: inject + @BeforeClass(inheritGroups = true) + @Override + public void setupRequiredClients() { vdcRef = Reference.builder() .type("application/vnd.vmware.vcloud.vdc+xml") .name("") - .href(URI.create(endpoint+"/vdc/"+vdcId)) - .id(vdcId) + .href(URI.create(endpoint+"/vdc/"+vDCId)) + .id(vDCId) .build(); vdcClient = context.getApi().getVdcClient(); } - + @Test(testName = "GET /vdc/{id}") public void testGetVdc() { // required for testing @@ -116,14 +126,157 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { } } -// POST /vdc/{id}/action/captureVApp -// POST /vdc/{id}/action/cloneMedia -// POST /vdc/{id}/action/cloneVApp -// POST /vdc/{id}/action/cloneVAppTemplate -// POST /vdc/{id}/action/composeVApp -// POST /vdc/{id}/action/instantiateVAppTemplate -// POST /vdc/{id}/action/uploadVAppTemplate -// POST /vdc/{id}/media + @Test(testName = "POST /vdc/{id}/action/captureVApp", enabled = false) + public void testCaptureVApp() { + Reference templateSource = null; // TODO: vApp reference + VAppTemplate template = vdcClient.captureVApp(vdcRef, CaptureVAppParams.builder() + .source(templateSource) + // TODO: test optional params + //.name("") + //.description("") + //.sections(sections) // TODO: ovf sections + .build()); + + Checks.checkVAppTemplate(template); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/cloneMedia") + public void testCloneMedia() { + Reference mediaSource = null; // TODO: media reference + Media media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() + .source(mediaSource) + // TODO: test optional params + //.name("") + //.description("") + //.isSourceDelete(true) + .build()); + + Checks.checkMediaFor(VDC, media); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/cloneVApp", enabled = false) + public void testCloneVApp() { + Reference vAppSource = null; // TODO: vApp reference + VApp vApp = vdcClient.cloneVApp(vdcRef, CloneVAppParams.builder() + .source(vAppSource) + // TODO: test optional params + //.name("") + //.description("") + //.deploy(true) + //.isSourceDelete(true) + //.powerOn(true) + //.instantiationParams(InstantiationParams.builder() + // .sections(sections) // TODO: ovf sections? various tests? + // .build()) + + // Reserved. Unimplemented params; may test eventually when implemented + //.vAppParent(vAppParentRef) + //.linkedClone(true) + .build()); + + Checks.checkVApp(vApp); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/cloneVAppTemplate", enabled = false) + public void testCloneVAppTemplate() { + Reference templateSource = null; // TODO: vAppTemplate reference + VAppTemplate template = vdcClient.cloneVAppTemplate(vdcRef, CloneVAppTemplateParams.builder() + .source(templateSource) + // TODO: test optional params + //.name("") + //.description("") + //.isSourceDelete(true) + //.sections(sections) // TODO: ovf sections + .build()); + + Checks.checkVAppTemplate(template); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/composeVApp", enabled = false) + public void testComposeVApp() { + VApp vApp = vdcClient.composeVApp(vdcRef, ComposeVAppParams.builder() + // TODO: test optional params + //.name("") + //.description("") + //.deploy(true) + //.isSourceDelete(true) + //.powerOn(true) + //.instantiationParams(InstantiationParams.builder() + // .sections(sections) // TODO: ovf sections? various tests? + // .build()) + + // Reserved. Unimplemented params; may test eventually when implemented + //.linkedClone() + .build()); + + Checks.checkVApp(vApp); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/instantiateVAppTemplate", enabled = false) + public void testInstantiateVAppTemplate() { + Reference templateSource = null; // TODO: vApp or vAppTemplate reference + VApp vApp = vdcClient.instantiateVApp(vdcRef, InstantiateVAppParams.builder() + .source(templateSource) + // TODO: test optional params + //.name("") + //.description("") + //.isSourceDelete(true) + .build()); + + Checks.checkVApp(vApp); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/action/uploadVAppTemplate", enabled = false) + public void testUploadVAppTemplate() { + VAppTemplate template = vdcClient.uploadVAppTemplate(vdcRef, UploadVAppTemplateParams.builder() + // TODO: test optional params + //.name("") + //.description("") + //.transferFormat("") + //.manifestRequired(true) + .build()); + + Checks.checkVAppTemplate(template); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } + + @Test(testName = "POST /vdc/{id}/media") + public void testCreateMedia() { + Media media = vdcClient.createMedia(vdcRef, Media.builder() + .name("") + .imageType(Media.ImageType.ISO) + .size(0) + // TODO: test optional params + //.name("") + //.description("") + //.isSourceDelete(true) + .build()); + + Checks.checkMediaFor(VDC, media); + + // TODO: await task to complete + // TODO: make assertions that the task was successful + } @Test(testName = "GET /network/{id}/metadata") public void testGetMetadata() { @@ -141,5 +294,4 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMetadataValueFor(VDC, metadataValue); } - } From e0b11006511c65266f43c2428e7bad02dc70a5aa Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 13:37:32 +0000 Subject: [PATCH 23/27] fix expect test before --- .../vcloud/director/v1_5/features/VdcClientExpectTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index fbfcd1412d..ff8dce1e2e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -50,6 +50,7 @@ import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -65,9 +66,9 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest private Reference vdcRef; - @BeforeGroups(groups = { "unit" }, dependsOnMethods = { "setupClient" }) + @BeforeClass public void before() { - String vdcId = "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"; // TODO: inject + String vdcId = "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"; vdcRef = Reference.builder() .type("application/vnd.vmware.vcloud.vdc+xml") .name("") From d8924519c78a07cdca114645a19bb81b97617098 Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 13:41:17 +0000 Subject: [PATCH 24/27] fix domain object inhertance --- .../v1_5/domain/InstantiateVAppParamsType.java | 12 +++++++++--- .../vcloud/director/v1_5/domain/ParamsType.java | 4 ++-- .../director/v1_5/domain/VAppCreationParamsType.java | 10 ++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java index 0660a06a87..4f35618a76 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParamsType.java @@ -80,9 +80,9 @@ public class InstantiateVAppParamsType> public static class Builder> extends VAppCreationParamsType.Builder { - private Reference source; - private Boolean isSourceDelete; - private Boolean linkedClone; + protected Reference source; + protected Boolean isSourceDelete; + protected Boolean linkedClone; /** * @see InstantiateVAppParamsType#getSource() @@ -114,6 +114,12 @@ public class InstantiateVAppParamsType> instantiateVAppParams.setSource(source); instantiateVAppParams.setIsSourceDelete(isSourceDelete); instantiateVAppParams.setLinkedClone(linkedClone); + instantiateVAppParams.setVAppParent(vAppParent); + instantiateVAppParams.setInstantiationParams(instantiationParams); + instantiateVAppParams.setDeploy(deploy); + instantiateVAppParams.setPowerOn(powerOn); + instantiateVAppParams.setDescription(description); + instantiateVAppParams.setName(name); return instantiateVAppParams; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java index 83542c3017..a2f8d4e7ce 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/ParamsType.java @@ -81,8 +81,8 @@ public class ParamsType> { public static class Builder>{ - private String description; - private String name; + protected String description; + protected String name; /** * @see ParamsType#getDescription() diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java index 1fc316b172..2488b79dc7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/VAppCreationParamsType.java @@ -83,10 +83,10 @@ public class VAppCreationParamsType> public static class Builder> extends ParamsType.Builder { - private Reference vAppParent; - private InstantiationParams instantiationParams; - private Boolean deploy; - private Boolean powerOn; + protected Reference vAppParent; + protected InstantiationParams instantiationParams; + protected Boolean deploy; + protected Boolean powerOn; /** * @see VAppCreationParamsType#getVAppParent() @@ -127,6 +127,8 @@ public class VAppCreationParamsType> vAppCreationParams.setInstantiationParams(instantiationParams); vAppCreationParams.setDeploy(deploy); vAppCreationParams.setPowerOn(powerOn); + vAppCreationParams.setDescription(description); + vAppCreationParams.setName(name); return vAppCreationParams; } From 672acd898ee00988efb7441e96b9c61d8db2bc11 Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 13:43:45 +0000 Subject: [PATCH 25/27] add concrete instantiate params --- .../v1_5/domain/InstantiateVAppParams.java | 158 ++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java new file mode 100644 index 0000000000..55d7c2f709 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/InstantiateVAppParams.java @@ -0,0 +1,158 @@ +/** + * 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; + + + +/** + * Parameters for Instantiating a vApp + * + * @author danikov + */ +public class InstantiateVAppParams + extends InstantiateVAppParamsType { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder(); + } + + public static class Builder + extends InstantiateVAppParamsType.Builder { + + public InstantiateVAppParams build() { + InstantiateVAppParams instantiateVAppParams = new InstantiateVAppParams(); + instantiateVAppParams.setSource(source); + instantiateVAppParams.setIsSourceDelete(isSourceDelete); + instantiateVAppParams.setLinkedClone(linkedClone); + instantiateVAppParams.setVAppParent(vAppParent); + instantiateVAppParams.setInstantiationParams(instantiationParams); + instantiateVAppParams.setDeploy(deploy); + instantiateVAppParams.setPowerOn(powerOn); + instantiateVAppParams.setDescription(description); + instantiateVAppParams.setName(name); + return instantiateVAppParams; + } + + /** + * @see InstantiateVAppParams#getSource() + */ + public Builder source(Reference source) { + super.source(source); + return this; + } + + /** + * @see InstantiateVAppParams#getIsSourceDelete() + */ + public Builder isSourceDelete(Boolean isSourceDelete) { + super.isSourceDelete(isSourceDelete); + return this; + } + + /** + * @see InstantiateVAppParams#getLinkedClone() + */ + public Builder linkedClone(Boolean linkedClone) { + super.linkedClone(linkedClone); + return this; + } + + /** + * @see ParamsType#getDescription() + */ + public Builder description(String description) { + super.description(description); + return this; + } + + /** + * @see ParamsType#getName() + */ + public Builder name(String name) { + super.name(name); + return this; + } + + /** + * @see VAppCreationParamsType#getVAppParent() + */ + public Builder vAppParent(Reference vAppParent) { + super.vAppParent(vAppParent); + return this; + } + + /** + * @see VAppCreationParamsType#getInstantiationParams() + */ + public Builder instantiationParams(InstantiationParams instantiationParams) { + super.instantiationParams(instantiationParams); + return this; + } + + /** + * @see VAppCreationParamsType#getDeploy() + */ + public Builder deploy(Boolean deploy) { + super.deploy(deploy); + return this; + } + + /** + * @see VAppCreationParamsType#getPowerOn() + */ + public Builder powerOn(Boolean powerOn) { + super.powerOn(powerOn); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromInstantiateVAppParamsType( + InstantiateVAppParamsType in) { + return Builder.class.cast(super.fromVAppCreationParamsType(in)); + } + public Builder fromInstantiateVAppParams(InstantiateVAppParams in) { + return fromInstantiateVAppParamsType(in); + } + } + + protected InstantiateVAppParams() { + // For JAXB and builder use + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InstantiateVAppParams that = InstantiateVAppParams.class.cast(o); + return super.equals(that); + } + +} From 58bddc6798c05bb654b4527ae21722ba1a8aeb5b Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 14:14:14 +0000 Subject: [PATCH 26/27] disable dependent tests --- .../v1_5/features/VdcClientExpectTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index ff8dce1e2e..b1e6e6c107 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -147,7 +147,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest } } - @Test + @Test(enabled = false) public void testCaptureVApp() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -169,7 +169,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest assertEquals(client.getVdcClient().captureVApp(vdcRef, params), expected); } - @Test + @Test(enabled = false) public void testResponse4xxForCaptureVAppNoParams() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -219,7 +219,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest assertEquals(client.getVdcClient().cloneMedia(vdcRef, params), expected); } - @Test + @Test(enabled = false) public void testCloneVApp() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -241,7 +241,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest assertEquals(client.getVdcClient().cloneVApp(vdcRef, params), expected); } - @Test + @Test(enabled = false) public void testCloneVAppTemplate() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -263,7 +263,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest assertEquals(client.getVdcClient().cloneVAppTemplate(vdcRef, params), expected); } - @Test + @Test(enabled = false) public void testComposeVApp() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -285,7 +285,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest assertEquals(client.getVdcClient().composeVApp(vdcRef, params), expected); } - @Test + @Test(enabled = false) public void testInstantiateVAppTemplate() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() @@ -307,7 +307,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest assertEquals(client.getVdcClient().instantiateVApp(vdcRef, params), expected); } - @Test + @Test(enabled = false) public void testUploadVAppTemplate() { VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, new VcloudHttpRequestPrimer() From 3c78423d501c7605d79f6c46bc0f94a01e9e4b01 Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 23 Feb 2012 14:34:57 +0000 Subject: [PATCH 27/27] update to remove deprecated test approaches --- .../v1_5/features/VdcClientExpectTest.java | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index b1e6e6c107..7641fe31de 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -40,7 +40,6 @@ import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.ResourceEntities; @@ -51,11 +50,8 @@ import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; - /** * Allows us to test a client via its side effects. * @@ -356,40 +352,38 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest URI vdcUri = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata"), - getStandardPayloadResponse("/vdc/metadata.xml", VCloudDirectorMediaType.METADATA)); + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/metadata.xml", VCloudDirectorMediaType.METADATA) + .httpResponseBuilder().build()); - Metadata expected = Metadata.builder() - .type("application/vnd.vmware.vcloud.metadata+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata")) - .link(Link.builder() - .rel("up") - .type("application/vnd.vmware.vcloud.vdc+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f")) - .build()) - .entries(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build())) - .build(); + Reference mediaRef = Reference.builder().href(vdcUri).build(); + + Metadata expected = metadata(); - Reference vdcRef = Reference.builder().href(vdcUri).build(); - - assertEquals(client.getVdcClient().getMetadata(vdcRef), expected); + assertEquals(client.getMediaClient().getMetadata(mediaRef), expected); } - @Test(enabled=false) // No metadata in exemplar xml... public void testGetMetadataValue() { URI vdcUri = URI.create("https://vcloudbeta.bluelock.com/api/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata/KEY"), - getStandardPayloadResponse("/vdc/metadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY)); + new VcloudHttpRequestPrimer() + .apiCommand("GET", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/metadata/key") + .acceptAnyMedia() + .httpRequestBuilder().build(), + new VcloudHttpResponsePrimer() + .xmlFilePayload("/vdc/metadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE) + .httpResponseBuilder().build()); - MetadataValue expected = MetadataValue.builder() - .value("value") - .build(); + MetadataValue expected = metadataValue(); + + Reference mediaRef = Reference.builder().href(vdcUri).build(); - Reference vdcRef = Reference.builder().href(vdcUri).build(); - - assertEquals(client.getVdcClient().getMetadataValue(vdcRef, "KEY"), expected); + assertEquals(client.getVdcClient().getMetadataValue(mediaRef, "key"), expected); } public static Vdc getVdc() { @@ -561,4 +555,14 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest // TODO Auto-generated method stub return null; } + + private Metadata metadata() { + // TODO Auto-generated method stub + return null; + } + + private MetadataValue metadataValue() { + // TODO Auto-generated method stub + return null; + } }