mirror of https://github.com/apache/jclouds.git
Issue 695: Added InternetServiceClient, plus domain objects for InternetService/NodeService+tests.
This commit is contained in:
parent
e505c88d60
commit
db310519ae
|
@ -33,6 +33,12 @@ import org.jclouds.tmrk.enterprisecloud.features.*;
|
|||
*/
|
||||
public interface TerremarkEnterpriseCloudAsyncClient {
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Internet Service features.
|
||||
*/
|
||||
@Delegate
|
||||
InternetServiceAsyncClient getInternetServiceClient();
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Layout features.
|
||||
*/
|
||||
|
|
|
@ -37,6 +37,12 @@ import org.jclouds.tmrk.enterprisecloud.features.*;
|
|||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface TerremarkEnterpriseCloudClient {
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Internet Service features.
|
||||
*/
|
||||
@Delegate
|
||||
InternetServiceClient getInternetServiceClient();
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Layout features.
|
||||
*/
|
||||
|
|
|
@ -46,6 +46,7 @@ public class TerremarkEnterpriseCloudRestClientModule extends
|
|||
RestClientModule<TerremarkEnterpriseCloudClient, TerremarkEnterpriseCloudAsyncClient> {
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
||||
.put(InternetServiceClient.class, InternetServiceAsyncClient.class)
|
||||
.put(LayoutClient.class, LayoutAsyncClient.class)
|
||||
.put(LocationClient.class, LocationAsyncClient.class)
|
||||
.put(NetworkClient.class, NetworkAsyncClient.class)
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.network;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="IpAddressReferenceType">
|
||||
* @author Jason King
|
||||
*
|
||||
*/
|
||||
public class IpAddressReference extends BaseNamedResource<IpAddressReference> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromNetworkReference(this);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseNamedResource.Builder<IpAddressReference> {
|
||||
|
||||
private NamedResource network;
|
||||
private NamedResource host;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.network.IpAddressReference#getNetwork
|
||||
*/
|
||||
public Builder network(NamedResource network) {
|
||||
this.network = network;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.network.IpAddressReference#getHost
|
||||
*/
|
||||
public Builder host(NamedResource host) {
|
||||
this.host = host;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IpAddressReference build() {
|
||||
return new IpAddressReference(href, type, name, network, host);
|
||||
}
|
||||
|
||||
public Builder fromNetworkReference(IpAddressReference in) {
|
||||
return fromNamedResource(in).network(in.getNetwork()).host(in.getHost());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<IpAddressReference> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromNamedResource(BaseNamedResource<IpAddressReference> in) {
|
||||
return Builder.class.cast(super.fromNamedResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Network", required = false)
|
||||
private NamedResource network;
|
||||
|
||||
@XmlElement(name = "Host", required = false)
|
||||
private NamedResource host;
|
||||
|
||||
private IpAddressReference(URI href, String type, String name,
|
||||
@Nullable NamedResource network, @Nullable NamedResource host) {
|
||||
super(href, type, name);
|
||||
this.network = network;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
private IpAddressReference() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public NamedResource getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
public NamedResource getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
IpAddressReference that = (IpAddressReference) o;
|
||||
|
||||
if (host != null ? !host.equals(that.host) : that.host != null)
|
||||
return false;
|
||||
if (network != null ? !network.equals(that.network) : that.network != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (network != null ? network.hashCode() : 0);
|
||||
result = 31 * result + (host != null ? host.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", network="+network+", host="+host;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.service;
|
||||
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
|
||||
@XmlEnum
|
||||
public enum Protocol {
|
||||
|
||||
@XmlEnumValue("HTTP")
|
||||
HTTP,
|
||||
|
||||
@XmlEnumValue("HTTPS")
|
||||
HTTPS,
|
||||
|
||||
@XmlEnumValue("TCP")
|
||||
TCP,
|
||||
|
||||
@XmlEnumValue("UDP")
|
||||
UDP,
|
||||
|
||||
@XmlEnumValue("IPSEC")
|
||||
IPSEC,
|
||||
|
||||
@XmlEnumValue("FTP")
|
||||
FTP,
|
||||
|
||||
@XmlEnumValue("Any")
|
||||
Any;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,419 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.service.internet;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Task;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Entity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.Protocol;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.node.NodeServices;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="InternetServiceType">
|
||||
* @author Jason King
|
||||
*/
|
||||
@XmlRootElement(name="InternetService")
|
||||
public class InternetService extends Entity<InternetService> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromSshKey(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Entity.Builder<InternetService> {
|
||||
|
||||
|
||||
private Protocol protocol;
|
||||
private int port;
|
||||
private boolean enabled;
|
||||
private String description;
|
||||
private NamedResource publicIp;
|
||||
private InternetServicePersistenceType persistence;
|
||||
private String redirectUrl;
|
||||
private NamedResource monitor;
|
||||
private NamedResource trustedNetworkGroup;
|
||||
private NamedResource backupInternetService;
|
||||
private NodeServices nodeServices;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getProtocol
|
||||
*/
|
||||
public Builder protocol(Protocol protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getPort
|
||||
*/
|
||||
public Builder port(int port) {
|
||||
this.port = port;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#isEnabled
|
||||
*/
|
||||
public Builder enabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getDescription
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getPersistence
|
||||
*/
|
||||
public Builder persistence(InternetServicePersistenceType persistence) {
|
||||
this.persistence = persistence;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getPublicIp
|
||||
*/
|
||||
public Builder publicIp(NamedResource publicIp) {
|
||||
this.publicIp = publicIp;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getRedirectUrl
|
||||
*/
|
||||
public Builder redirectUrl(String redirectUrl) {
|
||||
this.redirectUrl = redirectUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getMonitor
|
||||
*/
|
||||
public Builder monitor(NamedResource monitor) {
|
||||
this.monitor = monitor;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getTrustedNetworkGroup
|
||||
*/
|
||||
public Builder trustedNetworkGroup(NamedResource trustedNetworkGroup) {
|
||||
this.trustedNetworkGroup = trustedNetworkGroup;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getBackupInternetService
|
||||
*/
|
||||
public Builder backupInternetService(NamedResource backupInternetService) {
|
||||
this.backupInternetService = backupInternetService;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService#getNodeServices
|
||||
*/
|
||||
public Builder nodeServices(NodeServices nodeServices) {
|
||||
this.nodeServices = nodeServices;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InternetService build() {
|
||||
return new InternetService(href, type, name, links, actions, tasks,
|
||||
protocol, port, enabled, description,publicIp,persistence,
|
||||
redirectUrl, monitor, trustedNetworkGroup, backupInternetService, nodeServices);
|
||||
}
|
||||
|
||||
public Builder fromSshKey(InternetService in) {
|
||||
return fromEntity(in).protocol(in.getProtocol())
|
||||
.port(in.getPort())
|
||||
.enabled(in.isEnabled())
|
||||
.description(in.getDescription())
|
||||
.publicIp(in.getPublicIp())
|
||||
.persistence(in.getPersistence())
|
||||
.redirectUrl(in.getRedirectUrl())
|
||||
.monitor(in.getMonitor())
|
||||
.trustedNetworkGroup(in.getTrustedNetworkGroup())
|
||||
.backupInternetService(in.getBackupInternetService())
|
||||
.nodeServices(in.getNodeServices());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<InternetService> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<InternetService> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromEntity(Entity<InternetService> in) {
|
||||
return Builder.class.cast(super.fromEntity(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
return Builder.class.cast(super.tasks(tasks));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Protocol", required = false)
|
||||
private Protocol protocol;
|
||||
|
||||
@XmlElement(name = "Port", required = false)
|
||||
private int port;
|
||||
|
||||
@XmlElement(name = "Enabled", required = true)
|
||||
private boolean enabled;
|
||||
|
||||
@XmlElement(name = "PrivateKey", required = false)
|
||||
private String description;
|
||||
|
||||
@XmlElement(name = "PublicIp", required = false)
|
||||
private NamedResource publicIp;
|
||||
|
||||
@XmlElement(name = "Persistence", required = false)
|
||||
private InternetServicePersistenceType persistence;
|
||||
|
||||
@XmlElement(name = "RedirectUrl", required = false)
|
||||
private String redirectUrl;
|
||||
|
||||
@XmlElement(name = "Monitor", required = false)
|
||||
private NamedResource monitor;
|
||||
|
||||
@XmlElement(name = "TrustedNetworkGroup", required = false)
|
||||
private NamedResource trustedNetworkGroup;
|
||||
|
||||
@XmlElement(name = "BackupInternetService", required = false)
|
||||
private NamedResource backupInternetService;
|
||||
|
||||
@XmlElement(name = "NodeServices", required = false)
|
||||
private NodeServices nodeServices;
|
||||
|
||||
private InternetService(URI href, String type, String name, Set<Link> links, Set<Action> actions, Set<Task> tasks,
|
||||
@Nullable Protocol protocol, int port, boolean enabled, @Nullable String description,
|
||||
@Nullable NamedResource publicIp, @Nullable InternetServicePersistenceType persistence, @Nullable String redirectUrl, @Nullable NamedResource monitor,
|
||||
@Nullable NamedResource trustedNetworkGroup, @Nullable NamedResource backupInternetService, @Nullable NodeServices nodeServices) {
|
||||
super(href, type, name, links, actions, tasks);
|
||||
this.protocol = protocol;
|
||||
this.port = port;
|
||||
this.enabled = enabled;
|
||||
this.description = description;
|
||||
this.publicIp = publicIp;
|
||||
this.persistence = persistence;
|
||||
this.redirectUrl = redirectUrl;
|
||||
this.monitor = monitor;
|
||||
this.trustedNetworkGroup = trustedNetworkGroup;
|
||||
this.backupInternetService = backupInternetService;
|
||||
this.nodeServices = nodeServices;
|
||||
}
|
||||
|
||||
private InternetService() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Protocol getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public NamedResource getPublicIp() {
|
||||
return publicIp;
|
||||
}
|
||||
|
||||
public InternetServicePersistenceType getPersistence() {
|
||||
return persistence;
|
||||
}
|
||||
|
||||
public String getRedirectUrl() {
|
||||
return redirectUrl;
|
||||
}
|
||||
|
||||
public NamedResource getMonitor() {
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public NamedResource getTrustedNetworkGroup() {
|
||||
return trustedNetworkGroup;
|
||||
}
|
||||
|
||||
public NamedResource getBackupInternetService() {
|
||||
return backupInternetService;
|
||||
}
|
||||
|
||||
public NodeServices getNodeServices() {
|
||||
return nodeServices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
InternetService that = (InternetService) o;
|
||||
|
||||
if (enabled != that.enabled) return false;
|
||||
if (port != that.port) return false;
|
||||
if (backupInternetService != null ? !backupInternetService.equals(that.backupInternetService) : that.backupInternetService != null)
|
||||
return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||
return false;
|
||||
if (monitor != null ? !monitor.equals(that.monitor) : that.monitor != null)
|
||||
return false;
|
||||
if (nodeServices != null ? !nodeServices.equals(that.nodeServices) : that.nodeServices != null)
|
||||
return false;
|
||||
if (persistence != null ? !persistence.equals(that.persistence) : that.persistence != null)
|
||||
return false;
|
||||
if (protocol != that.protocol) return false;
|
||||
if (publicIp != null ? !publicIp.equals(that.publicIp) : that.publicIp != null)
|
||||
return false;
|
||||
if (redirectUrl != null ? !redirectUrl.equals(that.redirectUrl) : that.redirectUrl != null)
|
||||
return false;
|
||||
if (trustedNetworkGroup != null ? !trustedNetworkGroup.equals(that.trustedNetworkGroup) : that.trustedNetworkGroup != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (protocol != null ? protocol.hashCode() : 0);
|
||||
result = 31 * result + port;
|
||||
result = 31 * result + (enabled ? 1 : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (publicIp != null ? publicIp.hashCode() : 0);
|
||||
result = 31 * result + (persistence != null ? persistence.hashCode() : 0);
|
||||
result = 31 * result + (redirectUrl != null ? redirectUrl.hashCode() : 0);
|
||||
result = 31 * result + (monitor != null ? monitor.hashCode() : 0);
|
||||
result = 31 * result + (trustedNetworkGroup != null ? trustedNetworkGroup.hashCode() : 0);
|
||||
result = 31 * result + (backupInternetService != null ? backupInternetService.hashCode() : 0);
|
||||
result = 31 * result + (nodeServices != null ? nodeServices.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+
|
||||
", protocol="+protocol+", port="+port+", enabled="+enabled+", description="+description+
|
||||
", publicIp="+publicIp+" persistence="+persistence+", redirectUrl="+redirectUrl+
|
||||
", monitor="+monitor+", trustedNetworkGroup="+trustedNetworkGroup+
|
||||
", backupInternetService="+backupInternetService+", nodeServices="+nodeServices;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.service.internet;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
|
||||
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="InternetServiceType">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class InternetServicePersistenceType {
|
||||
|
||||
@XmlEnum
|
||||
public static enum PersistenceType {
|
||||
|
||||
@XmlEnumValue("None")
|
||||
NONE,
|
||||
|
||||
@XmlEnumValue("SourceIp")
|
||||
SOURCE_IP;
|
||||
|
||||
public String value() {
|
||||
return UPPER_UNDERSCORE.to(LOWER_CAMEL, name());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromNodeServices(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private PersistenceType persistenceType;
|
||||
private int timeout;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetServicePersistenceType#getPersistenceType
|
||||
*/
|
||||
public Builder persistenceType(PersistenceType persistenceType) {
|
||||
this.persistenceType = persistenceType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetServicePersistenceType#getTimeout
|
||||
*/
|
||||
public Builder timeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InternetServicePersistenceType build() {
|
||||
return new InternetServicePersistenceType(persistenceType,timeout);
|
||||
}
|
||||
|
||||
public Builder fromNodeServices(InternetServicePersistenceType in) {
|
||||
return persistenceType(in.getPersistenceType()).timeout(in.getTimeout());
|
||||
}
|
||||
}
|
||||
|
||||
private InternetServicePersistenceType() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private InternetServicePersistenceType(@Nullable PersistenceType persistenceType, int timeout ) {
|
||||
this.persistenceType = persistenceType;
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Type")
|
||||
private PersistenceType persistenceType;
|
||||
|
||||
@XmlElement(name = "Timeout")
|
||||
private int timeout;
|
||||
|
||||
public PersistenceType getPersistenceType() {
|
||||
return persistenceType;
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
InternetServicePersistenceType that = (InternetServicePersistenceType) o;
|
||||
|
||||
if (timeout != that.timeout) return false;
|
||||
if (persistenceType != that.persistenceType) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = persistenceType != null ? persistenceType.hashCode() : 0;
|
||||
result = 31 * result + timeout;
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[persistenceType="+persistenceType+", timeout="+timeout+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,281 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.service.node;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Task;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Entity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.Resource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.network.IpAddressReference;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.Protocol;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="NodeServiceType">
|
||||
* @author Jason King
|
||||
*/
|
||||
public class NodeService extends Entity<NodeService> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromSshKey(this);
|
||||
}
|
||||
|
||||
public static class Builder extends Entity.Builder<NodeService> {
|
||||
private IpAddressReference ipAddress;
|
||||
private Protocol protocol;
|
||||
private int port;
|
||||
private boolean enabled;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @see NodeService#getIpAddress
|
||||
*/
|
||||
public Builder ipAddress(IpAddressReference ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NodeService#getProtocol
|
||||
*/
|
||||
public Builder protocol(Protocol protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NodeService#getPort
|
||||
*/
|
||||
public Builder port(int port) {
|
||||
this.port = port;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NodeService#isEnabled
|
||||
*/
|
||||
public Builder enabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see NodeService#getDescription
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeService build() {
|
||||
return new NodeService(href, type, name, links, actions, tasks, ipAddress, protocol, port, enabled, description);
|
||||
}
|
||||
|
||||
public Builder fromSshKey(NodeService in) {
|
||||
return fromEntity(in).ipAddress(in.getIpAddress())
|
||||
.protocol(in.getProtocol())
|
||||
.port(in.getPort())
|
||||
.enabled(in.isEnabled())
|
||||
.description(in.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromBaseResource(BaseResource<NodeService> in) {
|
||||
return Builder.class.cast(super.fromBaseResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromResource(Resource<NodeService> in) {
|
||||
return Builder.class.cast(super.fromResource(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromEntity(Entity<NodeService> in) {
|
||||
return Builder.class.cast(super.fromEntity(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder name(String name) {
|
||||
return Builder.class.cast(super.name(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder tasks(Set<Task> tasks) {
|
||||
return Builder.class.cast(super.tasks(tasks));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "IpAddress", required = false)
|
||||
private IpAddressReference ipAddress;
|
||||
|
||||
@XmlElement(name = "Protocol", required = false)
|
||||
private Protocol protocol;
|
||||
|
||||
@XmlElement(name = "Port", required = false)
|
||||
private int port;
|
||||
|
||||
@XmlElement(name = "Enabled", required = false)
|
||||
private boolean enabled;
|
||||
|
||||
@XmlElement(name = "PrivateKey", required = false)
|
||||
private String description;
|
||||
|
||||
private NodeService(URI href, String type, String name, Set<Link> links, Set<Action> actions, Set<Task> tasks,
|
||||
@Nullable IpAddressReference ipAddress, @Nullable Protocol protocol, int port, boolean enabled, @Nullable String description) {
|
||||
super(href, type, name, links, actions, tasks);
|
||||
this.ipAddress = ipAddress;
|
||||
this.protocol = protocol;
|
||||
this.port = port;
|
||||
this.enabled = enabled;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private NodeService() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public IpAddressReference getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public Protocol getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
NodeService that = (NodeService) o;
|
||||
|
||||
if (enabled != that.enabled) return false;
|
||||
if (port != that.port) return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||
return false;
|
||||
if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null)
|
||||
return false;
|
||||
if (protocol != that.protocol) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0);
|
||||
result = 31 * result + (protocol != null ? protocol.hashCode() : 0);
|
||||
result = 31 * result + port;
|
||||
result = 31 * result + (enabled ? 1 : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", ipAddress="+ipAddress+", protocol="+protocol+", port="+port+", enabled="+enabled+", description="+description;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.domain.service.node;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Jason King
|
||||
*/
|
||||
public class NodeServices {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromNodeServices(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<NodeService> services = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.service.node.NodeServices#getNodeServices()
|
||||
*/
|
||||
public Builder services(Set<NodeService> services) {
|
||||
this.services = Sets.newLinkedHashSet(checkNotNull(services, "services"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addNodeService(NodeService service) {
|
||||
services.add(checkNotNull(service, "service"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public NodeServices build() {
|
||||
return new NodeServices(services);
|
||||
}
|
||||
|
||||
public Builder fromNodeServices(NodeServices in) {
|
||||
return services(in.getNodeServices());
|
||||
}
|
||||
}
|
||||
|
||||
private NodeServices() {
|
||||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private NodeServices(Set<NodeService> services) {
|
||||
this.services = Sets.newLinkedHashSet(services);
|
||||
}
|
||||
|
||||
@XmlElement(name = "NodeService")
|
||||
private Set<NodeService> services = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<NodeService> getNodeServices() {
|
||||
return Collections.unmodifiableSet(services);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
NodeServices that = (NodeServices) o;
|
||||
|
||||
if (!services.equals(that.services)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return services.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "["+ services.toString()+"]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.features;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.rest.annotations.*;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Layouts via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see org.jclouds.tmrk.enterprisecloud.features.LayoutClient
|
||||
* @see <a href=
|
||||
* "http://support.theenterprisecloud.com/kb/default.asp?id=984&Lang=1&SID="
|
||||
* />
|
||||
* @author Jason King
|
||||
*/
|
||||
@RequestFilters(BasicAuthentication.class)
|
||||
@Headers(keys = "x-tmrk-version", values = "{jclouds.api-version}")
|
||||
public interface InternetServiceAsyncClient {
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.features.InternetServiceClient#getInternetService
|
||||
*/
|
||||
@GET
|
||||
@Consumes("application/vnd.tmrk.cloud.internetService")
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<InternetService> getInternetService(@EndpointParam URI uri);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.features;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Internet Service.
|
||||
* <p/>
|
||||
*
|
||||
* @see org.jclouds.tmrk.enterprisecloud.features.LayoutAsyncClient
|
||||
* @see <a href=
|
||||
* "http://support.theenterprisecloud.com/kb/default.asp?id=984&Lang=1&SID="
|
||||
* />
|
||||
* @author Jason King
|
||||
*/
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface InternetServiceClient {
|
||||
|
||||
|
||||
/**
|
||||
* getInternetService call returns information regarding a specified Internet service defined in an environment.
|
||||
* @param uri the uri of the internet service
|
||||
* e.g. /cloudapi/ecloud/internetservices/{internet service id}
|
||||
* @return the internet service
|
||||
*/
|
||||
InternetService getInternetService(URI uri);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.features;
|
||||
|
||||
import com.google.inject.TypeLiteral;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code InternetServiceAsyncClient}
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "LayoutAsyncClientTest")
|
||||
public class InternetServiceAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClientTest<InternetServiceAsyncClient> {
|
||||
|
||||
public void testGetInternetService() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||
Method method = InternetServiceAsyncClient.class.getMethod("getInternetService", URI.class);
|
||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/internetservices/797"));
|
||||
|
||||
String requestLine = "GET https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/internetservices/797 HTTP/1.1";
|
||||
assertRequestLineEquals(httpRequest, requestLine);
|
||||
assertNonPayloadHeadersEqual(httpRequest,
|
||||
"Accept: application/vnd.tmrk.cloud.internetService\nx-tmrk-version: 2011-07-01\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<InternetServiceAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<InternetServiceAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.features;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code InternetServiceClient}
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "live", testName = "InternetServiceClientLiveTest")
|
||||
public class InternetServiceClientLiveTest extends BaseTerremarkEnterpriseCloudClientLiveTest {
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
super.setupClient();
|
||||
client = context.getApi().getInternetServiceClient();
|
||||
}
|
||||
|
||||
private InternetServiceClient client;
|
||||
|
||||
public void testGetLayouts() throws Exception {
|
||||
//TODO: THe URI should come from the environment
|
||||
InternetService internetService = client.getInternetService(URI.create("/cloudapi/ecloud/internetservices/797"));
|
||||
assertNotNull(internetService);
|
||||
}
|
||||
|
||||
public void testGetMissingLayouts() {
|
||||
assertNull(client.getInternetService(URI.create("/cloudapi/ecloud/internetservices/-1")));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
/**
|
||||
* 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.tmrk.enterprisecloud.xml;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
import org.jclouds.rest.BaseRestClientTest;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.network.IpAddressReference;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.Protocol;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetServicePersistenceType;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.node.NodeService;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.service.node.NodeServices;
|
||||
import org.jclouds.tmrk.enterprisecloud.features.InternetServiceAsyncClient;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.jclouds.rest.RestContextFactory.contextSpec;
|
||||
import static org.jclouds.rest.RestContextFactory.createContextBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests behavior of JAXB parsing for Location
|
||||
*
|
||||
* @author Jason King
|
||||
*/
|
||||
@Test(groups = "unit", testName = "InternetServiceJAXBParsingTest")
|
||||
public class InternetServiceJAXBParsingTest extends BaseRestClientTest {
|
||||
|
||||
@BeforeClass
|
||||
void setupFactory() {
|
||||
RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo",
|
||||
"credentialFoo", String.class, Integer.class,
|
||||
ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(), new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Named("exception")
|
||||
Set<String> exception() {
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
injector = createContextBuilder(contextSpec).buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
crypto = injector.getInstance(Crypto.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseInternetServiceWithJAXB() throws Exception {
|
||||
Method method = InternetServiceAsyncClient.class.getMethod("getInternetService",URI.class);
|
||||
HttpRequest request = factory(InternetServiceAsyncClient.class).createRequest(method, new URI("/1"));
|
||||
assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class);
|
||||
|
||||
Function<HttpResponse, InternetService> parser = (Function<HttpResponse, InternetService>) RestAnnotationProcessor
|
||||
.createResponseParser(parserFactory, injector, method, request);
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/internetService.xml");
|
||||
InternetService internetService = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
assertEquals(internetService.getProtocol(), Protocol.TCP);
|
||||
assertEquals(internetService.getPort(),22);
|
||||
assertTrue(internetService.isEnabled());
|
||||
assertEquals(internetService.getPublicIp(), NamedResource.builder().href(URI.create("/cloudapi/ecloud/publicips/3929")).type("application/vnd.tmrk.cloud.publicIp").name("208.39.65.40").build());
|
||||
assertEquals(internetService.getPersistence().getPersistenceType(), InternetServicePersistenceType.PersistenceType.NONE);
|
||||
assertEquals(internetService.getPersistence().getTimeout(), 0); //Default value
|
||||
assertEquals(internetService.getMonitor(),NamedResource.builder().href(URI.create("/cloudapi/ecloud/internetservices/797/monitor")).type("application/vnd.tmrk.cloud.defaultMonitor").build());
|
||||
assertNodeServices(internetService.getNodeServices());
|
||||
|
||||
System.out.println(internetService);
|
||||
}
|
||||
|
||||
private void assertNodeServices(NodeServices nodeServices) {
|
||||
assertEquals(nodeServices.getNodeServices().size(),1);
|
||||
NodeService nodeService = Iterables.getOnlyElement(nodeServices.getNodeServices());
|
||||
assertEquals(nodeService.getName(),"ssh");
|
||||
|
||||
IpAddressReference ipAddress = nodeService.getIpAddress();
|
||||
assertEquals(ipAddress.getName(),"10.146.205.131");
|
||||
assertEquals(ipAddress.getNetwork(),NamedResource.builder().href(URI.create("/cloudapi/ecloud/networks/3933")).type("application/vnd.tmrk.cloud.network").name("10.146.205.128/27").build());
|
||||
assertEquals(ipAddress.getHost(),NamedResource.builder().href(URI.create("/cloudapi/ecloud/networkhosts/7144")).type("application/vnd.tmrk.cloud.networkHost").name("vmDMZ1").build());
|
||||
assertEquals(nodeService.getProtocol(), Protocol.TCP);
|
||||
assertEquals(nodeService.getPort(),22);
|
||||
assertTrue(nodeService.isEnabled());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<InternetService href="/cloudapi/ecloud/internetservices/797" name="ssh"
|
||||
type="application/vnd.tmrk.cloud.internetService"
|
||||
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/publicips/3929" name="208.39.65.40"
|
||||
type="application/vnd.tmrk.cloud.publicIp" rel="up"/>
|
||||
</Links>
|
||||
<Actions>
|
||||
<Action href="/cloudapi/ecloud/internetservices/797" name="edit"
|
||||
type="application/vnd.tmrk.cloud.internetService"/>
|
||||
<Action href="/cloudapi/ecloud/nodeservices/internetservices/797/action/createnodeservice"
|
||||
name="createNodeService"
|
||||
type="application/vnd.tmrk.cloud.createNodeService"/>
|
||||
<Action href="/cloudapi/ecloud/internetservices/797" name="remove"
|
||||
actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/internetservices/797/action/createecvmonitor"
|
||||
name="createEcvMonitor"
|
||||
type="application/vnd.tmrk.cloud.createEcvMonitor"
|
||||
actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/internetservices/797/action/createhttpmonitor"
|
||||
name="createHttpMonitor"
|
||||
type="application/vnd.tmrk.cloud.createHttpMonitor"
|
||||
actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/internetservices/797/action/createpingmonitor"
|
||||
name="createPingMonitor"
|
||||
type="application/vnd.tmrk.cloud.createPingMonitor"/>
|
||||
<Action href="/cloudapi/ecloud/internetservices/797/action/createdefaultmonitor"
|
||||
name="createDefaultMonitor" actionDisabled="disabled"/>
|
||||
<Action href="/cloudapi/ecloud/internetservices/797/action/createloopbackmonitor"
|
||||
name="createLoopbackMonitor"/>
|
||||
</Actions>
|
||||
<Tasks>
|
||||
<Task href="/cloudapi/ecloud/tasks/30926"
|
||||
type="application/vnd.tmrk.cloud.task">
|
||||
<Operation>Add Internet Service</Operation>
|
||||
<Status>Complete</Status>
|
||||
<ImpactedItem href="/cloudapi/ecloud/internetservices/797"
|
||||
name="208.39.65.40"
|
||||
type="application/vnd.tmrk.cloud.internetService"/>
|
||||
<StartTime>2011-12-19T19:34:33.57Z</StartTime>
|
||||
<CompletedTime>2011-12-19T19:34:36.03Z</CompletedTime>
|
||||
<Notes>Name: ssh
|
||||
Public IP: 208.39.65.40
|
||||
Protocol: TCP
|
||||
Port: 22
|
||||
Persistence: N/A
|
||||
Persistence Type: NONE
|
||||
Redirect URL:
|
||||
State: Enabled
|
||||
Trusted Network Group: ANY
|
||||
</Notes>
|
||||
<InitiatedBy href="/cloudapi/ecloud/admin/users/1804"
|
||||
name="Jason King"
|
||||
type="application/vnd.tmrk.cloud.admin.user"/>
|
||||
</Task>
|
||||
<TotalCount>1</TotalCount>
|
||||
</Tasks>
|
||||
<Protocol>TCP</Protocol>
|
||||
<Port>22</Port>
|
||||
<Enabled>true</Enabled>
|
||||
<Description>this is ssh</Description>
|
||||
<PublicIp href="/cloudapi/ecloud/publicips/3929" name="208.39.65.40"
|
||||
type="application/vnd.tmrk.cloud.publicIp"/>
|
||||
<Persistence>
|
||||
<Type>None</Type>
|
||||
</Persistence>
|
||||
<Monitor href="/cloudapi/ecloud/internetservices/797/monitor"
|
||||
type="application/vnd.tmrk.cloud.defaultMonitor"/>
|
||||
<NodeServices>
|
||||
<NodeService href="/cloudapi/ecloud/nodeservices/606" name="ssh"
|
||||
type="application/vnd.tmrk.cloud.nodeService">
|
||||
<Links>
|
||||
<Link href="/cloudapi/ecloud/internetservices/797" name="ssh"
|
||||
type="application/vnd.tmrk.cloud.internetService"
|
||||
rel="up"/>
|
||||
</Links>
|
||||
<Actions>
|
||||
<Action href="/cloudapi/ecloud/nodeservices/606" name="edit"
|
||||
type="application/vnd.tmrk.cloud.nodeService"/>
|
||||
<Action href="/cloudapi/ecloud/nodeservices/606" name="remove"/>
|
||||
</Actions>
|
||||
<IpAddress
|
||||
href="/cloudapi/ecloud/ipaddresses/networks/3933/10.146.205.131"
|
||||
name="10.146.205.131">
|
||||
<Network href="/cloudapi/ecloud/networks/3933"
|
||||
name="10.146.205.128/27"
|
||||
type="application/vnd.tmrk.cloud.network"/>
|
||||
<Host href="/cloudapi/ecloud/networkhosts/7144" name="vmDMZ1"
|
||||
type="application/vnd.tmrk.cloud.networkHost"/>
|
||||
</IpAddress>
|
||||
<Protocol>TCP</Protocol>
|
||||
<Port>22</Port>
|
||||
<Enabled>true</Enabled>
|
||||
<Description/>
|
||||
</NodeService>
|
||||
</NodeServices>
|
||||
</InternetService>
|
Loading…
Reference in New Issue