mirror of https://github.com/apache/jclouds.git
Merge pull request #1454 from jclouds/ultradns-tcpool-recordupdate
update pool record support in ultradns
This commit is contained in:
commit
420f332a08
|
@ -17,24 +17,25 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class UltraDNSWSError {
|
||||
public static UltraDNSWSError fromCodeAndDescription(int code, String description) {
|
||||
public static UltraDNSWSError fromCodeAndDescription(int code, Optional<String> description) {
|
||||
return new UltraDNSWSError(code, description);
|
||||
}
|
||||
|
||||
private final int code;
|
||||
private final String description;
|
||||
private final Optional<String> description;
|
||||
|
||||
private UltraDNSWSError(int code, String description) {
|
||||
private UltraDNSWSError(int code, Optional<String> description) {
|
||||
this.code = code;
|
||||
this.description = checkNotNull(description, "description for code %s", code);
|
||||
}
|
||||
|
@ -49,7 +50,7 @@ public final class UltraDNSWSError {
|
|||
/**
|
||||
* The description of the error. ex {@code Zone does not exist in the system.}
|
||||
*/
|
||||
public String getDescription() {
|
||||
public Optional<String> getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
@ -70,6 +71,6 @@ public final class UltraDNSWSError {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Error %s: %s", code, description);
|
||||
return description.isPresent() ? format("Error %s: %s", code, description.get()) : format("Error %s", code);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.binders;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.MapBinder;
|
||||
import org.jclouds.ultradns.ws.domain.UpdatePoolRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class UpdatePoolRecordToXML implements MapBinder {
|
||||
private static final String HEADER = "<v01:updatePoolRecord><transactionID /><poolRecordID>%s</poolRecordID><parentPoolId /><childPoolId />";
|
||||
private static final String FOOTER = "</v01:updatePoolRecord>";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
|
||||
|
||||
StringBuilder xml = new StringBuilder();
|
||||
xml.append(format(HEADER, postParams.get("poolRecordID")));
|
||||
|
||||
UpdatePoolRecord update = UpdatePoolRecord.class.cast(postParams.get("update"));
|
||||
|
||||
xml.append("<pointsTo>").append(update.getPointsTo()).append("</pointsTo>");
|
||||
xml.append("<priority>").append(update.getPriority()).append("</priority>");
|
||||
xml.append("<failOverDelay>").append(update.getFailOverDelay()).append("</failOverDelay>");
|
||||
xml.append("<ttl>").append(update.getTTL()).append("</ttl>");
|
||||
xml.append("<weight>").append(update.getWeight()).append("</weight>");
|
||||
xml.append("<mode>").append(update.getMode()).append("</mode>");
|
||||
xml.append("<threshold>").append(update.getThreshold()).append("</threshold>");
|
||||
|
||||
xml.append(FOOTER);
|
||||
return (R) request.toBuilder().payload(xml.toString()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||
throw new UnsupportedOperationException("use map form");
|
||||
}
|
||||
}
|
|
@ -47,13 +47,13 @@ public final class PoolRecordSpec {
|
|||
this.probingEnabled = probingEnabled;
|
||||
this.allFailEnabled = allFailEnabled;
|
||||
this.weight = weight;
|
||||
checkArgument(weight >= 0, "weight of %s must be unsigned", description);
|
||||
checkArgument(weight >= 0, "weight of %s must be >= 0", description);
|
||||
this.failOverDelay = failOverDelay;
|
||||
checkArgument(failOverDelay >= 0, "failOverDelay of %s must be unsigned", description);
|
||||
checkArgument(failOverDelay >= 0, "failOverDelay of %s must be >= 0", description);
|
||||
this.threshold = threshold;
|
||||
checkArgument(threshold >= 0, "threshold of %s must be unsigned", description);
|
||||
checkArgument(threshold >= 0, "threshold of %s must be >= 0", description);
|
||||
this.ttl = ttl;
|
||||
checkArgument(ttl >= 0, "ttl of %s must be unsigned", description);
|
||||
checkArgument(ttl >= 0, "ttl of %s must be >= 0", description);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,8 +114,8 @@ public final class PoolRecordSpec {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects
|
||||
.hashCode(description, state, probingEnabled, allFailEnabled, weight, failOverDelay, threshold, ttl);
|
||||
return Objects.hashCode(description, state, probingEnabled, allFailEnabled, weight, failOverDelay, threshold,
|
||||
ttl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,9 +42,9 @@ public class ResourceRecord {
|
|||
|
||||
private ResourceRecord(String dName, int type, int ttl, List<String> infoValues) {
|
||||
this.dName = checkNotNull(dName, "dName");
|
||||
checkArgument(type >= 0, "type of %s must be unsigned", dName);
|
||||
checkArgument(type >= 0, "type of %s must be >= 0", dName);
|
||||
this.type = type;
|
||||
checkArgument(ttl >= 0, "ttl of %s must be unsigned", dName);
|
||||
checkArgument(ttl >= 0, "ttl of %s must be >= 0", dName);
|
||||
this.ttl = ttl;
|
||||
this.infoValues = checkNotNull(infoValues, "infoValues of %s", dName);
|
||||
}
|
||||
|
|
|
@ -46,9 +46,9 @@ public final class TrafficControllerPoolRecord {
|
|||
this.id = checkNotNull(id, "id");
|
||||
this.poolId = checkNotNull(poolId, "poolId for %s", id);
|
||||
this.pointsTo = checkNotNull(pointsTo, "pointsTo for %s", poolId);
|
||||
checkArgument(weight >= 0, "weight of %s must be unsigned", id);
|
||||
checkArgument(weight >= 0, "weight of %s must be >= 0", id);
|
||||
this.weight = weight;
|
||||
checkArgument(priority >= 0, "priority of %s must be unsigned", id);
|
||||
checkArgument(priority >= 0, "priority of %s must be >= 0", id);
|
||||
this.priority = priority;
|
||||
this.type = checkNotNull(type, "type for %s", poolId);
|
||||
this.forceAnswer = checkNotNull(forceAnswer, "forceAnswer for %s", poolId);
|
||||
|
|
|
@ -0,0 +1,232 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.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 com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* holds updates for a record
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class UpdatePoolRecord {
|
||||
|
||||
/**
|
||||
* @param spec what to prime updates from
|
||||
* @param pointsTo new value to point to.
|
||||
*/
|
||||
public static UpdatePoolRecord pointingTo(PoolRecordSpec spec, String pointsTo) {
|
||||
return new Builder().from(spec).pointsTo(pointsTo).build();
|
||||
}
|
||||
|
||||
private final String pointsTo;
|
||||
private final String mode;
|
||||
private final int priority;
|
||||
private final int weight;
|
||||
private final int failOverDelay;
|
||||
private final int threshold;
|
||||
private final int ttl;
|
||||
|
||||
private UpdatePoolRecord(String pointsTo, String mode, int priority, int weight, int failOverDelay, int threshold,
|
||||
int ttl) {
|
||||
this.pointsTo = checkNotNull(pointsTo, "pointsTo");
|
||||
this.mode = checkNotNull(mode, "mode for %s", pointsTo);
|
||||
this.priority = priority;
|
||||
this.weight = weight;
|
||||
checkArgument(weight >= 0, "weight of %s must be >= 0", pointsTo);
|
||||
this.failOverDelay = failOverDelay;
|
||||
checkArgument(failOverDelay >= 0, "failOverDelay of %s must be >= 0", pointsTo);
|
||||
this.threshold = threshold;
|
||||
checkArgument(threshold >= 0, "threshold of %s must be >= 0", pointsTo);
|
||||
this.ttl = ttl;
|
||||
checkArgument(ttl >= 0, "ttl of %s must be >= 0", pointsTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* correlates to {@link TrafficControllerPoolRecord#getPointsTo()}
|
||||
*/
|
||||
public String getPointsTo() {
|
||||
return pointsTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* correlates to {@link PoolRecordSpec#getState()}
|
||||
*/
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* correlates to {@link PoolRecordSpec#getPriority()}
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* correlates to {@link PoolRecordSpec#getWeight()}
|
||||
*/
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* correlates to {@link PoolRecordSpec#getFailOverDelay()}
|
||||
*/
|
||||
public int getFailOverDelay() {
|
||||
return failOverDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* correlates to {@link PoolRecordSpec#getThreshold()}
|
||||
*/
|
||||
public int getThreshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* correlates to {@link PoolRecordSpec#getTTL()}
|
||||
*/
|
||||
public int getTTL() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(pointsTo, mode, priority, weight, failOverDelay, threshold, ttl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
UpdatePoolRecord that = UpdatePoolRecord.class.cast(obj);
|
||||
return equal(this.pointsTo, that.pointsTo) && equal(this.mode, that.mode) && equal(this.priority, that.priority)
|
||||
&& equal(this.weight, that.weight) && equal(this.failOverDelay, that.failOverDelay)
|
||||
&& equal(this.threshold, that.threshold) && equal(this.ttl, that.ttl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper(this).add("pointsTo", pointsTo).add("mode", mode).add("priority", priority)
|
||||
.add("weight", weight).add("failOverDelay", failOverDelay).add("threshold", threshold).add("ttl", ttl)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().from(this);
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String pointsTo;
|
||||
private String mode;
|
||||
private int priority;
|
||||
private int weight;
|
||||
private int failOverDelay;
|
||||
private int threshold;
|
||||
private int ttl;
|
||||
|
||||
/**
|
||||
* @see UpdatePoolRecord#getPointsTo()
|
||||
*/
|
||||
public Builder pointsTo(String pointsTo) {
|
||||
this.pointsTo = pointsTo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UpdatePoolRecord#getMode()
|
||||
*/
|
||||
public Builder mode(String mode) {
|
||||
this.mode = mode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UpdatePoolRecord#getPriority()
|
||||
*/
|
||||
public Builder priority(int priority) {
|
||||
this.priority = priority;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UpdatePoolRecord#getWeight()
|
||||
*/
|
||||
public Builder weight(int weight) {
|
||||
this.weight = weight;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UpdatePoolRecord#getFailOverDelay()
|
||||
*/
|
||||
public Builder failOverDelay(int failOverDelay) {
|
||||
this.failOverDelay = failOverDelay;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UpdatePoolRecord#getThreshold()
|
||||
*/
|
||||
public Builder threshold(int threshold) {
|
||||
this.threshold = threshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UpdatePoolRecord#getTTL()
|
||||
*/
|
||||
public Builder ttl(int ttl) {
|
||||
this.ttl = ttl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UpdatePoolRecord build() {
|
||||
return new UpdatePoolRecord(pointsTo, mode, priority, weight, failOverDelay, threshold, ttl);
|
||||
}
|
||||
|
||||
public Builder from(PoolRecordSpec in) {
|
||||
return this.mode(in.getState()).weight(in.getWeight()).failOverDelay(in.getFailOverDelay())
|
||||
.threshold(in.getThreshold()).ttl(in.getTTL());
|
||||
}
|
||||
|
||||
public Builder from(TrafficControllerPoolRecord in) {
|
||||
return this.weight(in.getWeight()).pointsTo(in.getPointsTo()).priority(in.getPriority());
|
||||
}
|
||||
|
||||
public Builder from(UpdatePoolRecord in) {
|
||||
return this.pointsTo(in.pointsTo).mode(in.mode).priority(in.priority).weight(in.weight)
|
||||
.failOverDelay(in.failOverDelay).threshold(in.threshold).ttl(in.ttl);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ public final class Zone {
|
|||
DNSSECStatus dnssecStatus, Optional<String> primarySrc) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name for %s", id);
|
||||
checkArgument(typeCode >= 0, "typeCode of %s must be unsigned", id);
|
||||
checkArgument(typeCode >= 0, "typeCode of %s must be >= 0", id);
|
||||
this.typeCode = typeCode;
|
||||
this.type = checkNotNull(type, "type for %s", name);
|
||||
this.accountId = checkNotNull(accountId, "accountId for %s", name);
|
||||
|
|
|
@ -41,7 +41,7 @@ public final class ZoneProperties {
|
|||
|
||||
private ZoneProperties(String name, Type type, int typeCode, Date modified, int resourceRecordCount) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
checkArgument(typeCode >= 0, "typeCode of %s must be unsigned", name);
|
||||
checkArgument(typeCode >= 0, "typeCode of %s must be >= 0", name);
|
||||
this.typeCode = typeCode;
|
||||
this.type = checkNotNull(type, "type for %s", name);
|
||||
this.modified = checkNotNull(modified, "modified for %s", name);
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.jclouds.ultradns.ws.binders.ZoneAndResourceRecordToXML;
|
|||
import org.jclouds.ultradns.ws.domain.ResourceRecord;
|
||||
import org.jclouds.ultradns.ws.domain.ResourceRecordMetadata;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ElementTextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ResourceRecordListHandler;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
@ -56,7 +56,7 @@ public interface ResourceRecordAsyncApi {
|
|||
*/
|
||||
@Named("createResourceRecord")
|
||||
@POST
|
||||
@XMLResponseParser(TextHandler.Guid.class)
|
||||
@XMLResponseParser(ElementTextHandler.Guid.class)
|
||||
@MapBinder(ZoneAndResourceRecordToXML.class)
|
||||
ListenableFuture<String> create(@PayloadParam("resourceRecord") ResourceRecord toCreate)
|
||||
throws ResourceAlreadyExistsException;
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsExcepti
|
|||
import org.jclouds.ultradns.ws.domain.ResourceRecord;
|
||||
import org.jclouds.ultradns.ws.domain.RoundRobinPool;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ElementTextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ResourceRecordListHandler;
|
||||
import org.jclouds.ultradns.ws.xml.RoundRobinPoolListHandler;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public interface RoundRobinPoolAsyncApi {
|
|||
*/
|
||||
@Named("addRRLBPool")
|
||||
@POST
|
||||
@XMLResponseParser(TextHandler.RRPoolID.class)
|
||||
@XMLResponseParser(ElementTextHandler.RRPoolID.class)
|
||||
@Payload("<v01:addRRLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>1</poolRecordType><rrGUID /></v01:addRRLBPool>")
|
||||
ListenableFuture<String> createAPoolForHostname(@PayloadParam("description") String name,
|
||||
@PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException;
|
||||
|
@ -84,7 +84,7 @@ public interface RoundRobinPoolAsyncApi {
|
|||
*/
|
||||
@Named("addRecordToRRPool")
|
||||
@POST
|
||||
@XMLResponseParser(TextHandler.Guid.class)
|
||||
@XMLResponseParser(ElementTextHandler.Guid.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") int ttl)
|
||||
|
@ -114,7 +114,7 @@ public interface RoundRobinPoolAsyncApi {
|
|||
*/
|
||||
@Named("addRRLBPool")
|
||||
@POST
|
||||
@XMLResponseParser(TextHandler.RRPoolID.class)
|
||||
@XMLResponseParser(ElementTextHandler.RRPoolID.class)
|
||||
@Payload("<v01:addRRLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>28</poolRecordType><rrGUID /></v01:addRRLBPool>")
|
||||
ListenableFuture<String> createAAAAPoolForHostname(@PayloadParam("description") String name,
|
||||
@PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException;
|
||||
|
@ -124,7 +124,7 @@ public interface RoundRobinPoolAsyncApi {
|
|||
*/
|
||||
@Named("addRecordToRRPool")
|
||||
@POST
|
||||
@XMLResponseParser(TextHandler.Guid.class)
|
||||
@XMLResponseParser(ElementTextHandler.Guid.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") int ttl)
|
||||
|
|
|
@ -36,8 +36,6 @@ public interface TaskApi {
|
|||
String runTest(String value);
|
||||
|
||||
/**
|
||||
* Retrieves information about the specified task
|
||||
*
|
||||
* @param guid
|
||||
* guid of the task to get information about.
|
||||
* @return null if not found
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jclouds.rest.annotations.VirtualHost;
|
|||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.ultradns.ws.domain.Task;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ElementTextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TaskHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TaskListHandler;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public interface TaskAsyncApi {
|
|||
*/
|
||||
@Named("runTest")
|
||||
@POST
|
||||
@XMLResponseParser(TextHandler.Guid.class)
|
||||
@XMLResponseParser(ElementTextHandler.Guid.class)
|
||||
@Payload("<v01:runTest><value>{value}</value></v01:runTest>")
|
||||
ListenableFuture<String> runTest(@PayloadParam("value") String value);
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ import org.jclouds.javax.annotation.Nullable;
|
|||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException;
|
||||
import org.jclouds.ultradns.ws.domain.PoolRecordSpec;
|
||||
import org.jclouds.ultradns.ws.domain.ResourceRecord;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord;
|
||||
import org.jclouds.ultradns.ws.domain.UpdatePoolRecord;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
|
@ -83,14 +83,14 @@ public interface TrafficControllerPoolApi {
|
|||
FluentIterable<TrafficControllerPoolRecord> listRecords(String poolId) throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* adds a new record to the pool
|
||||
* adds a new record to the pool with default weight.
|
||||
*
|
||||
* @param pointsTo
|
||||
* the ipv4 address or hostname
|
||||
* @param lbPoolID
|
||||
* the pool to add the record to.
|
||||
* @param ttl
|
||||
* the {@link ResourceRecord#getTTL ttl} of the record
|
||||
* the {@link PoolRecordSpec#getTTL ttl} of the record
|
||||
* @return the {@link TrafficControllerPoolRecord#getId() id} of the new
|
||||
* record
|
||||
* @throws ResourceAlreadyExistsException
|
||||
|
@ -99,15 +99,46 @@ public interface TrafficControllerPoolApi {
|
|||
String addRecordToPoolWithTTL(String pointsTo, String lbPoolID, int ttl) throws ResourceAlreadyExistsException;
|
||||
|
||||
/**
|
||||
* Retrieves information about the specified pool record
|
||||
* adds a new record to the pool with a specified weight.
|
||||
*
|
||||
* @param pointsTo
|
||||
* the ipv4 address or hostname
|
||||
* @param lbPoolID
|
||||
* the pool to add the record to.
|
||||
* @param ttl
|
||||
* the {@link PoolRecordSpec#getTTL ttl} of the record
|
||||
* @param weight
|
||||
* the {@link PoolRecordSpec#getWeight() weight} of the record
|
||||
* @return the {@link TrafficControllerPoolRecord#getId() id} of the new
|
||||
* record
|
||||
* @throws ResourceAlreadyExistsException
|
||||
* if a record already exists with the same attrs
|
||||
*/
|
||||
String addRecordToPoolWithTTLAndWeight(String pointsTo, String lbPoolID, int ttl, int weight)
|
||||
throws ResourceAlreadyExistsException;
|
||||
|
||||
/**
|
||||
* @param poolRecordID
|
||||
* {@see TrafficControllerPoolRecord#getId()}
|
||||
* {@link TrafficControllerPoolRecord#getId()}
|
||||
* @return null if not found
|
||||
*/
|
||||
@Nullable
|
||||
PoolRecordSpec getRecordSpec(String poolRecordID);
|
||||
|
||||
/**
|
||||
* This request updates an existing pool record.
|
||||
*
|
||||
* @param poolRecordID
|
||||
* {@link TrafficControllerPoolRecord#getId()}
|
||||
* @param update
|
||||
* what to update, usually primed via
|
||||
* {@link UpdatePoolRecord#pointingTo(PoolRecordSpec, String)} or
|
||||
* {@link org.jclouds.ultradns.ws.domain.UpdatePoolRecord.Builder#from(PoolRecordSpec)}
|
||||
* @throws ResourceNotFoundException
|
||||
* if the record doesn't exist
|
||||
*/
|
||||
void updateRecord(String poolRecordID, UpdatePoolRecord update) throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* deletes a specific pooled resource record
|
||||
*
|
||||
|
|
|
@ -25,19 +25,22 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
|||
import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.rest.annotations.Fallback;
|
||||
import org.jclouds.rest.annotations.MapBinder;
|
||||
import org.jclouds.rest.annotations.Payload;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException;
|
||||
import org.jclouds.ultradns.ws.binders.UpdatePoolRecordToXML;
|
||||
import org.jclouds.ultradns.ws.domain.PoolRecordSpec;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord;
|
||||
import org.jclouds.ultradns.ws.domain.UpdatePoolRecord;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.AttributeHandler;
|
||||
import org.jclouds.ultradns.ws.xml.PoolRecordSpecHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ElementTextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TrafficControllerPoolListHandler;
|
||||
import org.jclouds.ultradns.ws.xml.TrafficControllerPoolRecordListHandler;
|
||||
|
||||
|
@ -59,7 +62,7 @@ public interface TrafficControllerPoolAsyncApi {
|
|||
*/
|
||||
@Named("addTCLBPool")
|
||||
@POST
|
||||
@XMLResponseParser(TextHandler.TCPoolID.class)
|
||||
@XMLResponseParser(ElementTextHandler.TCPoolID.class)
|
||||
@Payload("<v01:addTCLBPool><transactionID /><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><description>{description}</description><poolRecordType>1</poolRecordType><failOver>Enabled</failOver><probing>Enabled</probing><maxActive>0</maxActive><rrGUID /></v01:addTCLBPool>")
|
||||
ListenableFuture<String> createPoolForHostname(@PayloadParam("description") String name,
|
||||
@PayloadParam("hostName") String hostname) throws ResourceAlreadyExistsException;
|
||||
|
@ -107,11 +110,22 @@ public interface TrafficControllerPoolAsyncApi {
|
|||
*/
|
||||
@Named("addPoolRecord")
|
||||
@POST
|
||||
@XMLResponseParser(TextHandler.PoolRecordID.class)
|
||||
@XMLResponseParser(ElementTextHandler.PoolRecordID.class)
|
||||
@Payload("<v01:addPoolRecord><transactionID /><poolID>{poolID}</poolID><pointsTo>{pointsTo}</pointsTo><priority /><failOverDelay /><ttl>{ttl}</ttl><weight /><mode /><threshold /></v01:addPoolRecord>")
|
||||
ListenableFuture<String> addRecordToPoolWithTTL(@PayloadParam("pointsTo") String pointsTo,
|
||||
@PayloadParam("poolID") String lbPoolID, @PayloadParam("ttl") int ttl) throws ResourceAlreadyExistsException;
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPoolApi#addRecordToPoolWithTTLAndWeight
|
||||
*/
|
||||
@Named("addPoolRecord")
|
||||
@POST
|
||||
@XMLResponseParser(ElementTextHandler.PoolRecordID.class)
|
||||
@Payload("<v01:addPoolRecord><transactionID /><poolID>{poolID}</poolID><pointsTo>{pointsTo}</pointsTo><priority /><failOverDelay /><ttl>{ttl}</ttl><weight>{weight}</weight><mode /><threshold /></v01:addPoolRecord>")
|
||||
ListenableFuture<String> addRecordToPoolWithTTLAndWeight(@PayloadParam("pointsTo") String pointsTo,
|
||||
@PayloadParam("poolID") String lbPoolID, @PayloadParam("ttl") int ttl, @PayloadParam("weight") int weight)
|
||||
throws ResourceAlreadyExistsException;
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPoolApi#getRecordSpec(String)
|
||||
*/
|
||||
|
@ -122,6 +136,15 @@ public interface TrafficControllerPoolAsyncApi {
|
|||
@Fallback(NullOnNotFoundOr404.class)
|
||||
ListenableFuture<PoolRecordSpec> getRecordSpec(@PayloadParam("poolRecordId") String poolRecordID);
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPoolApi#getRecordSpec(String)
|
||||
*/
|
||||
@Named("updatePoolRecord>")
|
||||
@POST
|
||||
@MapBinder(UpdatePoolRecordToXML.class)
|
||||
ListenableFuture<Void> updateRecord(@PayloadParam("poolRecordID") String poolRecordID,
|
||||
@PayloadParam("update") UpdatePoolRecord update) throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPoolApi#deleteRecord(String)
|
||||
*/
|
||||
|
|
|
@ -45,8 +45,6 @@ public interface ZoneApi {
|
|||
void createInAccount(String name, String accountId) throws ResourceAlreadyExistsException;
|
||||
|
||||
/**
|
||||
* Retrieves information about the specified zone
|
||||
*
|
||||
* @param name
|
||||
* the fully-qualified name, including the trailing dot, of the
|
||||
* zone to get information about.
|
||||
|
|
|
@ -78,10 +78,7 @@ public class UltraDNSWSErrorHandler implements HttpErrorHandler {
|
|||
* there are 51002 potential codes. This defines the ones we are handling.
|
||||
*/
|
||||
static final class ErrorCodes {
|
||||
/**
|
||||
* Cannot find task with guid.
|
||||
*/
|
||||
static final int TASK_NOT_FOUND = 0;
|
||||
static final int UNKNOWN = 0;
|
||||
/**
|
||||
* Zone does not exist in the system.
|
||||
*/
|
||||
|
@ -117,18 +114,23 @@ public class UltraDNSWSErrorHandler implements HttpErrorHandler {
|
|||
}
|
||||
|
||||
private Exception refineException(UltraDNSWSResponseException exception) {
|
||||
String message = exception.getError().getDescription().or(exception.getMessage());
|
||||
switch (exception.getError().getCode()) {
|
||||
case TASK_NOT_FOUND:
|
||||
case UNKNOWN:
|
||||
if (!exception.getError().getDescription().isPresent())
|
||||
return exception;
|
||||
if (exception.getError().getDescription().get().indexOf("Cannot find") == -1)
|
||||
return exception;
|
||||
case ZONE_NOT_FOUND:
|
||||
case RESOURCE_RECORD_NOT_FOUND:
|
||||
case ACCOUNT_NOT_FOUND:
|
||||
case POOL_NOT_FOUND:
|
||||
case POOL_RECORD_NOT_FOUND:
|
||||
return new ResourceNotFoundException(exception.getError().getDescription(), exception);
|
||||
return new ResourceNotFoundException(message, exception);
|
||||
case ZONE_ALREADY_EXISTS:
|
||||
case RESOURCE_RECORD_ALREADY_EXISTS:
|
||||
case POOL_ALREADY_EXISTS:
|
||||
return new ResourceAlreadyExistsException(exception.getError().getDescription(), exception);
|
||||
return new ResourceAlreadyExistsException(message, exception);
|
||||
}
|
||||
return exception;
|
||||
}
|
||||
|
|
|
@ -32,15 +32,6 @@ import com.google.common.base.Predicate;
|
|||
*/
|
||||
public class TrafficControllerPoolPredicates {
|
||||
|
||||
/**
|
||||
* evaluates to true if the input {@link TrafficControllerPool} exists
|
||||
* with {@link TrafficControllerPool#getId() id} corresponding to the
|
||||
* {@code id} parameter.
|
||||
*
|
||||
* @param id
|
||||
* the {@link TrafficControllerPool#getId() id} of the
|
||||
* desired pool record
|
||||
*/
|
||||
public static Predicate<TrafficControllerPool> idEqualTo(String id) {
|
||||
return new IdEqualToPredicate(id);
|
||||
}
|
||||
|
@ -54,9 +45,7 @@ public class TrafficControllerPoolPredicates {
|
|||
|
||||
@Override
|
||||
public boolean apply(TrafficControllerPool input) {
|
||||
if (input == null)
|
||||
return false;
|
||||
return id.equals(input.getId());
|
||||
return input != null && id.equals(input.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,36 +54,25 @@ public class TrafficControllerPoolPredicates {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* evaluates to true if the input {@link TrafficControllerPoolRecord} exists
|
||||
* with {@link TrafficControllerPoolRecord#getId() id} corresponding to the
|
||||
* {@code recordId} parameter.
|
||||
*
|
||||
* @param recordId
|
||||
* the {@link TrafficControllerPoolRecord#getId() id} of the
|
||||
* desired pool record
|
||||
*/
|
||||
public static Predicate<TrafficControllerPoolRecord> recordIdEqualTo(String recordId) {
|
||||
return new RecordIdEqualToPredicate(recordId);
|
||||
}
|
||||
|
||||
private static final class RecordIdEqualToPredicate implements Predicate<TrafficControllerPoolRecord> {
|
||||
private final String id;
|
||||
private final String recordId;
|
||||
|
||||
public RecordIdEqualToPredicate(String id) {
|
||||
this.id = checkNotNull(id, "recordId");
|
||||
public RecordIdEqualToPredicate(String recordId) {
|
||||
this.recordId = checkNotNull(recordId, "recordId");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(TrafficControllerPoolRecord input) {
|
||||
if (input == null)
|
||||
return false;
|
||||
return id.equals(input.getId());
|
||||
return input != null && recordId.equals(input.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RecordIdEqualTo(" + id + ")";
|
||||
return "RecordIdEqualTo(" + recordId + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,22 +32,25 @@ import com.google.common.base.Predicate;
|
|||
*/
|
||||
public class ZonePredicates {
|
||||
|
||||
/**
|
||||
* matches zones of the given type
|
||||
*/
|
||||
public static Predicate<Zone> typeEquals(final Type type) {
|
||||
checkNotNull(type, "type must be defined");
|
||||
public static Predicate<Zone> typeEqualTo(Type type) {
|
||||
return new TypeEqualToPredicate(type);
|
||||
}
|
||||
|
||||
return new Predicate<Zone>() {
|
||||
@Override
|
||||
public boolean apply(Zone zone) {
|
||||
return type.equals(zone.getType());
|
||||
}
|
||||
private static final class TypeEqualToPredicate implements Predicate<Zone> {
|
||||
private final Type type;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "typeEquals(" + type + ")";
|
||||
}
|
||||
};
|
||||
public TypeEqualToPredicate(Type type) {
|
||||
this.type = checkNotNull(type, "type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Zone input) {
|
||||
return input != null && type.equals(input.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TypeEqualTo(" + type + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public abstract class AttributeHandler extends ParseSax.HandlerForGeneratedReque
|
|||
}
|
||||
}
|
||||
|
||||
private String attributeName;
|
||||
private final String attributeName;
|
||||
private String attribute = null;
|
||||
|
||||
private AttributeHandler(String attributeName) {
|
||||
|
@ -46,11 +46,7 @@ public abstract class AttributeHandler extends ParseSax.HandlerForGeneratedReque
|
|||
|
||||
@Override
|
||||
public String getResult() {
|
||||
try {
|
||||
return checkNotNull(attribute, "%s not present in the response", attributeName);
|
||||
} finally {
|
||||
attribute = null;
|
||||
}
|
||||
return checkNotNull(attribute, "%s not present in the response", attributeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,48 +28,44 @@ import org.jclouds.http.functions.ParseSax;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class TextHandler extends ParseSax.HandlerForGeneratedRequestWithResult<String> {
|
||||
public abstract class ElementTextHandler extends ParseSax.HandlerForGeneratedRequestWithResult<String> {
|
||||
|
||||
public static class Guid extends TextHandler {
|
||||
public static class Guid extends ElementTextHandler {
|
||||
public Guid() {
|
||||
super("guid");
|
||||
}
|
||||
}
|
||||
|
||||
public static class RRPoolID extends TextHandler {
|
||||
public static class RRPoolID extends ElementTextHandler {
|
||||
public RRPoolID() {
|
||||
super("RRPoolID");
|
||||
}
|
||||
}
|
||||
|
||||
public static class TCPoolID extends TextHandler {
|
||||
public static class TCPoolID extends ElementTextHandler {
|
||||
public TCPoolID() {
|
||||
super("TCPoolID");
|
||||
}
|
||||
}
|
||||
|
||||
public static class PoolRecordID extends TextHandler {
|
||||
public static class PoolRecordID extends ElementTextHandler {
|
||||
public PoolRecordID() {
|
||||
super("poolRecordID");
|
||||
}
|
||||
}
|
||||
|
||||
private String textElement;
|
||||
private final String textElement;
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private String text = null;
|
||||
|
||||
private TextHandler(String textElement) {
|
||||
private ElementTextHandler(String textElement) {
|
||||
this.textElement = checkNotNull(textElement, "textElement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResult() {
|
||||
try {
|
||||
return checkNotNull(text, "%s not present in the response", textElement);
|
||||
} finally {
|
||||
text = null;
|
||||
}
|
||||
return checkNotNull(text, "%s not present in the response", textElement);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -24,6 +24,8 @@ import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
|||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSError;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -36,12 +38,7 @@ public class UltraWSExceptionHandler extends ParseSax.HandlerForGeneratedRequest
|
|||
|
||||
@Override
|
||||
public UltraDNSWSError getResult() {
|
||||
try {
|
||||
return code != -1 ? UltraDNSWSError.fromCodeAndDescription(code, description) : null;
|
||||
} finally {
|
||||
code = -1;
|
||||
description = null;
|
||||
}
|
||||
return code != -1 ? UltraDNSWSError.fromCodeAndDescription(code, Optional.fromNullable(description)) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.ultradns.ws;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiLiveTest;
|
||||
|
@ -37,8 +37,8 @@ public class UltraDNSWSApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
}
|
||||
|
||||
private void checkAccount(Account account) {
|
||||
checkNotNull(account.getId(), "Id cannot be null for an Account.");
|
||||
checkNotNull(account.getName(), "Name cannot be null for Account %s", account);
|
||||
assertNotNull(account.getId(), "Id cannot be null for " + account);
|
||||
assertNotNull(account.getName(), "Name cannot be null for " + account);
|
||||
}
|
||||
|
||||
protected UltraDNSWSApi api() {
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Predicates.equalTo;
|
||||
import static java.lang.String.format;
|
||||
import static java.util.logging.Logger.getAnonymousLogger;
|
||||
import static org.jclouds.ultradns.ws.domain.ResourceRecord.rrBuilder;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
@ -72,20 +72,20 @@ 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() > 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);
|
||||
assertNotNull(rr.getName(), "DName cannot be null for " + rr);
|
||||
assertNotNull(rr.getType(), "Type cannot be null for " + rr);
|
||||
assertTrue(rr.getType() > 0, "Type must be unsigned for " + rr);
|
||||
assertNotNull(rr.getType(), "Type cannot be null for " + rr);
|
||||
assertNotNull(rr.getTTL(), "TTL cannot be null for " + rr);
|
||||
assertNotNull(rr.getRData(), "InfoValues cannot be null for " + rr);
|
||||
}
|
||||
|
||||
static void checkResourceRecordMetadata(ResourceRecordMetadata rr) {
|
||||
checkNotNull(rr.getZoneId(), "ZoneId cannot be null for a ResourceRecordMetadata %s", rr);
|
||||
checkNotNull(rr.getGuid(), "Guid cannot be null for a ResourceRecordMetadata %s", rr);
|
||||
checkNotNull(rr.getZoneName(), "ZoneName cannot be null for a ResourceRecordMetadata %s", rr);
|
||||
checkNotNull(rr.getCreated(), "Created cannot be null for a ResourceRecordMetadata %s", rr);
|
||||
checkNotNull(rr.getModified(), "Modified cannot be null for a ResourceRecordMetadata %s", rr);
|
||||
assertNotNull(rr.getZoneId(), "ZoneId cannot be null for " + rr);
|
||||
assertNotNull(rr.getGuid(), "Guid cannot be null for " + rr);
|
||||
assertNotNull(rr.getZoneName(), "ZoneName cannot be null for " + rr);
|
||||
assertNotNull(rr.getCreated(), "Created cannot be null for " + rr);
|
||||
assertNotNull(rr.getModified(), "Modified cannot be null for " + rr);
|
||||
checkResourceRecord(rr.getRecord());
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,7 @@ public class ResourceRecordApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
void logSummary() {
|
||||
getAnonymousLogger().info("zoneCount: " + zones);
|
||||
for (Entry<Integer, AtomicLong> entry : recordTypeCounts.asMap().entrySet())
|
||||
getAnonymousLogger().info(
|
||||
String.format("type: %s, count: %s", entry.getKey(), entry.getValue()));
|
||||
getAnonymousLogger().info(format("type: %s, count: %s", entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Zone does not exist in the system.")
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Predicates.equalTo;
|
||||
import static java.util.logging.Logger.getAnonymousLogger;
|
||||
import static org.jclouds.ultradns.ws.domain.ResourceRecord.rrBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
@ -62,10 +62,10 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
}
|
||||
|
||||
private void checkRRPool(RoundRobinPool pool) {
|
||||
checkNotNull(pool.getZoneId(), "ZoneId cannot be null for a RoundRobinPool %s", pool);
|
||||
checkNotNull(pool.getId(), "Id cannot be null for a RoundRobinPool %s", pool);
|
||||
checkNotNull(pool.getName(), "Name cannot be null for a RoundRobinPool %s", pool);
|
||||
checkNotNull(pool.getDName(), "DName cannot be null for a RoundRobinPool %s", pool);
|
||||
assertNotNull(pool.getZoneId(), "ZoneId cannot be null for " + pool);
|
||||
assertNotNull(pool.getId(), "Id cannot be null for " + pool);
|
||||
assertNotNull(pool.getName(), "Name cannot be null for " + pool);
|
||||
assertNotNull(pool.getDName(), "DName cannot be null for " + pool);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import org.jclouds.ultradns.ws.domain.Task;
|
||||
|
@ -33,10 +33,10 @@ import org.testng.annotations.Test;
|
|||
public class TaskApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private void checkTask(Task task) {
|
||||
checkNotNull(task.getGuid(), "Guid cannot be null for a Task %s", task);
|
||||
checkNotNull(task.getStatusCode(), "StatusCode cannot be null for a Task %s", task);
|
||||
checkNotNull(task.getMessage(), "While Message can be null for a Task, its Optional wrapper cannot %s", task);
|
||||
checkNotNull(task.getResultUrl(), "While ResultUrl can be null for a Task, its Optional wrapper cannot %s", task);
|
||||
assertNotNull(task.getGuid(), "Guid cannot be null for " + task);
|
||||
assertNotNull(task.getStatusCode(), "StatusCode cannot be null for " + task);
|
||||
assertNotNull(task.getMessage(), "While Message can be null, its Optional wrapper cannot " + task);
|
||||
assertNotNull(task.getResultUrl(), "While ResultUrl can be null, its Optional wrapper cannot " + task);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -53,7 +53,7 @@ public class TaskApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
assertEquals(got.getGuid(), task.getGuid());
|
||||
assertEquals(got.getStatusCode(), task.getStatusCode());
|
||||
assertEquals(got.getMessage(), task.getMessage());
|
||||
assertEquals(got.getResultUrl(), task.getMessage());
|
||||
assertEquals(got.getResultUrl(), task.getResultUrl());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,10 @@ import static org.testng.Assert.assertNull;
|
|||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSApi;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException;
|
||||
import org.jclouds.ultradns.ws.domain.UpdatePoolRecord;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiExpectTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetPoolRecordSpecResponseTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetTCLoadBalancingPoolsByZoneResponseTest;
|
||||
|
@ -140,6 +142,18 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
UltraDNSWSApi success = requestSendsResponse(createRecord, createRecordResponse);
|
||||
assertEquals(success.getTrafficControllerPoolApiForZone("jclouds.org.").addRecordToPoolWithTTL("1.2.3.4", "04053D8E57C7931F", 300), "06063DAC54F8D3D9");
|
||||
}
|
||||
|
||||
HttpRequest createRecordWithWeight = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/create_tcrecord_weight.xml", "application/xml")).build();
|
||||
|
||||
public void testCreateRecordWithWeightWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(createRecordWithWeight, createRecordResponse);
|
||||
assertEquals(
|
||||
success.getTrafficControllerPoolApiForZone("jclouds.org.").addRecordToPoolWithTTLAndWeight("1.2.3.4",
|
||||
"04053D8E57C7931F", 300, 0), "06063DAC54F8D3D9");
|
||||
}
|
||||
|
||||
HttpResponse recordAlreadyCreated = HttpResponse.builder().statusCode(500)
|
||||
.payload(payloadFromResourceWithContentType("/tcrecord_already_exists.xml", "application/xml")).build();
|
||||
|
@ -172,6 +186,33 @@ public class TrafficControllerPoolApiExpectTest extends BaseUltraDNSWSApiExpectT
|
|||
assertNull(notFound.getTrafficControllerPoolApiForZone("jclouds.org.").getRecordSpec("04053D8E57C7931F"));
|
||||
}
|
||||
|
||||
UpdatePoolRecord update = UpdatePoolRecord.builder()
|
||||
.pointsTo("www.baz.com.")
|
||||
.mode("Normal")
|
||||
.weight(98)
|
||||
.failOverDelay(0)
|
||||
.threshold(1)
|
||||
.ttl(200).build();
|
||||
|
||||
HttpRequest updateRecord = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/update_poolrecord.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse updateRecordResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/poolrecord_updated.xml", "application/xml")).build();
|
||||
|
||||
public void testUpdateRecordWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(updateRecord, updateRecordResponse);
|
||||
success.getTrafficControllerPoolApiForZone("jclouds.org.").updateRecord("04053D8E57C7931F", update);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Pool Record does not exist.")
|
||||
public void testUpdateRecordWhenResponseNotFound() {
|
||||
UltraDNSWSApi notFound = requestSendsResponse(updateRecord, recordDoesntExist);
|
||||
notFound.getTrafficControllerPoolApiForZone("jclouds.org.").updateRecord("04053D8E57C7931F", update);
|
||||
}
|
||||
|
||||
HttpRequest deleteRecord = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static java.util.logging.Logger.getAnonymousLogger;
|
||||
import static org.jclouds.ultradns.ws.predicates.TrafficControllerPoolPredicates.idEqualTo;
|
||||
import static org.jclouds.ultradns.ws.predicates.TrafficControllerPoolPredicates.recordIdEqualTo;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
@ -35,6 +35,7 @@ import org.jclouds.ultradns.ws.domain.PoolRecordSpec;
|
|||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord.Status;
|
||||
import org.jclouds.ultradns.ws.domain.UpdatePoolRecord;
|
||||
import org.jclouds.ultradns.ws.domain.Zone;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiLiveTest;
|
||||
import org.testng.annotations.AfterClass;
|
||||
|
@ -64,10 +65,10 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest
|
|||
}
|
||||
|
||||
private void checkTCPool(TrafficControllerPool pool) {
|
||||
checkNotNull(pool.getZoneId(), "ZoneId cannot be null for %s", pool);
|
||||
checkNotNull(pool.getId(), "Id cannot be null for %s", pool);
|
||||
checkNotNull(pool.getName(), "Name cannot be null for %s", pool);
|
||||
checkNotNull(pool.getDName(), "DName cannot be null for %s", pool);
|
||||
assertNotNull(pool.getZoneId(), "ZoneId cannot be null " + pool);
|
||||
assertNotNull(pool.getId(), "Id cannot be null " + pool);
|
||||
assertNotNull(pool.getName(), "Name cannot be null " + pool);
|
||||
assertNotNull(pool.getDName(), "DName cannot be null " + pool);
|
||||
assertEquals(api(zoneName).getNameByDName(pool.getDName()), pool.getName());
|
||||
}
|
||||
|
||||
|
@ -103,21 +104,21 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest
|
|||
}
|
||||
|
||||
static TrafficControllerPoolRecord checkTrafficControllerPoolRecord(TrafficControllerPoolRecord record) {
|
||||
checkNotNull(record.getId(), "Id cannot be null for %s", record);
|
||||
checkNotNull(record.getPoolId(), "PoolId cannot be null for %s", record);
|
||||
checkNotNull(record.getPointsTo(), "PointsTo cannot be null for %s", record);
|
||||
assertNotNull(record.getId(), "Id cannot be null for " + record);
|
||||
assertNotNull(record.getPoolId(), "PoolId cannot be null for " + record);
|
||||
assertNotNull(record.getPointsTo(), "PointsTo cannot be null for " + record);
|
||||
assertTrue(record.getWeight() >= 0, "Weight must be unsigned for " + record);
|
||||
assertTrue(record.getPriority() >= 0, "Priority must be unsigned for " + record);
|
||||
checkNotNull(record.getType(), "Type cannot be null for %s", record);
|
||||
checkNotNull(record.getStatus(), "Status cannot be null for %s", record);
|
||||
assertNotNull(record.getType(), "Type cannot be null for " + record);
|
||||
assertNotNull(record.getStatus(), "Status cannot be null for " + record);
|
||||
assertTrue(record.getStatus() != Status.UNRECOGNIZED, "unrecognized status for " + record);
|
||||
checkNotNull(record.getDescription(), "Description cannot be null for %s", record);
|
||||
assertNotNull(record.getDescription(), "Description cannot be null for " + record);
|
||||
return record;
|
||||
}
|
||||
|
||||
static PoolRecordSpec checkPoolRecordSpec(PoolRecordSpec record) {
|
||||
checkNotNull(record.getDescription(), "Description cannot be null for %s", record);
|
||||
checkNotNull(record.getState(), "State cannot be null for %s", record);
|
||||
assertNotNull(record.getDescription(), "Description cannot be null for " + record);
|
||||
assertNotNull(record.getState(), "State cannot be null for " + record);
|
||||
// TODO: collect all possible states then consider enum
|
||||
assertTrue(ImmutableSet.of("Normal", "Normal-NoTest").contains(record.getState()), "Unknown State for " + record);
|
||||
assertTrue(record.getWeight() >= 0, "Weight must be unsigned for " + record);
|
||||
|
@ -152,6 +153,12 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest
|
|||
assertNull(api(zoneName).getRecordSpec("06063D9C54C5AE09"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Pool Record does not exist.")
|
||||
public void testUpdateRecordWhenNotFound() {
|
||||
api(zoneName).updateRecord("06063D9C54C5AE09",
|
||||
UpdatePoolRecord.builder().pointsTo("www.foo.com.").mode("Normal").build());
|
||||
}
|
||||
|
||||
String hostname = "www.tcpool." + zoneName;
|
||||
String poolId;
|
||||
|
||||
|
@ -182,25 +189,32 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest
|
|||
|
||||
@DataProvider(name = "records")
|
||||
public Object[][] createRecords() {
|
||||
Object[][] records = new Object[2][3];
|
||||
Object[][] records = new Object[2][4];
|
||||
records[0][0] = "1.2.3.4";
|
||||
records[0][1] = "A";
|
||||
records[0][2] = 60;
|
||||
records[0][3] = Optional.of(98);
|
||||
records[1][0] = "5.6.7.8";
|
||||
records[1][1] = "A";
|
||||
records[1][2] = 60;
|
||||
records[1][3] = Optional.of(2);
|
||||
return records;
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreatePool", dataProvider = "records")
|
||||
public TrafficControllerPoolRecord addRecordToPool(final String pointsTo, final String type, final int ttl) {
|
||||
String recordId = api(zoneName).addRecordToPoolWithTTL(pointsTo, poolId, ttl);
|
||||
public TrafficControllerPoolRecord addRecordToPool(String pointsTo, String type, int ttl, Optional<Integer> weight) {
|
||||
String recordId;
|
||||
if (weight.isPresent()) {
|
||||
recordId = api(zoneName).addRecordToPoolWithTTLAndWeight(pointsTo, poolId, ttl, weight.get());
|
||||
} else {
|
||||
recordId = api(zoneName).addRecordToPoolWithTTL(pointsTo, poolId, ttl);
|
||||
}
|
||||
getAnonymousLogger().info("created " + type + " record: " + recordId);
|
||||
TrafficControllerPoolRecord record = checkPoolRecordConsistent(zoneName, getRecordById(recordId).get());
|
||||
PoolRecordSpec recordSpec = checkPoolRecordSpec(api(zoneName).getRecordSpec(recordId));
|
||||
assertEquals(record.getPointsTo(), pointsTo);
|
||||
assertEquals(record.getType(), type);
|
||||
assertEquals(record.getWeight(), 2);
|
||||
assertEquals(record.getWeight(), weight.or(2).intValue());
|
||||
assertEquals(recordSpec.getTTL(), ttl);
|
||||
return record;
|
||||
}
|
||||
|
@ -210,7 +224,7 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest
|
|||
|
||||
@Test(dependsOnMethods = "testCreatePool")
|
||||
public void addCNAMERecordsToPool() {
|
||||
cname1 = addRecordToPool("www.foo.com.", "CNAME", 30).getId();
|
||||
cname1 = addRecordToPool("www.foo.com.", "CNAME", 30, Optional.<Integer> absent()).getId();
|
||||
|
||||
try {
|
||||
api(zoneName).addRecordToPoolWithTTL("www.foo.com.", poolId, 30);
|
||||
|
@ -219,10 +233,28 @@ public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest
|
|||
|
||||
}
|
||||
|
||||
cname2 = addRecordToPool("www.bar.com.", "CNAME", 30).getId();
|
||||
cname2 = addRecordToPool("www.bar.com.", "CNAME", 30, Optional.<Integer> absent()).getId();
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "addCNAMERecordsToPool")
|
||||
public void testUpdateRecord() {
|
||||
PoolRecordSpec spec = api(zoneName).getRecordSpec(cname2);
|
||||
UpdatePoolRecord update = UpdatePoolRecord.builder().from(spec)
|
||||
.pointsTo("www.baz.com.")
|
||||
.weight(98)
|
||||
.ttl(200).build();
|
||||
|
||||
api(zoneName).updateRecord(cname2, update);
|
||||
|
||||
TrafficControllerPoolRecord record = getRecordById(cname2).get();
|
||||
assertEquals(record.getPointsTo(), "www.baz.com.");
|
||||
|
||||
spec = api(zoneName).getRecordSpec(cname2);
|
||||
assertEquals(spec.getWeight(), 98);
|
||||
assertEquals(spec.getTTL(), 200);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testUpdateRecord")
|
||||
public void testDeleteRecord() {
|
||||
api(zoneName).deleteRecord(cname1);
|
||||
assertFalse(getRecordById(cname1).isPresent());
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.ultradns.ws.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static java.util.logging.Logger.getAnonymousLogger;
|
||||
import static org.jclouds.ultradns.ws.domain.Zone.Type.PRIMARY;
|
||||
import static org.jclouds.ultradns.ws.predicates.ZonePredicates.typeEquals;
|
||||
import static org.jclouds.ultradns.ws.predicates.ZonePredicates.typeEqualTo;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
@ -55,17 +55,16 @@ public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
}
|
||||
|
||||
private void checkZone(Zone zone) {
|
||||
checkNotNull(zone.getId(), "Id cannot be null for a Zone %s", zone);
|
||||
checkNotNull(zone.getName(), "Name cannot be null for a Zone %s", zone);
|
||||
checkNotNull(zone.getType(), "Type cannot be null for a Zone %s", zone);
|
||||
checkNotNull(zone.getTypeCode(), "TypeCode cannot be null for a Zone %s", zone);
|
||||
assertNotNull(zone.getId(), "Id cannot be null for " + zone);
|
||||
assertNotNull(zone.getName(), "Name cannot be null for " + zone);
|
||||
assertNotNull(zone.getType(), "Type cannot be null for " + zone);
|
||||
assertNotNull(zone.getTypeCode(), "TypeCode cannot be null for " + zone);
|
||||
assertEquals(zone.getTypeCode(), zone.getType().getCode());
|
||||
checkNotNull(zone.getAccountId(), "AccountId cannot be null for a Zone %s", zone);
|
||||
assertNotNull(zone.getAccountId(), "AccountId cannot be null for " + zone);
|
||||
assertEquals(zone.getAccountId(), account.getId());
|
||||
checkNotNull(zone.getOwnerId(), "OwnerId cannot be null for a Zone %s", zone);
|
||||
checkNotNull(zone.getDNSSECStatus(), "DNSSECStatus cannot be null for a Zone %s", zone);
|
||||
checkNotNull(zone.getPrimarySrc(), "While PrimarySrc can be null for a Zone, its Optional wrapper cannot %s",
|
||||
zone);
|
||||
assertNotNull(zone.getOwnerId(), "OwnerId cannot be null for " + zone);
|
||||
assertNotNull(zone.getDNSSECStatus(), "DNSSECStatus cannot be null for " + zone);
|
||||
assertNotNull(zone.getPrimarySrc(), "While PrimarySrc can be null, its Optional wrapper cannot " + zone);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,9 +75,9 @@ public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
checkZone(zone);
|
||||
}
|
||||
|
||||
if (response.anyMatch(typeEquals(PRIMARY))) {
|
||||
if (response.anyMatch(typeEqualTo(PRIMARY))) {
|
||||
assertEquals(api().listByAccountAndType(account.getId(), PRIMARY).toSet(), response
|
||||
.filter(typeEquals(PRIMARY)).toSet());
|
||||
.filter(typeEqualTo(PRIMARY)).toSet());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +93,7 @@ public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
assertEquals(zoneProperties.getName(), zone.getName());
|
||||
assertEquals(zoneProperties.getType(), zone.getType());
|
||||
assertEquals(zoneProperties.getTypeCode(), zone.getTypeCode());
|
||||
checkNotNull(zoneProperties.getModified(), "Modified cannot be null for a Zone %s", zone);
|
||||
assertNotNull(zoneProperties.getModified(), "Modified cannot be null for " + zone);
|
||||
assertTrue(zoneProperties.getResourceRecordCount() >= 0,
|
||||
"ResourceRecordCount must be positive or zero for a Zone " + zone);
|
||||
}
|
||||
|
@ -134,7 +133,7 @@ public class ZoneApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
assertEquals(newZone.getName(), name);
|
||||
assertEquals(newZone.getType(), Type.PRIMARY);
|
||||
assertEquals(newZone.getTypeCode(), Type.PRIMARY.getCode());
|
||||
checkNotNull(newZone.getModified(), "Modified cannot be null for a Zone %s", newZone);
|
||||
assertNotNull(newZone.getModified(), "Modified cannot be null for " + newZone);
|
||||
assertEquals(newZone.getResourceRecordCount(), 5);
|
||||
} finally {
|
||||
api().delete(name);
|
||||
|
|
|
@ -47,7 +47,26 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
UltraDNSWSErrorHandler.class);
|
||||
|
||||
@Test
|
||||
public void testCode0SetsResourceNotFoundException() throws IOException {
|
||||
public void testCode0SetsUltraDNSWSResponseException() throws IOException {
|
||||
HttpRequest request = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443").payload(payloadFromResource("/list_tasks.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/server_fault.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
assertEquals(command.getException().getClass(), UltraDNSWSResponseException.class);
|
||||
assertEquals(command.getException().getMessage(), "Error 0");
|
||||
|
||||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException());
|
||||
|
||||
assertEquals(exception.getError().getCode(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCode0ForDescriptionMatchingCannotFindSetsResourceNotFoundException() throws IOException {
|
||||
HttpRequest request = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443").payload(payloadFromResource("/list_tasks.xml")).build();
|
||||
|
@ -63,7 +82,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
|
||||
|
||||
assertEquals(exception.getMessage(), "Error 0: Cannot find task with guid AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getDescription(), "Cannot find task with guid AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getDescription().get(), "Cannot find task with guid AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getCode(), 0);
|
||||
}
|
||||
|
||||
|
@ -85,7 +104,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
|
||||
|
||||
assertEquals(exception.getMessage(), "Error 2401: Account not found in the system. ID: AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getDescription(), "Account not found in the system. ID: AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getDescription().get(), "Account not found in the system. ID: AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getCode(), 2401);
|
||||
}
|
||||
|
||||
|
@ -106,7 +125,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
|
||||
|
||||
assertEquals(exception.getMessage(), "Error 1801: Zone does not exist in the system.");
|
||||
assertEquals(exception.getError().getDescription(), "Zone does not exist in the system.");
|
||||
assertEquals(exception.getError().getDescription().get(), "Zone does not exist in the system.");
|
||||
assertEquals(exception.getError().getCode(), 1801);
|
||||
}
|
||||
|
||||
|
@ -127,7 +146,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
|
||||
|
||||
assertEquals(exception.getMessage(), "Error 2103: No Resource Record with GUID found in the system AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getDescription(), "No Resource Record with GUID found in the system AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getDescription().get(), "No Resource Record with GUID found in the system AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getCode(), 2103);
|
||||
}
|
||||
|
||||
|
@ -148,7 +167,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
|
||||
|
||||
assertEquals(exception.getMessage(), "Error 1802: Zone already exists in the system.");
|
||||
assertEquals(exception.getError().getDescription(), "Zone already exists in the system.");
|
||||
assertEquals(exception.getError().getDescription().get(), "Zone already exists in the system.");
|
||||
assertEquals(exception.getError().getCode(), 1802);
|
||||
}
|
||||
|
||||
|
@ -171,7 +190,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
assertEquals(exception.getMessage(),
|
||||
"Error 2111: Resource Record of type 15 with these attributes already exists in the system.");
|
||||
assertEquals(exception.getError().getDescription(),
|
||||
assertEquals(exception.getError().getDescription().get(),
|
||||
"Resource Record of type 15 with these attributes already exists in the system.");
|
||||
assertEquals(exception.getError().getCode(), 2111);
|
||||
}
|
||||
|
@ -193,7 +212,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
|
||||
|
||||
assertEquals(exception.getMessage(), "Error 2911: Pool does not exist in the system");
|
||||
assertEquals(exception.getError().getDescription(), "Pool does not exist in the system");
|
||||
assertEquals(exception.getError().getDescription().get(), "Pool does not exist in the system");
|
||||
assertEquals(exception.getError().getCode(), 2911);
|
||||
}
|
||||
|
||||
|
@ -216,7 +235,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
|
||||
assertEquals(exception.getMessage(),
|
||||
"Error 2912: Pool already created for this host name : www.rrpool.adrianc.rrpool.ultradnstest.jclouds.org.");
|
||||
assertEquals(exception.getError().getDescription(),
|
||||
assertEquals(exception.getError().getDescription().get(),
|
||||
"Pool already created for this host name : www.rrpool.adrianc.rrpool.ultradnstest.jclouds.org.");
|
||||
assertEquals(exception.getError().getCode(), 2912);
|
||||
}
|
||||
|
@ -238,7 +257,7 @@ public class UltraDNSWSErrorHandlerTest {
|
|||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
|
||||
|
||||
assertEquals(exception.getMessage(), "Error 3101: Pool Record does not exist.");
|
||||
assertEquals(exception.getError().getDescription(), "Pool Record does not exist.");
|
||||
assertEquals(exception.getError().getDescription().get(), "Pool Record does not exist.");
|
||||
assertEquals(exception.getError().getCode(), 3101);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.xml.TextHandler;
|
||||
import org.jclouds.ultradns.ws.xml.ElementTextHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ public class RunTestResponseTest extends BaseHandlerTest {
|
|||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/taskid.xml");
|
||||
|
||||
TextHandler.Guid handler = injector.getInstance(TextHandler.Guid.class);
|
||||
ElementTextHandler.Guid handler = injector.getInstance(ElementTextHandler.Guid.class);
|
||||
assertEquals(factory.create(handler).parse(is), "8d7a1725-4f4a-4b70-affa-f01dcce1526e");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.jclouds.ultradns.ws.UltraDNSWSError;
|
|||
import org.jclouds.ultradns.ws.xml.UltraWSExceptionHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -45,6 +47,6 @@ public class TaskNotFoundTest extends BaseHandlerTest {
|
|||
}
|
||||
|
||||
public UltraDNSWSError expected() {
|
||||
return UltraDNSWSError.fromCodeAndDescription(0, "Cannot find task with guid AAAAAAAAAAAAAAAA");
|
||||
return UltraDNSWSError.fromCodeAndDescription(0, Optional.of("Cannot find task with guid AAAAAAAAAAAAAAAA"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.jclouds.ultradns.ws.UltraDNSWSError;
|
|||
import org.jclouds.ultradns.ws.xml.UltraWSExceptionHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -45,7 +47,7 @@ public class UltraWSExceptionTest extends BaseHandlerTest {
|
|||
}
|
||||
|
||||
public UltraDNSWSError expected() {
|
||||
return UltraDNSWSError.fromCodeAndDescription(1801, "Zone does not exist in the system.");
|
||||
return UltraDNSWSError.fromCodeAndDescription(1801, Optional.of("Zone does not exist in the system."));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.jclouds.ultradns.ws.predicates;
|
|||
|
||||
import static org.jclouds.ultradns.ws.predicates.TrafficControllerPoolPredicates.idEqualTo;
|
||||
import static org.jclouds.ultradns.ws.predicates.TrafficControllerPoolPredicates.recordIdEqualTo;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPoolRecord;
|
||||
|
@ -43,12 +45,12 @@ public class TrafficControllerPoolPredicatesTest {
|
|||
|
||||
@Test
|
||||
public void testIdEqualToWhenEqual() {
|
||||
assert idEqualTo("000000000000002").apply(pool);
|
||||
assertTrue(idEqualTo("000000000000002").apply(pool));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdEqualToWhenNotEqual() {
|
||||
assert !idEqualTo("000000000000003").apply(pool);
|
||||
assertFalse(idEqualTo("000000000000003").apply(pool));
|
||||
}
|
||||
|
||||
TrafficControllerPoolRecord record = TrafficControllerPoolRecord.builder()
|
||||
|
@ -66,11 +68,11 @@ public class TrafficControllerPoolPredicatesTest {
|
|||
|
||||
@Test
|
||||
public void testRecordIdEqualToWhenEqual() {
|
||||
assert recordIdEqualTo("0000000000000001").apply(record);
|
||||
assertTrue(recordIdEqualTo("0000000000000001").apply(record));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecordIdEqualToWhenNotEqual() {
|
||||
assert !recordIdEqualTo("0000000000000002").apply(record);
|
||||
assertFalse(recordIdEqualTo("0000000000000002").apply(record));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.ultradns.ws.predicates;
|
||||
|
||||
import static org.jclouds.ultradns.ws.predicates.ZonePredicates.typeEquals;
|
||||
import static org.jclouds.ultradns.ws.predicates.ZonePredicates.typeEqualTo;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.ultradns.ws.domain.Zone;
|
||||
import org.jclouds.ultradns.ws.domain.Zone.DNSSECStatus;
|
||||
|
@ -41,11 +43,11 @@ public class ZonePredicatesTest {
|
|||
|
||||
@Test
|
||||
public void testTypeEqualsWhenEqual() {
|
||||
assert typeEquals(Type.PRIMARY).apply(zone);
|
||||
assertTrue(typeEqualTo(Type.PRIMARY).apply(zone));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTypeEqualsWhenNotEqual() {
|
||||
assert !typeEquals(Type.SECONDARY).apply(zone);
|
||||
assertFalse(typeEqualTo(Type.SECONDARY).apply(zone));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v01="http://webservice.api.ultra.neustar.com/v01/"><soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken><wsse:Username>identity</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">credential</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body><v01:addPoolRecord><transactionID /><poolID>04053D8E57C7931F</poolID><pointsTo>1.2.3.4</pointsTo><priority /><failOverDelay /><ttl>300</ttl><weight>0</weight><mode /><threshold /></v01:addPoolRecord></soapenv:Body></soapenv:Envelope>
|
|
@ -0,0 +1 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:updatePoolRecordResponse xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/"><result xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">Successful</result></ns1:updatePoolRecordResponse></soap:Body></soap:Envelope>
|
|
@ -0,0 +1,17 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<soap:Fault>
|
||||
<faultcode>soap:Server</faultcode>
|
||||
<faultstring>Fault occurred while processing.</faultstring>
|
||||
<detail>
|
||||
<ns1:UltraWSException xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/">
|
||||
<errorCode xmlns:ns2="http://schema.ultraservice.neustar.com/v01/"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:type="xs:int">0</errorCode>
|
||||
<errorDescription xmlns:ns2="http://schema.ultraservice.neustar.com/v01/"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
|
||||
</ns1:UltraWSException>
|
||||
</detail>
|
||||
</soap:Fault>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1 @@
|
|||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v01="http://webservice.api.ultra.neustar.com/v01/"><soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken><wsse:Username>identity</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">credential</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body><v01:updatePoolRecord><transactionID /><poolRecordID>04053D8E57C7931F</poolRecordID><parentPoolId /><childPoolId /><pointsTo>www.baz.com.</pointsTo><priority>0</priority><failOverDelay>0</failOverDelay><ttl>200</ttl><weight>98</weight><mode>Normal</mode><threshold>1</threshold></v01:updatePoolRecord></soapenv:Body></soapenv:Envelope>
|
Loading…
Reference in New Issue