mirror of https://github.com/apache/jclouds.git
Merge pull request #538 from grkvlt/vcloud-updates
Issue 830: Updates and improvements for domain objects
This commit is contained in:
commit
dfedfa0ebe
|
@ -32,12 +32,13 @@ import javax.xml.bind.annotation.XmlType;
|
|||
*/
|
||||
@XmlType(name = "CloneVAppParams")
|
||||
@XmlRootElement(name = "CloneVAppParams")
|
||||
public class CloneVAppParams extends InstantiateVAppParamsType {
|
||||
public class CloneVAppParams extends InstantiateVAppParams {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromCloneVAppParams(this);
|
||||
}
|
||||
|
@ -45,7 +46,13 @@ public class CloneVAppParams extends InstantiateVAppParamsType {
|
|||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static abstract class Builder<B extends Builder<B>> extends InstantiateVAppParamsType.Builder<B> {
|
||||
public static abstract class Builder<B extends Builder<B>> extends InstantiateVAppParams.Builder<B> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected B self() {
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloneVAppParams build() {
|
||||
|
|
|
@ -28,17 +28,13 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Represents parameters for copying a vApp template and optionally
|
||||
* deleting the source.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>Java class for CloneVAppTemplateParams complex type.
|
||||
* <p/>
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p/>
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="CloneVAppTemplateParams">
|
||||
* <complexContent>
|
||||
|
@ -63,6 +59,7 @@ public class CloneVAppTemplateParams extends ParamsType {
|
|||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromCloneVAppTemplateParams(this);
|
||||
}
|
||||
|
@ -75,6 +72,12 @@ public class CloneVAppTemplateParams extends ParamsType {
|
|||
private Reference source;
|
||||
private Boolean isSourceDelete;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected B self() {
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CloneVAppTemplateParams#getSource()
|
||||
*/
|
||||
|
@ -101,6 +104,7 @@ public class CloneVAppTemplateParams extends ParamsType {
|
|||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloneVAppTemplateParams build() {
|
||||
return new CloneVAppTemplateParams(this);
|
||||
}
|
||||
|
@ -130,9 +134,6 @@ public class CloneVAppTemplateParams extends ParamsType {
|
|||
|
||||
/**
|
||||
* Gets the value of the source property.
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link Reference }
|
||||
*/
|
||||
public Reference getSource() {
|
||||
return source;
|
||||
|
@ -140,9 +141,6 @@ public class CloneVAppTemplateParams extends ParamsType {
|
|||
|
||||
/**
|
||||
* Gets the value of the isSourceDelete property.
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link Boolean }
|
||||
*/
|
||||
public Boolean isSourceDelete() {
|
||||
return isSourceDelete;
|
||||
|
@ -155,21 +153,21 @@ public class CloneVAppTemplateParams extends ParamsType {
|
|||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
CloneVAppTemplateParams that = CloneVAppTemplateParams.class.cast(o);
|
||||
return equal(source, that.source) &&
|
||||
equal(isSourceDelete, that.isSourceDelete);
|
||||
return super.equals(that) &&
|
||||
equal(this.source, that.source) &&
|
||||
equal(this.isSourceDelete, that.isSourceDelete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(source,
|
||||
isSourceDelete);
|
||||
return Objects.hashCode(super.hashCode(), source, isSourceDelete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("")
|
||||
public ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("source", source)
|
||||
.add("isSourceDelete", isSourceDelete).toString();
|
||||
.add("isSourceDelete", isSourceDelete);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,48 +16,176 @@
|
|||
* 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.net.URI;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Parameters for Instantiating a vApp
|
||||
* Represents vApp instantiation parameters.
|
||||
*
|
||||
* @author danikov
|
||||
* @author grkvlt@apache.org
|
||||
* @see <a href="http://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/types/InstantiateVAppParamsType.html">
|
||||
* vCloud REST API - InstantiateVAppParamsType</a>
|
||||
* @since 0.9
|
||||
*/
|
||||
public class InstantiateVAppParams extends InstantiateVAppParamsType {
|
||||
@XmlRootElement(name = "InstantiateVAppParams")
|
||||
@XmlType(name = "InstantiateVAppParamsType")
|
||||
public class InstantiateVAppParams extends VAppCreationParamsType {
|
||||
|
||||
public static final String MEDIA_TYPe = VCloudDirectorMediaType.INSTANTIATE_VAPP_TEMPLATE_PARAMS;
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromInstantiateVAppParams(this);
|
||||
return builder().fromInstantiateVAppParamsType(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static abstract class Builder<B extends Builder<B>> extends InstantiateVAppParamsType.Builder<B> {
|
||||
public static abstract class Builder<B extends Builder<B>> extends VAppCreationParamsType.Builder<B> {
|
||||
|
||||
private Reference source;
|
||||
private Boolean sourceDelete;
|
||||
private Boolean linkedClone;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected B self() {
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#getSource()
|
||||
*/
|
||||
public B source(Reference source) {
|
||||
this.source = source;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets source to a new Reference that uses this URI as the href.
|
||||
*
|
||||
* @see InstantiateVAppParamsType#getSource()
|
||||
*/
|
||||
public B source(URI source) {
|
||||
this.source = Reference.builder().href(source).build();
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isSourceDelete()
|
||||
*/
|
||||
public B isSourceDelete(Boolean sourceDelete) {
|
||||
this.sourceDelete = sourceDelete;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isSourceDelete()
|
||||
*/
|
||||
public B sourceDelete() {
|
||||
this.sourceDelete = Boolean.TRUE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isSourceDelete()
|
||||
*/
|
||||
public B notSourceDelete() {
|
||||
this.sourceDelete = Boolean.FALSE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isLinkedClone()
|
||||
*/
|
||||
public B isLinkedClone(Boolean linkedClone) {
|
||||
this.linkedClone = linkedClone;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isLinkedClone()
|
||||
*/
|
||||
public B linkedClone() {
|
||||
this.linkedClone = Boolean.TRUE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isLinkedClone()
|
||||
*/
|
||||
public B notLinkedClone() {
|
||||
this.linkedClone = Boolean.FALSE;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstantiateVAppParams build() {
|
||||
return new InstantiateVAppParams(this);
|
||||
}
|
||||
|
||||
public B fromInstantiateVAppParams(InstantiateVAppParams in) {
|
||||
return fromInstantiateVAppParamsType(in);
|
||||
public B fromInstantiateVAppParamsType(InstantiateVAppParams in) {
|
||||
return fromVAppCreationParamsType(in)
|
||||
.source(in.getSource())
|
||||
.isSourceDelete(in.isSourceDelete())
|
||||
.isLinkedClone(in.isLinkedClone());
|
||||
}
|
||||
}
|
||||
|
||||
protected InstantiateVAppParams() {
|
||||
// For JAXB and builder use
|
||||
}
|
||||
|
||||
public InstantiateVAppParams(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.source = builder.source;
|
||||
this.sourceDelete = builder.sourceDelete;
|
||||
this.linkedClone = builder.linkedClone;
|
||||
}
|
||||
|
||||
protected InstantiateVAppParams() {
|
||||
// for JAXB
|
||||
@XmlElement(name = "Source", required = true)
|
||||
private Reference source;
|
||||
@XmlElement(name = "IsSourceDelete")
|
||||
private Boolean sourceDelete;
|
||||
@XmlAttribute
|
||||
private Boolean linkedClone;
|
||||
|
||||
/**
|
||||
* Gets the value of the source property.
|
||||
*/
|
||||
public Reference getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the isSourceDelete property.
|
||||
*/
|
||||
public Boolean isSourceDelete() {
|
||||
return sourceDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the linkedClone property.
|
||||
*/
|
||||
public Boolean isLinkedClone() {
|
||||
return linkedClone;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,6 +195,22 @@ public class InstantiateVAppParams extends InstantiateVAppParamsType {
|
|||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
InstantiateVAppParams that = InstantiateVAppParams.class.cast(o);
|
||||
return super.equals(that);
|
||||
return super.equals(that) &&
|
||||
equal(this.source, that.source) &&
|
||||
equal(this.sourceDelete, that.sourceDelete) &&
|
||||
equal(this.linkedClone, that.linkedClone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), source, sourceDelete, linkedClone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("source", source)
|
||||
.add("isSourceDelete", sourceDelete)
|
||||
.add("linkedClone", linkedClone);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
* 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.net.URI;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents vApp instantiation parameters.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="InstantiateVAppParams" />
|
||||
* </pre>
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlType(name = "InstantiateVAppParams")
|
||||
public class InstantiateVAppParamsType extends VAppCreationParamsType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromInstantiateVAppParamsType(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static abstract class Builder<B extends Builder<B>> extends VAppCreationParamsType.Builder<B> {
|
||||
|
||||
private Reference source;
|
||||
private Boolean sourceDelete;
|
||||
private Boolean linkedClone;
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#getSource()
|
||||
*/
|
||||
public B source(Reference source) {
|
||||
this.source = source;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets source to a new Reference that uses this URI as the href.
|
||||
*
|
||||
* @see InstantiateVAppParamsType#getSource()
|
||||
*/
|
||||
public B source(URI source) {
|
||||
this.source = Reference.builder().href(source).build();
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isSourceDelete()
|
||||
*/
|
||||
public B isSourceDelete(Boolean sourceDelete) {
|
||||
this.sourceDelete = sourceDelete;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isSourceDelete()
|
||||
*/
|
||||
public B sourceDelete() {
|
||||
this.sourceDelete = Boolean.TRUE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isSourceDelete()
|
||||
*/
|
||||
public B notSourceDelete() {
|
||||
this.sourceDelete = Boolean.FALSE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isLinkedClone()
|
||||
*/
|
||||
public B isLinkedClone(Boolean linkedClone) {
|
||||
this.linkedClone = linkedClone;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isLinkedClone()
|
||||
*/
|
||||
public B linkedClone() {
|
||||
this.linkedClone = Boolean.TRUE;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppParamsType#isLinkedClone()
|
||||
*/
|
||||
public B notLinkedClone() {
|
||||
this.linkedClone = Boolean.FALSE;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstantiateVAppParamsType build() {
|
||||
return new InstantiateVAppParamsType(this);
|
||||
}
|
||||
|
||||
public B fromInstantiateVAppParamsType(InstantiateVAppParamsType in) {
|
||||
return fromVAppCreationParamsType(in)
|
||||
.source(in.getSource())
|
||||
.isSourceDelete(in.isSourceDelete())
|
||||
.isLinkedClone(in.isLinkedClone());
|
||||
}
|
||||
}
|
||||
|
||||
protected InstantiateVAppParamsType() {
|
||||
// For JAXB and builder use
|
||||
}
|
||||
|
||||
public InstantiateVAppParamsType(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.source = builder.source;
|
||||
this.sourceDelete = builder.sourceDelete;
|
||||
this.linkedClone = builder.linkedClone;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Source", required = true)
|
||||
private Reference source;
|
||||
@XmlElement(name = "IsSourceDelete")
|
||||
private Boolean sourceDelete;
|
||||
@XmlAttribute
|
||||
private Boolean linkedClone;
|
||||
|
||||
/**
|
||||
* Gets the value of the source property.
|
||||
*/
|
||||
public Reference getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the isSourceDelete property.
|
||||
*/
|
||||
public Boolean isSourceDelete() {
|
||||
return sourceDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the linkedClone property.
|
||||
*/
|
||||
public Boolean isLinkedClone() {
|
||||
return linkedClone;
|
||||
}
|
||||
|
||||
@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 super.equals(that) &&
|
||||
equal(this.source, that.source) &&
|
||||
equal(this.sourceDelete, that.sourceDelete) &&
|
||||
equal(this.linkedClone, that.linkedClone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), source, sourceDelete, linkedClone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("source", source)
|
||||
.add("isSourceDelete", sourceDelete)
|
||||
.add("linkedClone", linkedClone);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
* </pre>
|
||||
*/
|
||||
@XmlRootElement(name = "InstantiateVAppTemplateParams")
|
||||
public class InstantiateVAppTemplateParams extends InstantiateVAppParamsType {
|
||||
public class InstantiateVAppTemplateParams extends InstantiateVAppParams {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
|
@ -47,7 +47,7 @@ public class InstantiateVAppTemplateParams extends InstantiateVAppParamsType {
|
|||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static abstract class Builder<B extends Builder<B>> extends InstantiateVAppParamsType.Builder<B> {
|
||||
public static abstract class Builder<B extends Builder<B>> extends InstantiateVAppParams.Builder<B> {
|
||||
|
||||
private Boolean allEULAsAccepted;
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ 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.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
|
@ -29,19 +28,18 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Represents a list of ovf:Section to configure for instantiating a VApp.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="InstantiationParams" />
|
||||
* </pre>
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
* @see <a href="http://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/types/InstantiationParamsType.html">
|
||||
* vCloud REST API - InstantiationParamsType</a>
|
||||
* @since 0.9
|
||||
*/
|
||||
@XmlRootElement(name = "InstantiationParams")
|
||||
@XmlType(name = "InstantiationParamsType")
|
||||
|
@ -56,13 +54,21 @@ public class InstantiationParams {
|
|||
}
|
||||
|
||||
public static class Builder {
|
||||
private Set<? extends SectionType> sections = Sets.newLinkedHashSet();
|
||||
private Set<SectionType> sections = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see InstantiationParams#getSections()
|
||||
*/
|
||||
public Builder sections(Set<? extends SectionType> sections) {
|
||||
this.sections = checkNotNull(sections, "sections");
|
||||
public Builder sections(Iterable<? extends SectionType> sections) {
|
||||
this.sections = Sets.newLinkedHashSet(checkNotNull(sections, "sections"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiationParams#getSections()
|
||||
*/
|
||||
public Builder section(SectionType section) {
|
||||
this.sections.add(checkNotNull(section, "section"));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -81,7 +87,7 @@ public class InstantiationParams {
|
|||
}
|
||||
|
||||
private InstantiationParams(Set<? extends SectionType> sections) {
|
||||
this.sections = sections;
|
||||
this.sections = ImmutableSet.copyOf(sections);
|
||||
}
|
||||
|
||||
@XmlElementRef
|
||||
|
@ -113,7 +119,7 @@ public class InstantiationParams {
|
|||
* </ul>
|
||||
*/
|
||||
public Set<? extends SectionType> getSections() {
|
||||
return Collections.unmodifiableSet(this.sections);
|
||||
return sections;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,7 +129,7 @@ public class InstantiationParams {
|
|||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
InstantiationParams that = InstantiationParams.class.cast(o);
|
||||
return equal(sections, that.sections);
|
||||
return equal(this.sections, that.sections);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,11 +30,11 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
/**
|
||||
* A basic type used to specify parameters for operations.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="Params" />
|
||||
* </pre>
|
||||
* @see <a href="http://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/types/ParamsType.html">
|
||||
* vCloud REST API - ParamsType</a>
|
||||
* @since 0.9
|
||||
*/
|
||||
@XmlType(name = "Params")
|
||||
@XmlType(name = "ParamsType")
|
||||
public class ParamsType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
|
@ -100,14 +100,14 @@ public class ParamsType {
|
|||
protected String name;
|
||||
|
||||
/**
|
||||
* Gets the value of the description property.
|
||||
* Optional description.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the name property.
|
||||
* A name as parameter.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
|
@ -127,6 +127,7 @@ public abstract class ResourceEntityType extends EntityType {
|
|||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromResourceEntityType(this);
|
||||
}
|
||||
|
|
|
@ -20,26 +20,44 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
|||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* Represents vApp/VM undeployment parameters.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="UndeployVAppParamsType" />
|
||||
* </pre>
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
* @see <a href="http://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/types/UndeployVAppParamsType.html">
|
||||
* vCloud REST API - UndeployVAppParamsType</a>
|
||||
* @since 0.9
|
||||
*/
|
||||
@XmlRootElement(name = "UndeployVAppParams")
|
||||
@XmlType(name = "UndeployVAppParamsType")
|
||||
public class UndeployVAppParams {
|
||||
|
||||
public static final String MEDIA_TYPe = VCloudDirectorMediaType.UNDEPLOY_VAPP_PARAMS;
|
||||
|
||||
public static class PowerAction {
|
||||
/** Power off the VMs. This is the default action if this attribute is missing or empty) */
|
||||
public static final String POWER_OFF = "powerOff";
|
||||
/** Suspend the VMs. */
|
||||
public static final String SUSPEND = "suspend";
|
||||
/** Shut down the VMs. */
|
||||
public static final String SHUTDOWN = "shutdown";
|
||||
/** Attempt to power off the VMs. */
|
||||
public static final String FORCE = "force";
|
||||
|
||||
public static final List<String> ALL = Arrays.asList(POWER_OFF, SUSPEND, SHUTDOWN, FORCE);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
@ -83,16 +101,14 @@ public class UndeployVAppParams {
|
|||
*
|
||||
* All values other than {@code default} ignore actions, order, and delay specified in the StartupSection. One of:
|
||||
* <ul>
|
||||
* <li>{@code powerOff} (Power off the VMs. This is the default action if this attribute is missing or empty)
|
||||
* <li>{@code suspend} (Suspend the VMs)
|
||||
* <li>{@code shutdown} (Shut down the VMs)
|
||||
* <li>{@code force} (Attempt to power off the VMs.
|
||||
* <li>{@link PowerAction#POWER_OFF powerOff}
|
||||
* <li>{@link PowerAction#SUSPEND suspend}
|
||||
* <li>{@link PowerAction#SHUTDOWN shutdown}
|
||||
* <li>{@link PowerAction#FORCE force}
|
||||
* </ul>
|
||||
* Failures in undeploying the VM or associated networks are ignored. All references to the vApp and its VMs are
|
||||
* removed from the database), default (Use the actions, order, and delay specified in the StartupSection).
|
||||
*
|
||||
* TODO add an enumeration for these values
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public String getUndeployPowerAction() {
|
||||
|
|
|
@ -30,11 +30,10 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
/**
|
||||
* Represents vApp creation parameters.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="VAppCreationParams" />
|
||||
* </pre>
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
* @see <a href="http://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/types/VAppCreationParamsType.html">
|
||||
* vCloud REST API - VAppCreationParamsType</a>
|
||||
* @since 0.9
|
||||
*/
|
||||
@XmlType(name = "VAppCreationParamsType")
|
||||
public class VAppCreationParamsType extends ParamsType {
|
||||
|
@ -43,6 +42,7 @@ public class VAppCreationParamsType extends ParamsType {
|
|||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromVAppCreationParamsType(this);
|
||||
}
|
||||
|
@ -148,28 +148,30 @@ public class VAppCreationParamsType extends ParamsType {
|
|||
protected Boolean powerOn;
|
||||
|
||||
/**
|
||||
* Gets the value of the vAppParent property.
|
||||
* Reserved.
|
||||
*
|
||||
* Unimplemented.
|
||||
*/
|
||||
public Reference getVAppParent() {
|
||||
return vAppParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the instantiationParams property.
|
||||
* Instantiation parameters of a VApp.
|
||||
*/
|
||||
public InstantiationParams getInstantiationParams() {
|
||||
return instantiationParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the deploy property.
|
||||
* Flag to deploy the VApp after successful creation.
|
||||
*/
|
||||
public Boolean isDeploy() {
|
||||
return deploy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the powerOn property.
|
||||
* Flag to deploy and power on the VApp after successful creation.
|
||||
*/
|
||||
public Boolean isPowerOn() {
|
||||
return powerOn;
|
||||
|
|
|
@ -575,7 +575,7 @@ public interface VAppAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ResourceAllocationSettingData> getVirtualHardwareSectionCpu(@EndpointParam URI vAppURI);
|
||||
ListenableFuture<ResourceAllocationSettingData> getVirtualHardwareSectionCpu(@EndpointParam URI vmURI);
|
||||
|
||||
/**
|
||||
* @see VAppClient#modifyVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData)
|
||||
|
@ -585,7 +585,7 @@ public interface VAppAsyncClient {
|
|||
@Produces(OVF_RASD_ITEM)
|
||||
@Consumes(TASK)
|
||||
@JAXBResponseParser
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionCpu(@EndpointParam URI vAppURI,
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionCpu(@EndpointParam URI vmURI,
|
||||
@BinderParam(BindToXMLPayload.class) ResourceAllocationSettingData rasd);
|
||||
|
||||
/**
|
||||
|
@ -596,7 +596,7 @@ public interface VAppAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<RasdItemsList> getVirtualHardwareSectionDisks(@EndpointParam URI vAppURI);
|
||||
ListenableFuture<RasdItemsList> getVirtualHardwareSectionDisks(@EndpointParam URI vmURI);
|
||||
|
||||
/**
|
||||
* @see VAppClient#modifyVirtualHardwareSectionDisks(URI, RasdItemsList)
|
||||
|
@ -606,7 +606,7 @@ public interface VAppAsyncClient {
|
|||
@Produces(OVF_RASD_ITEMS_LIST)
|
||||
@Consumes(TASK)
|
||||
@JAXBResponseParser
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionDisks(@EndpointParam URI vAppURI,
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionDisks(@EndpointParam URI vmURI,
|
||||
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
|
||||
|
||||
/**
|
||||
|
@ -617,7 +617,7 @@ public interface VAppAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<RasdItemsList> getVirtualHardwareSectionMedia(@EndpointParam URI vAppURI);
|
||||
ListenableFuture<RasdItemsList> getVirtualHardwareSectionMedia(@EndpointParam URI vmURI);
|
||||
|
||||
/**
|
||||
* @see VAppClient#getVirtualHardwareSectionMemory(URI)
|
||||
|
@ -627,7 +627,7 @@ public interface VAppAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ResourceAllocationSettingData> getVirtualHardwareSectionMemory(@EndpointParam URI vAppURI);
|
||||
ListenableFuture<ResourceAllocationSettingData> getVirtualHardwareSectionMemory(@EndpointParam URI vmURI);
|
||||
|
||||
/**
|
||||
* @see VAppClient#modifyVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData)
|
||||
|
@ -637,7 +637,7 @@ public interface VAppAsyncClient {
|
|||
@Produces(OVF_RASD_ITEM)
|
||||
@Consumes(TASK)
|
||||
@JAXBResponseParser
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionMemory(@EndpointParam URI vAppURI,
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionMemory(@EndpointParam URI vmURI,
|
||||
@BinderParam(BindToXMLPayload.class) ResourceAllocationSettingData rasd);
|
||||
|
||||
/**
|
||||
|
@ -648,7 +648,7 @@ public interface VAppAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<RasdItemsList> getVirtualHardwareSectionNetworkCards(@EndpointParam URI vAppURI);
|
||||
ListenableFuture<RasdItemsList> getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI);
|
||||
|
||||
/**
|
||||
* @see VAppClient#modifyVirtualHardwareSectionNetworkCards(URI, RasdItemsList)
|
||||
|
@ -658,7 +658,7 @@ public interface VAppAsyncClient {
|
|||
@Produces(OVF_RASD_ITEMS_LIST)
|
||||
@Consumes(TASK)
|
||||
@JAXBResponseParser
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionNetworkCards(@EndpointParam URI vAppURI,
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI,
|
||||
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
|
||||
|
||||
/**
|
||||
|
@ -669,7 +669,7 @@ public interface VAppAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<RasdItemsList> getVirtualHardwareSectionSerialPorts(@EndpointParam URI vAppURI);
|
||||
ListenableFuture<RasdItemsList> getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI);
|
||||
|
||||
/**
|
||||
* @see VAppClient#modifyVirtualHardwareSectionSerialPorts(URI, RasdItemsList)
|
||||
|
@ -679,7 +679,7 @@ public interface VAppAsyncClient {
|
|||
@Produces(OVF_RASD_ITEMS_LIST)
|
||||
@Consumes(TASK)
|
||||
@JAXBResponseParser
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionSerialPorts(@EndpointParam URI vAppURI,
|
||||
ListenableFuture<Task> modifyVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI,
|
||||
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
|
||||
|
||||
/**
|
||||
|
|
|
@ -674,7 +674,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
ResourceAllocationSettingData getVirtualHardwareSectionCpu(URI vAppURI);
|
||||
ResourceAllocationSettingData getVirtualHardwareSectionCpu(URI vmURI);
|
||||
|
||||
/**
|
||||
* Modifies the CPU properties in virtual hardware section of a VM.
|
||||
|
@ -685,7 +685,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
Task modifyVirtualHardwareSectionCpu(URI vAppURI, ResourceAllocationSettingData rasd);
|
||||
Task modifyVirtualHardwareSectionCpu(URI vmURI, ResourceAllocationSettingData rasd);
|
||||
|
||||
/**
|
||||
* Retrieves a list of ResourceAllocationSettingData items for disks from virtual hardware section of a VM.
|
||||
|
@ -696,7 +696,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
RasdItemsList getVirtualHardwareSectionDisks(URI vAppURI);
|
||||
RasdItemsList getVirtualHardwareSectionDisks(URI vmURI);
|
||||
|
||||
/**
|
||||
* Modifies the disks list in virtual hardware section of a VM.
|
||||
|
@ -707,7 +707,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
Task modifyVirtualHardwareSectionDisks(URI vAppURI, RasdItemsList rasdItemsList);
|
||||
Task modifyVirtualHardwareSectionDisks(URI vmURI, RasdItemsList rasdItemsList);
|
||||
|
||||
/**
|
||||
* Retrieves the list of ResourceAllocationSettingData items that represents the floppies and CD/DVD drives in a VM.
|
||||
|
@ -718,7 +718,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
RasdItemsList getVirtualHardwareSectionMedia(URI vAppURI);
|
||||
RasdItemsList getVirtualHardwareSectionMedia(URI vmURI);
|
||||
|
||||
/**
|
||||
* Retrieves the ResourceAllocationSettingData item that contains memory information from virtual hardware section of a VM.
|
||||
|
@ -729,7 +729,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
ResourceAllocationSettingData getVirtualHardwareSectionMemory(URI vAppURI);
|
||||
ResourceAllocationSettingData getVirtualHardwareSectionMemory(URI vmURI);
|
||||
|
||||
/**
|
||||
* Modifies the memory properties in virtual hardware section of a VM.
|
||||
|
@ -740,7 +740,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
Task modifyVirtualHardwareSectionMemory(URI vAppURI, ResourceAllocationSettingData rasd);
|
||||
Task modifyVirtualHardwareSectionMemory(URI vmURI, ResourceAllocationSettingData rasd);
|
||||
|
||||
/**
|
||||
* Retrieves a list of ResourceAllocationSettingData items for network cards from virtual hardware section of a VM.
|
||||
|
@ -751,7 +751,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
RasdItemsList getVirtualHardwareSectionNetworkCards(URI vAppURI);
|
||||
RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmURI);
|
||||
|
||||
/**
|
||||
* Modifies the network cards list in virtual hardware section of a VM.
|
||||
|
@ -762,7 +762,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 0.9
|
||||
*/
|
||||
Task modifyVirtualHardwareSectionNetworkCards(URI vAppURI, RasdItemsList rasdItemsList);
|
||||
Task modifyVirtualHardwareSectionNetworkCards(URI vmURI, RasdItemsList rasdItemsList);
|
||||
|
||||
/**
|
||||
* Retrieves a list of ResourceAllocationSettingData items for serial ports from virtual hardware section of a VM.
|
||||
|
@ -773,7 +773,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
RasdItemsList getVirtualHardwareSectionSerialPorts(URI vAppURI);
|
||||
RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmURI);
|
||||
|
||||
/**
|
||||
* Modifies the serial ports list in virtual hardware section of a VM.
|
||||
|
@ -784,7 +784,7 @@ public interface VAppClient {
|
|||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
Task modifyVirtualHardwareSectionSerialPorts(URI vAppURI, RasdItemsList rasdItemsList);
|
||||
Task modifyVirtualHardwareSectionSerialPorts(URI vmURI, RasdItemsList rasdItemsList);
|
||||
|
||||
/**
|
||||
* @return synchronous access to {@link Metadata} features
|
||||
|
|
|
@ -40,7 +40,7 @@ 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.InstantiateVAppParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||
|
@ -130,7 +130,7 @@ public interface VdcAsyncClient {
|
|||
@Produces(VCloudDirectorMediaType.INSTANTIATE_VAPP_TEMPLATE_PARAMS)
|
||||
@JAXBResponseParser
|
||||
ListenableFuture<VApp> instantiateVApp(@EndpointParam URI vdcURI,
|
||||
@BinderParam(BindToXMLPayload.class) InstantiateVAppParamsType params);
|
||||
@BinderParam(BindToXMLPayload.class) InstantiateVAppParams params);
|
||||
|
||||
/**
|
||||
* @see VdcClient#uploadVAppTemplate(URI, UploadVAppTemplateParams)
|
||||
|
|
|
@ -28,7 +28,7 @@ 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.InstantiateVAppParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||
|
@ -144,7 +144,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.
|
||||
*/
|
||||
VApp instantiateVApp(URI vdcUri, InstantiateVAppParamsType params);
|
||||
VApp instantiateVApp(URI vdcUri, InstantiateVAppParams params);
|
||||
|
||||
/**
|
||||
* Uploading vApp template to a vDC.
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* 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.predicates;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.EntityType;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Predicates for working with {@link EntityType} collections.
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
public class EntityPredicates {
|
||||
|
||||
/**
|
||||
* Matches {@link EntityType entities} with the given name.
|
||||
*
|
||||
* @param T type of the entity, for example {@link Vm}
|
||||
* @param name value of the name attribute of the entity
|
||||
* @return predicate that will match entities of the given name
|
||||
*/
|
||||
public static <T extends EntityType> Predicate<T> nameEquals(final String name) {
|
||||
checkNotNull(name, "name must be defined");
|
||||
|
||||
return new Predicate<T>() {
|
||||
@Override
|
||||
public boolean apply(T entity) {
|
||||
return name.equals(entity.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "nameEquals(" + name + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches {@link EntityType entities} with names starting with the given prefix.
|
||||
*
|
||||
* @param T type of the entity, for example {@link Vm}
|
||||
* @param name prefix of the name attribute of the entity
|
||||
* @return predicate that will match entities with names starting with the given prefix
|
||||
*/
|
||||
public static <T extends EntityType> Predicate<T> nameStartsWith(final String prefix) {
|
||||
checkNotNull(prefix, "prefix must be defined");
|
||||
|
||||
return new Predicate<T>() {
|
||||
@Override
|
||||
public boolean apply(T entity) {
|
||||
String name = entity.getName();
|
||||
return name != null && name.startsWith(prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "nameStartsWith(" + prefix + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches {@link EntityType entities} with names in the given collection.
|
||||
*
|
||||
* @param T type of the entity, for example {@link Vm}
|
||||
* @param names collection of values for the name attribute of the entity
|
||||
* @return predicate that will match entities with names starting with the given prefix
|
||||
*/
|
||||
public static <T extends EntityType> Predicate<T> nameIn(final Iterable<String> names) {
|
||||
checkNotNull(names, "names must be defined");
|
||||
|
||||
return new Predicate<T>() {
|
||||
@Override
|
||||
public boolean apply(T entity) {
|
||||
String name = entity.getName();
|
||||
return Iterables.contains(names, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "nameIn(" + Iterables.toString(names) + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches {@link EntityType entities} of the given type.
|
||||
*
|
||||
* @param T type of the entity, for example {@link Vm}
|
||||
* @param type the media type string of the entity, for example {@link VCloudDirectorMediaType#CATALOG}
|
||||
* @return predicate that will match entities of the given type
|
||||
* @see VCloudDirectorMediaType
|
||||
*/
|
||||
public static <T extends EntityType> Predicate<T> typeEquals(final String type) {
|
||||
checkNotNull(type, "type must be defined");
|
||||
|
||||
return new Predicate<T>() {
|
||||
@Override
|
||||
public boolean apply(T entity) {
|
||||
return type.equals(entity.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "typeEquals(" + type + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches {@link EntityType entities} with the given {@link URI}.
|
||||
*
|
||||
* @param T type of the entity, for example {@link Vm}
|
||||
* @param href the URI of the entity
|
||||
* @return predicate that will match entities with the given URI
|
||||
* @see VCloudDirectorMediaType
|
||||
*/
|
||||
public static <T extends EntityType> Predicate<T> hrefEquals(final URI href) {
|
||||
checkNotNull(href, "href must be defined");
|
||||
|
||||
return new Predicate<T>() {
|
||||
@Override
|
||||
public boolean apply(T entity) {
|
||||
return href.equals(entity.getHref());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "hrefEquals(" + href.toASCIIString() + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -20,7 +20,8 @@ package org.jclouds.vcloud.director.v1_5.predicates;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
@ -127,4 +128,28 @@ public class ReferencePredicates {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches {@link Reference}s with the given {@link URI}.
|
||||
*
|
||||
* @param T type of the reference, for example {@link Link}
|
||||
* @param href the URI of the reference
|
||||
* @return predicate that will match references with the given URI
|
||||
* @see VCloudDirectorMediaType
|
||||
*/
|
||||
public static <T extends Reference> Predicate<T> hrefEquals(final URI href) {
|
||||
checkNotNull(href, "href must be defined");
|
||||
|
||||
return new Predicate<T>() {
|
||||
@Override
|
||||
public boolean apply(T reference) {
|
||||
return href.equals(reference.getHref());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "hrefEquals(" + href.toASCIIString() + ")";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue