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 4e8fb0cf83..5c56774c43 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 @@ -50,6 +50,8 @@ public class VCloudDirectorMediaType { public static final String TASKS_LIST = "application/vnd.vmware.vcloud.tasksList+xml"; public static final String TASK = "application/vnd.vmware.vcloud.task+xml"; + + public static final String NETWORK = "application/vnd.vmware.vcloud.entity.network+xml"; public static final String ORG_NETWORK = "application/vnd.vmware.vcloud.orgNetwork+xml"; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkType.java new file mode 100644 index 0000000000..528a30f825 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkType.java @@ -0,0 +1,197 @@ +/** + * 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.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.Sets; + +@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "NetworkType") +public class NetworkType> extends EntityType { + + public static > Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromNetworkType(this); + } + + public static class Builder> extends EntityType.Builder { + + protected NetworkConfiguration networkConfiguration; + + /** + * @see NetworkType#getConfiguration() + */ + public Builder configuration(NetworkConfiguration networkConfiguration) { + this.networkConfiguration = networkConfiguration; + return this; + } + + @Override + public NetworkType build() { + NetworkType network = new NetworkType(href, name); + network.setConfiguration(networkConfiguration); + network.setDescription(description); + network.setId(id); + network.setType(type); + network.setLinks(links); + network.setTasksInProgress(tasksInProgress); + return network; + } + + /** + * @see EntityType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see EntityType#getDescription() + */ + @Override + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @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; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); + } + + public Builder fromNetworkType(NetworkType in) { + return fromEntityType(in).configuration(in.getConfiguration()); + } + } + + protected NetworkType() { + // For JAXB and builder use + } + + protected NetworkType(URI href, String name) { + super(href, name); + } + + @XmlElement(namespace = VCLOUD_1_5_NS, name = "Configuration") + private NetworkConfiguration networkConfiguration; + + /** + * @return optional configuration + */ + public NetworkConfiguration getConfiguration() { + return networkConfiguration; + } + + public void setConfiguration(NetworkConfiguration networkConfiguration) { + this.networkConfiguration = networkConfiguration; + } + + @Override + public boolean equals(Object o) { + if (!super.equals(o)) + return false; + NetworkType that = NetworkType.class.cast(o); + return super.equals(that) && equal(networkConfiguration, that.networkConfiguration); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(networkConfiguration); + } + + @Override + public ToStringHelper string() { + return super.string().add("configuration", networkConfiguration); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java index c10ddd07b1..01c154954c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java @@ -18,13 +18,13 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; +import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; /** * Provides synchronous access to Network. @@ -42,20 +42,20 @@ public interface NetworkClient { * * @return the network or null if not found */ - OrgNetwork getNetwork(URI networkRef); + OrgNetwork getNetwork(ReferenceType networkRef); /** * Retrieves an list of the network's metadata * * @return a list of metadata */ - Metadata getMetadata(URI networkRef); + Metadata getMetadata(ReferenceType networkRef); /** * Retrieves a metadata entry * * @return the metadata entry, or null if not found */ - MetadataEntry getMetadataEntry(URI metaDataRef); + MetadataEntry getMetadataEntry(ReferenceType networkRef, String key); }