synchronized naming of route53 with aws sdk, and changed resource record type from enum to string

This commit is contained in:
adriancole 2013-02-19 15:32:20 -08:00
parent c01bc173d0
commit f8a3f5ee1d
38 changed files with 428 additions and 437 deletions

View File

@ -25,8 +25,8 @@ import javax.ws.rs.PathParam;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change;
import org.jclouds.route53.features.RecordSetApi; import org.jclouds.route53.features.ResourceRecordSetApi;
import org.jclouds.route53.features.ZoneApi; import org.jclouds.route53.features.HostedZoneApi;
/** /**
* Provides access to Amazon Route53 via the Query API * Provides access to Amazon Route53 via the Query API
@ -53,11 +53,11 @@ public interface Route53Api {
* Provides synchronous access to Zone features. * Provides synchronous access to Zone features.
*/ */
@Delegate @Delegate
ZoneApi getZoneApi(); HostedZoneApi getHostedZoneApi();
/** /**
* Provides synchronous access to record set features. * Provides synchronous access to record set features.
*/ */
@Delegate @Delegate
RecordSetApi getRecordSetApiForZone(@PathParam("zoneId") String zoneId); ResourceRecordSetApi getResourceRecordSetApiForHostedZone(@PathParam("zoneId") String zoneId);
} }

View File

@ -30,8 +30,8 @@ import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change;
import org.jclouds.route53.features.RecordSetAsyncApi; import org.jclouds.route53.features.ResourceRecordSetAsyncApi;
import org.jclouds.route53.features.ZoneAsyncApi; import org.jclouds.route53.features.HostedZoneAsyncApi;
import org.jclouds.route53.filters.RestAuthentication; import org.jclouds.route53.filters.RestAuthentication;
import org.jclouds.route53.xml.ChangeHandler; import org.jclouds.route53.xml.ChangeHandler;
@ -64,11 +64,11 @@ public interface Route53AsyncApi {
* Provides asynchronous access to Zone features. * Provides asynchronous access to Zone features.
*/ */
@Delegate @Delegate
ZoneAsyncApi getZoneApi(); HostedZoneAsyncApi getHostedZoneApi();
/** /**
* Provides asynchronous access to record set features. * Provides asynchronous access to record set features.
*/ */
@Delegate @Delegate
RecordSetAsyncApi getRecordSetApiForZone(@PathParam("zoneId") String zoneId); ResourceRecordSetAsyncApi getResourceRecordSetApiForHostedZone(@PathParam("zoneId") String zoneId);
} }

View File

@ -23,7 +23,7 @@ import javax.inject.Singleton;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpRequest.Builder; import org.jclouds.http.HttpRequest.Builder;
import org.jclouds.rest.Binder; import org.jclouds.rest.Binder;
import org.jclouds.route53.domain.RecordSetIterable.NextRecord; import org.jclouds.route53.domain.ResourceRecordSetIterable.NextRecord;
/** /**
* *

View File

@ -34,10 +34,10 @@ import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RequestSigner; import org.jclouds.rest.RequestSigner;
import org.jclouds.route53.Route53Api; import org.jclouds.route53.Route53Api;
import org.jclouds.route53.Route53AsyncApi; import org.jclouds.route53.Route53AsyncApi;
import org.jclouds.route53.features.RecordSetApi; import org.jclouds.route53.features.ResourceRecordSetApi;
import org.jclouds.route53.features.RecordSetAsyncApi; import org.jclouds.route53.features.ResourceRecordSetAsyncApi;
import org.jclouds.route53.features.ZoneApi; import org.jclouds.route53.features.HostedZoneApi;
import org.jclouds.route53.features.ZoneAsyncApi; import org.jclouds.route53.features.HostedZoneAsyncApi;
import org.jclouds.route53.filters.RestAuthentication; import org.jclouds.route53.filters.RestAuthentication;
import org.jclouds.route53.handlers.Route53ErrorHandler; import org.jclouds.route53.handlers.Route53ErrorHandler;
@ -53,8 +53,8 @@ import com.google.inject.Provides;
@ConfiguresRestClient @ConfiguresRestClient
public class Route53RestClientModule extends AWSRestClientModule<Route53Api, Route53AsyncApi> { public class Route53RestClientModule extends AWSRestClientModule<Route53Api, Route53AsyncApi> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()// public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(ZoneApi.class, ZoneAsyncApi.class) .put(HostedZoneApi.class, HostedZoneAsyncApi.class)
.put(RecordSetApi.class, RecordSetAsyncApi.class).build(); .put(ResourceRecordSetApi.class, ResourceRecordSetAsyncApi.class).build();
public Route53RestClientModule() { public Route53RestClientModule() {
super(TypeToken.of(Route53Api.class), TypeToken.of(Route53AsyncApi.class), DELEGATE_MAP); super(TypeToken.of(Route53Api.class), TypeToken.of(Route53AsyncApi.class), DELEGATE_MAP);

View File

@ -38,11 +38,11 @@ import com.google.common.collect.ImmutableList;
*/ */
public class ChangeBatch extends ForwardingList<ActionOnResourceRecordSet> { public class ChangeBatch extends ForwardingList<ActionOnResourceRecordSet> {
public static ChangeBatch createAll(Iterable<RecordSet> toCreate) { public static ChangeBatch createAll(Iterable<ResourceRecordSet> toCreate) {
return builder().createAll(toCreate).build(); return builder().createAll(toCreate).build();
} }
public static ChangeBatch deleteAll(Iterable<RecordSet> toDelete) { public static ChangeBatch deleteAll(Iterable<ResourceRecordSet> toDelete) {
return builder().deleteAll(toDelete).build(); return builder().deleteAll(toDelete).build();
} }
@ -55,9 +55,9 @@ public class ChangeBatch extends ForwardingList<ActionOnResourceRecordSet> {
public static class ActionOnResourceRecordSet { public static class ActionOnResourceRecordSet {
private final Action action; private final Action action;
private final RecordSet rrs; private final ResourceRecordSet rrs;
private ActionOnResourceRecordSet(Action action, RecordSet rrs) { private ActionOnResourceRecordSet(Action action, ResourceRecordSet rrs) {
this.action = action; this.action = action;
this.rrs = rrs; this.rrs = rrs;
} }
@ -66,7 +66,7 @@ public class ChangeBatch extends ForwardingList<ActionOnResourceRecordSet> {
return action; return action;
} }
public RecordSet getRRS() { public ResourceRecordSet getRRS() {
return rrs; return rrs;
} }
@ -145,24 +145,24 @@ public class ChangeBatch extends ForwardingList<ActionOnResourceRecordSet> {
return this; return this;
} }
public Builder create(RecordSet rrs) { public Builder create(ResourceRecordSet rrs) {
this.changes.add(new ActionOnResourceRecordSet(Action.CREATE, rrs)); this.changes.add(new ActionOnResourceRecordSet(Action.CREATE, rrs));
return this; return this;
} }
public Builder createAll(Iterable<RecordSet> toCreate) { public Builder createAll(Iterable<ResourceRecordSet> toCreate) {
for (RecordSet rrs : toCreate) for (ResourceRecordSet rrs : toCreate)
create(rrs); create(rrs);
return this; return this;
} }
public Builder delete(RecordSet rrs) { public Builder delete(ResourceRecordSet rrs) {
this.changes.add(new ActionOnResourceRecordSet(Action.DELETE, rrs)); this.changes.add(new ActionOnResourceRecordSet(Action.DELETE, rrs));
return this; return this;
} }
public Builder deleteAll(Iterable<RecordSet> toDelete) { public Builder deleteAll(Iterable<ResourceRecordSet> toDelete) {
for (RecordSet rrs : toDelete) for (ResourceRecordSet rrs : toDelete)
delete(rrs); delete(rrs);
return this; return this;
} }

View File

@ -29,7 +29,7 @@ import com.google.common.base.Optional;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public final class Zone { public final class HostedZone {
private final String id; private final String id;
private final String name; private final String name;
@ -37,7 +37,7 @@ public final class Zone {
private final int resourceRecordSetCount; private final int resourceRecordSetCount;
private final Optional<String> comment; private final Optional<String> comment;
private Zone(String id, String name, String callerReference, int resourceRecordSetCount, Optional<String> comment) { private HostedZone(String id, String name, String callerReference, int resourceRecordSetCount, Optional<String> comment) {
this.id = checkNotNull(id, "id"); this.id = checkNotNull(id, "id");
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
this.callerReference = checkNotNull(callerReference, "callerReference for %s", name); this.callerReference = checkNotNull(callerReference, "callerReference for %s", name);
@ -67,7 +67,7 @@ public final class Zone {
} }
/** /**
* A percentage value that indicates the size of the policy in packed form. * count of record sets
*/ */
public int getResourceRecordSetCount() { public int getResourceRecordSetCount() {
return resourceRecordSetCount; return resourceRecordSetCount;
@ -88,7 +88,7 @@ public final class Zone {
return true; return true;
if (obj == null || getClass() != obj.getClass()) if (obj == null || getClass() != obj.getClass())
return false; return false;
Zone that = Zone.class.cast(obj); HostedZone that = HostedZone.class.cast(obj);
return equal(this.id, that.id) && equal(this.name, that.name) return equal(this.id, that.id) && equal(this.name, that.name)
&& equal(this.callerReference, that.callerReference); && equal(this.callerReference, that.callerReference);
} }
@ -112,11 +112,11 @@ public final class Zone {
private String id; private String id;
private String name; private String name;
private String callerReference; private String callerReference;
private int resourceRecordSetCount = 0; private int resourceRecordSetCount;
private Optional<String> comment = Optional.absent(); private Optional<String> comment = Optional.absent();
/** /**
* @see Zone#getId() * @see HostedZone#getId()
*/ */
public Builder id(String id) { public Builder id(String id) {
this.id = id; this.id = id;
@ -124,7 +124,7 @@ public final class Zone {
} }
/** /**
* @see Zone#getName() * @see HostedZone#getName()
*/ */
public Builder name(String name) { public Builder name(String name) {
this.name = name; this.name = name;
@ -132,7 +132,7 @@ public final class Zone {
} }
/** /**
* @see Zone#getCallerReference() * @see HostedZone#getCallerReference()
*/ */
public Builder callerReference(String callerReference) { public Builder callerReference(String callerReference) {
this.callerReference = callerReference; this.callerReference = callerReference;
@ -140,7 +140,7 @@ public final class Zone {
} }
/** /**
* @see Zone#getResourceRecordSetCount() * @see HostedZone#getResourceRecordSetCount()
*/ */
public Builder resourceRecordSetCount(int resourceRecordSetCount) { public Builder resourceRecordSetCount(int resourceRecordSetCount) {
this.resourceRecordSetCount = resourceRecordSetCount; this.resourceRecordSetCount = resourceRecordSetCount;
@ -148,18 +148,18 @@ public final class Zone {
} }
/** /**
* @see Zone#getComment() * @see HostedZone#getComment()
*/ */
public Builder comment(String comment) { public Builder comment(String comment) {
this.comment = Optional.fromNullable(comment); this.comment = Optional.fromNullable(comment);
return this; return this;
} }
public Zone build() { public HostedZone build() {
return new Zone(id, name, callerReference, resourceRecordSetCount, comment); return new HostedZone(id, name, callerReference, resourceRecordSetCount, comment);
} }
public Builder from(Zone in) { public Builder from(HostedZone in) {
return this.id(in.id).name(in.name).callerReference(in.callerReference) return this.id(in.id).name(in.name).callerReference(in.callerReference)
.resourceRecordSetCount(in.resourceRecordSetCount).comment(in.comment.orNull()); .resourceRecordSetCount(in.resourceRecordSetCount).comment(in.comment.orNull());
} }

View File

@ -29,12 +29,12 @@ import com.google.common.collect.ImmutableList;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public final class ZoneAndNameServers { public final class HostedZoneAndNameServers {
private final Zone zone; private final HostedZone zone;
private final ImmutableList<String> nameServers; private final ImmutableList<String> nameServers;
private ZoneAndNameServers(Zone zone, ImmutableList<String> nameServers) { private HostedZoneAndNameServers(HostedZone zone, ImmutableList<String> nameServers) {
this.zone = checkNotNull(zone, "zone"); this.zone = checkNotNull(zone, "zone");
this.nameServers = checkNotNull(nameServers, "nameServers for %s", zone); this.nameServers = checkNotNull(nameServers, "nameServers for %s", zone);
} }
@ -42,7 +42,7 @@ public final class ZoneAndNameServers {
/** /**
* the hosted zone * the hosted zone
*/ */
public Zone getZone() { public HostedZone getZone() {
return zone; return zone;
} }
@ -64,7 +64,7 @@ public final class ZoneAndNameServers {
return true; return true;
if (obj == null || getClass() != obj.getClass()) if (obj == null || getClass() != obj.getClass())
return false; return false;
ZoneAndNameServers that = ZoneAndNameServers.class.cast(obj); HostedZoneAndNameServers that = HostedZoneAndNameServers.class.cast(obj);
return equal(this.zone, that.zone) && equal(this.nameServers, that.nameServers); return equal(this.zone, that.zone) && equal(this.nameServers, that.nameServers);
} }
@ -73,7 +73,7 @@ public final class ZoneAndNameServers {
return toStringHelper("").add("zone", zone).add("nameServers", nameServers).toString(); return toStringHelper("").add("zone", zone).add("nameServers", nameServers).toString();
} }
public static ZoneAndNameServers create(Zone zone, Iterable<String> nameServers) { public static HostedZoneAndNameServers create(HostedZone zone, Iterable<String> nameServers) {
return new ZoneAndNameServers(zone, ImmutableList.<String> copyOf(checkNotNull(nameServers, "nameServers"))); return new HostedZoneAndNameServers(zone, ImmutableList.<String> copyOf(checkNotNull(nameServers, "nameServers")));
} }
} }

View File

@ -29,25 +29,25 @@ import com.google.common.collect.ImmutableList;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public final class NewZone { public final class NewHostedZone {
private final ZoneAndNameServers zone; private final HostedZoneAndNameServers zone;
private final Change change; private final Change change;
private NewZone(ZoneAndNameServers zone, Change change) { private NewHostedZone(HostedZoneAndNameServers zone, Change change) {
this.zone = checkNotNull(zone, "zone"); this.zone = checkNotNull(zone, "zone");
this.change = checkNotNull(change, "change of %s", zone); this.change = checkNotNull(change, "change of %s", zone);
} }
/** /**
* @see ZoneAndNameServers#getZone() * @see HostedZoneAndNameServers#getZone()
*/ */
public Zone getZone() { public HostedZone getZone() {
return zone.getZone(); return zone.getZone();
} }
/** /**
* @see ZoneAndNameServers#getNameServers() * @see HostedZoneAndNameServers#getNameServers()
*/ */
public ImmutableList<String> getNameServers() { public ImmutableList<String> getNameServers() {
return zone.getNameServers(); return zone.getNameServers();
@ -71,7 +71,7 @@ public final class NewZone {
return true; return true;
if (obj == null || getClass() != obj.getClass()) if (obj == null || getClass() != obj.getClass())
return false; return false;
NewZone that = NewZone.class.cast(obj); NewHostedZone that = NewHostedZone.class.cast(obj);
return equal(this.zone, that.zone); return equal(this.zone, that.zone);
} }
@ -81,7 +81,7 @@ public final class NewZone {
.add("change", change).toString(); .add("change", change).toString();
} }
public static NewZone create(ZoneAndNameServers zone, Change change) { public static NewHostedZone create(HostedZoneAndNameServers zone, Change change) {
return new NewZone(zone, change); return new NewHostedZone(zone, change);
} }
} }

View File

@ -22,32 +22,29 @@ import static com.google.common.base.Objects.equal;
import static com.google.common.base.Objects.toStringHelper; import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set; import java.util.List;
import org.jclouds.route53.domain.RecordSet.RecordSubset.Latency; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Latency;
import org.jclouds.route53.domain.RecordSet.RecordSubset.Weighted; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Weighted;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableList;
import com.google.common.primitives.UnsignedInteger;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class RecordSet { public class ResourceRecordSet {
protected final String name; protected final String name;
protected final Type type; protected final String type;
protected final Optional<Integer> ttl; protected final Optional<UnsignedInteger> ttl;
protected final Set<String> values; protected final List<String> values;
protected final Optional<AliasTarget> aliasTarget; protected final Optional<AliasTarget> aliasTarget;
public enum Type {
A, AAAA, CNAME, MX, NS, PTR, SOA, SPF, SRV, TXT;
}
/** /**
* In this case, the rrs is an alias, and it points to another Route53 hosted * In this case, the rrs is an alias, and it points to another Route53 hosted
* resource, such as an ELB, S3 bucket, or zone. * resource, such as an ELB, S3 bucket, or zone.
@ -98,22 +95,22 @@ public class RecordSet {
/** /**
* A portion of a RRs who share the same name and type * A portion of a RRs who share the same name and type
*/ */
public static abstract class RecordSubset extends RecordSet { public static abstract class RecordSubset extends ResourceRecordSet {
public static final class Weighted extends RecordSubset { public static final class Weighted extends RecordSubset {
private final int weight; private final UnsignedInteger weight;
private Weighted(String id, String name, Type type, int weight, Optional<Integer> ttl, Set<String> values, private Weighted(String id, String name, String type, UnsignedInteger weight, Optional<UnsignedInteger> ttl, List<String> values,
Optional<AliasTarget> aliasTarget) { Optional<AliasTarget> aliasTarget) {
super(id, name, type, ttl, values, aliasTarget); super(id, name, type, ttl, values, aliasTarget);
this.weight = weight; this.weight = checkNotNull(weight, "weight");
} }
/** /**
* determines what portion of traffic for the current resource record * determines what portion of traffic for the current resource record
* set is routed to this subset. * set is routed to this subset.
*/ */
public int getWeight() { public UnsignedInteger getWeight() {
return weight; return weight;
} }
@ -127,7 +124,7 @@ public class RecordSet {
private final String region; private final String region;
private Latency(String id, String name, Type type, String region, Optional<Integer> ttl, Set<String> values, private Latency(String id, String name, String type, String region, Optional<UnsignedInteger> ttl, List<String> values,
Optional<AliasTarget> aliasTarget) { Optional<AliasTarget> aliasTarget) {
super(id, name, type, ttl, values, aliasTarget); super(id, name, type, ttl, values, aliasTarget);
this.region = checkNotNull(region, "region of %s", name); this.region = checkNotNull(region, "region of %s", name);
@ -149,7 +146,7 @@ public class RecordSet {
private final String id; private final String id;
private RecordSubset(String id, String name, Type type, Optional<Integer> ttl, Set<String> values, private RecordSubset(String id, String name, String type, Optional<UnsignedInteger> ttl, List<String> values,
Optional<AliasTarget> aliasTarget) { Optional<AliasTarget> aliasTarget) {
super(name, type, ttl, values, aliasTarget); super(name, type, ttl, values, aliasTarget);
this.id = checkNotNull(id, "id of %s", name); this.id = checkNotNull(id, "id of %s", name);
@ -186,7 +183,7 @@ public class RecordSet {
} }
} }
private RecordSet(String name, Type type, Optional<Integer> ttl, Set<String> values, Optional<AliasTarget> aliasTarget) { private ResourceRecordSet(String name, String type, Optional<UnsignedInteger> ttl, List<String> values, Optional<AliasTarget> aliasTarget) {
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
this.type = checkNotNull(type, "type of %s", name); this.type = checkNotNull(type, "type of %s", name);
this.ttl = checkNotNull(ttl, "ttl for %s", name); this.ttl = checkNotNull(ttl, "ttl for %s", name);
@ -204,7 +201,7 @@ public class RecordSet {
/** /**
* The resource record set type. * The resource record set type.
*/ */
public Type getType() { public String getType() {
return type; return type;
} }
@ -212,21 +209,21 @@ public class RecordSet {
* Present in all resource record sets except aliases. The resource record * Present in all resource record sets except aliases. The resource record
* cache time to live (TTL), in seconds. * cache time to live (TTL), in seconds.
*/ */
public Optional<Integer> getTTL() { public Optional<UnsignedInteger> getTTL() {
return ttl; return ttl;
} }
/** /**
* Type-specific values that differentiates the RRs in this set. Empty if * Type-specific values that differentiates the RRs in this set. Empty if
* {@link #getType()} is {@link Type#A} or {@link Type#AAAA} and * {@link #getType()} is {@code A} or {@code AAAA} and
* {@link #getAliasTarget} is present. * {@link #getAliasTarget} is present.
*/ */
public Set<String> getValues() { public List<String> getValues() {
return values; return values;
} }
/** /**
* When present, {@link #getType()} is {@link Type#A} or {@link Type#AAAA}. * When present, {@link #getType()} is {@code A} or {@code AAAA}.
* Instead of {@link #getValues()} containing the corresponding IP addresses, * Instead of {@link #getValues()} containing the corresponding IP addresses,
* the server will follow this link and resolve one on-demand. * the server will follow this link and resolve one on-demand.
*/ */
@ -245,7 +242,7 @@ public class RecordSet {
return true; return true;
if (obj == null || getClass() != obj.getClass()) if (obj == null || getClass() != obj.getClass())
return false; return false;
RecordSet other = RecordSet.class.cast(obj); ResourceRecordSet other = ResourceRecordSet.class.cast(obj);
return equal(this.name, other.name) && equal(this.type, other.type); return equal(this.name, other.name) && equal(this.type, other.type);
} }
@ -266,12 +263,12 @@ public class RecordSet {
public final static class Builder { public final static class Builder {
private String id; private String id;
private String name; private String name;
private Type type; private String type;
private Optional<Integer> ttl = Optional.absent(); private Optional<UnsignedInteger> ttl = Optional.absent();
private ImmutableSet.Builder<String> values = ImmutableSet.<String> builder(); private ImmutableList.Builder<String> values = ImmutableList.<String> builder();
private String dnsName; private String dnsName;
private String zoneId; private String zoneId;
private Integer weight; private UnsignedInteger weight;
private String region; private String region;
/** /**
@ -283,7 +280,7 @@ public class RecordSet {
} }
/** /**
* @see RecordSet#getName() * @see ResourceRecordSet#getName()
*/ */
public Builder name(String name) { public Builder name(String name) {
this.name = name; this.name = name;
@ -291,23 +288,30 @@ public class RecordSet {
} }
/** /**
* @see RecordSet#getType() * @see ResourceRecordSet#getType()
*/ */
public Builder type(Type type) { public Builder type(String type) {
this.type = type; this.type = type;
return this; return this;
} }
/** /**
* @see RecordSet#getTTL() * @see ResourceRecordSet#getTTL()
*/ */
public Builder ttl(Integer ttl) { public Builder ttl(UnsignedInteger ttl) {
this.ttl = Optional.fromNullable(ttl); this.ttl = Optional.fromNullable(ttl);
return this; return this;
} }
/** /**
* @see RecordSet#getAliasTarget() * @see ResourceRecordSet#getTTL()
*/
public Builder ttl(int ttl) {
return ttl(UnsignedInteger.asUnsigned(ttl));
}
/**
* @see ResourceRecordSet#getAliasTarget()
*/ */
public Builder dnsName(String dnsName) { public Builder dnsName(String dnsName) {
this.dnsName = dnsName; this.dnsName = dnsName;
@ -315,7 +319,7 @@ public class RecordSet {
} }
/** /**
* @see RecordSet#getAliasTarget() * @see ResourceRecordSet#getAliasTarget()
*/ */
public Builder zoneId(String zoneId) { public Builder zoneId(String zoneId) {
this.zoneId = zoneId; this.zoneId = zoneId;
@ -323,7 +327,7 @@ public class RecordSet {
} }
/** /**
* @see RecordSet#getAliasTarget() * @see ResourceRecordSet#getAliasTarget()
*/ */
public Builder aliasTarget(AliasTarget aliasTarget) { public Builder aliasTarget(AliasTarget aliasTarget) {
if (aliasTarget == null) { if (aliasTarget == null) {
@ -337,7 +341,7 @@ public class RecordSet {
} }
/** /**
* @see RecordSet#getValues() * @see ResourceRecordSet#getValues()
*/ */
public Builder add(String values) { public Builder add(String values) {
this.values.add(values); this.values.add(values);
@ -345,7 +349,7 @@ public class RecordSet {
} }
/** /**
* @see RecordSet#getValues() * @see ResourceRecordSet#getValues()
*/ */
public Builder addAll(Iterable<String> values) { public Builder addAll(Iterable<String> values) {
this.values.addAll(values); this.values.addAll(values);
@ -355,7 +359,7 @@ public class RecordSet {
/** /**
* @see RecordSubset.Weighted * @see RecordSubset.Weighted
*/ */
public Builder weight(Integer weight) { public Builder weight(UnsignedInteger weight) {
this.weight = weight; this.weight = weight;
return this; return this;
} }
@ -368,7 +372,7 @@ public class RecordSet {
return this; return this;
} }
public RecordSet build() { public ResourceRecordSet build() {
Optional<AliasTarget> aliasTarget = dnsName != null ? Optional.fromNullable(AliasTarget.dnsNameInZone(dnsName, zoneId)) Optional<AliasTarget> aliasTarget = dnsName != null ? Optional.fromNullable(AliasTarget.dnsNameInZone(dnsName, zoneId))
: Optional.<AliasTarget> absent(); : Optional.<AliasTarget> absent();
if (weight != null) { if (weight != null) {
@ -376,10 +380,10 @@ public class RecordSet {
} else if (region != null) { } else if (region != null) {
return new RecordSubset.Latency(id, name, type, region, ttl, values.build(), aliasTarget); return new RecordSubset.Latency(id, name, type, region, ttl, values.build(), aliasTarget);
} }
return new RecordSet(name, type, ttl, values.build(), aliasTarget); return new ResourceRecordSet(name, type, ttl, values.build(), aliasTarget);
} }
public Builder from(RecordSet in) { public Builder from(ResourceRecordSet in) {
if (in instanceof RecordSubset) if (in instanceof RecordSubset)
id(RecordSubset.class.cast(in).id); id(RecordSubset.class.cast(in).id);
if (in instanceof Weighted) { if (in instanceof Weighted) {

View File

@ -27,7 +27,6 @@ import java.util.Iterator;
import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.IterableWithMarker;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.route53.domain.RecordSet.Type;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Optional; import com.google.common.base.Optional;
@ -37,12 +36,12 @@ import com.google.common.collect.ImmutableList;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class RecordSetIterable extends IterableWithMarker<RecordSet> { public class ResourceRecordSetIterable extends IterableWithMarker<ResourceRecordSet> {
private final Iterable<RecordSet> items; private final Iterable<ResourceRecordSet> items;
private final Optional<NextRecord> nextRecord; private final Optional<NextRecord> nextRecord;
private RecordSetIterable(Iterable<RecordSet> items, @Nullable NextRecord nextRecord) { private ResourceRecordSetIterable(Iterable<ResourceRecordSet> items, @Nullable NextRecord nextRecord) {
this.items = checkNotNull(items, "items"); this.items = checkNotNull(items, "items");
this.nextRecord = Optional.fromNullable(nextRecord); this.nextRecord = Optional.fromNullable(nextRecord);
} }
@ -61,7 +60,7 @@ public class RecordSetIterable extends IterableWithMarker<RecordSet> {
} }
@Override @Override
public Iterator<RecordSet> iterator() { public Iterator<ResourceRecordSet> iterator() {
return items.iterator(); return items.iterator();
} }
@ -76,7 +75,7 @@ public class RecordSetIterable extends IterableWithMarker<RecordSet> {
return true; return true;
if (obj == null || getClass() != obj.getClass()) if (obj == null || getClass() != obj.getClass())
return false; return false;
RecordSetIterable that = RecordSetIterable.class.cast(obj); ResourceRecordSetIterable that = ResourceRecordSetIterable.class.cast(obj);
return equal(this.items, that.items) && equal(this.nextRecord, that.nextRecord); return equal(this.items, that.items) && equal(this.nextRecord, that.nextRecord);
} }
@ -89,19 +88,19 @@ public class RecordSetIterable extends IterableWithMarker<RecordSet> {
* If the results were truncated, this holds the position of the next item. * If the results were truncated, this holds the position of the next item.
*/ */
public static class NextRecord { public static class NextRecord {
public static NextRecord nameAndType(String name, Type type) { public static NextRecord nameAndType(String name, String type) {
return new NextRecord(name, type, null); return new NextRecord(name, type, null);
} }
public static NextRecord nameTypeAndIdentifier(String name, Type type, String identifier) { public static NextRecord nameTypeAndIdentifier(String name, String type, String identifier) {
return new NextRecord(name, type, identifier); return new NextRecord(name, type, identifier);
} }
private final String name; private final String name;
private final Type type; private final String type;
private final Optional<String> identifier; private final Optional<String> identifier;
private NextRecord(String name, Type type, String identifier) { private NextRecord(String name, String type, String identifier) {
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
this.type = checkNotNull(type, "type for %s", name); this.type = checkNotNull(type, "type for %s", name);
this.identifier = Optional.fromNullable(identifier); this.identifier = Optional.fromNullable(identifier);
@ -117,7 +116,7 @@ public class RecordSetIterable extends IterableWithMarker<RecordSet> {
/** /**
* the type of the next record in the list. * the type of the next record in the list.
*/ */
public Type getType() { public String getType() {
return type; return type;
} }
@ -157,17 +156,17 @@ public class RecordSetIterable extends IterableWithMarker<RecordSet> {
public static final class Builder { public static final class Builder {
private ImmutableList.Builder<RecordSet> items = ImmutableList.<RecordSet> builder(); private ImmutableList.Builder<ResourceRecordSet> items = ImmutableList.<ResourceRecordSet> builder();
private String nextRecordName; private String nextRecordName;
private Type nextRecordType; private String nextRecordType;
private String nextRecordIdentifier; private String nextRecordIdentifier;
public Builder add(RecordSet item) { public Builder add(ResourceRecordSet item) {
this.items.add(item); this.items.add(item);
return this; return this;
} }
public Builder addAll(Iterable<RecordSet> items) { public Builder addAll(Iterable<ResourceRecordSet> items) {
this.items.addAll(items); this.items.addAll(items);
return this; return this;
} }
@ -177,7 +176,7 @@ public class RecordSetIterable extends IterableWithMarker<RecordSet> {
return this; return this;
} }
public Builder nextRecordType(Type nextRecordType) { public Builder nextRecordType(String nextRecordType) {
this.nextRecordType = nextRecordType; this.nextRecordType = nextRecordType;
return this; return this;
} }
@ -187,10 +186,10 @@ public class RecordSetIterable extends IterableWithMarker<RecordSet> {
return this; return this;
} }
public RecordSetIterable build() { public ResourceRecordSetIterable build() {
NextRecord nextRecord = nextRecordName != null ? new NextRecord(nextRecordName, nextRecordType, NextRecord nextRecord = nextRecordName != null ? new NextRecord(nextRecordName, nextRecordType,
nextRecordIdentifier) : null; nextRecordIdentifier) : null;
return new RecordSetIterable(items.build(), nextRecord); return new ResourceRecordSetIterable(items.build(), nextRecord);
} }
} }
} }

View File

@ -26,19 +26,19 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change;
import org.jclouds.route53.domain.Change.Status; import org.jclouds.route53.domain.Change.Status;
import org.jclouds.route53.domain.NewZone; import org.jclouds.route53.domain.HostedZone;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZoneAndNameServers;
import org.jclouds.route53.domain.ZoneAndNameServers; import org.jclouds.route53.domain.NewHostedZone;
/** /**
* @see ZoneAsyncApi * @see HostedZoneAsyncApi
* @see <a href= * @see <a href=
* "http://docs.aws.amazon.com/Route53/latest/APIReference/ActionsOnHostedZones.html" * "http://docs.aws.amazon.com/Route53/latest/APIReference/ActionsOnHostedZones.html"
* /> * />
* @author Adrian Cole * @author Adrian Cole
*/ */
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface ZoneApi { public interface HostedZoneApi {
/** /**
* This action creates a new hosted zone. * This action creates a new hosted zone.
@ -55,28 +55,28 @@ public interface ZoneApi {
* retries. ex. {@code MyDNSMigration_01} * retries. ex. {@code MyDNSMigration_01}
* @return the new zone in progress, in {@link Status#PENDING}. * @return the new zone in progress, in {@link Status#PENDING}.
*/ */
NewZone createWithReference(String name, String callerReference); NewHostedZone createWithReference(String name, String callerReference);
/** /**
* like {@link #createWithReference(String, String)}, except you can specify * like {@link #createWithReference(String, String)}, except you can specify
* a comment. * a comment.
*/ */
NewZone createWithReferenceAndComment(String name, String callerReference, String comment); NewHostedZone createWithReferenceAndComment(String name, String callerReference, String comment);
/** /**
* returns all zones in order. * returns all zones in order.
*/ */
PagedIterable<Zone> list(); PagedIterable<HostedZone> list();
/** /**
* retrieves up to 100 zones in order. * retrieves up to 100 zones in order.
*/ */
IterableWithMarker<Zone> listFirstPage(); IterableWithMarker<HostedZone> listFirstPage();
/** /**
* retrieves up to 100 zones in order, starting at {@code nextMarker} * retrieves up to 100 zones in order, starting at {@code nextMarker}
*/ */
IterableWithMarker<Zone> listAt(String nextMarker); IterableWithMarker<HostedZone> listAt(String nextMarker);
/** /**
* Retrieves information about the specified zone, including its nameserver * Retrieves information about the specified zone, including its nameserver
@ -88,7 +88,7 @@ public interface ZoneApi {
* @return null if not found * @return null if not found
*/ */
@Nullable @Nullable
ZoneAndNameServers get(String id); HostedZoneAndNameServers get(String id);
/** /**
* This action deletes a hosted zone. * This action deletes a hosted zone.

View File

@ -40,11 +40,11 @@ import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change;
import org.jclouds.route53.domain.NewZone; import org.jclouds.route53.domain.HostedZone;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZoneAndNameServers;
import org.jclouds.route53.domain.ZoneAndNameServers; import org.jclouds.route53.domain.NewHostedZone;
import org.jclouds.route53.filters.RestAuthentication; import org.jclouds.route53.filters.RestAuthentication;
import org.jclouds.route53.functions.ZonesToPagedIterable; import org.jclouds.route53.functions.HostedZonesToPagedIterable;
import org.jclouds.route53.xml.ChangeHandler; import org.jclouds.route53.xml.ChangeHandler;
import org.jclouds.route53.xml.CreateHostedZoneResponseHandler; import org.jclouds.route53.xml.CreateHostedZoneResponseHandler;
import org.jclouds.route53.xml.GetHostedZoneResponseHandler; import org.jclouds.route53.xml.GetHostedZoneResponseHandler;
@ -53,7 +53,7 @@ import org.jclouds.route53.xml.ListHostedZonesResponseHandler;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
* @see ZoneApi * @see HostedZoneApi
* @see <a href= * @see <a href=
* "http://docs.aws.amazon.com/Route53/latest/APIReference/ActionsOnHostedZones.html" * "http://docs.aws.amazon.com/Route53/latest/APIReference/ActionsOnHostedZones.html"
* /> * />
@ -62,9 +62,9 @@ import com.google.common.util.concurrent.ListenableFuture;
@RequestFilters(RestAuthentication.class) @RequestFilters(RestAuthentication.class)
@VirtualHost @VirtualHost
@Path("/{jclouds.api-version}") @Path("/{jclouds.api-version}")
public interface ZoneAsyncApi { public interface HostedZoneAsyncApi {
/** /**
* @see ZoneApi#createWithReference * @see HostedZoneApi#createWithReference
*/ */
@Named("CreateHostedZone") @Named("CreateHostedZone")
@POST @POST
@ -72,11 +72,11 @@ public interface ZoneAsyncApi {
@Path("/hostedzone") @Path("/hostedzone")
@Payload("<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Name>{name}</Name><CallerReference>{callerReference}</CallerReference></CreateHostedZoneRequest>") @Payload("<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Name>{name}</Name><CallerReference>{callerReference}</CallerReference></CreateHostedZoneRequest>")
@XMLResponseParser(CreateHostedZoneResponseHandler.class) @XMLResponseParser(CreateHostedZoneResponseHandler.class)
ListenableFuture<NewZone> createWithReference(@PayloadParam("name") String name, ListenableFuture<NewHostedZone> createWithReference(@PayloadParam("name") String name,
@PayloadParam("callerReference") String callerReference); @PayloadParam("callerReference") String callerReference);
/** /**
* @see ZoneApi#createWithReferenceAndComment * @see HostedZoneApi#createWithReferenceAndComment
*/ */
@Named("CreateHostedZone") @Named("CreateHostedZone")
@POST @POST
@ -84,49 +84,49 @@ public interface ZoneAsyncApi {
@Path("/hostedzone") @Path("/hostedzone")
@Payload("<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Name>{name}</Name><CallerReference>{callerReference}</CallerReference><HostedZoneConfig><Comment>{comment}</Comment></HostedZoneConfig></CreateHostedZoneRequest>") @Payload("<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Name>{name}</Name><CallerReference>{callerReference}</CallerReference><HostedZoneConfig><Comment>{comment}</Comment></HostedZoneConfig></CreateHostedZoneRequest>")
@XMLResponseParser(CreateHostedZoneResponseHandler.class) @XMLResponseParser(CreateHostedZoneResponseHandler.class)
ListenableFuture<NewZone> createWithReferenceAndComment(@PayloadParam("name") String name, ListenableFuture<NewHostedZone> createWithReferenceAndComment(@PayloadParam("name") String name,
@PayloadParam("callerReference") String callerReference, @PayloadParam("comment") String comment); @PayloadParam("callerReference") String callerReference, @PayloadParam("comment") String comment);
/** /**
* @see ZoneApi#list() * @see HostedZoneApi#list()
*/ */
@Named("ListHostedZones") @Named("ListHostedZones")
@GET @GET
@Path("/hostedzone") @Path("/hostedzone")
@XMLResponseParser(ListHostedZonesResponseHandler.class) @XMLResponseParser(ListHostedZonesResponseHandler.class)
@Transform(ZonesToPagedIterable.class) @Transform(HostedZonesToPagedIterable.class)
ListenableFuture<PagedIterable<Zone>> list(); ListenableFuture<PagedIterable<HostedZone>> list();
/** /**
* @see ZoneApi#listFirstPage * @see HostedZoneApi#listFirstPage
*/ */
@Named("ListHostedZones") @Named("ListHostedZones")
@GET @GET
@Path("/hostedzone") @Path("/hostedzone")
@XMLResponseParser(ListHostedZonesResponseHandler.class) @XMLResponseParser(ListHostedZonesResponseHandler.class)
ListenableFuture<IterableWithMarker<Zone>> listFirstPage(); ListenableFuture<IterableWithMarker<HostedZone>> listFirstPage();
/** /**
* @see ZoneApi#listAt(String) * @see HostedZoneApi#listAt(String)
*/ */
@Named("ListHostedZones") @Named("ListHostedZones")
@GET @GET
@Path("/hostedzone") @Path("/hostedzone")
@XMLResponseParser(ListHostedZonesResponseHandler.class) @XMLResponseParser(ListHostedZonesResponseHandler.class)
ListenableFuture<IterableWithMarker<Zone>> listAt(@QueryParam("marker") String nextMarker); ListenableFuture<IterableWithMarker<HostedZone>> listAt(@QueryParam("marker") String nextMarker);
/** /**
* @see ZoneApi#get() * @see HostedZoneApi#get()
*/ */
@Named("GetHostedZone") @Named("GetHostedZone")
@GET @GET
@Path("/hostedzone/{zoneId}") @Path("/hostedzone/{zoneId}")
@XMLResponseParser(GetHostedZoneResponseHandler.class) @XMLResponseParser(GetHostedZoneResponseHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ZoneAndNameServers> get(@PathParam("zoneId") String zoneId); ListenableFuture<HostedZoneAndNameServers> get(@PathParam("zoneId") String zoneId);
/** /**
* @see ZoneApi#delete() * @see HostedZoneApi#delete()
*/ */
@Named("DeleteHostedZone") @Named("DeleteHostedZone")
@DELETE @DELETE

View File

@ -25,24 +25,24 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change;
import org.jclouds.route53.domain.ChangeBatch; import org.jclouds.route53.domain.ChangeBatch;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSetIterable; import org.jclouds.route53.domain.ResourceRecordSetIterable;
import org.jclouds.route53.domain.RecordSetIterable.NextRecord; import org.jclouds.route53.domain.ResourceRecordSetIterable.NextRecord;
/** /**
* @see RecordSetAsyncApi * @see ResourceRecordSetAsyncApi
* @see <a href= * @see <a href=
* "http://docs.aws.amazon.com/Route53/latest/APIReference/ActionsOnRRS.html" * "http://docs.aws.amazon.com/Route53/latest/APIReference/ActionsOnRRS.html"
* /> * />
* @author Adrian Cole * @author Adrian Cole
*/ */
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface RecordSetApi { public interface ResourceRecordSetApi {
/** /**
* schedules creation of the resource record set. * schedules creation of the resource record set.
*/ */
Change create(RecordSet rrs); Change create(ResourceRecordSet rrs);
/** /**
* applies a batch of changes atomically. * applies a batch of changes atomically.
@ -52,18 +52,18 @@ public interface RecordSetApi {
/** /**
* returns all resource record sets in order. * returns all resource record sets in order.
*/ */
PagedIterable<RecordSet> list(); PagedIterable<ResourceRecordSet> list();
/** /**
* retrieves up to 100 resource record sets in order. * retrieves up to 100 resource record sets in order.
*/ */
RecordSetIterable listFirstPage(); ResourceRecordSetIterable listFirstPage();
/** /**
* retrieves up to 100 resource record sets in order, starting at * retrieves up to 100 resource record sets in order, starting at
* {@code nextRecord} * {@code nextRecord}
*/ */
RecordSetIterable listAt(NextRecord nextRecord); ResourceRecordSetIterable listAt(NextRecord nextRecord);
/** /**
* This action deletes a resource record set. * This action deletes a resource record set.
@ -73,5 +73,5 @@ public interface RecordSetApi {
* @return null if not found or the change in progress * @return null if not found or the change in progress
*/ */
@Nullable @Nullable
Change delete(RecordSet rrs); Change delete(ResourceRecordSet rrs);
} }

View File

@ -41,11 +41,11 @@ import org.jclouds.route53.binders.BindChangeBatch;
import org.jclouds.route53.binders.BindNextRecord; import org.jclouds.route53.binders.BindNextRecord;
import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change;
import org.jclouds.route53.domain.ChangeBatch; import org.jclouds.route53.domain.ChangeBatch;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSetIterable; import org.jclouds.route53.domain.ResourceRecordSetIterable;
import org.jclouds.route53.domain.RecordSetIterable.NextRecord; import org.jclouds.route53.domain.ResourceRecordSetIterable.NextRecord;
import org.jclouds.route53.filters.RestAuthentication; import org.jclouds.route53.filters.RestAuthentication;
import org.jclouds.route53.functions.RecordSetIterableToPagedIterable; import org.jclouds.route53.functions.ResourceRecordSetIterableToPagedIterable;
import org.jclouds.route53.functions.SerializeRRS; import org.jclouds.route53.functions.SerializeRRS;
import org.jclouds.route53.xml.ChangeHandler; import org.jclouds.route53.xml.ChangeHandler;
import org.jclouds.route53.xml.ListResourceRecordSetsResponseHandler; import org.jclouds.route53.xml.ListResourceRecordSetsResponseHandler;
@ -53,7 +53,7 @@ import org.jclouds.route53.xml.ListResourceRecordSetsResponseHandler;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
* @see RecordSetApi * @see ResourceRecordSetApi
* @see <a href= * @see <a href=
* "http://docs.aws.amazon.com/Route53/latest/APIReference/ActionsOnRRS.html" * "http://docs.aws.amazon.com/Route53/latest/APIReference/ActionsOnRRS.html"
* /> * />
@ -62,9 +62,9 @@ import com.google.common.util.concurrent.ListenableFuture;
@RequestFilters(RestAuthentication.class) @RequestFilters(RestAuthentication.class)
@VirtualHost @VirtualHost
@Path("/{jclouds.api-version}/hostedzone/{zoneId}") @Path("/{jclouds.api-version}/hostedzone/{zoneId}")
public interface RecordSetAsyncApi { public interface ResourceRecordSetAsyncApi {
/** /**
* @see RecordSetApi#create * @see ResourceRecordSetApi#create
*/ */
@Named("ChangeResourceRecordSets") @Named("ChangeResourceRecordSets")
@POST @POST
@ -72,10 +72,10 @@ public interface RecordSetAsyncApi {
@Path("/rrset") @Path("/rrset")
@Payload("<ChangeResourceRecordSetsRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><ChangeBatch><Changes><Change><Action>CREATE</Action>{rrs}</Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>") @Payload("<ChangeResourceRecordSetsRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><ChangeBatch><Changes><Change><Action>CREATE</Action>{rrs}</Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>")
@XMLResponseParser(ChangeHandler.class) @XMLResponseParser(ChangeHandler.class)
ListenableFuture<Change> create(@PayloadParam("rrs") @ParamParser(SerializeRRS.class) RecordSet rrs); ListenableFuture<Change> create(@PayloadParam("rrs") @ParamParser(SerializeRRS.class) ResourceRecordSet rrs);
/** /**
* @see RecordSetApi#apply * @see ResourceRecordSetApi#apply
*/ */
@Named("ChangeResourceRecordSets") @Named("ChangeResourceRecordSets")
@POST @POST
@ -85,35 +85,35 @@ public interface RecordSetAsyncApi {
ListenableFuture<Change> apply(@BinderParam(BindChangeBatch.class) ChangeBatch changes); ListenableFuture<Change> apply(@BinderParam(BindChangeBatch.class) ChangeBatch changes);
/** /**
* @see RecordSetApi#list() * @see ResourceRecordSetApi#list()
*/ */
@Named("ListResourceRecordSets") @Named("ListResourceRecordSets")
@GET @GET
@Path("/rrset") @Path("/rrset")
@XMLResponseParser(ListResourceRecordSetsResponseHandler.class) @XMLResponseParser(ListResourceRecordSetsResponseHandler.class)
@Transform(RecordSetIterableToPagedIterable.class) @Transform(ResourceRecordSetIterableToPagedIterable.class)
ListenableFuture<PagedIterable<RecordSet>> list(); ListenableFuture<PagedIterable<ResourceRecordSet>> list();
/** /**
* @see RecordSetApi#listFirstPage * @see ResourceRecordSetApi#listFirstPage
*/ */
@Named("ListResourceRecordSets") @Named("ListResourceRecordSets")
@GET @GET
@Path("/rrset") @Path("/rrset")
@XMLResponseParser(ListResourceRecordSetsResponseHandler.class) @XMLResponseParser(ListResourceRecordSetsResponseHandler.class)
ListenableFuture<RecordSetIterable> listFirstPage(); ListenableFuture<ResourceRecordSetIterable> listFirstPage();
/** /**
* @see RecordSetApi#listAt(NextRecord) * @see ResourceRecordSetApi#listAt(NextRecord)
*/ */
@Named("ListResourceRecordSets") @Named("ListResourceRecordSets")
@GET @GET
@Path("/rrset") @Path("/rrset")
@XMLResponseParser(ListResourceRecordSetsResponseHandler.class) @XMLResponseParser(ListResourceRecordSetsResponseHandler.class)
ListenableFuture<RecordSetIterable> listAt(@BinderParam(BindNextRecord.class) NextRecord nextRecord); ListenableFuture<ResourceRecordSetIterable> listAt(@BinderParam(BindNextRecord.class) NextRecord nextRecord);
/** /**
* @see RecordSetApi#delete * @see ResourceRecordSetApi#delete
*/ */
@Named("ChangeResourceRecordSets") @Named("ChangeResourceRecordSets")
@POST @POST
@ -122,5 +122,5 @@ public interface RecordSetAsyncApi {
@Payload("<ChangeResourceRecordSetsRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><ChangeBatch><Changes><Change><Action>DELETE</Action>{rrs}</Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>") @Payload("<ChangeResourceRecordSetsRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><ChangeBatch><Changes><Change><Action>DELETE</Action>{rrs}</Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>")
@XMLResponseParser(ChangeHandler.class) @XMLResponseParser(ChangeHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Change> delete(@PayloadParam("rrs") @ParamParser(SerializeRRS.class) RecordSet rrs); ListenableFuture<Change> delete(@PayloadParam("rrs") @ParamParser(SerializeRRS.class) ResourceRecordSet rrs);
} }

View File

@ -25,8 +25,8 @@ import javax.inject.Inject;
import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.internal.CallerArg0ToPagedIterable; import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
import org.jclouds.route53.Route53Api; import org.jclouds.route53.Route53Api;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import org.jclouds.route53.features.ZoneApi; import org.jclouds.route53.features.HostedZoneApi;
import com.google.common.annotations.Beta; import com.google.common.annotations.Beta;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -35,30 +35,29 @@ import com.google.common.base.Function;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Beta @Beta
public class ZonesToPagedIterable extends CallerArg0ToPagedIterable<Zone, ZonesToPagedIterable> { public class HostedZonesToPagedIterable extends CallerArg0ToPagedIterable<HostedZone, HostedZonesToPagedIterable> {
private final Route53Api api; private final Route53Api api;
@Inject @Inject
protected ZonesToPagedIterable(Route53Api api) { protected HostedZonesToPagedIterable(Route53Api api) {
this.api = checkNotNull(api, "api"); this.api = checkNotNull(api, "api");
} }
@Override @Override
protected Function<Object, IterableWithMarker<Zone>> markerToNextForCallingArg0(String ignored) { protected Function<Object, IterableWithMarker<HostedZone>> markerToNextForCallingArg0(String ignored) {
final ZoneApi zoneApi = api.getZoneApi(); final HostedZoneApi zoneApi = api.getHostedZoneApi();
return new Function<Object, IterableWithMarker<Zone>>() { return new Function<Object, IterableWithMarker<HostedZone>>() {
@Override @Override
public IterableWithMarker<Zone> apply(Object input) { public IterableWithMarker<HostedZone> apply(Object input) {
return zoneApi.listAt(input.toString()); return zoneApi.listAt(input.toString());
} }
@Override @Override
public String toString() { public String toString() {
return "listZones()"; return "listHostedZones()";
} }
}; };
} }
} }

View File

@ -25,9 +25,9 @@ import javax.inject.Inject;
import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.internal.CallerArg0ToPagedIterable; import org.jclouds.collect.internal.CallerArg0ToPagedIterable;
import org.jclouds.route53.Route53Api; import org.jclouds.route53.Route53Api;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSetIterable.NextRecord; import org.jclouds.route53.domain.ResourceRecordSetIterable.NextRecord;
import org.jclouds.route53.features.RecordSetApi; import org.jclouds.route53.features.ResourceRecordSetApi;
import com.google.common.annotations.Beta; import com.google.common.annotations.Beta;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -36,24 +36,24 @@ import com.google.common.base.Function;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Beta @Beta
public class RecordSetIterableToPagedIterable extends public class ResourceRecordSetIterableToPagedIterable extends
CallerArg0ToPagedIterable<RecordSet, RecordSetIterableToPagedIterable> { CallerArg0ToPagedIterable<ResourceRecordSet, ResourceRecordSetIterableToPagedIterable> {
private final Route53Api api; private final Route53Api api;
@Inject @Inject
protected RecordSetIterableToPagedIterable(Route53Api api) { protected ResourceRecordSetIterableToPagedIterable(Route53Api api) {
this.api = checkNotNull(api, "api"); this.api = checkNotNull(api, "api");
} }
@Override @Override
protected Function<Object, IterableWithMarker<RecordSet>> markerToNextForCallingArg0(String zoneId) { protected Function<Object, IterableWithMarker<ResourceRecordSet>> markerToNextForCallingArg0(String zoneId) {
final RecordSetApi resourceRecordSetApi = api.getRecordSetApiForZone(zoneId); final ResourceRecordSetApi resourceResourceRecordSetApi = api.getResourceRecordSetApiForHostedZone(zoneId);
return new Function<Object, IterableWithMarker<RecordSet>>() { return new Function<Object, IterableWithMarker<ResourceRecordSet>>() {
@Override @Override
public IterableWithMarker<RecordSet> apply(Object input) { public IterableWithMarker<ResourceRecordSet> apply(Object input) {
return resourceRecordSetApi.listAt(NextRecord.class.cast(input)); return resourceResourceRecordSetApi.listAt(NextRecord.class.cast(input));
} }
@Override @Override

View File

@ -21,12 +21,13 @@ package org.jclouds.route53.functions;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.rest.annotations.ParamParser; import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSet.RecordSubset; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset;
import org.jclouds.route53.domain.RecordSet.RecordSubset.Latency; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Latency;
import org.jclouds.route53.domain.RecordSet.RecordSubset.Weighted; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Weighted;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.primitives.UnsignedInteger;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -35,7 +36,7 @@ import com.google.common.base.Function;
public class SerializeRRS implements Function<Object, String> { public class SerializeRRS implements Function<Object, String> {
@Override @Override
public String apply(Object in) { public String apply(Object in) {
RecordSet rrs = RecordSet.class.cast(checkNotNull(in, "rrs")); ResourceRecordSet rrs = ResourceRecordSet.class.cast(checkNotNull(in, "rrs"));
StringBuilder builder = new StringBuilder().append("<ResourceRecordSet>"); StringBuilder builder = new StringBuilder().append("<ResourceRecordSet>");
builder.append("<Name>").append(rrs.getName()).append("</Name>"); builder.append("<Name>").append(rrs.getName()).append("</Name>");
builder.append("<Type>").append(rrs.getType()).append("</Type>"); builder.append("<Type>").append(rrs.getType()).append("</Type>");
@ -53,7 +54,7 @@ public class SerializeRRS implements Function<Object, String> {
builder.append("<DNSName>").append(rrs.getAliasTarget().get().getDNSName()).append("</DNSName>"); builder.append("<DNSName>").append(rrs.getAliasTarget().get().getDNSName()).append("</DNSName>");
builder.append("</AliasTarget>"); builder.append("</AliasTarget>");
} else { } else {
builder.append("<TTL>").append(rrs.getTTL().or(0)).append("</TTL>"); builder.append("<TTL>").append(rrs.getTTL().or(UnsignedInteger.ZERO)).append("</TTL>");
builder.append("<ResourceRecords>"); builder.append("<ResourceRecords>");
for (String record : rrs.getValues()) for (String record : rrs.getValues())
builder.append("<ResourceRecord>").append("<Value>").append(record).append("</Value>") builder.append("<ResourceRecord>").append("<Value>").append(record).append("</Value>")

View File

@ -20,26 +20,26 @@ package org.jclouds.route53.predicates;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
/** /**
* Predicates handy when working with Zones * Predicates handy when working with HostedZones
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ZonePredicates { public class HostedZonePredicates {
/** /**
* matches zones of the given name * matches zones of the given name
*/ */
public static Predicate<Zone> nameEquals(final String name) { public static Predicate<HostedZone> nameEquals(final String name) {
checkNotNull(name, "name must be defined"); checkNotNull(name, "name must be defined");
return new Predicate<Zone>() { return new Predicate<HostedZone>() {
@Override @Override
public boolean apply(Zone zone) { public boolean apply(HostedZone zone) {
return name.equals(zone.getName()); return name.equals(zone.getName());
} }

View File

@ -20,27 +20,26 @@ package org.jclouds.route53.predicates;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSet.Type;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
/** /**
* Predicates handy when working with ResourceRecordSet Types * Predicates handy when working with ResourceResourceRecordSet Types
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class RecordSetPredicates { public class ResourceRecordSetPredicates {
/** /**
* matches zones of the given type * matches zones of the given type
*/ */
public static Predicate<RecordSet> typeEquals(final Type type) { public static Predicate<ResourceRecordSet> typeEquals(final String type) {
checkNotNull(type, "type must be defined"); checkNotNull(type, "type must be defined");
return new Predicate<RecordSet>() { return new Predicate<ResourceRecordSet>() {
@Override @Override
public boolean apply(RecordSet zone) { public boolean apply(ResourceRecordSet zone) {
return type.equals(zone.getType()); return type.equals(zone.getType());
} }

View File

@ -21,8 +21,8 @@ package org.jclouds.route53.xml;
import static org.jclouds.util.SaxUtils.equalsOrSuffix; import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.route53.domain.NewZone; import org.jclouds.route53.domain.HostedZoneAndNameServers;
import org.jclouds.route53.domain.ZoneAndNameServers; import org.jclouds.route53.domain.NewHostedZone;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -34,7 +34,7 @@ import com.google.inject.Inject;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class CreateHostedZoneResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<NewZone> { public class CreateHostedZoneResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<NewHostedZone> {
private final GetHostedZoneResponseHandler zoneHandler; private final GetHostedZoneResponseHandler zoneHandler;
private final ChangeHandler changeHandler; private final ChangeHandler changeHandler;
@ -48,9 +48,9 @@ public class CreateHostedZoneResponseHandler extends ParseSax.HandlerForGenerate
} }
@Override @Override
public NewZone getResult() { public NewHostedZone getResult() {
ZoneAndNameServers zone = zoneHandler.getResult(); HostedZoneAndNameServers zone = zoneHandler.getResult();
return NewZone.create(zone, changeHandler.getResult()); return NewHostedZone.create(zone, changeHandler.getResult());
} }
@Override @Override

View File

@ -22,8 +22,8 @@ import static org.jclouds.util.SaxUtils.currentOrNull;
import static org.jclouds.util.SaxUtils.equalsOrSuffix; import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import org.jclouds.route53.domain.ZoneAndNameServers; import org.jclouds.route53.domain.HostedZoneAndNameServers;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -37,26 +37,26 @@ import com.google.inject.Inject;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class GetHostedZoneResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<ZoneAndNameServers> { public class GetHostedZoneResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult<HostedZoneAndNameServers> {
private final ZoneHandler zoneHandler; private final HostedZoneHandler zoneHandler;
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private boolean inZone; private boolean inHostedZone;
private Zone zone; private HostedZone zone;
private Builder<String> nameServers = ImmutableList.<String> builder(); private Builder<String> nameServers = ImmutableList.<String> builder();
@Inject @Inject
public GetHostedZoneResponseHandler(ZoneHandler zoneHandler) { public GetHostedZoneResponseHandler(HostedZoneHandler zoneHandler) {
this.zoneHandler = zoneHandler; this.zoneHandler = zoneHandler;
} }
@Override @Override
public ZoneAndNameServers getResult() { public HostedZoneAndNameServers getResult() {
try { try {
return ZoneAndNameServers.create(zone, nameServers.build()); return HostedZoneAndNameServers.create(zone, nameServers.build());
} finally { } finally {
zone = null; zone = null;
nameServers = ImmutableList.<String> builder(); nameServers = ImmutableList.<String> builder();
@ -66,18 +66,18 @@ public class GetHostedZoneResponseHandler extends ParseSax.HandlerForGeneratedRe
@Override @Override
public void startElement(String url, String name, String qName, Attributes attributes) { public void startElement(String url, String name, String qName, Attributes attributes) {
if (equalsOrSuffix(qName, "HostedZone")) { if (equalsOrSuffix(qName, "HostedZone")) {
inZone = true; inHostedZone = true;
} }
if (inZone) { if (inHostedZone) {
zoneHandler.startElement(url, name, qName, attributes); zoneHandler.startElement(url, name, qName, attributes);
} }
} }
@Override @Override
public void endElement(String uri, String name, String qName) { public void endElement(String uri, String name, String qName) {
if (inZone) { if (inHostedZone) {
if (qName.equals("HostedZone")) { if (qName.equals("HostedZone")) {
inZone = false; inHostedZone = false;
zone = zoneHandler.getResult(); zone = zoneHandler.getResult();
} else { } else {
zoneHandler.endElement(uri, name, qName); zoneHandler.endElement(uri, name, qName);
@ -91,7 +91,7 @@ public class GetHostedZoneResponseHandler extends ParseSax.HandlerForGeneratedRe
@Override @Override
public void characters(char ch[], int start, int length) { public void characters(char ch[], int start, int length) {
if (inZone) { if (inHostedZone) {
zoneHandler.characters(ch, start, length); zoneHandler.characters(ch, start, length);
} else { } else {
currentText.append(ch, start, length); currentText.append(ch, start, length);

View File

@ -21,24 +21,26 @@ package org.jclouds.route53.xml;
import static org.jclouds.util.SaxUtils.currentOrNull; import static org.jclouds.util.SaxUtils.currentOrNull;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.primitives.UnsignedInteger;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ZoneHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Zone> { public class HostedZoneHandler extends ParseSax.HandlerForGeneratedRequestWithResult<HostedZone> {
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private Zone.Builder builder = Zone.builder(); private HostedZone.Builder builder = HostedZone.builder();
@Override @Override
public Zone getResult() { public HostedZone getResult() {
try { try {
return builder.build(); return builder.build();
} finally { } finally {
builder = Zone.builder(); builder = HostedZone.builder();
} }
} }
@ -57,7 +59,7 @@ public class ZoneHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Z
} else if (qName.equals("Comment")) { } else if (qName.equals("Comment")) {
builder.comment(currentOrNull(currentText)); builder.comment(currentOrNull(currentText));
} else if (qName.equals("ResourceRecordSetCount")) { } else if (qName.equals("ResourceRecordSetCount")) {
builder.resourceRecordSetCount(Integer.parseInt(currentOrNull(currentText))); builder.resourceRecordSetCount(UnsignedInteger.valueOf(currentOrNull(currentText)).intValue());
} }
currentText = new StringBuilder(); currentText = new StringBuilder();
} }

View File

@ -24,7 +24,7 @@ import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.IterableWithMarkers; import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -39,44 +39,44 @@ import com.google.inject.Inject;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListHostedZonesResponseHandler extends public class ListHostedZonesResponseHandler extends
ParseSax.HandlerForGeneratedRequestWithResult<IterableWithMarker<Zone>> { ParseSax.HandlerForGeneratedRequestWithResult<IterableWithMarker<HostedZone>> {
private final ZoneHandler zoneHandler; private final HostedZoneHandler zoneHandler;
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private Builder<Zone> zones = ImmutableList.<Zone> builder(); private Builder<HostedZone> zones = ImmutableList.<HostedZone> builder();
private boolean inZones; private boolean inHostedZones;
private String afterMarker; private String afterMarker;
@Inject @Inject
public ListHostedZonesResponseHandler(ZoneHandler zoneHandler) { public ListHostedZonesResponseHandler(HostedZoneHandler zoneHandler) {
this.zoneHandler = zoneHandler; this.zoneHandler = zoneHandler;
} }
@Override @Override
public IterableWithMarker<Zone> getResult() { public IterableWithMarker<HostedZone> getResult() {
try { try {
return IterableWithMarkers.from(zones.build(), afterMarker); return IterableWithMarkers.from(zones.build(), afterMarker);
} finally { } finally {
zones = ImmutableList.<Zone> builder(); zones = ImmutableList.<HostedZone> builder();
} }
} }
@Override @Override
public void startElement(String url, String name, String qName, Attributes attributes) { public void startElement(String url, String name, String qName, Attributes attributes) {
if (equalsOrSuffix(qName, "HostedZones")) { if (equalsOrSuffix(qName, "HostedZones")) {
inZones = true; inHostedZones = true;
} }
if (inZones) { if (inHostedZones) {
zoneHandler.startElement(url, name, qName, attributes); zoneHandler.startElement(url, name, qName, attributes);
} }
} }
@Override @Override
public void endElement(String uri, String name, String qName) { public void endElement(String uri, String name, String qName) {
if (inZones) { if (inHostedZones) {
if (qName.equals("HostedZones")) { if (qName.equals("HostedZones")) {
inZones = false; inHostedZones = false;
} else if (qName.equals("HostedZone")) { } else if (qName.equals("HostedZone")) {
zones.add(zoneHandler.getResult()); zones.add(zoneHandler.getResult());
} else { } else {
@ -91,7 +91,7 @@ public class ListHostedZonesResponseHandler extends
@Override @Override
public void characters(char ch[], int start, int length) { public void characters(char ch[], int start, int length) {
if (inZones) { if (inHostedZones) {
zoneHandler.characters(ch, start, length); zoneHandler.characters(ch, start, length);
} else { } else {
currentText.append(ch, start, length); currentText.append(ch, start, length);

View File

@ -22,9 +22,8 @@ import static org.jclouds.util.SaxUtils.currentOrNull;
import static org.jclouds.util.SaxUtils.equalsOrSuffix; import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.route53.domain.RecordSet.Type; import org.jclouds.route53.domain.ResourceRecordSetIterable;
import org.jclouds.route53.domain.RecordSetIterable; import org.jclouds.route53.domain.ResourceRecordSetIterable.Builder;
import org.jclouds.route53.domain.RecordSetIterable.Builder;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -37,12 +36,12 @@ import com.google.inject.Inject;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ListResourceRecordSetsResponseHandler extends public class ListResourceRecordSetsResponseHandler extends
ParseSax.HandlerForGeneratedRequestWithResult<RecordSetIterable> { ParseSax.HandlerForGeneratedRequestWithResult<ResourceRecordSetIterable> {
private final ResourceRecordSetHandler resourceRecordSetHandler; private final ResourceRecordSetHandler resourceRecordSetHandler;
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private Builder builder = RecordSetIterable.builder(); private Builder builder = ResourceRecordSetIterable.builder();
private boolean inResourceRecordSets; private boolean inResourceRecordSets;
@ -52,11 +51,11 @@ public class ListResourceRecordSetsResponseHandler extends
} }
@Override @Override
public RecordSetIterable getResult() { public ResourceRecordSetIterable getResult() {
try { try {
return builder.build(); return builder.build();
} finally { } finally {
builder = RecordSetIterable.builder(); builder = ResourceRecordSetIterable.builder();
} }
} }
@ -83,7 +82,7 @@ public class ListResourceRecordSetsResponseHandler extends
} else if (qName.equals("NextRecordName")) { } else if (qName.equals("NextRecordName")) {
builder.nextRecordName(currentOrNull(currentText)); builder.nextRecordName(currentOrNull(currentText));
} else if (qName.equals("NextRecordType")) { } else if (qName.equals("NextRecordType")) {
builder.nextRecordType(Type.valueOf(currentOrNull(currentText))); builder.nextRecordType(currentOrNull(currentText));
} else if (qName.equals("NextRecordIdentifier")) { } else if (qName.equals("NextRecordIdentifier")) {
builder.nextRecordIdentifier(currentOrNull(currentText)); builder.nextRecordIdentifier(currentOrNull(currentText));
} }

View File

@ -21,25 +21,26 @@ package org.jclouds.route53.xml;
import static org.jclouds.util.SaxUtils.currentOrNull; import static org.jclouds.util.SaxUtils.currentOrNull;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSet.Type;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.primitives.UnsignedInteger;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ResourceRecordSetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<RecordSet> { public class ResourceRecordSetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<ResourceRecordSet> {
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private RecordSet.Builder builder = RecordSet.builder(); private ResourceRecordSet.Builder builder = ResourceRecordSet.builder();
@Override @Override
public RecordSet getResult() { public ResourceRecordSet getResult() {
try { try {
return builder.build(); return builder.build();
} finally { } finally {
builder = RecordSet.builder(); builder = ResourceRecordSet.builder();
} }
} }
@ -52,9 +53,9 @@ public class ResourceRecordSetHandler extends ParseSax.HandlerForGeneratedReques
if (qName.equals("Name")) { if (qName.equals("Name")) {
builder.name(currentOrNull(currentText)); builder.name(currentOrNull(currentText));
} else if (qName.equals("Type")) { } else if (qName.equals("Type")) {
builder.type(Type.valueOf(currentOrNull(currentText))); builder.type(currentOrNull(currentText));
} else if (qName.equals("TTL")) { } else if (qName.equals("TTL")) {
builder.ttl(Integer.parseInt(currentOrNull(currentText))); builder.ttl(UnsignedInteger.valueOf(currentOrNull(currentText)));
} else if (qName.equals("Value")) { } else if (qName.equals("Value")) {
builder.add(currentOrNull(currentText)); builder.add(currentOrNull(currentText));
} else if (qName.equals("HostedZoneId")) { } else if (qName.equals("HostedZoneId")) {
@ -64,7 +65,7 @@ public class ResourceRecordSetHandler extends ParseSax.HandlerForGeneratedReques
} else if (qName.equals("DNSName")) { } else if (qName.equals("DNSName")) {
builder.dnsName(currentOrNull(currentText)); builder.dnsName(currentOrNull(currentText));
} else if (qName.equals("Weight")) { } else if (qName.equals("Weight")) {
builder.weight(Integer.parseInt(currentOrNull(currentText))); builder.weight(UnsignedInteger.valueOf(currentOrNull(currentText)));
} else if (qName.equals("Region")) { } else if (qName.equals("Region")) {
builder.region(currentOrNull(currentText)); builder.region(currentOrNull(currentText));
} }

View File

@ -37,8 +37,8 @@ public class Route53ApiExpectTest extends BaseRoute53ApiExpectTest {
.endpoint("https://route53.amazonaws.com/2012-02-29/change/C2682N5HXP0BZ4") .endpoint("https://route53.amazonaws.com/2012-02-29/change/C2682N5HXP0BZ4")
.addHeader("Host", "route53.amazonaws.com") .addHeader("Host", "route53.amazonaws.com")
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800") .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", .addHeader("X-Amzn-Authorization", authForDate)
authForDate)
.build(); .build();
HttpResponse getChangeResponse = HttpResponse.builder().statusCode(200) HttpResponse getChangeResponse = HttpResponse.builder().statusCode(200)

View File

@ -37,14 +37,13 @@ import com.google.common.collect.ImmutableSet;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "ZoneApiExpectTest") @Test(groups = "unit", testName = "HostedZoneApiExpectTest")
public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest { public class HostedZoneApiExpectTest extends BaseRoute53ApiExpectTest {
HttpRequest createWithReference = HttpRequest.builder().method("POST") HttpRequest createWithReference = HttpRequest.builder().method("POST")
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone") .endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone")
.addHeader("Host", "route53.amazonaws.com") .addHeader("Host", "route53.amazonaws.com")
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800") .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", .addHeader("X-Amzn-Authorization", authForDate)
authForDate)
.payload( .payload(
payloadFromStringWithContentType( payloadFromStringWithContentType(
"<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Name>jclouds.org.</Name><CallerReference>expect</CallerReference></CreateHostedZoneRequest>", "<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Name>jclouds.org.</Name><CallerReference>expect</CallerReference></CreateHostedZoneRequest>",
@ -55,7 +54,7 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
public void testCreateWithReferenceWhenResponseIs2xx() { public void testCreateWithReferenceWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(createWithReference, createResponse); Route53Api success = requestSendsResponse(createWithReference, createResponse);
assertEquals(success.getZoneApi().createWithReference("jclouds.org.", "expect").toString(), assertEquals(success.getHostedZoneApi().createWithReference("jclouds.org.", "expect").toString(),
new CreateHostedZoneResponseTest().expected().toString()); new CreateHostedZoneResponseTest().expected().toString());
} }
@ -63,8 +62,7 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone") .endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone")
.addHeader("Host", "route53.amazonaws.com") .addHeader("Host", "route53.amazonaws.com")
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800") .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", .addHeader("X-Amzn-Authorization", authForDate)
authForDate)
.payload( .payload(
payloadFromStringWithContentType( payloadFromStringWithContentType(
"<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Name>jclouds.org.</Name><CallerReference>expect</CallerReference><HostedZoneConfig><Comment>comment</Comment></HostedZoneConfig></CreateHostedZoneRequest>", "<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\"><Name>jclouds.org.</Name><CallerReference>expect</CallerReference><HostedZoneConfig><Comment>comment</Comment></HostedZoneConfig></CreateHostedZoneRequest>",
@ -72,7 +70,7 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
public void testCreateWithReferenceAndCommentWhenResponseIs2xx() { public void testCreateWithReferenceAndCommentWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(createWithReferenceAndComment, createResponse); Route53Api success = requestSendsResponse(createWithReferenceAndComment, createResponse);
assertEquals(success.getZoneApi().createWithReferenceAndComment("jclouds.org.", "expect", "comment").toString(), assertEquals(success.getHostedZoneApi().createWithReferenceAndComment("jclouds.org.", "expect", "comment").toString(),
new CreateHostedZoneResponseTest().expected().toString()); new CreateHostedZoneResponseTest().expected().toString());
} }
@ -80,8 +78,7 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1XTHCPEFRWV1X") .endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1XTHCPEFRWV1X")
.addHeader("Host", "route53.amazonaws.com") .addHeader("Host", "route53.amazonaws.com")
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800") .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", .addHeader("X-Amzn-Authorization", authForDate)
authForDate)
.build(); .build();
HttpResponse getResponse = HttpResponse.builder().statusCode(200) HttpResponse getResponse = HttpResponse.builder().statusCode(200)
@ -89,21 +86,20 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
public void testGetWhenResponseIs2xx() { public void testGetWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(get, getResponse); Route53Api success = requestSendsResponse(get, getResponse);
assertEquals(success.getZoneApi().get("Z1XTHCPEFRWV1X").toString(), new GetHostedZoneResponseTest().expected() assertEquals(success.getHostedZoneApi().get("Z1XTHCPEFRWV1X").toString(), new GetHostedZoneResponseTest().expected()
.toString()); .toString());
} }
public void testGetWhenResponseIs404() { public void testGetWhenResponseIs404() {
Route53Api fail = requestSendsResponse(get, notFound); Route53Api fail = requestSendsResponse(get, notFound);
assertNull(fail.getZoneApi().get("Z1XTHCPEFRWV1X")); assertNull(fail.getHostedZoneApi().get("Z1XTHCPEFRWV1X"));
} }
HttpRequest list = HttpRequest.builder().method("GET") HttpRequest list = HttpRequest.builder().method("GET")
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone") .endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone")
.addHeader("Host", "route53.amazonaws.com") .addHeader("Host", "route53.amazonaws.com")
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800") .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", .addHeader("X-Amzn-Authorization", authForDate)
authForDate)
.build(); .build();
HttpResponse listResponse = HttpResponse.builder().statusCode(200) HttpResponse listResponse = HttpResponse.builder().statusCode(200)
@ -111,7 +107,7 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
public void testListWhenResponseIs2xx() { public void testListWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(list, listResponse); Route53Api success = requestSendsResponse(list, listResponse);
assertEquals(success.getZoneApi().list().get(0).toString(), new ListHostedZonesResponseTest().expected() assertEquals(success.getHostedZoneApi().list().get(0).toString(), new ListHostedZonesResponseTest().expected()
.toString()); .toString());
} }
@ -119,20 +115,19 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
@Test(expectedExceptions = ResourceNotFoundException.class) @Test(expectedExceptions = ResourceNotFoundException.class)
public void testListWhenResponseIs404() { public void testListWhenResponseIs404() {
Route53Api fail = requestSendsResponse(list, notFound); Route53Api fail = requestSendsResponse(list, notFound);
assertEquals(fail.getZoneApi().list().get(0).toImmutableSet(), ImmutableSet.of()); assertEquals(fail.getHostedZoneApi().list().get(0).toImmutableSet(), ImmutableSet.of());
} }
HttpRequest listAt = HttpRequest.builder().method("GET") HttpRequest listAt = HttpRequest.builder().method("GET")
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone?marker=Z333333YYYYYYY") .endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone?marker=Z333333YYYYYYY")
.addHeader("Host", "route53.amazonaws.com") .addHeader("Host", "route53.amazonaws.com")
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800") .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", .addHeader("X-Amzn-Authorization", authForDate)
authForDate)
.build(); .build();
public void testListAtWhenResponseIs2xx() { public void testListAtWhenResponseIs2xx() {
Route53Api apiWhenAtExist = requestSendsResponse(listAt, listResponse); Route53Api apiWhenAtExist = requestSendsResponse(listAt, listResponse);
assertEquals(apiWhenAtExist.getZoneApi().listAt("Z333333YYYYYYY").toString(), assertEquals(apiWhenAtExist.getHostedZoneApi().listAt("Z333333YYYYYYY").toString(),
new ListHostedZonesResponseTest().expected().toString()); new ListHostedZonesResponseTest().expected().toString());
} }
@ -141,7 +136,7 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
.payload(payloadFromStringWithContentType("<ListHostedZonesResponse />", "text/xml")).build(); .payload(payloadFromStringWithContentType("<ListHostedZonesResponse />", "text/xml")).build();
Route53Api success = requestsSendResponses(list, listResponse, listAt, noMore); Route53Api success = requestsSendResponses(list, listResponse, listAt, noMore);
assertEquals(success.getZoneApi().list().concat().toString(), new ListHostedZonesResponseTest().expected() assertEquals(success.getHostedZoneApi().list().concat().toString(), new ListHostedZonesResponseTest().expected()
.toString()); .toString());
} }
@ -149,8 +144,7 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1XTHCPEFRWV1X") .endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1XTHCPEFRWV1X")
.addHeader("Host", "route53.amazonaws.com") .addHeader("Host", "route53.amazonaws.com")
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800") .addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
.addHeader("X-Amzn-Authorization", .addHeader("X-Amzn-Authorization", authForDate)
authForDate)
.build(); .build();
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
@ -158,11 +152,11 @@ public class ZoneApiExpectTest extends BaseRoute53ApiExpectTest {
public void testDeleteWhenResponseIs2xx() { public void testDeleteWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(delete, deleteResponse); Route53Api success = requestSendsResponse(delete, deleteResponse);
assertEquals(success.getZoneApi().delete("Z1XTHCPEFRWV1X").toString(), new GetChangeResponseTest().expected().toString()); assertEquals(success.getHostedZoneApi().delete("Z1XTHCPEFRWV1X").toString(), new GetChangeResponseTest().expected().toString());
} }
public void testDeleteWhenResponseIs404() { public void testDeleteWhenResponseIs404() {
Route53Api fail = requestSendsResponse(delete, notFound); Route53Api fail = requestSendsResponse(delete, notFound);
assertNull(fail.getZoneApi().delete("Z1XTHCPEFRWV1X")); assertNull(fail.getHostedZoneApi().delete("Z1XTHCPEFRWV1X"));
} }
} }

View File

@ -29,8 +29,8 @@ import java.util.Date;
import org.jclouds.JcloudsVersion; import org.jclouds.JcloudsVersion;
import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change;
import org.jclouds.route53.domain.NewZone; import org.jclouds.route53.domain.NewHostedZone;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import org.jclouds.route53.internal.BaseRoute53ApiLiveTest; import org.jclouds.route53.internal.BaseRoute53ApiLiveTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -39,62 +39,62 @@ import com.google.common.collect.ImmutableList;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", testName = "ZoneApiLiveTest") @Test(groups = "live", testName = "HostedZoneApiLiveTest")
public class ZoneApiLiveTest extends BaseRoute53ApiLiveTest { public class HostedZoneApiLiveTest extends BaseRoute53ApiLiveTest {
private void checkZone(Zone zone) { private void checkHostedZone(HostedZone zone) {
getAnonymousLogger().info(format("zone %s rrs: %s", zone.getName(), zone.getResourceRecordSetCount())); getAnonymousLogger().info(format("zone %s rrs: %s", zone.getName(), zone.getResourceRecordSetCount()));
checkNotNull(zone.getId(), "Id: Zone %s", zone); checkNotNull(zone.getId(), "Id: HostedZone %s", zone);
checkNotNull(zone.getName(), "Name: Zone %s", zone); checkNotNull(zone.getName(), "Name: HostedZone %s", zone);
checkNotNull(zone.getCallerReference(), "CallerReference: Zone %s", zone); checkNotNull(zone.getCallerReference(), "CallerReference: HostedZone %s", zone);
checkNotNull(zone.getComment(), "While Comment can be null for a Zone, its Optional wrapper cannot %s", zone); checkNotNull(zone.getComment(), "While Comment can be null for a HostedZone, its Optional wrapper cannot %s", zone);
} }
@Test @Test
protected void testListZones() { protected void testListHostedZones() {
ImmutableList<Zone> zones = api().list().concat().toImmutableList(); ImmutableList<HostedZone> zones = api().list().concat().toImmutableList();
getAnonymousLogger().info("zones: " + zones.size()); getAnonymousLogger().info("zones: " + zones.size());
for (Zone zone : zones) { for (HostedZone zone : zones) {
checkZone(zone); checkHostedZone(zone);
assertEquals(api().get(zone.getId()).getZone(), zone); assertEquals(api().get(zone.getId()).getZone(), zone);
} }
} }
@Test @Test
public void testGetZoneWhenNotFound() { public void testGetHostedZoneWhenNotFound() {
assertNull(api().get("AAAAAAAAAAAAAAAA")); assertNull(api().get("AAAAAAAAAAAAAAAA"));
} }
@Test @Test
public void testDeleteZoneWhenNotFound() { public void testDeleteHostedZoneWhenNotFound() {
assertNull(api().delete("AAAAAAAAAAAAAAAA")); assertNull(api().delete("AAAAAAAAAAAAAAAA"));
} }
@Test @Test
public void testCreateAndDeleteZone() { public void testCreateAndDeleteHostedZone() {
String name = System.getProperty("user.name").replace('.', '-') + ".zone.route53test.jclouds.org."; String name = System.getProperty("user.name").replace('.', '-') + ".zone.route53test.jclouds.org.";
String nonce = name + " @ " + new Date(); String nonce = name + " @ " + new Date();
String comment = name + " for " + JcloudsVersion.get(); String comment = name + " for " + JcloudsVersion.get();
NewZone newZone = api().createWithReferenceAndComment(name, nonce, comment); NewHostedZone newHostedZone = api().createWithReferenceAndComment(name, nonce, comment);
getAnonymousLogger().info("created zone: " + newZone); getAnonymousLogger().info("created zone: " + newHostedZone);
try { try {
checkZone(newZone.getZone()); checkHostedZone(newHostedZone.getZone());
assertEquals(newZone.getChange().getStatus(), PENDING, "invalid status on zone " + newZone); assertEquals(newHostedZone.getChange().getStatus(), PENDING, "invalid status on zone " + newHostedZone);
assertTrue(newZone.getNameServers().size() > 0, "no name servers for zone " + newZone); assertTrue(newHostedZone.getNameServers().size() > 0, "no name servers for zone " + newHostedZone);
assertEquals(newZone.getZone().getName(), name); assertEquals(newHostedZone.getZone().getName(), name);
assertEquals(newZone.getZone().getCallerReference(), nonce); assertEquals(newHostedZone.getZone().getCallerReference(), nonce);
assertEquals(newZone.getZone().getComment().get(), comment); assertEquals(newHostedZone.getZone().getComment().get(), comment);
assertTrue(inSync.apply(newZone.getChange()), "zone didn't sync " + newZone); assertTrue(inSync.apply(newHostedZone.getChange()), "zone didn't sync " + newHostedZone);
} finally { } finally {
Change delete = api().delete(newZone.getZone().getId()); Change delete = api().delete(newHostedZone.getZone().getId());
assertTrue(inSync.apply(delete), "delete didn't sync " + delete); assertTrue(inSync.apply(delete), "delete didn't sync " + delete);
} }
} }
protected ZoneApi api() { protected HostedZoneApi api() {
return context.getApi().getZoneApi(); return context.getApi().getHostedZoneApi();
} }
} }

View File

@ -26,9 +26,8 @@ import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.route53.InvalidChangeBatchException; import org.jclouds.route53.InvalidChangeBatchException;
import org.jclouds.route53.Route53Api; import org.jclouds.route53.Route53Api;
import org.jclouds.route53.domain.ChangeBatch; import org.jclouds.route53.domain.ChangeBatch;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSet.Type; import org.jclouds.route53.domain.ResourceRecordSetIterable.NextRecord;
import org.jclouds.route53.domain.RecordSetIterable.NextRecord;
import org.jclouds.route53.internal.BaseRoute53ApiExpectTest; import org.jclouds.route53.internal.BaseRoute53ApiExpectTest;
import org.jclouds.route53.parse.GetChangeResponseTest; import org.jclouds.route53.parse.GetChangeResponseTest;
import org.jclouds.route53.parse.ListResourceRecordSetsResponseTest; import org.jclouds.route53.parse.ListResourceRecordSetsResponseTest;
@ -39,8 +38,8 @@ import com.google.common.collect.ImmutableSet;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "ResourceRecordSetApiExpectTest") @Test(groups = "unit", testName = "ResourceResourceRecordSetApiExpectTest")
public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest { public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
HttpRequest create = HttpRequest.builder().method("POST") HttpRequest create = HttpRequest.builder().method("POST")
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset") .endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset")
@ -54,7 +53,7 @@ public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
public void testCreateWhenResponseIs2xx() { public void testCreateWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(create, jobResponse); Route53Api success = requestSendsResponse(create, jobResponse);
assertEquals(success.getRecordSetApiForZone("Z1PA6795UKMFR9").create(RecordSet.builder().name("jclouds.org.").type(Type.TXT).add("my texts").build()).toString(), assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").create(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").add("my texts").build()).toString(),
new GetChangeResponseTest().expected().toString()); new GetChangeResponseTest().expected().toString());
} }
@ -67,10 +66,10 @@ public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
public void testApplyWhenResponseIs2xx() { public void testApplyWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(apply, jobResponse); Route53Api success = requestSendsResponse(apply, jobResponse);
assertEquals(success.getRecordSetApiForZone("Z1PA6795UKMFR9").apply( assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").apply(
ChangeBatch.builder() ChangeBatch.builder()
.delete(RecordSet.builder().name("jclouds.org.").type(Type.TXT).add("my texts").build()) .delete(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").add("my texts").build())
.create(RecordSet.builder().name("jclouds.org.").type(Type.TXT).add("my better texts").build()) .create(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").add("my better texts").build())
.build()).toString(), .build()).toString(),
new GetChangeResponseTest().expected().toString()); new GetChangeResponseTest().expected().toString());
} }
@ -81,10 +80,10 @@ public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
.payload(payloadFromResourceWithContentType("/invalid_change_batch.xml", "application/xml")).build(); .payload(payloadFromResourceWithContentType("/invalid_change_batch.xml", "application/xml")).build();
Route53Api fails = requestSendsResponse(apply, batchErrorFound); Route53Api fails = requestSendsResponse(apply, batchErrorFound);
fails.getRecordSetApiForZone("Z1PA6795UKMFR9").apply( fails.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").apply(
ChangeBatch.builder() ChangeBatch.builder()
.delete(RecordSet.builder().name("jclouds.org.").type(Type.TXT).add("my texts").build()) .delete(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").add("my texts").build())
.create(RecordSet.builder().name("jclouds.org.").type(Type.TXT).add("my better texts").build()) .create(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").add("my better texts").build())
.build()); .build());
} }
@ -99,7 +98,7 @@ public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
public void testListWhenResponseIs2xx() { public void testListWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(list, listResponse); Route53Api success = requestSendsResponse(list, listResponse);
assertEquals(success.getRecordSetApiForZone("Z1PA6795UKMFR9").list().get(0).toString(), new ListResourceRecordSetsResponseTest().expected() assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().get(0).toString(), new ListResourceRecordSetsResponseTest().expected()
.toString()); .toString());
} }
@ -107,7 +106,7 @@ public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
@Test(expectedExceptions = ResourceNotFoundException.class) @Test(expectedExceptions = ResourceNotFoundException.class)
public void testListWhenResponseIs404() { public void testListWhenResponseIs404() {
Route53Api fail = requestSendsResponse(list, notFound); Route53Api fail = requestSendsResponse(list, notFound);
assertEquals(fail.getRecordSetApiForZone("Z1PA6795UKMFR9").list().get(0).toImmutableSet(), ImmutableSet.of()); assertEquals(fail.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().get(0).toImmutableSet(), ImmutableSet.of());
} }
HttpRequest listAt = HttpRequest.builder().method("GET") HttpRequest listAt = HttpRequest.builder().method("GET")
@ -118,8 +117,8 @@ public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
public void testListAtWhenResponseIs2xx() { public void testListAtWhenResponseIs2xx() {
Route53Api apiWhenAtExist = requestSendsResponse(listAt, listResponse); Route53Api apiWhenAtExist = requestSendsResponse(listAt, listResponse);
NextRecord next = NextRecord.nameAndType("testdoc2.example.com", Type.NS); NextRecord next = NextRecord.nameAndType("testdoc2.example.com", "NS");
assertEquals(apiWhenAtExist.getRecordSetApiForZone("Z1PA6795UKMFR9").listAt(next).toString(), assertEquals(apiWhenAtExist.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").listAt(next).toString(),
new ListResourceRecordSetsResponseTest().expected().toString()); new ListResourceRecordSetsResponseTest().expected().toString());
} }
@ -128,7 +127,7 @@ public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
.payload(payloadFromStringWithContentType("<ListResourceRecordSetsResponse />", "text/xml")).build(); .payload(payloadFromStringWithContentType("<ListResourceRecordSetsResponse />", "text/xml")).build();
Route53Api success = requestsSendResponses(list, listResponse, listAt, noMore); Route53Api success = requestsSendResponses(list, listResponse, listAt, noMore);
assertEquals(success.getRecordSetApiForZone("Z1PA6795UKMFR9").list().concat().toImmutableSet(), new ListResourceRecordSetsResponseTest().expected() assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().concat().toImmutableSet(), new ListResourceRecordSetsResponseTest().expected()
.toImmutableSet()); .toImmutableSet());
} }
@ -141,7 +140,7 @@ public class RecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
public void testDeleteWhenResponseIs2xx() { public void testDeleteWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(delete, jobResponse); Route53Api success = requestSendsResponse(delete, jobResponse);
assertEquals(success.getRecordSetApiForZone("Z1PA6795UKMFR9").create(RecordSet.builder().name("jclouds.org.").type(Type.TXT).add("my texts").build()).toString(), assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").create(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").add("my texts").build()).toString(),
new GetChangeResponseTest().expected().toString()); new GetChangeResponseTest().expected().toString());
} }
} }

View File

@ -7,11 +7,11 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICE"NS"E-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIO"NS" OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
@ -24,11 +24,8 @@ import static com.google.common.base.Predicates.or;
import static java.util.logging.Logger.getAnonymousLogger; import static java.util.logging.Logger.getAnonymousLogger;
import static org.jclouds.route53.domain.ChangeBatch.createAll; import static org.jclouds.route53.domain.ChangeBatch.createAll;
import static org.jclouds.route53.domain.ChangeBatch.deleteAll; import static org.jclouds.route53.domain.ChangeBatch.deleteAll;
import static org.jclouds.route53.domain.RecordSet.Type.NS; import static org.jclouds.route53.predicates.HostedZonePredicates.nameEquals;
import static org.jclouds.route53.domain.RecordSet.Type.SOA; import static org.jclouds.route53.predicates.ResourceRecordSetPredicates.typeEquals;
import static org.jclouds.route53.domain.RecordSet.Type.TXT;
import static org.jclouds.route53.predicates.RecordSetPredicates.typeEquals;
import static org.jclouds.route53.predicates.ZonePredicates.nameEquals;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
@ -40,12 +37,12 @@ import java.util.Set;
import org.jclouds.JcloudsVersion; import org.jclouds.JcloudsVersion;
import org.jclouds.collect.PagedIterable; import org.jclouds.collect.PagedIterable;
import org.jclouds.route53.domain.Change; import org.jclouds.route53.domain.Change;
import org.jclouds.route53.domain.NewZone; import org.jclouds.route53.domain.HostedZone;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.NewHostedZone;
import org.jclouds.route53.domain.RecordSet.RecordSubset; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSet.RecordSubset.Latency; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset;
import org.jclouds.route53.domain.RecordSet.RecordSubset.Weighted; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Latency;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Weighted;
import org.jclouds.route53.internal.BaseRoute53ApiLiveTest; import org.jclouds.route53.internal.BaseRoute53ApiLiveTest;
import org.testng.SkipException; import org.testng.SkipException;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -56,10 +53,10 @@ import com.google.common.collect.ImmutableList;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", testName = "ResourceRecordSetApiLiveTest") @Test(groups = "live", testName = "ResourceResourceRecordSetApiLiveTest")
public class RecordSetApiLiveTest extends BaseRoute53ApiLiveTest { public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
private void checkRRS(RecordSet rrs) { private void checkRRS(ResourceRecordSet rrs) {
checkNotNull(rrs.getName(), "Name: ResourceRecordSet %s", rrs); checkNotNull(rrs.getName(), "Name: ResourceRecordSet %s", rrs);
checkNotNull(rrs.getType(), "Type: ResourceRecordSet %s", rrs); checkNotNull(rrs.getType(), "Type: ResourceRecordSet %s", rrs);
checkNotNull(rrs.getTTL(), "TTL: ResourceRecordSet %s", rrs); checkNotNull(rrs.getTTL(), "TTL: ResourceRecordSet %s", rrs);
@ -73,7 +70,7 @@ public class RecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
checkNotNull(RecordSubset.class.cast(rrs).getId(), "Id: ResourceRecordSubset %s", rrs); checkNotNull(RecordSubset.class.cast(rrs).getId(), "Id: ResourceRecordSubset %s", rrs);
} }
if (rrs instanceof Weighted) { if (rrs instanceof Weighted) {
assertTrue(Weighted.class.cast(rrs).getWeight() >= 0, "Weight negative: ResourceRecordSubset " + rrs); checkNotNull(Weighted.class.cast(rrs).getWeight(), "Weight: ResourceRecordSubset %s", rrs);
} }
if (rrs instanceof Latency) { if (rrs instanceof Latency) {
checkNotNull(Latency.class.cast(rrs).getRegion(), "Region: ResourceRecordSubset %s", rrs); checkNotNull(Latency.class.cast(rrs).getRegion(), "Region: ResourceRecordSubset %s", rrs);
@ -82,72 +79,72 @@ public class RecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
@Test @Test
private void testListRRSs() { private void testListRRSs() {
for (Zone zone : zones().concat()) { for (HostedZone zone : zones().concat()) {
checkAllRRs(zone.getId()); checkAllRRs(zone.getId());
} }
} }
private void checkAllRRs(String zoneId) { private void checkAllRRs(String zoneId) {
Zone zone = context.getApi().getZoneApi().get(zoneId).getZone(); HostedZone zone = context.getApi().getHostedZoneApi().get(zoneId).getZone();
List<RecordSet> records = api(zone.getId()).list().concat().toImmutableList(); List<ResourceRecordSet> records = api(zone.getId()).list().concat().toImmutableList();
assertEquals(zone.getResourceRecordSetCount(), records.size()); assertEquals(zone.getResourceRecordSetCount(), records.size());
for (RecordSet rrs : records) { for (ResourceRecordSet rrs : records) {
checkRRS(rrs); checkRRS(rrs);
} }
} }
@Test @Test
public void testDeleteRRSNotFound() { public void testDeleteRRSNotFound() {
for (Zone zone : zones().concat()) { for (HostedZone zone : zones().concat()) {
assertNull(api(zone.getId()).delete( assertNull(api(zone.getId()).delete(
RecordSet.builder().name("krank.foo.bar.").type(TXT).add("kranko").build())); ResourceRecordSet.builder().name("krank.foo.bar.").type("TXT").add("kranko").build()));
} }
} }
/** /**
* cannot delete a zone without at least one of each * cannot delete a zone without at least one of each
*/ */
private static final Predicate<RecordSet> requiredRRTypes = or(typeEquals(SOA), typeEquals(NS)); private static final Predicate<ResourceRecordSet> requiredRRTypes = or(typeEquals("SOA"), typeEquals("NS"));
@Test @Test
public void testCreateAndDeleteBulkRecords() { public void testCreateAndDeleteBulkRecords() {
String name = System.getProperty("user.name").replace('.', '-') + ".bulk.route53test.jclouds.org."; String name = System.getProperty("user.name").replace('.', '-') + ".bulk.route53test.jclouds.org.";
clearAndDeleteZonesNamed(name); clearAndDeleteHostedZonesNamed(name);
ImmutableList<RecordSet> records = ImmutableList.<RecordSet> builder() ImmutableList<ResourceRecordSet> records = ImmutableList.<ResourceRecordSet> builder()
.add(RecordSet.builder().name("dom1." + name).type(TXT).add("\"somehow\" \" somewhere\"").build()) .add(ResourceRecordSet.builder().name("dom1." + name).type("TXT").add("\"somehow\" \" somewhere\"").build())
.add(RecordSet.builder().name("dom2." + name).type(TXT).add("\"goodies\"").build()).build(); .add(ResourceRecordSet.builder().name("dom2." + name).type("TXT").add("\"goodies\"").build()).build();
String nonce = name + " @ " + new Date(); String nonce = name + " @ " + new Date();
String comment = name + " for " + JcloudsVersion.get(); String comment = name + " for " + JcloudsVersion.get();
NewZone newZone = context.getApi().getZoneApi().createWithReferenceAndComment(name, nonce, comment); NewHostedZone newHostedZone = context.getApi().getHostedZoneApi().createWithReferenceAndComment(name, nonce, comment);
String zoneId = newZone.getZone().getId(); String zoneId = newHostedZone.getZone().getId();
getAnonymousLogger().info("created zone: " + newZone); getAnonymousLogger().info("created zone: " + newHostedZone);
try { try {
assertTrue(inSync.apply(newZone.getChange()), "zone didn't sync " + newZone); assertTrue(inSync.apply(newHostedZone.getChange()), "zone didn't sync " + newHostedZone);
sync(api(zoneId).apply(createAll(records))); sync(api(zoneId).apply(createAll(records)));
checkAllRRs(zoneId); checkAllRRs(zoneId);
sync(api(zoneId).apply(deleteAll(records))); sync(api(zoneId).apply(deleteAll(records)));
PagedIterable<RecordSet> refreshed = refresh(zoneId); PagedIterable<ResourceRecordSet> refreshed = refresh(zoneId);
assertTrue(refreshed.concat().filter(not(requiredRRTypes)).isEmpty(), "zone still has optional records: " assertTrue(refreshed.concat().filter(not(requiredRRTypes)).isEmpty(), "zone still has optional records: "
+ refreshed); + refreshed);
} finally { } finally {
clearAndDeleteZonesNamed(name); clearAndDeleteHostedZonesNamed(name);
} }
} }
private void clearAndDeleteZonesNamed(String name) { private void clearAndDeleteHostedZonesNamed(String name) {
for (Zone zone : context.getApi().getZoneApi().list().concat().filter(nameEquals(name))) { for (HostedZone zone : context.getApi().getHostedZoneApi().list().concat().filter(nameEquals(name))) {
getAnonymousLogger().info("clearing and deleting zone: " + zone); getAnonymousLogger().info("clearing and deleting zone: " + zone);
Set<RecordSet> remaining = refresh(zone.getId()).concat().filter(not(requiredRRTypes)).toImmutableSet(); Set<ResourceRecordSet> remaining = refresh(zone.getId()).concat().filter(not(requiredRRTypes)).toImmutableSet();
if (!remaining.isEmpty()) if (!remaining.isEmpty())
sync(api(zone.getId()).apply(deleteAll(remaining))); sync(api(zone.getId()).apply(deleteAll(remaining)));
sync(context.getApi().getZoneApi().delete(zone.getId())); sync(context.getApi().getHostedZoneApi().delete(zone.getId()));
} }
} }
@ -155,18 +152,18 @@ public class RecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
assertTrue(inSync.apply(job), "job didn't sync " + job); assertTrue(inSync.apply(job), "job didn't sync " + job);
} }
private PagedIterable<RecordSet> refresh(String zoneId) { private PagedIterable<ResourceRecordSet> refresh(String zoneId) {
return api(zoneId).list(); return api(zoneId).list();
} }
private PagedIterable<Zone> zones() { private PagedIterable<HostedZone> zones() {
PagedIterable<Zone> zones = context.getApi().getZoneApi().list(); PagedIterable<HostedZone> zones = context.getApi().getHostedZoneApi().list();
if (zones.get(0).isEmpty()) if (zones.get(0).isEmpty())
throw new SkipException("no zones in context: " + context); throw new SkipException("no zones in context: " + context);
return zones; return zones;
} }
private RecordSetApi api(String zoneId) { private ResourceRecordSetApi api(String zoneId) {
return context.getApi().getRecordSetApiForZone(zoneId); return context.getApi().getResourceRecordSetApiForHostedZone(zoneId);
} }
} }

View File

@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.route53.domain.NewZone; import org.jclouds.route53.domain.NewHostedZone;
import org.jclouds.route53.xml.CreateHostedZoneResponseHandler; import org.jclouds.route53.xml.CreateHostedZoneResponseHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -37,15 +37,15 @@ public class CreateHostedZoneResponseTest extends BaseHandlerTest {
public void test() { public void test() {
InputStream is = getClass().getResourceAsStream("/new_zone.xml"); InputStream is = getClass().getResourceAsStream("/new_zone.xml");
NewZone expected = expected(); NewHostedZone expected = expected();
CreateHostedZoneResponseHandler handler = injector.getInstance(CreateHostedZoneResponseHandler.class); CreateHostedZoneResponseHandler handler = injector.getInstance(CreateHostedZoneResponseHandler.class);
NewZone result = factory.create(handler).parse(is); NewHostedZone result = factory.create(handler).parse(is);
assertEquals(result, expected); assertEquals(result, expected);
} }
public NewZone expected() { public NewHostedZone expected() {
return NewZone.create(new GetHostedZoneResponseTest().expected(), new GetChangeResponseTest().expected()); return NewHostedZone.create(new GetHostedZoneResponseTest().expected(), new GetChangeResponseTest().expected());
} }
} }

View File

@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import org.jclouds.route53.domain.ZoneAndNameServers; import org.jclouds.route53.domain.HostedZoneAndNameServers;
import org.jclouds.route53.xml.GetHostedZoneResponseHandler; import org.jclouds.route53.xml.GetHostedZoneResponseHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -40,16 +40,16 @@ public class GetHostedZoneResponseTest extends BaseHandlerTest {
public void test() { public void test() {
InputStream is = getClass().getResourceAsStream("/hosted_zone.xml"); InputStream is = getClass().getResourceAsStream("/hosted_zone.xml");
ZoneAndNameServers expected = expected(); HostedZoneAndNameServers expected = expected();
GetHostedZoneResponseHandler handler = injector.getInstance(GetHostedZoneResponseHandler.class); GetHostedZoneResponseHandler handler = injector.getInstance(GetHostedZoneResponseHandler.class);
ZoneAndNameServers result = factory.create(handler).parse(is); HostedZoneAndNameServers result = factory.create(handler).parse(is);
assertEquals(result, expected); assertEquals(result, expected);
} }
public ZoneAndNameServers expected() { public HostedZoneAndNameServers expected() {
return ZoneAndNameServers.create(Zone.builder() return HostedZoneAndNameServers.create(HostedZone.builder()
.id("Z21DW1QVGID6NG") .id("Z21DW1QVGID6NG")
.name("example.com.") .name("example.com.")
.callerReference("a_unique_reference") .callerReference("a_unique_reference")

View File

@ -25,7 +25,7 @@ import java.io.InputStream;
import org.jclouds.collect.IterableWithMarker; import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.IterableWithMarkers; import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import org.jclouds.route53.xml.ListHostedZonesResponseHandler; import org.jclouds.route53.xml.ListHostedZonesResponseHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -41,25 +41,25 @@ public class ListHostedZonesResponseTest extends BaseHandlerTest {
public void test() { public void test() {
InputStream is = getClass().getResourceAsStream("/hosted_zones.xml"); InputStream is = getClass().getResourceAsStream("/hosted_zones.xml");
IterableWithMarker<Zone> expected = expected(); IterableWithMarker<HostedZone> expected = expected();
ListHostedZonesResponseHandler handler = injector.getInstance(ListHostedZonesResponseHandler.class); ListHostedZonesResponseHandler handler = injector.getInstance(ListHostedZonesResponseHandler.class);
IterableWithMarker<Zone> result = factory.create(handler).parse(is); IterableWithMarker<HostedZone> result = factory.create(handler).parse(is);
assertEquals(result.toString(), expected.toString()); assertEquals(result.toString(), expected.toString());
} }
public IterableWithMarker<Zone> expected() { public IterableWithMarker<HostedZone> expected() {
return IterableWithMarkers.from( return IterableWithMarkers.from(
ImmutableSet.of( ImmutableSet.of(
Zone.builder() HostedZone.builder()
.id("Z21DW1QVGID6NG") .id("Z21DW1QVGID6NG")
.name("example.com.") .name("example.com.")
.callerReference("a_unique_reference") .callerReference("a_unique_reference")
.resourceRecordSetCount(17) .resourceRecordSetCount(17)
.comment("Migrate an existing domain to Route 53").build(), .comment("Migrate an existing domain to Route 53").build(),
Zone.builder() HostedZone.builder()
.id("Z2682N5HXP0BZ4") .id("Z2682N5HXP0BZ4")
.name("example2.com.") .name("example2.com.")
.callerReference("a_unique_reference2") .callerReference("a_unique_reference2")

View File

@ -23,9 +23,8 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.jclouds.route53.domain.RecordSet.Type; import org.jclouds.route53.domain.ResourceRecordSetIterable;
import org.jclouds.route53.domain.RecordSetIterable;
import org.jclouds.route53.xml.ListResourceRecordSetsResponseHandler; import org.jclouds.route53.xml.ListResourceRecordSetsResponseHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -40,26 +39,26 @@ public class ListResourceRecordSetsResponseTest extends BaseHandlerTest {
public void test() { public void test() {
InputStream is = getClass().getResourceAsStream("/rrsets.xml"); InputStream is = getClass().getResourceAsStream("/rrsets.xml");
RecordSetIterable expected = expected(); ResourceRecordSetIterable expected = expected();
ListResourceRecordSetsResponseHandler handler = injector.getInstance(ListResourceRecordSetsResponseHandler.class); ListResourceRecordSetsResponseHandler handler = injector.getInstance(ListResourceRecordSetsResponseHandler.class);
RecordSetIterable result = factory.create(handler).parse(is); ResourceRecordSetIterable result = factory.create(handler).parse(is);
assertEquals(result.toString(), expected.toString()); assertEquals(result.toString(), expected.toString());
} }
public RecordSetIterable expected() { public ResourceRecordSetIterable expected() {
return RecordSetIterable.builder() return ResourceRecordSetIterable.builder()
.add(RecordSet.builder() .add(ResourceRecordSet.builder()
.name("example.com.") .name("example.com.")
.type(Type.SOA) .type("SOA")
.ttl(900) .ttl(900)
.add("ns-2048.awsdns-64.net. hostmaster.awsdns.com. 1 7200 900 1209600 86400") .add("ns-2048.awsdns-64.net. hostmaster.awsdns.com. 1 7200 900 1209600 86400")
.build()) .build())
.add(RecordSet.builder() .add(ResourceRecordSet.builder()
.name("example.com.") .name("example.com.")
.type(Type.NS) .type("NS")
.ttl(172800) .ttl(172800)
.add("ns-2048.awsdns-64.com.") .add("ns-2048.awsdns-64.com.")
.add("ns-2049.awsdns-65.net.") .add("ns-2049.awsdns-65.net.")
@ -67,6 +66,6 @@ public class ListResourceRecordSetsResponseTest extends BaseHandlerTest {
.add("ns-2051.awsdns-67.co.uk.") .add("ns-2051.awsdns-67.co.uk.")
.build()) .build())
.nextRecordName("testdoc2.example.com") .nextRecordName("testdoc2.example.com")
.nextRecordType(Type.NS).build(); .nextRecordType("NS").build();
} }
} }

View File

@ -18,18 +18,18 @@
*/ */
package org.jclouds.route53.predicates; package org.jclouds.route53.predicates;
import static org.jclouds.route53.predicates.ZonePredicates.nameEquals; import static org.jclouds.route53.predicates.HostedZonePredicates.nameEquals;
import org.jclouds.route53.domain.Zone; import org.jclouds.route53.domain.HostedZone;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "ZonePredicatesTest") @Test(groups = "unit", testName = "HostedZonePredicatesTest")
public class ZonePredicatesTest { public class HostedZonePredicatesTest {
Zone zone = Zone.builder().id("EEEFFFEEE").callerReference("goog").name("jclouds.org.").build(); HostedZone zone = HostedZone.builder().id("EEEFFFEEE").callerReference("goog").name("jclouds.org.").build();
@Test @Test
public void testNameEqualsWhenEqual() { public void testNameEqualsWhenEqual() {

View File

@ -18,11 +18,9 @@
*/ */
package org.jclouds.route53.predicates; package org.jclouds.route53.predicates;
import static org.jclouds.route53.domain.RecordSet.Type.AAAA; import static org.jclouds.route53.predicates.ResourceRecordSetPredicates.typeEquals;
import static org.jclouds.route53.domain.RecordSet.Type.NS;
import static org.jclouds.route53.predicates.RecordSetPredicates.typeEquals;
import org.jclouds.route53.domain.RecordSet; import org.jclouds.route53.domain.ResourceRecordSet;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -30,17 +28,17 @@ import org.testng.annotations.Test;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "ResourceRecordSetPredicatesTest") @Test(groups = "unit", testName = "ResourceRecordSetPredicatesTest")
public class RecordSetPredicatesTest { public class ResourceRecordSetPredicatesTest {
RecordSet rrs = RecordSet.builder().name("jclouds.org.").type(NS).add("ns-119.awsdns-14.com.") ResourceRecordSet rrs = ResourceRecordSet.builder().name("jclouds.org.").type("NS").add("ns-119.awsdns-14.com.")
.build(); .build();
@Test @Test
public void testTypeEqualsWhenEqual() { public void testTypeEqualsWhenEqual() {
assert typeEquals(NS).apply(rrs); assert typeEquals("NS").apply(rrs);
} }
@Test @Test
public void testTypeEqualsWhenNotEqual() { public void testTypeEqualsWhenNotEqual() {
assert !typeEquals(AAAA).apply(rrs); assert !typeEquals("AAAA").apply(rrs);
} }
} }

View File

@ -18,15 +18,15 @@
*/ */
package org.jclouds.aws.route53.features; package org.jclouds.aws.route53.features;
import org.jclouds.route53.features.ZoneApiLiveTest; import org.jclouds.route53.features.HostedZoneApiLiveTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", testName = "AWSZoneApiLiveTest") @Test(groups = "live", testName = "AWSHostedZoneApiLiveTest")
public class AWSZoneApiLiveTest extends ZoneApiLiveTest { public class AWSHostedZoneApiLiveTest extends HostedZoneApiLiveTest {
public AWSZoneApiLiveTest() { public AWSHostedZoneApiLiveTest() {
provider = "aws-route53"; provider = "aws-route53";
} }
} }

View File

@ -18,15 +18,15 @@
*/ */
package org.jclouds.aws.route53.features; package org.jclouds.aws.route53.features;
import org.jclouds.route53.features.RecordSetApiLiveTest; import org.jclouds.route53.features.ResourceRecordSetApiLiveTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", testName = "AWSResourceRecordSetApiLiveTest") @Test(groups = "live", testName = "AWSResourceResourceRecordSetApiLiveTest")
public class AWSRecordSetApiLiveTest extends RecordSetApiLiveTest { public class AWSResourceRecordSetApiLiveTest extends ResourceRecordSetApiLiveTest {
public AWSRecordSetApiLiveTest() { public AWSResourceRecordSetApiLiveTest() {
provider = "aws-route53"; provider = "aws-route53";
} }
} }