Adding adminURL to Endpoint so we can access admin client features

This commit is contained in:
Adam Lowe 2012-04-27 16:39:10 +01:00
parent f3dc23f578
commit 9cfa022863
2 changed files with 29 additions and 7 deletions

View File

@ -55,6 +55,7 @@ public class Endpoint implements Comparable<Endpoint> {
protected String region;
protected URI publicURL;
protected URI internalURL;
protected URI adminURL;
protected String tenantId;
/**
@ -89,6 +90,14 @@ public class Endpoint implements Comparable<Endpoint> {
return this;
}
/**
* @see Endpoint#getInternalURL()
*/
public Builder adminURL(URI adminURL) {
this.adminURL = checkNotNull(adminURL, "adminURL");
return this;
}
/**
* @see Endpoint#getTenantId()
*/
@ -98,7 +107,7 @@ public class Endpoint implements Comparable<Endpoint> {
}
public Endpoint build() {
return new Endpoint(versionId, region, publicURL, internalURL, tenantId);
return new Endpoint(versionId, region, publicURL, internalURL, adminURL, tenantId);
}
public Builder fromEndpoint(Endpoint from) {
@ -113,17 +122,20 @@ public class Endpoint implements Comparable<Endpoint> {
protected final String region;
protected final URI publicURL;
protected final URI internalURL;
protected final URI adminURL;
// renamed half-way through
@Deprecated
protected String tenantName;
protected final String tenantId;
protected Endpoint(String versionId, String region, @Nullable URI publicURL, @Nullable URI internalURL,
@Nullable String tenantId) {
@Nullable URI adminURL, @Nullable String tenantId) {
this.versionId = checkNotNull(versionId, "versionId");
this.region = checkNotNull(region, "region");
this.publicURL = publicURL;
this.internalURL = internalURL;
this.adminURL = adminURL;
this.tenantId = tenantId;
}
@ -160,6 +172,14 @@ public class Endpoint implements Comparable<Endpoint> {
return internalURL;
}
/**
* @return the admin url of the endpoint
*/
@Nullable
public URI getAdminURL() {
return adminURL;
}
/**
* @return the tenant versionId of the endpoint or null
*/
@ -176,7 +196,7 @@ public class Endpoint implements Comparable<Endpoint> {
if (object instanceof Endpoint) {
final Endpoint other = Endpoint.class.cast(object);
return equal(getVersionId(), other.getVersionId()) && equal(region, other.region) && equal(publicURL, other.publicURL)
&& equal(internalURL, other.internalURL) && equal(getTenantId(), other.getTenantId());
&& equal(internalURL, other.internalURL) && equal(adminURL, other.adminURL) && equal(getTenantId(), other.getTenantId());
} else {
return false;
}
@ -184,13 +204,13 @@ public class Endpoint implements Comparable<Endpoint> {
@Override
public int hashCode() {
return Objects.hashCode(getVersionId(), region, publicURL, internalURL, getTenantId());
return Objects.hashCode(getVersionId(), region, publicURL, internalURL, adminURL, getTenantId());
}
@Override
public String toString() {
return toStringHelper("").add("versionId", getVersionId()).add("region", region).add("publicURL", publicURL).add("internalURL",
internalURL).add("tenantId", getTenantId()).toString();
internalURL).add("adminURL", adminURL).add("tenantId", getTenantId()).toString();
}
@Override

View File

@ -67,11 +67,13 @@ public class ParseAccessTest extends BaseItemParserTest<Access> {
Service.builder().name("Object Storage").type("object-store").endpoints(
Endpoint.builder().tenantId("40806637803162").publicURL(
URI.create("https://objects.jclouds.org/v1.0/40806637803162"))
.adminURL(URI.create("https://objects.jclouds.org/v1.0/"))
.region("region-a.geo-1").versionId("1.0").build()).build(),
Service.builder().name("Identity").type("identity").endpoints(
Endpoint.builder().publicURL(URI.create("https://csnode.jclouds.org/v2.0/")).region(
"region-a.geo-1").versionId("2.0").build()).build(),
Endpoint.builder().publicURL(URI.create("https://csnode.jclouds.org/v2.0/"))
.adminURL(URI.create("https://csnode.jclouds.org:35357/v2.0/"))
.region("region-a.geo-1").versionId("2.0").build()).build(),
Service.builder().name("Image Management").type("image").endpoints(
Endpoint.builder().tenantId("40806637803162").publicURL(