mirror of https://github.com/apache/jclouds.git
added vpc data and cleaned usage
This commit is contained in:
parent
74b404eab8
commit
d9d5aa2a12
|
@ -59,6 +59,9 @@ public interface ELBAsyncClient {
|
|||
/**
|
||||
* Provides asynchronous access to LoadBalancer features.
|
||||
*/
|
||||
@Delegate
|
||||
LoadBalancerAsyncClient getLoadBalancerClient();
|
||||
|
||||
@Delegate
|
||||
LoadBalancerAsyncClient getLoadBalancerClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
@ -66,6 +69,9 @@ public interface ELBAsyncClient {
|
|||
/**
|
||||
* Provides asynchronous access to Policy features.
|
||||
*/
|
||||
@Delegate
|
||||
PolicyAsyncClient getPolicyClient();
|
||||
|
||||
@Delegate
|
||||
PolicyAsyncClient getPolicyClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
@ -73,6 +79,9 @@ public interface ELBAsyncClient {
|
|||
/**
|
||||
* Provides asynchronous access to Instance features.
|
||||
*/
|
||||
@Delegate
|
||||
InstanceAsyncClient getInstanceClient();
|
||||
|
||||
@Delegate
|
||||
InstanceAsyncClient getInstanceClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
|
|
@ -56,6 +56,9 @@ public interface ELBClient {
|
|||
/**
|
||||
* Provides synchronous access to LoadBalancer features.
|
||||
*/
|
||||
@Delegate
|
||||
LoadBalancerClient getLoadBalancerClient();
|
||||
|
||||
@Delegate
|
||||
LoadBalancerClient getLoadBalancerClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
@ -63,6 +66,9 @@ public interface ELBClient {
|
|||
/**
|
||||
* Provides synchronous access to Policy features.
|
||||
*/
|
||||
@Delegate
|
||||
PolicyClient getPolicyClient();
|
||||
|
||||
@Delegate
|
||||
PolicyClient getPolicyClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
@ -70,6 +76,9 @@ public interface ELBClient {
|
|||
/**
|
||||
* Provides synchronous access to Instance features.
|
||||
*/
|
||||
@Delegate
|
||||
InstanceClient getInstanceClient();
|
||||
|
||||
@Delegate
|
||||
InstanceClient getInstanceClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.utils.ModifyRequest;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Binds the listeners request to the http request
|
||||
|
@ -43,7 +44,8 @@ public class BindListenersToFormParams implements org.jclouds.rest.Binder {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||
Iterable<Listener> listeners = (Iterable<Listener>) checkNotNull(input, "listeners must be set!");
|
||||
Iterable<Listener> listeners = checkNotNull(input, "listeners must be set!") instanceof Listener ? ImmutableSet
|
||||
.of(Listener.class.cast(input)) : (Iterable<Listener>) input;
|
||||
|
||||
ImmutableMultimap.Builder<String, String> formParameters = ImmutableMultimap.builder();
|
||||
int listenerIndex = 1;
|
||||
|
|
|
@ -65,6 +65,8 @@ public class Listener {
|
|||
*/
|
||||
public T instancePort(int instancePort) {
|
||||
this.instancePort = instancePort;
|
||||
if (port == -1)
|
||||
port = instancePort;
|
||||
return self();
|
||||
}
|
||||
|
||||
|
@ -73,6 +75,8 @@ public class Listener {
|
|||
*/
|
||||
public T instanceProtocol(Protocol instanceProtocol) {
|
||||
this.instanceProtocol = instanceProtocol;
|
||||
if (protocol == null)
|
||||
protocol = instanceProtocol;
|
||||
return self();
|
||||
}
|
||||
|
||||
|
@ -81,6 +85,8 @@ public class Listener {
|
|||
*/
|
||||
public T port(int port) {
|
||||
this.port = port;
|
||||
if (instancePort == -1)
|
||||
instancePort = port;
|
||||
return self();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,26 +23,28 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* A load balancer is represented by a DNS name and a set of ports. The load balancer is the
|
||||
* destination to which all requests intended for your application should be directed. Each load
|
||||
* balancer can distribute requests to multiple EC2 instances. Load Balancers can span multiple
|
||||
* Availability Zones within an EC2 region, but they cannot span multiple regions.
|
||||
* A load balancer is represented by a DNS name and a set of ports. The load
|
||||
* balancer is the destination to which all requests intended for your
|
||||
* application should be directed. Each load balancer can distribute requests to
|
||||
* multiple EC2 instances. Load Balancers can span multiple Availability Zones
|
||||
* within an EC2 region, but they cannot span multiple regions.
|
||||
*
|
||||
* <h3>note</h3>
|
||||
*
|
||||
* Elastic Load Balancing automatically generates a DNS name for each load balancer. You can map any
|
||||
* other domain name (such as www.example.com) to the automatically generated DNS name using CNAME.
|
||||
* Or you can use an Amazon Route 53 alias for the load balancer's DNS name. Amazon Route 53
|
||||
* provides secure and reliable routing to the infrastructure that uses AWS products, such as Amazon
|
||||
* EC2, Amazon Simple Storage Service (Amazon S3), or Elastic Load Balancing. For more information
|
||||
* on using Amazon Route 53 for your load balancer, see Using Domain Names with Elastic Load
|
||||
* Balancing. For information about CNAME records, see the CNAME Record Wikipedia article.
|
||||
* Elastic Load Balancing automatically generates a DNS name for each load
|
||||
* balancer. You can map any other domain name (such as www.example.com) to the
|
||||
* automatically generated DNS name using CNAME. Or you can use an Amazon Route
|
||||
* 53 alias for the load balancer's DNS name. Amazon Route 53 provides secure
|
||||
* and reliable routing to the infrastructure that uses AWS products, such as
|
||||
* Amazon EC2, Amazon Simple Storage Service (Amazon S3), or Elastic Load
|
||||
* Balancing. For more information on using Amazon Route 53 for your load
|
||||
* balancer, see Using Domain Names with Elastic Load Balancing. For information
|
||||
* about CNAME records, see the CNAME Record Wikipedia article.
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/arch-loadbalancing.html"
|
||||
|
@ -51,43 +53,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class LoadBalancer {
|
||||
/**
|
||||
* Specifies the type of LoadBalancer. This option is only available for LoadBalancers attached
|
||||
* to an Amazon VPC.
|
||||
*/
|
||||
public static enum Scheme {
|
||||
|
||||
/**
|
||||
* the LoadBalancer has a publicly resolvable DNS name that resolves to public IP addresses
|
||||
*/
|
||||
INTERNET_FACING,
|
||||
/**
|
||||
* the LoadBalancer has a publicly resolvable DNS name that resolves to private IP addresses.
|
||||
*/
|
||||
INTERNAL,
|
||||
/**
|
||||
* The scheme was returned unrecognized.
|
||||
*/
|
||||
UNRECOGNIZED;
|
||||
|
||||
public String value() {
|
||||
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static Scheme fromValue(String scheme) {
|
||||
try {
|
||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(scheme, "scheme")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
@ -107,7 +72,12 @@ public class LoadBalancer {
|
|||
protected ImmutableSet.Builder<ListenerWithPolicies> listeners = ImmutableSet.<ListenerWithPolicies> builder();
|
||||
protected ImmutableSet.Builder<String> availabilityZones = ImmutableSet.<String> builder();
|
||||
protected Optional<Scheme> scheme = Optional.absent();
|
||||
protected Optional<SecurityGroupAndOwner> sourceSecurityGroup = Optional.absent();
|
||||
protected Optional<String> VPCId = Optional.absent();
|
||||
protected ImmutableSet.Builder<String> securityGroups = ImmutableSet.<String> builder();
|
||||
protected ImmutableSet.Builder<String> subnets = ImmutableSet.<String> builder();
|
||||
protected Optional<String> hostedZoneName = Optional.absent();
|
||||
protected Optional<String> hostedZoneId = Optional.absent();
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getName()
|
||||
|
@ -197,6 +167,14 @@ public class LoadBalancer {
|
|||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getSourceSecurityGroup()
|
||||
*/
|
||||
public T sourceSecurityGroup(SecurityGroupAndOwner scheme) {
|
||||
this.sourceSecurityGroup = Optional.fromNullable(scheme);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getVPCId()
|
||||
*/
|
||||
|
@ -205,16 +183,67 @@ public class LoadBalancer {
|
|||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getSecurityGroups()
|
||||
*/
|
||||
public T securityGroups(Iterable<String> securityGroups) {
|
||||
this.securityGroups.addAll(checkNotNull(securityGroups, "securityGroups"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getSecurityGroups()
|
||||
*/
|
||||
public T securityGroup(String securityGroup) {
|
||||
this.securityGroups.add(checkNotNull(securityGroup, "securityGroup"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getSubnets()
|
||||
*/
|
||||
public T subnets(Iterable<String> subnets) {
|
||||
this.subnets.addAll(checkNotNull(subnets, "subnets"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getSubnets()
|
||||
*/
|
||||
public T subnet(String subnet) {
|
||||
this.subnets.add(checkNotNull(subnet, "subnet"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getHostedZoneName()
|
||||
*/
|
||||
public T hostedZoneName(String hostedZoneName) {
|
||||
this.hostedZoneName = Optional.fromNullable(hostedZoneName);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LoadBalancer#getHostedZoneId()
|
||||
*/
|
||||
public T hostedZoneId(String hostedZoneId) {
|
||||
this.hostedZoneId = Optional.fromNullable(hostedZoneId);
|
||||
return self();
|
||||
}
|
||||
|
||||
public LoadBalancer build() {
|
||||
return new LoadBalancer(name, createdTime, dnsName, healthCheck, instanceIds.build(), listeners.build(),
|
||||
availabilityZones.build(), scheme, VPCId);
|
||||
availabilityZones.build(), scheme, sourceSecurityGroup, VPCId, securityGroups.build(),
|
||||
subnets.build(), hostedZoneName, hostedZoneId);
|
||||
}
|
||||
|
||||
public T fromLoadBalancer(LoadBalancer in) {
|
||||
return this.name(in.getName()).createdTime(in.getCreatedTime()).dnsName(in.getDnsName())
|
||||
.healthCheck(in.getHealthCheck()).listeners(in.getListeners()).instanceIds(in.getInstanceIds())
|
||||
.availabilityZones(in.getAvailabilityZones()).scheme(in.getScheme().orNull())
|
||||
.VPCId(in.getVPCId().orNull());
|
||||
.sourceSecurityGroup(in.getSourceSecurityGroup().orNull()).VPCId(in.getVPCId().orNull())
|
||||
.securityGroups(in.getSecurityGroups()).subnets(in.getSubnets())
|
||||
.hostedZoneName(in.getHostedZoneName().orNull()).hostedZoneId(in.getHostedZoneId().orNull());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,11 +262,18 @@ public class LoadBalancer {
|
|||
protected final Set<ListenerWithPolicies> listeners;
|
||||
protected final Set<String> availabilityZones;
|
||||
protected final Optional<Scheme> scheme;
|
||||
protected final Optional<SecurityGroupAndOwner> sourceSecurityGroup;
|
||||
protected final Optional<String> VPCId;
|
||||
protected final Set<String> securityGroups;
|
||||
protected final Set<String> subnets;
|
||||
protected final Optional<String> hostedZoneName;
|
||||
protected final Optional<String> hostedZoneId;
|
||||
|
||||
protected LoadBalancer(String name, Date createdTime, String dnsName, HealthCheck healthCheck,
|
||||
Iterable<String> instanceIds, Iterable<ListenerWithPolicies> listeners, Iterable<String> availabilityZones,
|
||||
Optional<Scheme> scheme, Optional<String> VPCId) {
|
||||
Optional<Scheme> scheme, Optional<SecurityGroupAndOwner> sourceSecurityGroup, Optional<String> VPCId,
|
||||
Iterable<String> securityGroups, Iterable<String> subnets, Optional<String> hostedZoneName,
|
||||
Optional<String> hostedZoneId) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.createdTime = checkNotNull(createdTime, "createdTime");
|
||||
this.dnsName = checkNotNull(dnsName, "dnsName");
|
||||
|
@ -246,12 +282,17 @@ public class LoadBalancer {
|
|||
this.listeners = ImmutableSet.copyOf(checkNotNull(listeners, "listeners"));
|
||||
this.availabilityZones = ImmutableSet.copyOf(checkNotNull(availabilityZones, "availabilityZones"));
|
||||
this.scheme = checkNotNull(scheme, "scheme");
|
||||
this.sourceSecurityGroup = checkNotNull(sourceSecurityGroup, "sourceSecurityGroup");
|
||||
this.VPCId = checkNotNull(VPCId, "VPCId");
|
||||
this.securityGroups = ImmutableSet.copyOf(checkNotNull(securityGroups, "securityGroups"));
|
||||
this.subnets = ImmutableSet.copyOf(checkNotNull(subnets, "subnets"));
|
||||
this.hostedZoneName = checkNotNull(hostedZoneName, "hostedZoneName");
|
||||
this.hostedZoneId = checkNotNull(hostedZoneId, "hostedZoneId");
|
||||
}
|
||||
|
||||
/**
|
||||
* The name associated with the LoadBalancer. The name must be unique within your set of
|
||||
* LoadBalancers.
|
||||
* The name associated with the LoadBalancer. The name must be unique within
|
||||
* your set of LoadBalancers.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
|
@ -272,7 +313,8 @@ public class LoadBalancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Specifies information regarding the various health probes conducted on the LoadBalancer.
|
||||
* Specifies information regarding the various health probes conducted on
|
||||
* the LoadBalancer.
|
||||
*/
|
||||
public HealthCheck getHealthCheck() {
|
||||
return healthCheck;
|
||||
|
@ -300,13 +342,24 @@ public class LoadBalancer {
|
|||
}
|
||||
|
||||
/**
|
||||
* Type of the loadbalancer; This option is only available for LoadBalancers attached to an
|
||||
* Amazon VPC.
|
||||
* Type of the loadbalancer; This option is only available for LoadBalancers
|
||||
* attached to an Amazon VPC.
|
||||
*/
|
||||
public Optional<Scheme> getScheme() {
|
||||
return scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* The security group that you can use as part of your inbound rules for
|
||||
* your LoadBalancer's back-end Amazon EC2 application instances. To only
|
||||
* allow traffic from LoadBalancers, add a security group rule to your back
|
||||
* end instance that specifies this source security group as the inbound
|
||||
* source.
|
||||
*/
|
||||
public Optional<SecurityGroupAndOwner> getSourceSecurityGroup() {
|
||||
return sourceSecurityGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the ID of the VPC attached to the LoadBalancer.
|
||||
*/
|
||||
|
@ -314,6 +367,34 @@ public class LoadBalancer {
|
|||
return VPCId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The security groups the LoadBalancer is a member of (VPC only).
|
||||
*/
|
||||
public Set<String> getSecurityGroups() {
|
||||
return securityGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of VPC subnet IDs for the LoadBalancer.
|
||||
*/
|
||||
public Set<String> getSubnets() {
|
||||
return subnets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the name of the Amazon Route 53 hosted zone that is associated with the LoadBalancer
|
||||
*/
|
||||
public Optional<String> getHostedZoneName() {
|
||||
return hostedZoneName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the ID of the Amazon Route 53 hosted zone name that is associated with the LoadBalancer.
|
||||
*/
|
||||
public Optional<String> getHostedZoneId() {
|
||||
return hostedZoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -345,7 +426,9 @@ public class LoadBalancer {
|
|||
return Objects.toStringHelper(this).omitNullValues().add("name", name).add("createdTime", createdTime)
|
||||
.add("dnsName", dnsName).add("healthCheck", healthCheck).add("instanceIds", instanceIds)
|
||||
.add("listeners", listeners).add("availabilityZones", availabilityZones).add("scheme", scheme.orNull())
|
||||
.add("VPCId", VPCId.orNull()).toString();
|
||||
.add("sourceSecurityGroup", sourceSecurityGroup.orNull()).add("VPCId", VPCId.orNull())
|
||||
.add("securityGroups", securityGroups).add("subnets", subnets)
|
||||
.add("hostedZoneName", hostedZoneName.orNull()).add("hostedZoneId", hostedZoneId.orNull()).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,16 +34,15 @@ import com.google.common.collect.Multimap;
|
|||
*/
|
||||
public class Policy {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromPolicy(this);
|
||||
public Builder toBuilder() {
|
||||
return builder().fromPolicy(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
public static class Builder {
|
||||
|
||||
protected String name;
|
||||
protected String typeName;
|
||||
|
@ -52,51 +51,44 @@ public class Policy {
|
|||
/**
|
||||
* @see Policy#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Policy#getTypeName()
|
||||
*/
|
||||
public T typeName(String typeName) {
|
||||
public Builder typeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
return self();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Policy#getAttributes()
|
||||
*/
|
||||
public T attributes(Multimap<String, Object> attributes) {
|
||||
public Builder attributes(Multimap<String, Object> attributes) {
|
||||
this.attributes.putAll(checkNotNull(attributes, "attributes"));
|
||||
return self();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Policy#getAttributes()
|
||||
*/
|
||||
public T attribute(String key, Object value) {
|
||||
public Builder attribute(String key, Object value) {
|
||||
this.attributes.put(checkNotNull(key, "key"), checkNotNull(value, "value"));
|
||||
return self();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Policy build() {
|
||||
return new Policy(name, typeName, attributes.build());
|
||||
}
|
||||
|
||||
public T fromPolicy(Policy in) {
|
||||
public Builder fromPolicy(Policy in) {
|
||||
return this.name(in.getName()).typeName(in.getTypeName()).attributes(in.getAttributes());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected final String name;
|
||||
protected final String typeName;
|
||||
protected final Multimap<String, Object> attributes;
|
||||
|
|
|
@ -40,16 +40,15 @@ import com.google.common.collect.Maps;
|
|||
*/
|
||||
public class PolicyType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromPolicyType(this);
|
||||
public Builder toBuilder() {
|
||||
return builder().fromPolicyType(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
public static class Builder {
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
|
@ -58,51 +57,44 @@ public class PolicyType {
|
|||
/**
|
||||
* @see PolicyType#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PolicyType#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return self();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PolicyType#getAttributeMetadata()
|
||||
*/
|
||||
public T attributeMetadata(Iterable<AttributeMetadata<?>> attributeMetadata) {
|
||||
public Builder attributeMetadata(Iterable<AttributeMetadata<?>> attributeMetadata) {
|
||||
this.attributeMetadata.addAll(checkNotNull(attributeMetadata, "attributeMetadata"));
|
||||
return self();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PolicyType#getAttributeMetadata()
|
||||
*/
|
||||
public T attributeMetadata(AttributeMetadata<?> attributeMetadata) {
|
||||
public Builder attributeMetadata(AttributeMetadata<?> attributeMetadata) {
|
||||
this.attributeMetadata.add(checkNotNull(attributeMetadata, "attributeMetadata"));
|
||||
return self();
|
||||
return this;
|
||||
}
|
||||
|
||||
public PolicyType build() {
|
||||
return new PolicyType(name, description, attributeMetadata.build());
|
||||
}
|
||||
|
||||
public T fromPolicyType(PolicyType in) {
|
||||
public Builder fromPolicyType(PolicyType in) {
|
||||
return this.name(in.getName()).description(in.getDescription()).attributeMetadata(in.getAttributeMetadata());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected final String name;
|
||||
protected final String description;
|
||||
protected final Set<AttributeMetadata<?>> attributeMetadata;
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* 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.elb.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
* Specifies the type of LoadBalancer. This option is only available for
|
||||
* LoadBalancers attached to an Amazon VPC.
|
||||
*/
|
||||
public enum Scheme {
|
||||
|
||||
/**
|
||||
* the LoadBalancer has a publicly resolvable DNS name that resolves to
|
||||
* public IP addresses
|
||||
*/
|
||||
INTERNET_FACING,
|
||||
/**
|
||||
* the LoadBalancer has a publicly resolvable DNS name that resolves to
|
||||
* private IP addresses.
|
||||
*/
|
||||
INTERNAL,
|
||||
/**
|
||||
* The scheme was returned unrecognized.
|
||||
*/
|
||||
UNRECOGNIZED;
|
||||
|
||||
public String value() {
|
||||
return (CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static Scheme fromValue(String scheme) {
|
||||
try {
|
||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(scheme, "scheme")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* 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.elb.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* The security group that you can use as part of your inbound rules for your
|
||||
* LoadBalancer's back-end Amazon EC2 application instances. To only allow
|
||||
* traffic from LoadBalancers, add a security group rule to your back end
|
||||
* instance that specifies this source security group as the inbound source.
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_LoadBalancerDescription.html"
|
||||
* >doc</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SecurityGroupAndOwner {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().fromSourceSecurityGroup(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
protected String name;
|
||||
protected String owner;
|
||||
|
||||
/**
|
||||
* @see SecurityGroupAndOwner#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroupAndOwner#getOwner()
|
||||
*/
|
||||
public Builder owner(String owner) {
|
||||
this.owner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SecurityGroupAndOwner build() {
|
||||
return new SecurityGroupAndOwner(name, owner);
|
||||
}
|
||||
|
||||
public Builder fromSourceSecurityGroup(SecurityGroupAndOwner in) {
|
||||
return this.name(in.getName()).owner(in.getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
protected final String name;
|
||||
protected final String owner;
|
||||
|
||||
protected SecurityGroupAndOwner(String name, String owner) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.owner = checkNotNull(owner, "owner");
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of the source security group.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Owner of the source security group.
|
||||
*/
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SecurityGroupAndOwner other = (SecurityGroupAndOwner) obj;
|
||||
return Objects.equal(this.name, other.name) && Objects.equal(this.owner, other.owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("name", name).add("owner", owner).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -58,6 +58,17 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
@RequestFilters(FormSigner.class)
|
||||
@VirtualHost
|
||||
public interface LoadBalancerAsyncClient {
|
||||
/**
|
||||
* @see LoadBalancerClient#createLoadBalancerListeningInAvailabilityZones()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(CreateLoadBalancerResponseHandler.class)
|
||||
@FormParams(keys = ACTION, values = "CreateLoadBalancer")
|
||||
ListenableFuture<String> createLoadBalancerListeningInAvailabilityZones(@FormParam("LoadBalancerName") String name,
|
||||
@BinderParam(BindListenersToFormParams.class) Listener listeners,
|
||||
@BinderParam(BindAvailabilityZonesToIndexedFormParams.class) Iterable<String> availabilityZones);
|
||||
|
||||
/**
|
||||
* @see LoadBalancerClient#createLoadBalancerListeningInAvailabilityZones()
|
||||
*/
|
||||
|
@ -69,6 +80,18 @@ public interface LoadBalancerAsyncClient {
|
|||
@BinderParam(BindListenersToFormParams.class) Iterable<Listener> listeners,
|
||||
@BinderParam(BindAvailabilityZonesToIndexedFormParams.class) Iterable<String> availabilityZones);
|
||||
|
||||
/**
|
||||
* @see LoadBalancerClient#createLoadBalancerListeningInSubnetAssignedToSecurityGroups()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(CreateLoadBalancerResponseHandler.class)
|
||||
@FormParams(keys = ACTION, values = "CreateLoadBalancer")
|
||||
ListenableFuture<String> createLoadBalancerListeningInSubnetAssignedToSecurityGroups(
|
||||
@FormParam("LoadBalancerName") String name,
|
||||
@FormParam("Subnets.member.1") String subnetId,
|
||||
@BinderParam(BindSecurityGroupsToIndexedFormParams.class) Iterable<String> securityGroupIds);
|
||||
|
||||
/**
|
||||
* @see LoadBalancerClient#createLoadBalancerListeningInSubnetsAssignedToSecurityGroups()
|
||||
*/
|
||||
|
@ -78,7 +101,7 @@ public interface LoadBalancerAsyncClient {
|
|||
@FormParams(keys = ACTION, values = "CreateLoadBalancer")
|
||||
ListenableFuture<String> createLoadBalancerListeningInSubnetsAssignedToSecurityGroups(
|
||||
@FormParam("LoadBalancerName") String name,
|
||||
@BinderParam(BindSubnetsToIndexedFormParams.class) Iterable<Listener> subnetIds,
|
||||
@BinderParam(BindSubnetsToIndexedFormParams.class) Iterable<String> subnetIds,
|
||||
@BinderParam(BindSecurityGroupsToIndexedFormParams.class) Iterable<String> securityGroupIds);
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,13 @@ public interface LoadBalancerClient {
|
|||
String createLoadBalancerListeningInAvailabilityZones(String name, Iterable<Listener> listeners,
|
||||
Iterable<String> availabilityZones);
|
||||
|
||||
String createLoadBalancerListeningInSubnetsAssignedToSecurityGroups(String name, Iterable<Listener> subnetIds,
|
||||
String createLoadBalancerListeningInAvailabilityZones(String name, Listener listeners,
|
||||
Iterable<String> availabilityZones);
|
||||
|
||||
String createLoadBalancerListeningInSubnetAssignedToSecurityGroups(String name, String subnetId,
|
||||
Iterable<String> securityGroupIds);
|
||||
|
||||
String createLoadBalancerListeningInSubnetsAssignedToSecurityGroups(String name, Iterable<String> subnetIds,
|
||||
Iterable<String> securityGroupIds);
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@ import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
|||
|
||||
import org.jclouds.elb.domain.ListenerWithPolicies;
|
||||
import org.jclouds.elb.domain.Protocol;
|
||||
import org.jclouds.elb.domain.SecurityGroupAndOwner;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
|
@ -38,6 +40,8 @@ public class ListenerWithPoliciesHandler extends ParseSax.HandlerForGeneratedReq
|
|||
private StringBuilder currentText = new StringBuilder();
|
||||
private ListenerWithPolicies.Builder<?> builder = ListenerWithPolicies.builder();
|
||||
|
||||
private boolean inPolicyNames;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -50,12 +54,24 @@ public class ListenerWithPoliciesHandler extends ParseSax.HandlerForGeneratedReq
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "PolicyNames")) {
|
||||
inPolicyNames = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "PolicyName")) {
|
||||
if (equalsOrSuffix(qName, "PolicyNames")) {
|
||||
inPolicyNames = false;
|
||||
} else if (equalsOrSuffix(qName, "member") && inPolicyNames) {
|
||||
builder.policyName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "InstancePort")) {
|
||||
builder.instancePort(Integer.parseInt(currentOrNull(currentText)));
|
||||
|
|
|
@ -25,7 +25,8 @@ import javax.inject.Inject;
|
|||
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.elb.domain.LoadBalancer;
|
||||
import org.jclouds.elb.domain.LoadBalancer.Scheme;
|
||||
import org.jclouds.elb.domain.Scheme;
|
||||
import org.jclouds.elb.domain.SecurityGroupAndOwner;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
@ -50,10 +51,13 @@ public class LoadBalancerHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private LoadBalancer.Builder<?> builder = LoadBalancer.builder();
|
||||
private SecurityGroupAndOwner.Builder sourceSecurityGroupBuilder;
|
||||
|
||||
private boolean inHealthCheck;
|
||||
private boolean inListeners;
|
||||
private boolean inAvailabilityZones;
|
||||
private boolean inSecurityGroups;
|
||||
private boolean inSubnets;
|
||||
|
||||
protected int memberDepth;
|
||||
|
||||
|
@ -82,6 +86,12 @@ public class LoadBalancerHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
inListeners = true;
|
||||
} else if (equalsOrSuffix(qName, "AvailabilityZones")) {
|
||||
inAvailabilityZones = true;
|
||||
} else if (equalsOrSuffix(qName, "SecurityGroups")) {
|
||||
inSecurityGroups = true;
|
||||
} else if (equalsOrSuffix(qName, "Subnets")) {
|
||||
inSubnets = true;
|
||||
} else if (equalsOrSuffix(qName, "SourceSecurityGroup")) {
|
||||
sourceSecurityGroupBuilder = SecurityGroupAndOwner.builder();
|
||||
}
|
||||
|
||||
if (inListeners) {
|
||||
|
@ -101,9 +111,17 @@ public class LoadBalancerHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
inListeners = false;
|
||||
} else if (equalsOrSuffix(qName, "AvailabilityZones")) {
|
||||
inAvailabilityZones = false;
|
||||
} else if (equalsOrSuffix(qName, "SecurityGroups")) {
|
||||
inSecurityGroups = false;
|
||||
} else if (equalsOrSuffix(qName, "Subnets")) {
|
||||
inSubnets = false;
|
||||
} else if (equalsOrSuffix(qName, "HealthCheck")) {
|
||||
builder.healthCheck(healthCheckHandler.getResult());
|
||||
inHealthCheck = false;
|
||||
} else if (equalsOrSuffix(qName, "SourceSecurityGroup")) {
|
||||
if (sourceSecurityGroupBuilder != null)
|
||||
builder.sourceSecurityGroup(sourceSecurityGroupBuilder.build());
|
||||
sourceSecurityGroupBuilder = null;
|
||||
} else if (equalsOrSuffix(qName, "LoadBalancerName")) {
|
||||
builder.name(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "CreatedTime")) {
|
||||
|
@ -112,10 +130,18 @@ public class LoadBalancerHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
builder.dnsName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "InstanceId")) {
|
||||
builder.instanceId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "GroupName")) {
|
||||
sourceSecurityGroupBuilder.name(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "OwnerAlias")) {
|
||||
sourceSecurityGroupBuilder.owner(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "Scheme")) {
|
||||
builder.scheme(Scheme.fromValue(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "VPCId")) {
|
||||
builder.VPCId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "CanonicalHostedZoneName")) {
|
||||
builder.hostedZoneName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "CanonicalHostedZoneNameID")) {
|
||||
builder.hostedZoneId(currentOrNull(currentText));
|
||||
} else if (inHealthCheck) {
|
||||
healthCheckHandler.endElement(uri, name, qName);
|
||||
} else if (inListeners) {
|
||||
|
@ -126,9 +152,16 @@ public class LoadBalancerHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
|
||||
protected void endMember(String uri, String name, String qName) throws SAXException {
|
||||
if (inListeners) {
|
||||
if (memberDepth == 2)
|
||||
builder.listener(listenerHandler.getResult());
|
||||
else
|
||||
listenerHandler.endElement(uri, name, qName);
|
||||
} else if (inAvailabilityZones) {
|
||||
builder.availabilityZone(currentOrNull(currentText));
|
||||
} else if (inSecurityGroups) {
|
||||
builder.securityGroup(currentOrNull(currentText));
|
||||
} else if (inSubnets) {
|
||||
builder.subnet(currentOrNull(currentText));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import com.google.common.primitives.Ints;
|
|||
public class PolicyHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Policy> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Policy.Builder<?> builder = Policy.builder();
|
||||
private Policy.Builder builder = Policy.builder();
|
||||
private String key;
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ public class PolicyTypeHandler extends ParseSax.HandlerForGeneratedRequestWithRe
|
|||
}
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private PolicyType.Builder<?> builder = PolicyType.builder();
|
||||
private PolicyType.Builder builder = PolicyType.builder();
|
||||
|
||||
private boolean inAttributeTypes;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.elb.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import org.jclouds.collect.PaginatedSet;
|
||||
import org.jclouds.elb.domain.ListenerWithPolicies;
|
||||
|
@ -35,13 +36,26 @@ import org.testng.annotations.Test;
|
|||
public class LoadBalancerClientLiveTest extends BaseELBClientLiveTest {
|
||||
|
||||
private void checkLoadBalancer(LoadBalancer loadBalancer) {
|
||||
checkNotNull(loadBalancer.getName(), "While Name can be null for a LoadBalancer, its Optional wrapper cannot.");
|
||||
checkNotNull(loadBalancer.getCreatedTime(), "CreatedTime cannot be null for a LoadBalancer.");
|
||||
checkNotNull(loadBalancer.getDnsName(), "DnsName cannot be null for a LoadBalancer.");
|
||||
checkNotNull(loadBalancer.getHealthCheck(), "HealthCheck cannot be null for a LoadBalancer.");
|
||||
checkNotNull(loadBalancer.getName(), "While Name can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getCreatedTime(), "CreatedTime cannot be null for a LoadBalancer: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getDnsName(), "DnsName cannot be null for a LoadBalancer: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getHealthCheck(), "HealthCheck cannot be null for a LoadBalancer: %s", loadBalancer);
|
||||
checkState(loadBalancer.getAvailabilityZones().size() > 0, "AvailabilityZones must have at least one zone: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getInstanceIds(), "While InstanceIds can be empty, it cannot be null: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getSourceSecurityGroup(),
|
||||
"While SourceSecurityGroup can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer);
|
||||
|
||||
// VPC
|
||||
checkNotNull(loadBalancer.getVPCId(), "While VPCId can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getScheme(),
|
||||
"While Scheme can be null for a LoadBalancer, its Optional wrapper cannot.");
|
||||
checkNotNull(loadBalancer.getVPCId(), "While VPCId can be null for a LoadBalancer, its Optional wrapper cannot.");
|
||||
"While Scheme can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getSecurityGroups(), "While SecurityGroups can be empty, it cannot be null: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getSubnets(), "While Subnets can be empty, it cannot be null: %s", loadBalancer);
|
||||
|
||||
// Route 53
|
||||
checkNotNull(loadBalancer.getHostedZoneId(), "While HostedZoneId can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer);
|
||||
checkNotNull(loadBalancer.getHostedZoneName(), "While HostedZoneName can be null for a LoadBalancer, its Optional wrapper cannot: %s", loadBalancer);
|
||||
|
||||
}
|
||||
|
||||
private void checkListener(ListenerWithPolicies listener) {
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* 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.elb.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.collect.PaginatedSet;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.elb.domain.HealthCheck;
|
||||
import org.jclouds.elb.domain.ListenerWithPolicies;
|
||||
import org.jclouds.elb.domain.LoadBalancer;
|
||||
import org.jclouds.elb.domain.Protocol;
|
||||
import org.jclouds.elb.domain.Scheme;
|
||||
import org.jclouds.elb.xml.DescribeLoadBalancersResultHandler;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "DescribeVPCLoadBalancersResponseTest")
|
||||
public class DescribeVPCLoadBalancersResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/describe_loadbalancers_vpc.xml");
|
||||
|
||||
PaginatedSet<LoadBalancer> expected = expected();
|
||||
|
||||
DescribeLoadBalancersResultHandler handler = injector.getInstance(DescribeLoadBalancersResultHandler.class);
|
||||
PaginatedSet<LoadBalancer> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
|
||||
}
|
||||
|
||||
public PaginatedSet<LoadBalancer> expected() {
|
||||
return PaginatedSet.copyOf(ImmutableSet.of(
|
||||
LoadBalancer.builder()
|
||||
.name("tests")
|
||||
.createdTime(new SimpleDateFormatDateService().iso8601DateParse("2012-07-08T19:54:24.190Z"))
|
||||
.dnsName("tests-144598086.us-east-1.elb.amazonaws.com")
|
||||
.healthCheck(HealthCheck.builder()
|
||||
.interval(30)
|
||||
.target("TCP:22")
|
||||
.healthyThreshold(10)
|
||||
.timeout(5)
|
||||
.unhealthyThreshold(2).build())
|
||||
.instanceIds(ImmutableSet.of("i-64bd081c"))
|
||||
.listener(ListenerWithPolicies.builder()
|
||||
.policyName("AWSConsolePolicy-1")
|
||||
.protocol(Protocol.HTTP)
|
||||
.port(80).build())
|
||||
.listener(ListenerWithPolicies.builder()
|
||||
.protocol(Protocol.TCP)
|
||||
.port(25)
|
||||
.instancePort(22).build())
|
||||
.availabilityZone("us-east-1e")
|
||||
.VPCId("vpc-56e10e3d")
|
||||
.scheme(Scheme.INTERNET_FACING)
|
||||
.subnet("subnet-28e10e43")
|
||||
.securityGroup("sg-6ba54204")
|
||||
.securityGroup("sg-99a641f6")
|
||||
.hostedZoneName("tests-144598086.us-east-1.elb.amazonaws.com")
|
||||
.hostedZoneId("Z3DZXE0Q79N41H")
|
||||
.build()));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
|
||||
<DescribeLoadBalancersResult>
|
||||
<LoadBalancerDescriptions>
|
||||
<member>
|
||||
<SecurityGroups>
|
||||
<member>sg-6ba54204</member>
|
||||
<member>sg-99a641f6</member>
|
||||
</SecurityGroups>
|
||||
<LoadBalancerName>tests</LoadBalancerName>
|
||||
<CreatedTime>2012-07-08T19:54:24.190Z</CreatedTime>
|
||||
<HealthCheck>
|
||||
<Interval>30</Interval>
|
||||
<Target>TCP:22</Target>
|
||||
<HealthyThreshold>10</HealthyThreshold>
|
||||
<Timeout>5</Timeout>
|
||||
<UnhealthyThreshold>2</UnhealthyThreshold>
|
||||
</HealthCheck>
|
||||
<VPCId>vpc-56e10e3d</VPCId>
|
||||
<ListenerDescriptions>
|
||||
<member>
|
||||
<PolicyNames>
|
||||
<member>AWSConsolePolicy-1</member>
|
||||
</PolicyNames>
|
||||
<Listener>
|
||||
<Protocol>HTTP</Protocol>
|
||||
<LoadBalancerPort>80</LoadBalancerPort>
|
||||
<InstanceProtocol>HTTP</InstanceProtocol>
|
||||
<InstancePort>80</InstancePort>
|
||||
</Listener>
|
||||
</member>
|
||||
<member>
|
||||
<PolicyNames/>
|
||||
<Listener>
|
||||
<Protocol>TCP</Protocol>
|
||||
<LoadBalancerPort>25</LoadBalancerPort>
|
||||
<InstanceProtocol>TCP</InstanceProtocol>
|
||||
<InstancePort>22</InstancePort>
|
||||
</Listener>
|
||||
</member>
|
||||
</ListenerDescriptions>
|
||||
<Instances>
|
||||
<member>
|
||||
<InstanceId>i-64bd081c</InstanceId>
|
||||
</member>
|
||||
</Instances>
|
||||
<Policies>
|
||||
<AppCookieStickinessPolicies/>
|
||||
<OtherPolicies/>
|
||||
<LBCookieStickinessPolicies>
|
||||
<member>
|
||||
<PolicyName>AWSConsolePolicy-1</PolicyName>
|
||||
<CookieExpirationPeriod>30</CookieExpirationPeriod>
|
||||
</member>
|
||||
</LBCookieStickinessPolicies>
|
||||
</Policies>
|
||||
<AvailabilityZones>
|
||||
<member>us-east-1e</member>
|
||||
</AvailabilityZones>
|
||||
<CanonicalHostedZoneName>tests-144598086.us-east-1.elb.amazonaws.com</CanonicalHostedZoneName>
|
||||
<CanonicalHostedZoneNameID>Z3DZXE0Q79N41H</CanonicalHostedZoneNameID>
|
||||
<Scheme>internet-facing</Scheme>
|
||||
<DNSName>tests-144598086.us-east-1.elb.amazonaws.com</DNSName>
|
||||
<BackendServerDescriptions/>
|
||||
<Subnets>
|
||||
<member>subnet-28e10e43</member>
|
||||
</Subnets>
|
||||
</member>
|
||||
</LoadBalancerDescriptions>
|
||||
</DescribeLoadBalancersResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>c7aa8000-c94d-11e1-b952-e56e755e80dd</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DescribeLoadBalancersResponse>
|
Loading…
Reference in New Issue