mirror of https://github.com/apache/jclouds.git
Make the URI of Servers and Load Balancers available.
This commit is contained in:
parent
57b09d71f4
commit
f3586bec30
|
@ -52,6 +52,7 @@ import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
|
import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
|
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
import org.jclouds.util.InetAddresses2;
|
import org.jclouds.util.InetAddresses2;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -113,6 +114,12 @@ public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMe
|
||||||
builder.privateAddresses(filter(
|
builder.privateAddresses(filter(
|
||||||
transform(filter(from.getAddresses().values(), isPrivateAddress), AddressToStringTransformationFunction.INSTANCE), isInet4Address));
|
transform(filter(from.getAddresses().values(), isPrivateAddress), AddressToStringTransformationFunction.INSTANCE), isInet4Address));
|
||||||
|
|
||||||
|
for (Link link: from.getLinks()) {
|
||||||
|
if (link.getRelation().equals(Link.Relation.SELF)) {
|
||||||
|
builder.uri(link.getHref());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,9 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
assertNotNull(convertedNodeMetadata.getUserMetadata());
|
assertNotNull(convertedNodeMetadata.getUserMetadata());
|
||||||
assertEquals(convertedNodeMetadata.getUserMetadata(),
|
assertEquals(convertedNodeMetadata.getUserMetadata(),
|
||||||
ImmutableMap.<String, String> of("Server Label", "Web Head 1", "Image Version", "2.1"));
|
ImmutableMap.<String, String> of("Server Label", "Web Head 1", "Image Version", "2.1"));
|
||||||
|
|
||||||
|
URI expectedURI = URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54");
|
||||||
|
assertEquals(convertedNodeMetadata.getUri(), expectedURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -167,6 +170,8 @@ public class ServerInZoneToNodeMetadataTest {
|
||||||
|
|
||||||
assertEquals(convertedNodeMetadata.getLocation(), zone);
|
assertEquals(convertedNodeMetadata.getLocation(), zone);
|
||||||
|
|
||||||
|
URI expectedURI = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752");
|
||||||
|
assertEquals(convertedNodeMetadata.getUri(), expectedURI);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Server expectedServer() {
|
public Server expectedServer() {
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.nova.v2_0.parse;
|
package org.jclouds.openstack.nova.v2_0.parse;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import org.jclouds.json.BaseItemParserTest;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -101,8 +101,13 @@ public class ParseServerTest extends BaseItemParserTest<Server> {
|
||||||
.putAll("public", Address.createV4("67.23.10.132"), Address.createV6("::babe:67.23.10.132"),
|
.putAll("public", Address.createV4("67.23.10.132"), Address.createV6("::babe:67.23.10.132"),
|
||||||
Address.createV4("67.23.10.131"), Address.createV6("::babe:4317:0A83"))
|
Address.createV4("67.23.10.131"), Address.createV6("::babe:4317:0A83"))
|
||||||
.putAll("private", Address.createV4("10.176.42.16"), Address.createV6("::babe:10.176.42.16"))
|
.putAll("private", Address.createV4("10.176.42.16"), Address.createV6("::babe:10.176.42.16"))
|
||||||
.build()).build();
|
.build())
|
||||||
|
.links(Link.create(
|
||||||
|
Relation.SELF, URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54")),
|
||||||
|
Link.create(
|
||||||
|
Relation.BOOKMARK,
|
||||||
|
URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54")))
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Injector injector() {
|
protected Injector injector() {
|
||||||
|
|
|
@ -72,6 +72,14 @@
|
||||||
"Image Version": "2.1"
|
"Image Version": "2.1"
|
||||||
},
|
},
|
||||||
"links": [
|
"links": [
|
||||||
|
{
|
||||||
|
"rel": "self",
|
||||||
|
"href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"rel": "bookmark",
|
||||||
|
"href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ package org.jclouds.rackspace.cloudloadbalancers.v1.domain;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -51,6 +52,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
private final SourceAddresses sourceAddresses;
|
private final SourceAddresses sourceAddresses;
|
||||||
private final Set<AccessRuleWithId> accessRules;
|
private final Set<AccessRuleWithId> accessRules;
|
||||||
private final Metadata metadata;
|
private final Metadata metadata;
|
||||||
|
private final URI uri;
|
||||||
|
|
||||||
public LoadBalancer(String region, int id, String name, String protocol, @Nullable Integer port, Set<Node> nodes,
|
public LoadBalancer(String region, int id, String name, String protocol, @Nullable Integer port, Set<Node> nodes,
|
||||||
@Nullable Integer timeout, @Nullable Boolean halfClosed, @Nullable Algorithm algorithm, Status status,
|
@Nullable Integer timeout, @Nullable Boolean halfClosed, @Nullable Algorithm algorithm, Status status,
|
||||||
|
@ -58,7 +60,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
String clusterName, Date created, Date updated, @Nullable Map<String, Boolean> connectionLogging,
|
String clusterName, Date created, Date updated, @Nullable Map<String, Boolean> connectionLogging,
|
||||||
@Nullable ConnectionThrottle connectionThrottle, boolean contentCaching, int nodeCount,
|
@Nullable ConnectionThrottle connectionThrottle, boolean contentCaching, int nodeCount,
|
||||||
@Nullable HealthMonitor healthMonitor, @Nullable SSLTermination sslTermination,
|
@Nullable HealthMonitor healthMonitor, @Nullable SSLTermination sslTermination,
|
||||||
SourceAddresses sourceAddresses, Set<AccessRuleWithId> accessRules, Metadata metadata) {
|
SourceAddresses sourceAddresses, Set<AccessRuleWithId> accessRules, Metadata metadata, URI uri) {
|
||||||
super(name, protocol, port, nodes, algorithm, timeout, halfClosed, sessionPersistenceType, connectionLogging,
|
super(name, protocol, port, nodes, algorithm, timeout, halfClosed, sessionPersistenceType, connectionLogging,
|
||||||
connectionThrottle, healthMonitor);
|
connectionThrottle, healthMonitor);
|
||||||
this.region = checkNotNull(region, "region");
|
this.region = checkNotNull(region, "region");
|
||||||
|
@ -75,6 +77,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
this.sourceAddresses = sourceAddresses;
|
this.sourceAddresses = sourceAddresses;
|
||||||
this.accessRules = accessRules == null ? ImmutableSet.<AccessRuleWithId> of() : ImmutableSet.copyOf(accessRules);
|
this.accessRules = accessRules == null ? ImmutableSet.<AccessRuleWithId> of() : ImmutableSet.copyOf(accessRules);
|
||||||
this.metadata = metadata == null ? new Metadata() : metadata;
|
this.metadata = metadata == null ? new Metadata() : metadata;
|
||||||
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegion() {
|
public String getRegion() {
|
||||||
|
@ -168,6 +171,10 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public URI getUri() {
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper(this).omitNullValues().add("id", id).add("region", region).add("status", status)
|
return Objects.toStringHelper(this).omitNullValues().add("id", id).add("region", region).add("status", status)
|
||||||
.add("name", name).add("protocol", protocol).add("port", port).add("nodeCount", getNodeCount())
|
.add("name", name).add("protocol", protocol).add("port", port).add("nodeCount", getNodeCount())
|
||||||
|
@ -176,7 +183,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
.add("contentCaching", contentCaching).add("sessionPersistenceType", getSessionPersistenceType())
|
.add("contentCaching", contentCaching).add("sessionPersistenceType", getSessionPersistenceType())
|
||||||
.add("sslTermination", sslTermination).add("connectionLogging", isConnectionLogging())
|
.add("sslTermination", sslTermination).add("connectionLogging", isConnectionLogging())
|
||||||
.add("connectionThrottle", connectionThrottle).add("healthMonitor", healthMonitor)
|
.add("connectionThrottle", connectionThrottle).add("healthMonitor", healthMonitor)
|
||||||
.add("accessRules", accessRules).add("metadata", getMetadata()).add("sourceAddresses", sourceAddresses)
|
.add("accessRules", accessRules).add("metadata", getMetadata()).add("uri", uri).add("sourceAddresses", sourceAddresses)
|
||||||
.add("virtualIPs", virtualIPs);
|
.add("virtualIPs", virtualIPs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,6 +279,7 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
private SourceAddresses sourceAddresses;
|
private SourceAddresses sourceAddresses;
|
||||||
private Set<AccessRuleWithId> accessRules;
|
private Set<AccessRuleWithId> accessRules;
|
||||||
private Metadata metadata;
|
private Metadata metadata;
|
||||||
|
private URI uri;
|
||||||
|
|
||||||
public Builder region(String region) {
|
public Builder region(String region) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
|
@ -341,10 +349,15 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder uri(URI uri) {
|
||||||
|
this.uri = uri;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public LoadBalancer build() {
|
public LoadBalancer build() {
|
||||||
return new LoadBalancer(region, id, name, protocol, port, nodes, timeout, halfClosed, algorithm, status,
|
return new LoadBalancer(region, id, name, protocol, port, nodes, timeout, halfClosed, algorithm, status,
|
||||||
virtualIPs, sessionPersistence, clusterName, created, updated, connectionLogging, connectionThrottle,
|
virtualIPs, sessionPersistence, clusterName, created, updated, connectionLogging, connectionThrottle,
|
||||||
contentCaching, nodeCount, healthMonitor, sslTermination, sourceAddresses, accessRules, metadata);
|
contentCaching, nodeCount, healthMonitor, sslTermination, sourceAddresses, accessRules, metadata, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -450,7 +463,8 @@ public class LoadBalancer extends BaseLoadBalancer<Node, LoadBalancer> {
|
||||||
return Builder.class.cast(super.from(in)).region(in.getRegion()).id(in.getId()).status(in.getStatus())
|
return Builder.class.cast(super.from(in)).region(in.getRegion()).id(in.getId()).status(in.getStatus())
|
||||||
.virtualIPs(in.getVirtualIPs()).clusterName(in.getClusterName()).created(in.getCreated())
|
.virtualIPs(in.getVirtualIPs()).clusterName(in.getClusterName()).created(in.getCreated())
|
||||||
.updated(in.getUpdated()).contentCaching(in.isContentCaching()).nodeCount(in.getNodeCount())
|
.updated(in.getUpdated()).contentCaching(in.isContentCaching()).nodeCount(in.getNodeCount())
|
||||||
.sslTermination(in.getSSLTermination()).sourceAddresses(in.getSourceAddresses());
|
.sslTermination(in.getSSLTermination()).sourceAddresses(in.getSourceAddresses())
|
||||||
|
.accessRules(in.getAccessRules()).metadata(in.getMetadata()).uri(in.getUri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRuleWithId;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRuleWithId;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
|
||||||
|
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer.Builder;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIPWithId;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIPWithId;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer.Builder;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -37,18 +39,21 @@ import com.google.inject.assistedinject.Assisted;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class ConvertLB implements Function<LB, LoadBalancer> {
|
public class ConvertLB implements Function<LB, LoadBalancer> {
|
||||||
|
private static final String LOAD_BALANCERS = "loadbalancers";
|
||||||
|
|
||||||
public static interface Factory {
|
public static interface Factory {
|
||||||
ConvertLB createForRegion(String region);
|
ConvertLB createForEndpointAndRegion(URI endpoint, String region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final String region;
|
private final String region;
|
||||||
|
private final URI endpoint;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ConvertLB(@Assisted String region) {
|
ConvertLB(@Assisted URI endpoint, @Assisted String region) {
|
||||||
|
this.endpoint = endpoint;
|
||||||
this.region = region.toUpperCase();
|
this.region = region.toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +91,10 @@ public class ConvertLB implements Function<LB, LoadBalancer> {
|
||||||
else
|
else
|
||||||
builder.metadata(ParseMetadata.transformCLBMetadataToMetadata(lb.metadata));
|
builder.metadata(ParseMetadata.transformCLBMetadataToMetadata(lb.metadata));
|
||||||
|
|
||||||
|
int indexOfLB = endpoint.toString().lastIndexOf(LOAD_BALANCERS);
|
||||||
|
String path = endpoint.toString().substring(0, indexOfLB + LOAD_BALANCERS.length());
|
||||||
|
builder.uri(URI.create(path + "/" + lb.id));
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
catch (NullPointerException e) {
|
catch (NullPointerException e) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -63,12 +64,14 @@ public class ParseLoadBalancer implements Function<HttpResponse, LoadBalancer>,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParseLoadBalancer setContext(HttpRequest request) {
|
public ParseLoadBalancer setContext(HttpRequest request) {
|
||||||
return setRegion(request.getEndpoint().getHost().substring(0, request.getEndpoint().getHost().indexOf('.')));
|
return setEndpointAndRegion(request.getEndpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
ParseLoadBalancer setRegion(String region) {
|
ParseLoadBalancer setEndpointAndRegion(URI endpoint) {
|
||||||
this.convertLB = factory.createForRegion(region);
|
String region = endpoint.getHost().substring(0, endpoint.getHost().indexOf('.'));
|
||||||
|
|
||||||
|
this.convertLB = factory.createForEndpointAndRegion(endpoint, region);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
import static org.jclouds.openstack.v2_0.options.PaginationOptions.Builder.marker;
|
||||||
|
|
||||||
import java.beans.ConstructorProperties;
|
import java.beans.ConstructorProperties;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -76,11 +77,14 @@ public class ParseLoadBalancers implements Function<HttpResponse, IterableWithMa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ParseLoadBalancers setContext(HttpRequest request) {
|
public ParseLoadBalancers setContext(HttpRequest request) {
|
||||||
return setRegion(request.getEndpoint().getHost().substring(0, request.getEndpoint().getHost().indexOf('.')));
|
return setEndpointAndRegion(request.getEndpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
ParseLoadBalancers setRegion(String region) {
|
ParseLoadBalancers setEndpointAndRegion(URI endpoint) {
|
||||||
this.convertLB = factory.createForRegion(region);
|
String region = endpoint.getHost().substring(0, endpoint.getHost().indexOf('.'));
|
||||||
|
|
||||||
|
this.convertLB = factory.createForEndpointAndRegion(endpoint, region);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.json.BaseItemParserTest;
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
|
@ -96,7 +98,8 @@ public class ParseLoadBalancerTest extends BaseItemParserTest<LoadBalancer> {
|
||||||
.clusterName("c1.dfw1")
|
.clusterName("c1.dfw1")
|
||||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
|
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
|
||||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z"))
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z"))
|
||||||
.metadata(metadata).build();
|
.metadata(metadata)
|
||||||
|
.uri(URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000")).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add factory binding as this is not default
|
// add factory binding as this is not default
|
||||||
|
@ -115,6 +118,6 @@ public class ParseLoadBalancerTest extends BaseItemParserTest<LoadBalancer> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<HttpResponse, LoadBalancer> parser(Injector i) {
|
protected Function<HttpResponse, LoadBalancer> parser(Injector i) {
|
||||||
return i.getInstance(ParseLoadBalancer.class).setRegion("DFW");
|
return i.getInstance(ParseLoadBalancer.class).setEndpointAndRegion(URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/2000"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.json.BaseItemParserTest;
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
|
@ -48,7 +50,8 @@ public class ParseLoadBalancerWhenDeletedTest extends BaseItemParserTest<LoadBal
|
||||||
public LoadBalancer expected() {
|
public LoadBalancer expected() {
|
||||||
return LoadBalancer.builder().region("LON").id(4865).name("adriancole-LON").status(Status.DELETED).nodeCount(0)
|
return LoadBalancer.builder().region("LON").id(4865).name("adriancole-LON").status(Status.DELETED).nodeCount(0)
|
||||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-12-05T18:03:23Z"))
|
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-12-05T18:03:23Z"))
|
||||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-12-05T18:04:04Z")).build();
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-12-05T18:04:04Z"))
|
||||||
|
.uri(URI.create("https://lon.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/4865")).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add factory binding as this is not default
|
// add factory binding as this is not default
|
||||||
|
@ -67,6 +70,6 @@ public class ParseLoadBalancerWhenDeletedTest extends BaseItemParserTest<LoadBal
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<HttpResponse, LoadBalancer> parser(Injector i) {
|
protected Function<HttpResponse, LoadBalancer> parser(Injector i) {
|
||||||
return i.getInstance(ParseLoadBalancer.class).setRegion("LON");
|
return i.getInstance(ParseLoadBalancer.class).setEndpointAndRegion(URI.create("https://lon.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/4865"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
package org.jclouds.rackspace.cloudloadbalancers.v1.functions;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.collect.IterableWithMarker;
|
import org.jclouds.collect.IterableWithMarker;
|
||||||
|
@ -62,7 +63,8 @@ public class ParseLoadBalancersTest extends BaseIterableWithMarkerParserTest<Loa
|
||||||
.virtualIPs(ImmutableSet.of(
|
.virtualIPs(ImmutableSet.of(
|
||||||
new VirtualIPWithId(VirtualIP.Type.PUBLIC, VirtualIP.IPVersion.IPV4, 403, "206.55.130.1")))
|
new VirtualIPWithId(VirtualIP.Type.PUBLIC, VirtualIP.IPVersion.IPV4, 403, "206.55.130.1")))
|
||||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
|
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
|
||||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build(),
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z"))
|
||||||
|
.uri(URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/71")).build(),
|
||||||
LoadBalancer
|
LoadBalancer
|
||||||
.builder()
|
.builder()
|
||||||
.region("DFW")
|
.region("DFW")
|
||||||
|
@ -76,7 +78,8 @@ public class ParseLoadBalancersTest extends BaseIterableWithMarkerParserTest<Loa
|
||||||
.virtualIPs(ImmutableSet.of(
|
.virtualIPs(ImmutableSet.of(
|
||||||
new VirtualIPWithId(VirtualIP.Type.PUBLIC, VirtualIP.IPVersion.IPV4, 401, "206.55.130.2")))
|
new VirtualIPWithId(VirtualIP.Type.PUBLIC, VirtualIP.IPVersion.IPV4, 401, "206.55.130.2")))
|
||||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
|
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
|
||||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z")).build());
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z"))
|
||||||
|
.uri(URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/166")).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,6 +108,6 @@ public class ParseLoadBalancersTest extends BaseIterableWithMarkerParserTest<Loa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Function<HttpResponse, IterableWithMarker<LoadBalancer>> parser(Injector i) {
|
protected Function<HttpResponse, IterableWithMarker<LoadBalancer>> parser(Injector i) {
|
||||||
return i.getInstance(ParseLoadBalancers.class).setRegion("DFW");
|
return i.getInstance(ParseLoadBalancers.class).setEndpointAndRegion(URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue