Merge pull request #1410 from jclouds/dns-un-unsignedint

DNS un-unsignedint
This commit is contained in:
Adrian Cole 2013-03-11 15:42:50 -07:00
commit 9b23141ba4
34 changed files with 287 additions and 375 deletions

View File

@ -20,6 +20,7 @@ package org.jclouds.route53.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
@ -31,7 +32,6 @@ import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.UnsignedInteger;
/**
*
@ -41,7 +41,7 @@ public class ResourceRecordSet {
protected final String name;
protected final String type;
protected final Optional<UnsignedInteger> ttl;
protected final Optional<Integer> ttl;
protected final List<String> values;
protected final Optional<AliasTarget> aliasTarget;
@ -98,9 +98,9 @@ public class ResourceRecordSet {
public static abstract class RecordSubset extends ResourceRecordSet {
public static final class Weighted extends RecordSubset {
private final UnsignedInteger weight;
private final int weight;
private Weighted(String id, String name, String type, UnsignedInteger weight, Optional<UnsignedInteger> ttl, List<String> values,
private Weighted(String id, String name, String type, int weight, Optional<Integer> ttl, List<String> values,
Optional<AliasTarget> aliasTarget) {
super(id, name, type, ttl, values, aliasTarget);
this.weight = checkNotNull(weight, "weight");
@ -110,7 +110,7 @@ public class ResourceRecordSet {
* determines what portion of traffic for the current resource record
* set is routed to this subset.
*/
public UnsignedInteger getWeight() {
public int getWeight() {
return weight;
}
@ -124,7 +124,7 @@ public class ResourceRecordSet {
private final String region;
private Latency(String id, String name, String type, String region, Optional<UnsignedInteger> ttl, List<String> values,
private Latency(String id, String name, String type, String region, Optional<Integer> ttl, List<String> values,
Optional<AliasTarget> aliasTarget) {
super(id, name, type, ttl, values, aliasTarget);
this.region = checkNotNull(region, "region of %s", name);
@ -146,7 +146,7 @@ public class ResourceRecordSet {
private final String id;
private RecordSubset(String id, String name, String type, Optional<UnsignedInteger> ttl, List<String> values,
private RecordSubset(String id, String name, String type, Optional<Integer> ttl, List<String> values,
Optional<AliasTarget> aliasTarget) {
super(name, type, ttl, values, aliasTarget);
this.id = checkNotNull(id, "id of %s", name);
@ -183,10 +183,11 @@ public class ResourceRecordSet {
}
}
private ResourceRecordSet(String name, String type, Optional<UnsignedInteger> ttl, List<String> values, Optional<AliasTarget> aliasTarget) {
private ResourceRecordSet(String name, String type, Optional<Integer> ttl, List<String> values, Optional<AliasTarget> aliasTarget) {
this.name = checkNotNull(name, "name");
this.type = checkNotNull(type, "type of %s", name);
this.ttl = checkNotNull(ttl, "ttl for %s", name);
checkArgument(ttl.or(0) >= 0, "ttl of %s must be unsigned", name);
this.values = checkNotNull(values, "values for %s", name);
this.aliasTarget = checkNotNull(aliasTarget, "aliasTarget for %s", aliasTarget);
}
@ -209,7 +210,7 @@ public class ResourceRecordSet {
* Present in all resource record sets except aliases. The resource record
* cache time to live (TTL), in seconds.
*/
public Optional<UnsignedInteger> getTTL() {
public Optional<Integer> getTTL() {
return ttl;
}
@ -264,11 +265,11 @@ public class ResourceRecordSet {
private String id;
private String name;
private String type;
private Optional<UnsignedInteger> ttl = Optional.absent();
private Optional<Integer> ttl = Optional.absent();
private ImmutableList.Builder<String> values = ImmutableList.<String> builder();
private String dnsName;
private String zoneId;
private UnsignedInteger weight;
private Integer weight;
private String region;
/**
@ -295,19 +296,12 @@ public class ResourceRecordSet {
return this;
}
/**
* @see ResourceRecordSet#getTTL()
*/
public Builder ttl(UnsignedInteger ttl) {
this.ttl = Optional.fromNullable(ttl);
return this;
}
/**
* @see ResourceRecordSet#getTTL()
*/
public Builder ttl(int ttl) {
return ttl(UnsignedInteger.fromIntBits(ttl));
this.ttl = Optional.of(ttl);
return this;
}
/**
@ -359,7 +353,7 @@ public class ResourceRecordSet {
/**
* @see RecordSubset.Weighted
*/
public Builder weight(UnsignedInteger weight) {
public Builder weight(int weight) {
this.weight = weight;
return this;
}

View File

@ -27,7 +27,6 @@ import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Latency;
import org.jclouds.route53.domain.ResourceRecordSet.RecordSubset.Weighted;
import com.google.common.base.Function;
import com.google.common.primitives.UnsignedInteger;
/**
* @author Adrian Cole
@ -54,7 +53,8 @@ public class SerializeRRS implements Function<Object, String> {
builder.append("<DNSName>").append(rrs.getAliasTarget().get().getDNSName()).append("</DNSName>");
builder.append("</AliasTarget>");
} else {
builder.append("<TTL>").append(rrs.getTTL().or(UnsignedInteger.ZERO)).append("</TTL>");
// default ttl from the amazon console is 300
builder.append("<TTL>").append(rrs.getTTL().or(300)).append("</TTL>");
builder.append("<ResourceRecords>");
for (String record : rrs.getValues())
builder.append("<ResourceRecord>").append("<Value>").append(record).append("</Value>")

View File

@ -24,7 +24,6 @@ import org.jclouds.http.functions.ParseSax;
import org.jclouds.route53.domain.HostedZone;
import org.xml.sax.Attributes;
import com.google.common.primitives.UnsignedInteger;
/**
*
@ -59,7 +58,7 @@ public class HostedZoneHandler extends ParseSax.HandlerForGeneratedRequestWithRe
} else if (qName.equals("Comment")) {
builder.comment(currentOrNull(currentText));
} else if (qName.equals("ResourceRecordSetCount")) {
builder.resourceRecordSetCount(UnsignedInteger.valueOf(currentOrNull(currentText)).intValue());
builder.resourceRecordSetCount(Integer.parseInt(currentOrNull(currentText)));
}
currentText = new StringBuilder();
}

View File

@ -24,7 +24,6 @@ import org.jclouds.http.functions.ParseSax;
import org.jclouds.route53.domain.ResourceRecordSet;
import org.xml.sax.Attributes;
import com.google.common.primitives.UnsignedInteger;
/**
*
@ -55,7 +54,7 @@ public class ResourceRecordSetHandler extends ParseSax.HandlerForGeneratedReques
} else if (qName.equals("Type")) {
builder.type(currentOrNull(currentText));
} else if (qName.equals("TTL")) {
builder.ttl(UnsignedInteger.valueOf(currentOrNull(currentText)));
builder.ttl(Integer.parseInt(currentOrNull(currentText)));
} else if (qName.equals("Value")) {
builder.add(currentOrNull(currentText));
} else if (qName.equals("HostedZoneId")) {
@ -65,7 +64,7 @@ public class ResourceRecordSetHandler extends ParseSax.HandlerForGeneratedReques
} else if (qName.equals("DNSName")) {
builder.dnsName(currentOrNull(currentText));
} else if (qName.equals("Weight")) {
builder.weight(UnsignedInteger.valueOf(currentOrNull(currentText)));
builder.weight(Integer.parseInt(currentOrNull(currentText)));
} else if (qName.equals("Region")) {
builder.region(currentOrNull(currentText));
}

View File

@ -140,7 +140,7 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
public void testDeleteWhenResponseIs2xx() {
Route53Api success = requestSendsResponse(delete, jobResponse);
assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").create(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").add("my texts").build()).toString(),
assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").create(ResourceRecordSet.builder().name("jclouds.org.").type("TXT").ttl(0).add("my texts").build()).toString(),
new GetChangeResponseTest().expected().toString());
}
}

View File

@ -1 +1 @@
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2012-02-29/"><ChangeBatch><Changes><Change><Action>DELETE</Action><ResourceRecordSet><Name>jclouds.org.</Name><Type>TXT</Type><TTL>0</TTL><ResourceRecords><ResourceRecord><Value>my texts</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change><Change><Action>CREATE</Action><ResourceRecordSet><Name>jclouds.org.</Name><Type>TXT</Type><TTL>0</TTL><ResourceRecords><ResourceRecord><Value>my better texts</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2012-02-29/"><ChangeBatch><Changes><Change><Action>DELETE</Action><ResourceRecordSet><Name>jclouds.org.</Name><Type>TXT</Type><TTL>300</TTL><ResourceRecords><ResourceRecord><Value>my texts</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change><Change><Action>CREATE</Action><ResourceRecordSet><Name>jclouds.org.</Name><Type>TXT</Type><TTL>300</TTL><ResourceRecords><ResourceRecord><Value>my better texts</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>

View File

@ -1 +1 @@
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2012-02-29/"><ChangeBatch><Changes><Change><Action>CREATE</Action><ResourceRecordSet><Name>jclouds.org.</Name><Type>TXT</Type><TTL>0</TTL><ResourceRecords><ResourceRecord><Value>my texts</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2012-02-29/"><ChangeBatch><Changes><Change><Action>CREATE</Action><ResourceRecordSet><Name>jclouds.org.</Name><Type>TXT</Type><TTL>300</TTL><ResourceRecords><ResourceRecord><Value>my texts</Value></ResourceRecord></ResourceRecords></ResourceRecordSet></Change></Changes></ChangeBatch></ChangeResourceRecordSetsRequest>

View File

@ -26,12 +26,8 @@ import javax.inject.Singleton;
import org.jclouds.dynect.v3.domain.SessionCredentials;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.UnsignedInteger;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.inject.AbstractModule;
@ -51,7 +47,6 @@ public class DynECTParserModule extends AbstractModule {
public Map<Type, Object> provideCustomAdapterBindings() {
return new ImmutableMap.Builder<Type, Object>()
.put(SessionCredentials.class, new SessionCredentialsTypeAdapter())
.put(UnsignedInteger.class, new UnsignedIntegerAdapter())
.build();
}
@ -64,11 +59,4 @@ public class DynECTParserModule extends AbstractModule {
return metadataObject;
}
}
private static class UnsignedIntegerAdapter implements JsonDeserializer<UnsignedInteger> {
public UnsignedInteger deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context)
throws JsonParseException {
return UnsignedInteger.fromIntBits(jsonElement.getAsBigInteger().intValue());
}
}
}

View File

@ -20,12 +20,12 @@ package org.jclouds.dynect.v3.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import com.google.common.base.Objects;
import com.google.common.primitives.UnsignedInteger;
/**
* @author Adrian Cole
@ -34,13 +34,14 @@ public class CreateRecord<D extends Map<String, Object>> {
private final String fqdn;
private final String type;
private final UnsignedInteger ttl;
private final int ttl;
private final D rdata;
private CreateRecord(String fqdn, String type, UnsignedInteger ttl, D rdata) {
private CreateRecord(String fqdn, String type, int ttl, D rdata) {
this.fqdn = checkNotNull(fqdn, "fqdn");
this.type = checkNotNull(type, "type of %s", fqdn);
this.ttl = checkNotNull(ttl, "ttl of %s", fqdn);
checkArgument(ttl >= 0, "ttl of %s must be unsigned", fqdn);
this.ttl = ttl;
this.rdata = checkNotNull(rdata, "rdata of %s", fqdn);
}
@ -63,7 +64,7 @@ public class CreateRecord<D extends Map<String, Object>> {
*
* @see Record#getTTL()
*/
public UnsignedInteger getTTL() {
public int getTTL() {
return ttl;
}
@ -106,7 +107,8 @@ public class CreateRecord<D extends Map<String, Object>> {
public static class Builder<D extends Map<String, Object>> {
protected String fqdn;
protected String type;
protected UnsignedInteger ttl = UnsignedInteger.ZERO;
// default of zone is implied when ttl is set to zero
protected int ttl = 0;
protected D rdata;
/**
@ -128,18 +130,11 @@ public class CreateRecord<D extends Map<String, Object>> {
/**
* @see CreateRecord#getTTL()
*/
public Builder<D> ttl(UnsignedInteger ttl) {
public Builder<D> ttl(int ttl) {
this.ttl = ttl;
return this;
}
/**
* @see CreateRecord#getTTL()
*/
public Builder<D> ttl(int ttl) {
return ttl(UnsignedInteger.fromIntBits(ttl));
}
/**
* @see CreateRecord#getRData()
*/

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.dynect.v3.domain;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
@ -26,28 +27,28 @@ import java.util.Map;
import javax.inject.Named;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.primitives.UnsignedInteger;
/**
* @author Adrian Cole
*/
public class Record<D extends Map<String, Object>> extends RecordId {
private final UnsignedInteger ttl;
private final int ttl;
@Named("rdata")
private final D rdata;
@ConstructorProperties({ "zone", "fqdn", "record_type", "record_id", "ttl", "rdata" })
protected Record(String zone, String fqdn, String type, long id, UnsignedInteger ttl, D rdata) {
protected Record(String zone, String fqdn, String type, long id, int ttl, D rdata) {
super(zone, fqdn, type, id);
this.ttl = checkNotNull(ttl, "ttl of %s", id);
checkArgument(ttl >= 0, "ttl of %s must be unsigned", fqdn);
this.ttl = ttl;
this.rdata = checkNotNull(rdata, "rdata of %s", id);
}
/**
* The current ttl of the record or zero if default for the zone
*/
public UnsignedInteger getTTL() {
public int getTTL() {
return ttl;
}
@ -74,24 +75,17 @@ public class Record<D extends Map<String, Object>> extends RecordId {
public abstract static class Builder<D extends Map<String, Object>, B extends Builder<D, B>> extends RecordId.Builder<B> {
protected UnsignedInteger ttl;
protected int ttl = -1;
protected D rdata;
/**
* @see Record#getTTL()
*/
public B ttl(UnsignedInteger ttl) {
public B ttl(int ttl) {
this.ttl = ttl;
return self();
}
/**
* @see Record#getTTL()
*/
public B ttl(int ttl) {
return ttl(UnsignedInteger.fromIntBits(ttl));
}
/**
* @see Record#getRData()
*/

View File

@ -28,7 +28,6 @@ import org.jclouds.dynect.v3.domain.Zone.SerialStyle;
import org.jclouds.dynect.v3.domain.rdata.SOAData;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.primitives.UnsignedInteger;
/**
* Start of Authority per RFC 1035
@ -41,7 +40,7 @@ public final class SOARecord extends Record<SOAData> {
private final SerialStyle serialStyle;
@ConstructorProperties({ "zone", "fqdn", "record_type", "record_id", "ttl", "rdata", "serial_style" })
private SOARecord(String zone, String fqdn, String type, long id, UnsignedInteger ttl, SOAData rdata, SerialStyle serialStyle) {
private SOARecord(String zone, String fqdn, String type, long id, int ttl, SOAData rdata, SerialStyle serialStyle) {
super(zone, fqdn, type, id, ttl, rdata);
this.serialStyle = checkNotNull(serialStyle, "serialStyle of %s", id);
}

View File

@ -40,22 +40,25 @@ import com.google.common.collect.ImmutableMap;
* @see <aaaa href="http://www.ietf.org/rfc/rfc3596.txt">RFC 3596</aaaa>
*/
public class AAAAData extends ForwardingMap<String, Object> {
private final ImmutableMap<String, Object> delegate;
private final String address;
@ConstructorProperties("address")
private AAAAData(String address) {
this.delegate = ImmutableMap.<String, Object> of("address", checkNotNull(address, "address"));
}
protected Map<String, Object> delegate() {
return delegate;
this.address = checkNotNull(address, "address");
this.delegate = ImmutableMap.<String, Object> of("address", address);
}
/**
* a 128 bit IPv6 address
*/
public String getAddress() {
return get("address").toString();
return address;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static AAAAData aaaa(String address) {

View File

@ -40,22 +40,26 @@ import com.google.common.collect.ImmutableMap;
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
*/
public class AData extends ForwardingMap<String, Object> {
private final ImmutableMap<String, Object> delegate;
private final String address;
@ConstructorProperties("address")
private AData(String address) {
this.address = checkNotNull(address, "address");
this.delegate = ImmutableMap.<String, Object> of("address", checkNotNull(address, "address"));
}
protected Map<String, Object> delegate() {
return delegate;
}
/**
* a 32-bit internet address
*/
public String getAddress() {
return get("address").toString();
return address;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static AData a(String address) {

View File

@ -40,15 +40,13 @@ import com.google.common.collect.ImmutableMap;
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
*/
public class CNAMEData extends ForwardingMap<String, Object> {
private final ImmutableMap<String, Object> delegate;
private final String cname;
@ConstructorProperties("cname")
private CNAMEData(String cname) {
this.delegate = ImmutableMap.<String, Object> of("cname", checkNotNull(cname, "cname"));
}
protected Map<String, Object> delegate() {
return delegate;
this.cname = checkNotNull(cname, "cname");
this.delegate = ImmutableMap.<String, Object> of("cname", cname);
}
/**
@ -56,7 +54,13 @@ public class CNAMEData extends ForwardingMap<String, Object> {
* The owner name is an alias.
*/
public String getCname() {
return get("cname").toString();
return cname;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static CNAMEData cname(String cname) {

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.dynect.v3.domain.rdata;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
@ -25,7 +26,6 @@ import java.util.Map;
import com.google.common.collect.ForwardingMap;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.UnsignedInteger;
/**
* Corresponds to the binary representation of the {@code MX} (Mail Exchange)
@ -43,24 +43,24 @@ import com.google.common.primitives.UnsignedInteger;
*/
public class MXData extends ForwardingMap<String, Object> {
private final int preference;
private final String exchange;
@ConstructorProperties({ "preference", "exchange" })
private MXData(UnsignedInteger preference, String exchange) {
this.delegate = ImmutableMap.<String, Object> builder().put("preference", checkNotNull(preference, "preference"))
.put("exchange", checkNotNull(exchange, "exchange")).build();
}
private final ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
private MXData(int preference, String exchange) {
checkArgument(preference >= 0, "preference of %s must be unsigned", exchange);
this.preference = preference;
this.exchange = checkNotNull(exchange, "exchange");
this.delegate = ImmutableMap.<String, Object> builder().put("preference", preference).put("exchange", exchange)
.build();
}
/**
* specifies the preference given to this RR among others at the same owner.
* Lower values are preferred.
*/
public UnsignedInteger getPreference() {
return UnsignedInteger.class.cast(get("preference"));
public int getPreference() {
return preference;
}
/**
@ -68,7 +68,13 @@ public class MXData extends ForwardingMap<String, Object> {
* the owner name.
*/
public String getExchange() {
return String.class.cast(get("exchange"));
return exchange;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static MXData mx(int preference, String exchange) {
@ -84,20 +90,13 @@ public class MXData extends ForwardingMap<String, Object> {
}
public final static class Builder {
private UnsignedInteger preference;
private int preference = -1;
private String exchange;
/**
* @see MXData#getPreference()
*/
public MXData.Builder preference(int preference) {
return preference(UnsignedInteger.fromIntBits(preference));
}
/**
* @see MXData#getPreference()
*/
public MXData.Builder preference(UnsignedInteger preference) {
this.preference = preference;
return this;
}

View File

@ -40,15 +40,13 @@ import com.google.common.collect.ImmutableMap;
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
*/
public class NSData extends ForwardingMap<String, Object> {
private final ImmutableMap<String, Object> delegate;
private final String nsdname;
@ConstructorProperties("nsdname")
private NSData(String nsdname) {
this.delegate = ImmutableMap.<String, Object> of("nsdname", checkNotNull(nsdname, "nsdname"));
}
protected Map<String, Object> delegate() {
return delegate;
this.nsdname = checkNotNull(nsdname, "nsdname");
this.delegate = ImmutableMap.<String, Object> of("nsdname", nsdname);
}
/**
@ -56,7 +54,13 @@ public class NSData extends ForwardingMap<String, Object> {
* specified class and domain.
*/
public String getNsdname() {
return get("nsdname").toString();
return nsdname;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static NSData ns(String nsdname) {

View File

@ -40,22 +40,26 @@ import com.google.common.collect.ImmutableMap;
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
*/
public class PTRData extends ForwardingMap<String, Object> {
private final ImmutableMap<String, Object> delegate;
private final String ptrdname;
@ConstructorProperties("ptrdname")
private PTRData(String ptrdname) {
this.delegate = ImmutableMap.<String, Object> of("ptrdname", checkNotNull(ptrdname, "ptrdname"));
}
protected Map<String, Object> delegate() {
return delegate;
this.ptrdname = checkNotNull(ptrdname, "ptrdname");
this.delegate = ImmutableMap.<String, Object> of("ptrdname", ptrdname);
}
/**
* domain-name which points to some location in the domain name space.
*/
public String getPtrdname() {
return get("ptrdname").toString();
return ptrdname;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static PTRData ptr(String ptrdname) {

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.dynect.v3.domain.rdata;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
@ -25,7 +26,6 @@ import java.util.Map;
import com.google.common.collect.ForwardingMap;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.UnsignedInteger;
/**
* Corresponds to the binary representation of the {@code SOA} (Start of Authority) RData
@ -46,10 +46,29 @@ import com.google.common.primitives.UnsignedInteger;
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
*/
public class SOAData extends ForwardingMap<String, Object> {
private final String mname;
private final String rname;
private final int serial;
private final int refresh;
private final int retry;
private final int expire;
private final int minimum;
@ConstructorProperties({ "mname", "rname", "serial", "refresh", "retry", "expire", "minimum" })
private SOAData(String mname, String rname, UnsignedInteger serial, UnsignedInteger refresh, UnsignedInteger retry,
UnsignedInteger expire, UnsignedInteger minimum) {
private SOAData(String mname, String rname, int serial, int refresh, int retry,
int expire, int minimum) {
this.mname = checkNotNull(mname, "mname");
this.rname = checkNotNull(rname, "rname of %s", mname);
checkArgument(serial >= 0, "serial of %s must be unsigned", mname);
this.serial = serial;
checkArgument(refresh >= 0, "refresh of %s must be unsigned", mname);
this.refresh = refresh;
checkArgument(retry >= 0, "retry of %s must be unsigned", mname);
this.retry = retry;
checkArgument(expire >= 0, "expire of %s must be unsigned", mname);
this.expire = expire;
checkArgument(minimum >= 0, "minimum of %s must be unsigned", mname);
this.minimum = minimum;
this.delegate = ImmutableMap.<String, Object> builder()
.put("mname", checkNotNull(mname, "mname"))
.put("rname", checkNotNull(rname, "rname of %s", mname))
@ -60,18 +79,12 @@ public class SOAData extends ForwardingMap<String, Object> {
.put("minimum", checkNotNull(minimum, "minimum of %s", mname)).build();
}
private final ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
/**
* domain-name of the name server that was the original or primary source of
* data for this zone
*/
public String getMname() {
return String.class.cast(get("mname"));
return mname;
}
/**
@ -79,43 +92,49 @@ public class SOAData extends ForwardingMap<String, Object> {
* zone.
*/
public String getRname() {
return String.class.cast(get("rname"));
return rname;
}
/**
* version number of the original copy of the zone.
*/
public UnsignedInteger getSerial() {
return UnsignedInteger.class.cast(get("serial"));
public int getSerial() {
return serial;
}
/**
* time interval before the zone should be refreshed
*/
public UnsignedInteger getRefresh() {
return UnsignedInteger.class.cast(get("refresh"));
public int getRefresh() {
return refresh;
}
/**
* time interval that should elapse before a failed refresh should be retried
*/
public UnsignedInteger getRetry() {
return UnsignedInteger.class.cast(get("retry"));
public int getRetry() {
return retry;
}
/**
* time value that specifies the upper limit on the time interval that can
* elapse before the zone is no longer authoritative.
*/
public UnsignedInteger getExpire() {
return UnsignedInteger.class.cast(get("expire"));
public int getExpire() {
return expire;
}
/**
* minimum TTL field that should be exported with any RR from this zone.
*/
public UnsignedInteger getMinimum() {
return UnsignedInteger.class.cast(get("minimum"));
public int getMinimum() {
return minimum;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static SOAData.Builder builder() {
@ -129,11 +148,11 @@ public class SOAData extends ForwardingMap<String, Object> {
public final static class Builder {
private String mname;
private String rname;
private UnsignedInteger serial;
private UnsignedInteger refresh;
private UnsignedInteger retry;
private UnsignedInteger expire;
private UnsignedInteger minimum;
private int serial = -1;
private int refresh = -1;
private int retry = -1;
private int expire = -1;
private int minimum = -1;
/**
* @see SOAData#getMname()
@ -151,26 +170,11 @@ public class SOAData extends ForwardingMap<String, Object> {
return this;
}
/**
* @see SOAData#getSerial()
*/
public SOAData.Builder serial(UnsignedInteger serial) {
this.serial = serial;
return this;
}
/**
* @see SOAData#getSerial()
*/
public SOAData.Builder serial(int serial) {
return serial(UnsignedInteger.fromIntBits(serial));
}
/**
* @see SOAData#getRefresh()
*/
public SOAData.Builder refresh(UnsignedInteger refresh) {
this.refresh = refresh;
this.serial = serial;
return this;
}
@ -178,14 +182,7 @@ public class SOAData extends ForwardingMap<String, Object> {
* @see SOAData#getRefresh()
*/
public SOAData.Builder refresh(int refresh) {
return refresh(UnsignedInteger.fromIntBits(refresh));
}
/**
* @see SOAData#getRetry()
*/
public SOAData.Builder retry(UnsignedInteger retry) {
this.retry = retry;
this.refresh = refresh;
return this;
}
@ -193,14 +190,7 @@ public class SOAData extends ForwardingMap<String, Object> {
* @see SOAData#getRetry()
*/
public SOAData.Builder retry(int retry) {
return retry(UnsignedInteger.fromIntBits(retry));
}
/**
* @see SOAData#getExpire()
*/
public SOAData.Builder expire(UnsignedInteger expire) {
this.expire = expire;
this.retry = retry;
return this;
}
@ -208,14 +198,7 @@ public class SOAData extends ForwardingMap<String, Object> {
* @see SOAData#getExpire()
*/
public SOAData.Builder expire(int expire) {
return expire(UnsignedInteger.fromIntBits(expire));
}
/**
* @see SOAData#getMinimum()
*/
public SOAData.Builder minimum(UnsignedInteger minimum) {
this.minimum = minimum;
this.expire = expire;
return this;
}
@ -223,7 +206,8 @@ public class SOAData extends ForwardingMap<String, Object> {
* @see SOAData#getMinimum()
*/
public SOAData.Builder minimum(int minimum) {
return minimum(UnsignedInteger.fromIntBits(minimum));
this.minimum = minimum;
return this;
}
public SOAData build() {

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.dynect.v3.domain.rdata;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
@ -25,7 +26,6 @@ import java.util.Map;
import com.google.common.collect.ForwardingMap;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.UnsignedInteger;
/**
* Corresponds to the binary representation of the {@code SRV} (Service) RData
@ -43,31 +43,36 @@ import com.google.common.primitives.UnsignedInteger;
* @see <a href="http://www.ietf.org/rfc/rfc2782.txt">RFC 2782</a>
*/
public class SRVData extends ForwardingMap<String, Object> {
private final int priority;
private final int weight;
private final int port;
private final String target;
@ConstructorProperties({ "priority", "weight", "port", "target" })
private SRVData(UnsignedInteger priority, UnsignedInteger weight, UnsignedInteger port, String target) {
private SRVData(int priority, int weight, int port, String target) {
checkArgument(checkNotNull(priority, "priority of %s", target).intValue() <= 0xFFFF, "priority must be 0-65535");
this.priority = priority;
checkArgument(checkNotNull(weight, "weight of %s", target).intValue() <= 0xFFFF, "weight must be 0-65535");
this.weight = weight;
checkArgument(checkNotNull(port, "port of %s", target).intValue() <= 0xFFFF, "port must be 0-65535");
this.port = port;
this.target = checkNotNull(target, "target");
this.delegate = ImmutableMap.<String, Object> builder()
.put("priority", checkNotNull(priority, "priority of %s", target))
.put("weight", checkNotNull(weight, "weight of %s", target))
.put("port", checkNotNull(port, "port of %s", target))
.put("target", checkNotNull(target, "target"))
.put("priority", priority)
.put("weight", weight)
.put("port", weight)
.put("target", weight)
.build();
}
private final ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
/**
* The priority of this target host. A client MUST attempt to contact the
* target host with the lowest-numbered priority it can reach; target hosts
* with the same priority SHOULD be tried in an order defined by the weight
* field.
*/
public UnsignedInteger getPriority() {
return UnsignedInteger.class.cast(get("priority"));
public int getPriority() {
return priority;
}
/**
@ -75,15 +80,15 @@ public class SRVData extends ForwardingMap<String, Object> {
* priority. Larger weights SHOULD be given a proportionately higher
* probability of being selected.
*/
public UnsignedInteger getWeight() {
return UnsignedInteger.class.cast(get("weight"));
public int getWeight() {
return weight;
}
/**
* The port on this target host of this service.
*/
public UnsignedInteger getPort() {
return UnsignedInteger.class.cast(get("port"));
public int getPort() {
return port;
}
/**
@ -91,7 +96,13 @@ public class SRVData extends ForwardingMap<String, Object> {
* records for this name, the name MUST NOT be an alias.
*/
public String getTarget() {
return String.class.cast(get("target"));
return target;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static SRVData.Builder builder() {
@ -103,31 +114,16 @@ public class SRVData extends ForwardingMap<String, Object> {
}
public final static class Builder {
private UnsignedInteger priority;
private UnsignedInteger weight;
private UnsignedInteger port;
private int priority = -1;
private int weight = -1;
private int port = -1;
private String target;
/**
* @see SRVData#getPriority()
*/
public SRVData.Builder priority(UnsignedInteger priority) {
this.priority = priority;
return this;
}
/**
* @see SRVData#getPriority()
*/
public SRVData.Builder priority(int priority) {
return priority(UnsignedInteger.fromIntBits(priority));
}
/**
* @see SRVData#getWeight()
*/
public SRVData.Builder weight(UnsignedInteger weight) {
this.weight = weight;
this.priority = priority;
return this;
}
@ -135,14 +131,7 @@ public class SRVData extends ForwardingMap<String, Object> {
* @see SRVData#getWeight()
*/
public SRVData.Builder weight(int weight) {
return weight(UnsignedInteger.fromIntBits(weight));
}
/**
* @see SRVData#getPort()
*/
public SRVData.Builder port(UnsignedInteger port) {
this.port = port;
this.weight = weight;
return this;
}
@ -150,7 +139,8 @@ public class SRVData extends ForwardingMap<String, Object> {
* @see SRVData#getPort()
*/
public SRVData.Builder port(int port) {
return port(UnsignedInteger.fromIntBits(port));
this.port = port;
return this;
}
/**

View File

@ -40,22 +40,26 @@ import com.google.common.collect.ImmutableMap;
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
*/
public class TXTData extends ForwardingMap<String, Object> {
private final ImmutableMap<String, Object> delegate;
private final String txtdata;
@ConstructorProperties("txtdata")
private TXTData(String txtdata) {
this.delegate = ImmutableMap.<String, Object> of("txtdata", checkNotNull(txtdata, "txtdata"));
}
protected Map<String, Object> delegate() {
return delegate;
this.txtdata = checkNotNull(txtdata, "txtdata");
this.delegate = ImmutableMap.<String, Object> of("txtdata", txtdata);
}
/**
* One or more character-strings.
*/
public String getTxtdata() {
return get("txtdata").toString();
return txtdata;
}
private final transient ImmutableMap<String, Object> delegate;
protected Map<String, Object> delegate() {
return delegate;
}
public static TXTData txt(String txtdata) {

View File

@ -128,7 +128,7 @@ public interface RecordAsyncApi {
.put("fqdn", in.getFQDN()).build());
return (R) request.toBuilder()
.endpoint(path)
.payload(json.toJson(ImmutableMap.of("rdata", ImmutableMap.copyOf(in.getRData()), "ttl", in.getTTL().intValue()))).build();
.payload(json.toJson(ImmutableMap.of("rdata", in.getRData(), "ttl", in.getTTL()))).build();
}
}

View File

@ -29,7 +29,6 @@ import com.google.common.base.Function;
import com.google.common.collect.BiMap;
import com.google.common.collect.ForwardingMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.primitives.UnsignedInteger;
/**
* Most UltraDNS commands use the numerical type value of a resource record
@ -41,8 +40,8 @@ import com.google.common.primitives.UnsignedInteger;
* @see org.jclouds.rest.annotations.ParamParser
*/
@Beta
public class ResourceTypeToValue extends ForwardingMap<String, UnsignedInteger> implements Function<Object, String>,
BiMap<String, UnsignedInteger> {
public class ResourceTypeToValue extends ForwardingMap<String, Integer> implements Function<Object, String>,
BiMap<String, Integer> {
/**
* look up the value (ex. {@code 28}) for the mnemonic name (ex. {@code AAAA}
@ -53,7 +52,7 @@ public class ResourceTypeToValue extends ForwardingMap<String, UnsignedInteger>
* @throws IllegalArgumentException
* if the type was not configured.
*/
public static UnsignedInteger lookup(String type) throws IllegalArgumentException {
public static Integer lookup(String type) throws IllegalArgumentException {
checkNotNull(type, "resource type was null");
checkArgument(lookup.containsKey(type), "%s do not include %s; types: %s", ResourceTypes.class.getSimpleName(),
type, EnumSet.allOf(ResourceTypes.class));
@ -113,22 +112,22 @@ public class ResourceTypeToValue extends ForwardingMap<String, UnsignedInteger>
*/
SRV(33);
private final UnsignedInteger value;
private final int value;
private ResourceTypes(int value) {
this.value = UnsignedInteger.fromIntBits(value);
this.value = value;
}
}
@Override
protected ImmutableBiMap<String, UnsignedInteger> delegate() {
protected ImmutableBiMap<String, Integer> delegate() {
return lookup;
}
private static final ImmutableBiMap<String, UnsignedInteger> lookup;
private static final ImmutableBiMap<String, Integer> lookup;
static {
ImmutableBiMap.Builder<String, UnsignedInteger> builder = ImmutableBiMap.builder();
ImmutableBiMap.Builder<String, Integer> builder = ImmutableBiMap.builder();
for (ResourceTypes r : EnumSet.allOf(ResourceTypes.class)) {
builder.put(r.name(), r.value);
}
@ -140,17 +139,17 @@ public class ResourceTypeToValue extends ForwardingMap<String, UnsignedInteger>
*/
@Deprecated
@Override
public UnsignedInteger forcePut(String key, UnsignedInteger value) {
public Integer forcePut(String key, Integer value) {
return lookup.forcePut(key, value);
}
@Override
public Set<UnsignedInteger> values() {
public Set<Integer> values() {
return lookup.values();
}
@Override
public BiMap<UnsignedInteger, String> inverse() {
public BiMap<Integer, String> inverse() {
return lookup.inverse();
}

View File

@ -21,6 +21,7 @@ package org.jclouds.ultradns.ws.domain;
import static com.google.common.base.Functions.toStringFunction;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Objects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.transform;
@ -30,7 +31,6 @@ import org.jclouds.ultradns.ws.ResourceTypeToValue;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.UnsignedInteger;
/**
* @author Adrian Cole
@ -38,14 +38,16 @@ import com.google.common.primitives.UnsignedInteger;
public class ResourceRecord {
private final String dName;
private final UnsignedInteger type;
private final UnsignedInteger ttl;
private final int type;
private final int ttl;
private final List<String> infoValues;
private ResourceRecord(String dName, UnsignedInteger type, UnsignedInteger ttl, List<String> infoValues) {
private ResourceRecord(String dName, int type, int ttl, List<String> infoValues) {
this.dName = checkNotNull(dName, "dName");
this.type = checkNotNull(type, "type of %s", dName);
this.ttl = checkNotNull(ttl, "ttl of %s", dName);
checkArgument(type >= 0, "type of %s must be unsigned", dName);
this.type = type;
checkArgument(ttl >= 0, "ttl of %s must be unsigned", dName);
this.ttl = ttl;
this.infoValues = checkNotNull(infoValues, "infoValues of %s", dName);
}
@ -59,11 +61,11 @@ public class ResourceRecord {
/**
* the type value. ex {@code 1} for type {@code A}
*/
public UnsignedInteger getType() {
public int getType() {
return type;
}
public UnsignedInteger getTTL() {
public int getTTL() {
return ttl;
}
@ -106,8 +108,8 @@ public class ResourceRecord {
public final static class Builder {
private String dName;
private UnsignedInteger type;
private UnsignedInteger ttl;
private int type = -1;
private int ttl = -1;
private ImmutableList.Builder<String> infoValues = ImmutableList.<String> builder();
/**
@ -132,26 +134,11 @@ public class ResourceRecord {
return this;
}
/**
* @see ResourceRecord#getType()
*/
public Builder type(UnsignedInteger type) {
this.type = type;
return this;
}
/**
* @see ResourceRecord#getType()
*/
public Builder type(int type) {
return type(UnsignedInteger.fromIntBits(type));
}
/**
* @see ResourceRecord#getTTL()
*/
public Builder ttl(UnsignedInteger ttl) {
this.ttl = ttl;
this.type = type;
return this;
}
@ -159,7 +146,8 @@ public class ResourceRecord {
* @see ResourceRecord#getTTL()
*/
public Builder ttl(int ttl) {
return ttl(UnsignedInteger.fromIntBits(ttl));
this.ttl = ttl;
return this;
}
/**

View File

@ -18,11 +18,11 @@
*/
package org.jclouds.ultradns.ws.domain;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.primitives.UnsignedInteger;
/**
*
@ -33,17 +33,18 @@ public final class Zone {
private final String id;
private final String name;
private final Type type;
private final UnsignedInteger typeCode;
private final int typeCode;
private final String accountId;
private final String ownerId;
private final DNSSECStatus dnssecStatus;
private final Optional<String> primarySrc;
private Zone(String id, String name, Type type, UnsignedInteger typeCode, String accountId, String ownerId,
private Zone(String id, String name, Type type, int typeCode, String accountId, String ownerId,
DNSSECStatus dnssecStatus, Optional<String> primarySrc) {
this.id = checkNotNull(id, "id");
this.name = checkNotNull(name, "name for %s", id);
this.typeCode = checkNotNull(typeCode, "typeCode for %s", name);
checkArgument(typeCode >= 0, "typeCode of %s must be unsigned", id);
this.typeCode = typeCode;
this.type = checkNotNull(type, "type for %s", name);
this.accountId = checkNotNull(accountId, "accountId for %s", name);
this.ownerId = checkNotNull(ownerId, "ownerId for %s", name);
@ -75,7 +76,7 @@ public final class Zone {
/**
* The type of the zone
*/
public UnsignedInteger getTypeCode() {
public int getTypeCode() {
return typeCode;
}
@ -136,13 +137,13 @@ public final class Zone {
PRIMARY(1), SECONDARY(2), ALIAS(3), UNRECOGNIZED(-1);
private final UnsignedInteger code;
private final int code;
Type(int code) {
this.code = UnsignedInteger.fromIntBits(code);
this.code = code;
}
public UnsignedInteger getCode() {
public int getCode() {
return code;
}
@ -152,11 +153,11 @@ public final class Zone {
}
public static Type fromValue(String type) {
return fromValue(UnsignedInteger.valueOf(checkNotNull(type, "type")));
return fromValue(Integer.parseInt(checkNotNull(type, "type")));
}
public static Type fromValue(UnsignedInteger code) {
switch (code.intValue()) {
public static Type fromValue(int code) {
switch (code) {
case 1:
return PRIMARY;
case 2:
@ -194,7 +195,7 @@ public final class Zone {
private String id;
private String name;
private Type type;
private UnsignedInteger typeCode;
private int typeCode = -1;
private String accountId;
private String ownerId;
private DNSSECStatus dnssecStatus;
@ -227,19 +228,12 @@ public final class Zone {
/**
* @see Zone#getTypeCode()
*/
public Builder typeCode(UnsignedInteger typeCode) {
public Builder typeCode(int typeCode) {
this.typeCode = typeCode;
this.type = Type.fromValue(typeCode);
return this;
}
/**
* @see ZoneProperties#getTypeCode()
*/
public Builder typeCode(int typeCode) {
return typeCode(UnsignedInteger.fromIntBits(typeCode));
}
/**
* @see Zone#getAccountId()
*/

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.ultradns.ws.domain;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date;
@ -25,7 +26,6 @@ import java.util.Date;
import org.jclouds.ultradns.ws.domain.Zone.Type;
import com.google.common.base.Objects;
import com.google.common.primitives.UnsignedInteger;
/**
*
@ -35,13 +35,14 @@ public final class ZoneProperties {
private final String name;
private final Type type;
private final UnsignedInteger typeCode;
private final int typeCode;
private final Date modified;
private final int resourceRecordCount;
private ZoneProperties(String name, Type type, UnsignedInteger typeCode, Date modified, int resourceRecordCount) {
private ZoneProperties(String name, Type type, int typeCode, Date modified, int resourceRecordCount) {
this.name = checkNotNull(name, "name");
this.typeCode = checkNotNull(typeCode, "typeCode for %s", name);
checkArgument(typeCode >= 0, "typeCode of %s must be unsigned", name);
this.typeCode = typeCode;
this.type = checkNotNull(type, "type for %s", name);
this.modified = checkNotNull(modified, "modified for %s", name);
this.resourceRecordCount = checkNotNull(resourceRecordCount, "resourceRecordCount for %s", name);
@ -64,7 +65,7 @@ public final class ZoneProperties {
/**
* The type of the zone
*/
public UnsignedInteger getTypeCode() {
public int getTypeCode() {
return typeCode;
}
@ -114,7 +115,7 @@ public final class ZoneProperties {
public final static class Builder {
private String name;
private Type type;
private UnsignedInteger typeCode;
private int typeCode = -1;
private Date modified;
private int resourceRecordCount;
@ -137,19 +138,12 @@ public final class ZoneProperties {
/**
* @see ZoneProperties#getTypeCode()
*/
public Builder typeCode(UnsignedInteger typeCode) {
public Builder typeCode(int typeCode) {
this.typeCode = typeCode;
this.type = Type.fromValue(typeCode);
return this;
}
/**
* @see ZoneProperties#getTypeCode()
*/
public Builder typeCode(int typeCode) {
return typeCode(UnsignedInteger.fromIntBits(typeCode));
}
/**
* @see ZoneProperties#getModified()
*/

View File

@ -25,7 +25,6 @@ import org.jclouds.ultradns.ws.domain.ResourceRecord;
import org.jclouds.ultradns.ws.domain.ResourceRecordMetadata;
import com.google.common.collect.FluentIterable;
import com.google.common.primitives.UnsignedInteger;
/**
* @see ResourceRecordAsyncApi
@ -88,12 +87,6 @@ public interface ResourceRecordApi {
* @throws ResourceNotFoundException
* if the zone doesn't exist
*/
FluentIterable<ResourceRecordMetadata> listByNameAndType(String hostName, UnsignedInteger rrType)
throws ResourceNotFoundException;
/**
* @see #listByNameAndType(String, UnsignedInteger)
*/
FluentIterable<ResourceRecordMetadata> listByNameAndType(String hostName, int rrType)
throws ResourceNotFoundException;
@ -101,7 +94,7 @@ public interface ResourceRecordApi {
* @param type
* the literal type defined in {@link ResourceTypeToValue}. ex
* {@code AAAA}
* @see #listByNameAndType(String, UnsignedInteger)
* @see #listByNameAndType(String, int)
*/
FluentIterable<ResourceRecordMetadata> listByNameAndType(String hostName, String type)
throws ResourceNotFoundException;

View File

@ -41,7 +41,6 @@ import org.jclouds.ultradns.ws.xml.GuidHandler;
import org.jclouds.ultradns.ws.xml.ResourceRecordListHandler;
import com.google.common.collect.FluentIterable;
import com.google.common.primitives.UnsignedInteger;
import com.google.common.util.concurrent.ListenableFuture;
/**
@ -92,17 +91,6 @@ public interface ResourceRecordAsyncApi {
ListenableFuture<FluentIterable<ResourceRecordMetadata>> listByName(@PayloadParam("hostName") String hostName)
throws ResourceNotFoundException;
/**
* @see ResourceRecordApi#listByNameAndType(String, UnsignedInteger)
*/
@Named("getResourceRecordsOfDNameByType")
@POST
@XMLResponseParser(ResourceRecordListHandler.class)
@Payload("<v01:getResourceRecordsOfDNameByType><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><rrType>{rrType}</rrType></v01:getResourceRecordsOfDNameByType>")
ListenableFuture<FluentIterable<ResourceRecordMetadata>> listByNameAndType(
@PayloadParam("hostName") String hostName, @PayloadParam("rrType") UnsignedInteger rrType)
throws ResourceNotFoundException;
/**
* @see ResourceRecordApi#listByNameAndType(String, int)
*/

View File

@ -25,7 +25,6 @@ import org.jclouds.ultradns.ws.domain.ResourceRecordMetadata;
import org.jclouds.ultradns.ws.domain.RoundRobinPool;
import com.google.common.collect.FluentIterable;
import com.google.common.primitives.UnsignedInteger;
/**
* @see RoundRobinPoolAsyncApi
@ -59,7 +58,7 @@ public interface RoundRobinPoolApi {
* @throws ResourceAlreadyExistsException
* if a record already exists with the same attrs
*/
String addARecordWithAddressAndTTL(String lbPoolID, String ipv4Address, UnsignedInteger ttl)
String addARecordWithAddressAndTTL(String lbPoolID, String ipv4Address, int ttl)
throws ResourceAlreadyExistsException;
/**
@ -89,7 +88,7 @@ public interface RoundRobinPoolApi {
* @throws ResourceAlreadyExistsException
* if a record already exists with the same attrs
*/
String addAAAARecordWithAddressAndTTL(String lbPoolID, String ipv6Address, UnsignedInteger ttl)
String addAAAARecordWithAddressAndTTL(String lbPoolID, String ipv6Address, int ttl)
throws ResourceAlreadyExistsException;
/**
@ -108,7 +107,7 @@ public interface RoundRobinPoolApi {
* @throws ResourceNotFoundException
* if the guid doesn't exist
*/
void updateRecordWithAddressAndTTL(String lbPoolID, String guid, String address, UnsignedInteger ttl)
void updateRecordWithAddressAndTTL(String lbPoolID, String guid, String address, int ttl)
throws ResourceNotFoundException;
/**

View File

@ -39,7 +39,6 @@ import org.jclouds.ultradns.ws.xml.ResourceRecordListHandler;
import org.jclouds.ultradns.ws.xml.RoundRobinPoolListHandler;
import com.google.common.collect.FluentIterable;
import com.google.common.primitives.UnsignedInteger;
import com.google.common.util.concurrent.ListenableFuture;
/**
@ -89,7 +88,7 @@ public interface RoundRobinPoolAsyncApi {
@XMLResponseParser(GuidHandler.class)
@Payload("<v01:addRecordToRRPool><transactionID /><roundRobinRecord lbPoolID=\"{lbPoolID}\" info1Value=\"{address}\" ZoneName=\"{zoneName}\" Type=\"1\" TTL=\"{ttl}\"/></v01:addRecordToRRPool>")
ListenableFuture<String> addARecordWithAddressAndTTL(@PayloadParam("lbPoolID") String lbPoolID,
@PayloadParam("address") String ipv4Address, @PayloadParam("ttl") UnsignedInteger ttl)
@PayloadParam("address") String ipv4Address, @PayloadParam("ttl") int ttl)
throws ResourceAlreadyExistsException;
/**
@ -100,7 +99,7 @@ public interface RoundRobinPoolAsyncApi {
@Payload("<v01:updateRecordOfRRPool><transactionID /><resourceRecord rrGuid=\"{guid}\" lbPoolID=\"{lbPoolID}\" info1Value=\"{address}\" TTL=\"{ttl}\"/></v01:updateRecordOfRRPool>")
ListenableFuture<Void> updateRecordWithAddressAndTTL(@PayloadParam("lbPoolID") String lbPoolID,
@PayloadParam("guid") String guid, @PayloadParam("address") String ipv4Address,
@PayloadParam("ttl") UnsignedInteger ttl) throws ResourceNotFoundException;
@PayloadParam("ttl") int ttl) throws ResourceNotFoundException;
/**
* @see RoundRobinPoolApi#deleteRecord(String)
@ -129,7 +128,7 @@ public interface RoundRobinPoolAsyncApi {
@XMLResponseParser(GuidHandler.class)
@Payload("<v01:addRecordToRRPool><transactionID /><roundRobinRecord lbPoolID=\"{lbPoolID}\" info1Value=\"{address}\" ZoneName=\"{zoneName}\" Type=\"28\" TTL=\"{ttl}\"/></v01:addRecordToRRPool>")
ListenableFuture<String> addAAAARecordWithAddressAndTTL(@PayloadParam("lbPoolID") String lbPoolID,
@PayloadParam("address") String ipv6Address, @PayloadParam("ttl") UnsignedInteger ttl)
@PayloadParam("address") String ipv6Address, @PayloadParam("ttl") int ttl)
throws ResourceAlreadyExistsException;
/**

View File

@ -29,7 +29,6 @@ import org.jclouds.ultradns.ws.domain.ResourceRecord;
import org.jclouds.ultradns.ws.domain.ResourceRecordMetadata;
import org.xml.sax.Attributes;
import com.google.common.primitives.UnsignedInteger;
import com.google.inject.Inject;
/**
@ -67,9 +66,9 @@ public class ResourceRecordMetadataHandler extends
rrm.zoneName(attributes.get("ZoneName"));
rrm.created(dateService.iso8601DateParse(attributes.get("Created")));
rrm.modified(dateService.iso8601DateParse(attributes.get("Modified")));
rr.type(UnsignedInteger.valueOf(attributes.get("Type")));
rr.type(Integer.parseInt(attributes.get("Type")));
rr.name(attributes.get("DName"));
rr.ttl(UnsignedInteger.valueOf(attributes.get("TTL")));
rr.ttl(Integer.parseInt(attributes.get("TTL")));
} else if (equalsOrSuffix(qName, "InfoValues")) {
rr.rdata(attributes.values());
}

View File

@ -29,7 +29,6 @@ import org.jclouds.ultradns.ws.domain.Zone;
import org.jclouds.ultradns.ws.domain.Zone.DNSSECStatus;
import org.xml.sax.Attributes;
import com.google.common.primitives.UnsignedInteger;
/**
*
@ -55,7 +54,7 @@ public class ZoneHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Z
zone = Zone.builder()
.id(attributes.get("zoneId"))
.name(attributes.get("zoneName"))
.typeCode(UnsignedInteger.valueOf(checkNotNull(attributes.get("zoneType"), "zoneType")))
.typeCode(Integer.parseInt(checkNotNull(attributes.get("zoneType"), "zoneType")))
.accountId(attributes.get("accountId"))
.ownerId(attributes.get("owner"))
.dnssecStatus(DNSSECStatus.fromValue(attributes.get("dnssecStatus")))

View File

@ -31,7 +31,6 @@ import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiExpectTest;
import org.jclouds.ultradns.ws.parse.GetResourceRecordsOfResourceRecordResponseTest;
import org.testng.annotations.Test;
import com.google.common.primitives.UnsignedInteger;
/**
* @author Adrian Cole
@ -127,7 +126,7 @@ public class ResourceRecordApiExpectTest extends BaseUltraDNSWSApiExpectTest {
assertEquals(
success.getResourceRecordApiForZone("jclouds.org.")
.listByNameAndType("www.jclouds.org.", UnsignedInteger.ONE).toString(),
.listByNameAndType("www.jclouds.org.", 1).toString(),
new GetResourceRecordsOfResourceRecordResponseTest().expected().toString());
assertEquals(success.getResourceRecordApiForZone("jclouds.org.").listByNameAndType("www.jclouds.org.", "A")

View File

@ -47,7 +47,6 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.BiMap;
import com.google.common.collect.FluentIterable;
import com.google.common.primitives.UnsignedInteger;
/**
* @author Adrian Cole
@ -77,7 +76,7 @@ public class ResourceRecordApiLiveTest extends BaseUltraDNSWSApiLiveTest {
static void checkResourceRecord(ResourceRecord rr) {
checkNotNull(rr.getName(), "DName cannot be null for a ResourceRecord %s", rr);
checkNotNull(rr.getType(), "Type cannot be null for a ResourceRecord %s", rr);
assertTrue(rr.getType().intValue() > 0, "Type must be positive for a ResourceRecord " + rr);
assertTrue(rr.getType() > 0, "Type must be unsigned for a ResourceRecord " + rr);
checkNotNull(rr.getType(), "Type cannot be null for a ResourceRecord %s", rr);
checkNotNull(rr.getTTL(), "TTL cannot be null for a ResourceRecord %s", rr);
checkNotNull(rr.getRData(), "InfoValues cannot be null for a ResourceRecord %s", rr);
@ -105,19 +104,19 @@ public class ResourceRecordApiLiveTest extends BaseUltraDNSWSApiLiveTest {
}
}
LoadingCache<UnsignedInteger, AtomicLong> recordTypeCounts = CacheBuilder.newBuilder().build(
new CacheLoader<UnsignedInteger, AtomicLong>() {
public AtomicLong load(UnsignedInteger key) throws Exception {
LoadingCache<Integer, AtomicLong> recordTypeCounts = CacheBuilder.newBuilder().build(
new CacheLoader<Integer, AtomicLong>() {
public AtomicLong load(Integer key) throws Exception {
return new AtomicLong();
}
});
private final static BiMap<UnsignedInteger, String> valueToType = new ResourceTypeToValue().inverse();
private final static BiMap<Integer, String> valueToType = new ResourceTypeToValue().inverse();
@AfterClass
void logSummary() {
getAnonymousLogger().info("zoneCount: " + zones);
for (Entry<UnsignedInteger, AtomicLong> entry : recordTypeCounts.asMap().entrySet())
for (Entry<Integer, AtomicLong> entry : recordTypeCounts.asMap().entrySet())
getAnonymousLogger().info(
String.format("type: %s, count: %s", valueToType.get(entry.getKey()), entry.getValue()));
}

View File

@ -42,7 +42,6 @@ import org.testng.annotations.Test;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.primitives.UnsignedInteger;
/**
* @author Adrian Cole
@ -122,21 +121,21 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
@Test(dependsOnMethods = "testCreateAPool")
public void addARecordToPool() {
aRecord1 = api(zoneName).addARecordWithAddressAndTTL(aPoolId, "1.2.3.4", UnsignedInteger.ONE);
aRecord1 = api(zoneName).addARecordWithAddressAndTTL(aPoolId, "1.2.3.4", 1);
getAnonymousLogger().info("created A record: " + aRecord1);
assertTrue(listRRs(aPoolId).anyMatch(
equalTo(rrBuilder().name(hostname).type("A").ttl(1).rdata("1.2.3.4").build())));
aRecord2 = api(zoneName).addARecordWithAddressAndTTL(aPoolId, "3.4.5.6", UnsignedInteger.ONE);
aRecord2 = api(zoneName).addARecordWithAddressAndTTL(aPoolId, "3.4.5.6", 1);
assertTrue(listRRs(aPoolId).anyMatch(
equalTo(rrBuilder().name(hostname).type("A").ttl(1).rdata("3.4.5.6").build())));
getAnonymousLogger().info("created A record: " + aRecord1);
try {
api(zoneName).addARecordWithAddressAndTTL(aPoolId, "1.2.3.4", UnsignedInteger.ONE);
api(zoneName).addARecordWithAddressAndTTL(aPoolId, "1.2.3.4", 1);
fail();
} catch (ResourceAlreadyExistsException e) {
@ -145,7 +144,7 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
@Test(dependsOnMethods = "addARecordToPool")
public void testUpdateRecord() {
api(zoneName).updateRecordWithAddressAndTTL(aPoolId, aRecord1, "1.1.1.1", UnsignedInteger.ZERO);
api(zoneName).updateRecordWithAddressAndTTL(aPoolId, aRecord1, "1.1.1.1", 0);
assertTrue(listRRs(aPoolId).anyMatch(
equalTo(rrBuilder().name(hostname).type("A").ttl(0).rdata("1.1.1.1").build())));
}
@ -190,7 +189,7 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
@Test(dependsOnMethods = "testCreateAAAAPool")
public void addAAAARecordToPool() {
aaaaRecord1 = api(zoneName).addAAAARecordWithAddressAndTTL(aaaaPoolId, "2001:0DB8:85A3:0000:0000:8A2E:0370:7334",
UnsignedInteger.ONE);
1);
getAnonymousLogger().info("created AAAA record: " + aaaaRecord1);
@ -199,7 +198,7 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
.build())));
aaaaRecord2 = api(zoneName).addAAAARecordWithAddressAndTTL(aaaaPoolId, "2002:0DB8:85A3:0000:0000:8A2E:0370:7334",
UnsignedInteger.ONE);
1);
assertTrue(listRRs(aaaaPoolId).anyMatch(
equalTo(rrBuilder().name(hostname).type("AAAA").ttl(1).rdata("2002:0DB8:85A3:0000:0000:8A2E:0370:7334")
@ -207,8 +206,7 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
getAnonymousLogger().info("created AAAA record: " + aaaaRecord1);
try {
api(zoneName).addAAAARecordWithAddressAndTTL(aaaaPoolId, "2001:0DB8:85A3:0000:0000:8A2E:0370:7334",
UnsignedInteger.ONE);
api(zoneName).addAAAARecordWithAddressAndTTL(aaaaPoolId, "2001:0DB8:85A3:0000:0000:8A2E:0370:7334", 1);
fail();
} catch (ResourceAlreadyExistsException e) {