mirror of https://github.com/apache/jclouds.git
added ability to read directional pools and records in ultradns
This commit is contained in:
parent
0abfaf5184
commit
ec439c65b7
|
@ -19,10 +19,10 @@
|
|||
package org.jclouds.ultradns.ws;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.POST;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.rest.annotations.Payload;
|
||||
|
@ -32,6 +32,7 @@ import org.jclouds.rest.annotations.VirtualHost;
|
|||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.Region;
|
||||
import org.jclouds.ultradns.ws.features.DirectionalPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordApi;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.TaskApi;
|
||||
|
@ -39,6 +40,7 @@ import org.jclouds.ultradns.ws.features.TrafficControllerPoolApi;
|
|||
import org.jclouds.ultradns.ws.features.ZoneApi;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.AccountHandler;
|
||||
import org.jclouds.ultradns.ws.xml.RegionListHandler;
|
||||
|
||||
/**
|
||||
* Provides access to Neustar UltraDNS via the SOAP API
|
||||
|
@ -101,6 +103,15 @@ public interface UltraDNSWSApi extends Closeable {
|
|||
@Delegate
|
||||
TrafficControllerPoolApi getTrafficControllerPoolApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides access to Directional Pool features.
|
||||
*
|
||||
* @param zoneName
|
||||
* zoneName including a trailing dot
|
||||
*/
|
||||
@Delegate
|
||||
DirectionalPoolApi getDirectionalPoolApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides access to Task features.
|
||||
*/
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.jclouds.rest.config.HttpApiModule;
|
|||
import org.jclouds.ultradns.ws.UltraDNSWSApi;
|
||||
import org.jclouds.ultradns.ws.handlers.UltraDNSWSErrorHandler;
|
||||
|
||||
|
||||
/**
|
||||
* Configures the UltraDNSWS connection.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
/**
|
||||
* 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.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalGroup {
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final Optional<String> description;
|
||||
|
||||
private DirectionalGroup(String id, String name, Optional<String> description) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.description = checkNotNull(description, "description");
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Optional<String> getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, name, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
DirectionalGroup that = DirectionalGroup.class.cast(obj);
|
||||
return equal(this.id, that.id) && equal(this.name, that.name) && equal(this.description, that.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").omitNullValues().add("id", id).add("name", name)
|
||||
.add("description", description.orNull()).toString();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().from(this);
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String id;
|
||||
private String name;
|
||||
private Optional<String> description = Optional.absent();
|
||||
|
||||
/**
|
||||
* @see DirectionalGroup#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalGroup#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalGroup#getDescription()
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = Optional.fromNullable(description);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DirectionalGroup build() {
|
||||
return new DirectionalGroup(id, name, description);
|
||||
}
|
||||
|
||||
public Builder from(DirectionalGroup in) {
|
||||
return id(in.id).name(in.name).description(in.description.orNull());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
/**
|
||||
* 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.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* Records are resolved in consideration of the location of the requestor.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class DirectionalPool {
|
||||
|
||||
private final String zoneId;
|
||||
private final String id;
|
||||
private final Optional<String> description;
|
||||
private final String dname;
|
||||
private final Type type;
|
||||
private final TieBreak tieBreak;
|
||||
|
||||
private DirectionalPool(String zoneId, String id, Optional<String> description, String dname, Type type,
|
||||
TieBreak tieBreak) {
|
||||
this.zoneId = checkNotNull(zoneId, "zoneId");
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.description = checkNotNull(description, "description for %s", id);
|
||||
this.dname = checkNotNull(dname, "dname for %s", id);
|
||||
this.type = type;
|
||||
this.tieBreak = tieBreak;
|
||||
}
|
||||
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The dname of the pool. ex. {@code jclouds.org.}
|
||||
*/
|
||||
public String getName() {
|
||||
return dname;
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of the pool. ex. {@code My Pool}
|
||||
*/
|
||||
public Optional<String> getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* if {@link #getType} is {@link Type#MIXED}, this can be
|
||||
* {@link TieBreak#SOURCEIP} or {@link TieBreak#GEOLOCATION}, otherwise
|
||||
* {@link TieBreak#GEOLOCATION}
|
||||
*/
|
||||
public TieBreak getTieBreak() {
|
||||
return tieBreak;
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
GEOLOCATION, SOURCEIP, MIXED;
|
||||
}
|
||||
|
||||
public static enum TieBreak {
|
||||
GEOLOCATION, SOURCEIP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(zoneId, id, description, dname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DirectionalPool that = DirectionalPool.class.cast(obj);
|
||||
return Objects.equal(this.zoneId, that.zoneId) && Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.description, that.description) && Objects.equal(this.dname, that.dname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("zoneId", zoneId).add("id", id).add("name", dname)
|
||||
.add("description", description.orNull()).add("type", type).add("tieBreak", tieBreak).toString();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().from(this);
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String zoneId;
|
||||
private String id;
|
||||
private Optional<String> description = Optional.absent();
|
||||
private String dname;
|
||||
private Type type = Type.GEOLOCATION;
|
||||
private TieBreak tieBreak = TieBreak.GEOLOCATION;
|
||||
|
||||
/**
|
||||
* @see DirectionalPool#getZoneId()
|
||||
*/
|
||||
public Builder zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalPool#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalPool#getName()
|
||||
*/
|
||||
public Builder name(String dname) {
|
||||
this.dname = dname;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalPool#getDescription()
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = Optional.fromNullable(description);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalPool#getType()
|
||||
*/
|
||||
public Builder type(Type type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalPool#getTieBreak()
|
||||
*/
|
||||
public Builder tieBreak(TieBreak tieBreak) {
|
||||
this.tieBreak = tieBreak;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DirectionalPool build() {
|
||||
return new DirectionalPool(zoneId, id, description, dname, type, tieBreak);
|
||||
}
|
||||
|
||||
public Builder from(DirectionalPool in) {
|
||||
return this.zoneId(in.zoneId).id(in.id).description(in.description.orNull()).name(in.dname).type(in.type)
|
||||
.tieBreak(in.tieBreak);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
/**
|
||||
* 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.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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalRecord {
|
||||
private final String type;
|
||||
private final int ttl;
|
||||
private final boolean noResponseRecord;
|
||||
private final List<String> infoValues;
|
||||
|
||||
private DirectionalRecord(String type, int ttl, boolean noResponseRecord, List<String> infoValues) {
|
||||
this.type = checkNotNull(type, "type");
|
||||
checkArgument(ttl >= 0, "ttl must be >= 0");
|
||||
this.ttl = ttl;
|
||||
this.noResponseRecord = noResponseRecord;
|
||||
this.infoValues = checkNotNull(infoValues, "infoValues");
|
||||
}
|
||||
|
||||
/**
|
||||
* the type. ex. {@code A}
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getTTL() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* true if blocks traffic from specified regions by returning No Error, No
|
||||
* Response.
|
||||
*/
|
||||
public boolean isNoResponseRecord() {
|
||||
return noResponseRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #getType() type}-specific binary values.
|
||||
*/
|
||||
public List<String> getRData() {
|
||||
return infoValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(noResponseRecord, type, ttl, infoValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
DirectionalRecord that = DirectionalRecord.class.cast(obj);
|
||||
return equal(this.type, that.type) && equal(this.ttl, that.ttl)
|
||||
&& equal(this.noResponseRecord, that.noResponseRecord) && equal(this.infoValues, that.infoValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("type", type).add("ttl", ttl).add("noResponseRecord", noResponseRecord)
|
||||
.add("infoValues", infoValues).toString();
|
||||
}
|
||||
|
||||
public static Builder drBuilder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return drBuilder().from(this);
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String type;
|
||||
private int ttl = -1;
|
||||
private boolean noResponseRecord;
|
||||
private ImmutableList.Builder<String> infoValues = ImmutableList.<String> builder();
|
||||
|
||||
/**
|
||||
* @see DirectionalRecord#getType()
|
||||
*/
|
||||
public Builder type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecord#getTTL()
|
||||
*/
|
||||
public Builder ttl(int ttl) {
|
||||
this.ttl = ttl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecord#isNoResponseRecord()
|
||||
*/
|
||||
public Builder noResponseRecord(boolean noResponseRecord) {
|
||||
this.noResponseRecord = noResponseRecord;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds to current values
|
||||
*
|
||||
* @see DirectionalRecord#getRData()
|
||||
*/
|
||||
public Builder infoValue(Object infoValue) {
|
||||
this.infoValues.add(infoValue.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* replaces current values
|
||||
*
|
||||
* @see DirectionalRecord#getRData()
|
||||
*/
|
||||
public Builder rdata(Object infoValue) {
|
||||
this.infoValues = ImmutableList.<String> builder().add(infoValue.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* replaces current values
|
||||
*
|
||||
* @see DirectionalRecord#getRData()
|
||||
*/
|
||||
public Builder rdata(Iterable<?> infoValues) {
|
||||
this.infoValues = ImmutableList.<String> builder().addAll(transform(infoValues, toStringFunction()));
|
||||
return this;
|
||||
}
|
||||
|
||||
public DirectionalRecord build() {
|
||||
return new DirectionalRecord(type, ttl, noResponseRecord, infoValues.build());
|
||||
}
|
||||
|
||||
public Builder from(DirectionalRecord in) {
|
||||
return type(in.type).ttl(in.ttl).noResponseRecord(in.noResponseRecord).rdata(in.infoValues);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
/**
|
||||
* 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.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalRecordDetail {
|
||||
|
||||
private final String zoneName;
|
||||
private final String name;
|
||||
private final String id;
|
||||
private final Optional<DirectionalGroup> group;
|
||||
private final Optional<DirectionalGroup> geolocationGroup;
|
||||
private final Optional<DirectionalGroup> sourceIpGroup;
|
||||
private final DirectionalRecord record;
|
||||
|
||||
private DirectionalRecordDetail(String zoneName, String name, String id,
|
||||
Optional<DirectionalGroup> geolocationGroup, Optional<DirectionalGroup> group,
|
||||
Optional<DirectionalGroup> sourceIpGroup, DirectionalRecord record) {
|
||||
this.zoneName = checkNotNull(zoneName, "zoneName");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.group = checkNotNull(group, "group of %s/%s/%s", zoneName, name, id);
|
||||
this.geolocationGroup = checkNotNull(geolocationGroup, "geolocationGroup of %s/%s/%s", zoneName, name, id);
|
||||
this.sourceIpGroup = checkNotNull(sourceIpGroup, "sourceIpGroup of %s/%s/%s", zoneName, name, id);
|
||||
this.record = checkNotNull(record, "record of %s/%s/%s", zoneName, name, id);
|
||||
}
|
||||
|
||||
public String getZoneName() {
|
||||
return zoneName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Optional<DirectionalGroup> getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public Optional<DirectionalGroup> getGeolocationGroup() {
|
||||
return geolocationGroup;
|
||||
}
|
||||
|
||||
public Optional<DirectionalGroup> getSourceIpGroup() {
|
||||
return sourceIpGroup;
|
||||
}
|
||||
|
||||
public DirectionalRecord getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(zoneName, name, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
DirectionalRecordDetail that = DirectionalRecordDetail.class.cast(obj);
|
||||
return equal(this.zoneName, that.zoneName) && equal(this.name, that.name) && equal(this.id, that.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").omitNullValues().add("zoneName", zoneName).add("name", name).add("id", id)
|
||||
.add("group", group.orNull()).add("geolocationGroup", geolocationGroup.orNull())
|
||||
.add("sourceIpGroup", sourceIpGroup.orNull()).add("record", record).toString();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().from(this);
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String zoneName;
|
||||
private String name;
|
||||
private String id;
|
||||
private Optional<DirectionalGroup> group = Optional.absent();
|
||||
private Optional<DirectionalGroup> geolocationGroup = Optional.absent();
|
||||
private Optional<DirectionalGroup> sourceIpGroup = Optional.absent();
|
||||
private DirectionalRecord record;
|
||||
|
||||
/**
|
||||
* @see DirectionalRecordDetail#getZoneName()
|
||||
*/
|
||||
public Builder zoneName(String zoneName) {
|
||||
this.zoneName = zoneName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecordDetail#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecordDetail#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecordDetail#getGroup()
|
||||
*/
|
||||
public Builder group(DirectionalGroup group) {
|
||||
this.group = Optional.fromNullable(group);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecordDetail#getGeolocationGroup()
|
||||
*/
|
||||
public Builder geolocationGroup(DirectionalGroup geolocationGroup) {
|
||||
this.geolocationGroup = Optional.fromNullable(geolocationGroup);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecordDetail#getSourceIpGroup()
|
||||
*/
|
||||
public Builder sourceIpGroup(DirectionalGroup sourceIpGroup) {
|
||||
this.sourceIpGroup = Optional.fromNullable(sourceIpGroup);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecordDetail#getRecord()
|
||||
*/
|
||||
public Builder record(DirectionalRecord record) {
|
||||
this.record = record;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DirectionalRecordDetail#getRecord()
|
||||
*/
|
||||
public Builder record(DirectionalRecord.Builder record) {
|
||||
this.record = record.build();
|
||||
return this;
|
||||
}
|
||||
|
||||
public DirectionalRecordDetail build() {
|
||||
return new DirectionalRecordDetail(zoneName, name, id, group, geolocationGroup, sourceIpGroup, record);
|
||||
}
|
||||
|
||||
public Builder from(DirectionalRecordDetail in) {
|
||||
return this.zoneName(in.zoneName).name(in.name).id(in.id).group(in.group.orNull())
|
||||
.geolocationGroup(in.geolocationGroup.orNull()).sourceIpGroup(in.sourceIpGroup.orNull())
|
||||
.record(in.record);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.domain;
|
||||
|
||||
/**
|
||||
* currently supported {@link ResourceRecord#getType() types} for directional
|
||||
* groups.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public enum DirectionalRecordType {
|
||||
// A/CNAME
|
||||
IPV4(1),
|
||||
|
||||
// AAAA/CNAME
|
||||
IPV6(28),
|
||||
|
||||
TXT(16),
|
||||
|
||||
SRV(33),
|
||||
|
||||
PTR(12),
|
||||
|
||||
RP(17),
|
||||
|
||||
HINFO(13),
|
||||
|
||||
NAPTR(35),
|
||||
|
||||
MX(15);
|
||||
|
||||
private final int code;
|
||||
|
||||
private DirectionalRecordType(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link ResourceRecord#getType() type} that can be used in directional
|
||||
* groups.
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* 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.features;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.POST;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.rest.annotations.Fallback;
|
||||
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.domain.DirectionalPool;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.DirectionalPoolListHandler;
|
||||
import org.jclouds.ultradns.ws.xml.DirectionalRecordDetailListHandler;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
/**
|
||||
* @see <a href="https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01?wsdl" />
|
||||
* @see <a href="https://www.ultradns.net/api/NUS_API_XML_SOAP.pdf" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(SOAPWrapWithPasswordAuth.class)
|
||||
@VirtualHost
|
||||
public interface DirectionalPoolApi {
|
||||
|
||||
/**
|
||||
* Returns all directional pools in the zone.
|
||||
*
|
||||
* @throws ResourceNotFoundException
|
||||
* if the zone doesn't exist
|
||||
*/
|
||||
@Named("getDirectionalPoolsOfZone")
|
||||
@POST
|
||||
@XMLResponseParser(DirectionalPoolListHandler.class)
|
||||
@Payload("<v01:getDirectionalPoolsOfZone><zoneName>{zoneName}</zoneName></v01:getDirectionalPoolsOfZone>")
|
||||
FluentIterable<DirectionalPool> list() throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* Returns all the directional pool records in the zone with the fully
|
||||
* qualified {@link hostName} and {@link rrType}
|
||||
*
|
||||
* @param hostName
|
||||
* fully qualified hostname including the trailing dot.
|
||||
* @param rrType
|
||||
* type value, with special casing: for {@code A} or {@code CNAME}
|
||||
* of ipv4 hosts, this is {@code 1}; for {@code AAAA} or
|
||||
* {@code CNAME} of ipv4 hosts, this is {@code 28}
|
||||
* @return empty if there are not pools for the specified host or no records
|
||||
* exist for the type.
|
||||
* @throws ResourceNotFoundException
|
||||
* if the zone doesn't exist
|
||||
*/
|
||||
@Named("getDirectionalDNSRecordsForHost")
|
||||
@POST
|
||||
@XMLResponseParser(DirectionalRecordDetailListHandler.class)
|
||||
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
||||
@Payload("<v01:getDirectionalDNSRecordsForHost><zoneName>{zoneName}</zoneName><hostName>{hostName}</hostName><poolRecordType>{poolRecordType}</poolRecordType></v01:getDirectionalDNSRecordsForHost>")
|
||||
FluentIterable<DirectionalRecordDetail> listRecordsByNameAndType(
|
||||
@PayloadParam("hostName") String dname, @PayloadParam("poolRecordType") int type)
|
||||
throws ResourceNotFoundException;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
* 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.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.cleanseAttributes;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool.TieBreak;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool.Type;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalPoolListHandler extends ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<DirectionalPool>> {
|
||||
|
||||
private final Builder<DirectionalPool> pools = ImmutableSet.<DirectionalPool> builder();
|
||||
|
||||
@Override
|
||||
public FluentIterable<DirectionalPool> getResult() {
|
||||
return FluentIterable.from(pools.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attrs) {
|
||||
if (equalsOrSuffix(qName, "DirectionalPoolData")) {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
|
||||
DirectionalPool.Builder pool = DirectionalPool.builder()
|
||||
.zoneId(attributes.get("Zoneid"))
|
||||
.id(attributes.get("dirpoolid"))
|
||||
.name(attributes.get("Pooldname"))
|
||||
.description(attributes.get("Description"));
|
||||
|
||||
String type = attributes.get("DirPoolType");
|
||||
if (type != null)
|
||||
pool.type(Type.valueOf(type));
|
||||
|
||||
String tieBreak = attributes.get("TieBreak");
|
||||
if (tieBreak != null)
|
||||
pool.tieBreak(TieBreak.valueOf(tieBreak));
|
||||
|
||||
pools.add(pool.build());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* 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.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.cleanseAttributes;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecord;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalRecordDetailHandler extends
|
||||
ParseSax.HandlerForGeneratedRequestWithResult<DirectionalRecordDetail> {
|
||||
|
||||
private DirectionalRecordDetail.Builder drd = DirectionalRecordDetail.builder();
|
||||
private DirectionalRecord.Builder dr = DirectionalRecord.drBuilder();
|
||||
|
||||
private String zoneName;
|
||||
private String dname;
|
||||
|
||||
@Override
|
||||
public DirectionalRecordDetail getResult() {
|
||||
try {
|
||||
return drd.record(dr.build()).build();
|
||||
} finally {
|
||||
drd = DirectionalRecordDetail.builder().zoneName(zoneName).name(dname);
|
||||
dr = DirectionalRecord.drBuilder();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
if (attributes.containsKey("ZoneName")) {
|
||||
zoneName = attributes.get("ZoneName");
|
||||
dname = attributes.get("DName");
|
||||
drd.zoneName(zoneName).name(dname);
|
||||
}
|
||||
if (attributes.containsKey("DirPoolRecordId")) {
|
||||
drd.id(attributes.get("DirPoolRecordId"));
|
||||
}
|
||||
if (attributes.containsKey("GroupId")) {
|
||||
drd.group(DirectionalGroup.builder()
|
||||
.id(attributes.get("GroupId"))
|
||||
.name(attributes.get("GroupName"))
|
||||
.description(attributes.get("GroupDescription")).build());
|
||||
}
|
||||
if (attributes.containsKey("GeolocationGroupId")) {
|
||||
drd.geolocationGroup(DirectionalGroup.builder()
|
||||
.id(attributes.get("GeolocationGroupId"))
|
||||
.name(attributes.get("GeolocationGroupName"))
|
||||
.description(attributes.get("GeolocationGroupDescription")).build());
|
||||
}
|
||||
if (attributes.containsKey("SourceIPGroupId")) {
|
||||
drd.sourceIpGroup(DirectionalGroup.builder()
|
||||
.id(attributes.get("SourceIPGroupId"))
|
||||
.name(attributes.get("SourceIPGroupName"))
|
||||
.description(attributes.get("SourceIPGroupDescription")).build());
|
||||
}
|
||||
if (attributes.containsKey("recordType")) {
|
||||
dr.type(attributes.get("recordType"));
|
||||
dr.ttl(Integer.parseInt(attributes.get("TTL")));
|
||||
dr.noResponseRecord("true".equalsIgnoreCase(attributes.get("noResponseRecord")));
|
||||
}
|
||||
if (equalsOrSuffix(qName, "InfoValues")) {
|
||||
dr.rdata(attributes.values());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* 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.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DirectionalRecordDetailListHandler extends
|
||||
ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<DirectionalRecordDetail>> {
|
||||
|
||||
private final DirectionalRecordDetailHandler directionalRecordHandler;
|
||||
|
||||
private final Builder<DirectionalRecordDetail> drs = ImmutableSet.<DirectionalRecordDetail> builder();
|
||||
|
||||
@Inject
|
||||
public DirectionalRecordDetailListHandler(DirectionalRecordDetailHandler directionalRecordHandler) {
|
||||
this.directionalRecordHandler = directionalRecordHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluentIterable<DirectionalRecordDetail> getResult() {
|
||||
return FluentIterable.from(drs.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) {
|
||||
directionalRecordHandler.startElement(url, name, qName, attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (equalsOrSuffix(qName, "DirectionalDNSRecordDetail")) {
|
||||
drs.add(directionalRecordHandler.getResult());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* 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.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSApi;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiExpectTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetDirectionalDNSRecordsForHostResponseTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetDirectionalPoolsByZoneResponseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "DirectionalPoolApiExpectTest")
|
||||
public class DirectionalPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
||||
|
||||
HttpRequest list = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_directionalpools.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/directionalpools.xml", "application/xml")).build();
|
||||
|
||||
public void testListWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(list, listResponse);
|
||||
|
||||
assertEquals(success.getDirectionalPoolApiForZone("jclouds.org.").list().toString(),
|
||||
new GetDirectionalPoolsByZoneResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest listRecords = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_directionalrecords.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listRecordsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/directionalrecords.xml", "application/xml")).build();
|
||||
|
||||
public void testListRecordsWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(listRecords, listRecordsResponse);
|
||||
|
||||
assertEquals(
|
||||
success.getDirectionalPoolApiForZone("jclouds.org.").listRecordsByNameAndType("www.jclouds.org.", 1).toString(),
|
||||
new GetDirectionalDNSRecordsForHostResponseTest().expected().toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/**
|
||||
* 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 WATCANTIES 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.features;
|
||||
|
||||
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 java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecord;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordType;
|
||||
import org.jclouds.ultradns.ws.domain.Zone;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", singleThreaded = true, testName = "DirectionalPoolApiLiveTest")
|
||||
public class DirectionalPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private Account account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setup() {
|
||||
super.setup();
|
||||
account = api.getCurrentAccount();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListDirectionalPools() {
|
||||
for (Zone zone : api.getZoneApi().listByAccount(account.getId())) {
|
||||
for (DirectionalPool pool : api(zone.getName()).list()) {
|
||||
checkDirectional(pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDirectional(DirectionalPool pool) {
|
||||
assertNotNull(pool.getZoneId(), "ZoneId cannot be null " + pool);
|
||||
assertNotNull(pool.getId(), "Id cannot be null " + pool);
|
||||
assertNotNull(pool.getName(), "DName cannot be null " + pool);
|
||||
assertNotNull(pool.getDescription(), "Description cannot be null " + pool);
|
||||
assertNotNull(pool.getType(), "Type cannot be null " + pool);
|
||||
assertNotNull(pool.getTieBreak(), "TieBreak cannot be null " + pool);
|
||||
}
|
||||
|
||||
Set<DirectionalGroup> allDirectionalGroups = Sets.newLinkedHashSet();
|
||||
|
||||
@Test
|
||||
public void testListDirectionalRecords() {
|
||||
for (Zone zone : api.getZoneApi().listByAccount(account.getId())) {
|
||||
for (DirectionalPool pool : api(zone.getName()).list()) {
|
||||
for (DirectionalRecordType type : EnumSet.allOf(DirectionalRecordType.class)) {
|
||||
for (DirectionalRecordDetail rr : api(zone.getName())
|
||||
.listRecordsByNameAndType(pool.getName(), type.getCode())) {
|
||||
checkDirectionalRecordDetail(rr);
|
||||
Iterable<DirectionalGroup> groups = Optional.presentInstances(ImmutableSet.of(rr.getGroup(),
|
||||
rr.getGeolocationGroup(), rr.getGeolocationGroup()));
|
||||
assertFalse(Iterables.isEmpty(groups), "No groups " + rr);
|
||||
for (DirectionalGroup group : groups) {
|
||||
allDirectionalGroups.add(group);
|
||||
assertNotNull(group.getId(), "Id cannot be null " + group);
|
||||
assertNotNull(group.getName(), "Name cannot be null " + group);
|
||||
assertNotNull(group.getDescription(), "Description cannot be null " + group);
|
||||
}
|
||||
assertEquals(rr.getZoneName(), zone.getName());
|
||||
assertEquals(rr.getName(), pool.getName());
|
||||
switch (pool.getType()) {
|
||||
case GEOLOCATION:
|
||||
assertNotNull(rr.getGeolocationGroup().or(rr.getGroup()).orNull(),
|
||||
"GeolocationGroup or Group must be present " + rr);
|
||||
assertNull(rr.getSourceIpGroup().orNull(), "SourceIpGroup must be absent " + rr);
|
||||
break;
|
||||
case SOURCEIP:
|
||||
assertNotNull(rr.getSourceIpGroup().or(rr.getGroup()).orNull(),
|
||||
"SourceIpGroup or Group must be present " + rr);
|
||||
assertNull(rr.getGeolocationGroup().orNull(), "GeolocationGroup must be absent " + rr);
|
||||
break;
|
||||
case MIXED:
|
||||
assertNotNull(rr.getGeolocationGroup().or(rr.getSourceIpGroup()).or(rr.getGroup()).orNull(),
|
||||
"GeolocationGroup, SourceIpGroup or Group must be present " + rr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void checkDirectionalRecord(DirectionalRecord rr) {
|
||||
assertNotNull(rr.getType(), "Type cannot be null " + rr);
|
||||
assertNotNull(rr.getTTL(), "TTL cannot be null " + rr);
|
||||
assertNotNull(rr.getRData(), "InfoValues cannot be null " + rr);
|
||||
}
|
||||
|
||||
static void checkDirectionalRecordDetail(DirectionalRecordDetail rr) {
|
||||
assertNotNull(rr.getZoneName(), "ZoneName cannot be null " + rr);
|
||||
assertNotNull(rr.getName(), "DName cannot be null " + rr);
|
||||
assertNotNull(rr.getId(), "Id cannot be null " + rr);
|
||||
assertNotNull(rr.getZoneName(), "ZoneName cannot be null " + rr);
|
||||
checkDirectionalRecord(rr.getRecord());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Parent Zone does not exist in the system.")
|
||||
public void testListDirectionalsWhenZoneIdNotFound() {
|
||||
api("AAAAAAAAAAAAAAAA").list();
|
||||
}
|
||||
|
||||
private DirectionalPoolApi api(String zoneName) {
|
||||
return api.getDirectionalPoolApiForZone(zoneName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalGroup;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecord;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalRecordDetail;
|
||||
import org.jclouds.ultradns.ws.xml.DirectionalRecordDetailListHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "GetDirectionalDNSRecordsForHostResponseTest")
|
||||
public class GetDirectionalDNSRecordsForHostResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/directionalrecords.xml");
|
||||
|
||||
FluentIterable<DirectionalRecordDetail> expected = expected();
|
||||
|
||||
DirectionalRecordDetailListHandler handler = injector.getInstance(DirectionalRecordDetailListHandler.class);
|
||||
FluentIterable<DirectionalRecordDetail> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toSet().toString(), expected.toSet().toString());
|
||||
}
|
||||
|
||||
public FluentIterable<DirectionalRecordDetail> expected() {
|
||||
return FluentIterable.from(ImmutableSet.<DirectionalRecordDetail> builder()
|
||||
.add(DirectionalRecordDetail.builder()
|
||||
.zoneName("directional-example.com.")
|
||||
.name("chaos.directional-example.com.")
|
||||
.id("06093C2D10CB1CB1")
|
||||
.geolocationGroup(DirectionalGroup.builder()
|
||||
.id("06093C2D10CB1CB2")
|
||||
.name("Geolocation field")
|
||||
.build())
|
||||
.sourceIpGroup(DirectionalGroup.builder()
|
||||
.id("06093C2D10CB1CB4")
|
||||
.name("172.16.1.0/24")
|
||||
.build())
|
||||
.record(DirectionalRecord.drBuilder()
|
||||
.type("A")
|
||||
.ttl(60)
|
||||
.noResponseRecord(false)
|
||||
.rdata("172.16.1.1").build()).build())
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* 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 WADirectionalANTIES 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.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool.TieBreak;
|
||||
import org.jclouds.ultradns.ws.domain.DirectionalPool.Type;
|
||||
import org.jclouds.ultradns.ws.xml.DirectionalPoolListHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "GetDirectionalPoolsByZoneResponseTest")
|
||||
public class GetDirectionalPoolsByZoneResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/directionalpools.xml");
|
||||
|
||||
FluentIterable<DirectionalPool> expected = expected();
|
||||
|
||||
DirectionalPoolListHandler handler = injector.getInstance(DirectionalPoolListHandler.class);
|
||||
FluentIterable<DirectionalPool> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toSet().toString(), expected.toSet().toString());
|
||||
}
|
||||
|
||||
public FluentIterable<DirectionalPool> expected() {
|
||||
return FluentIterable.from(ImmutableList.<DirectionalPool> builder()
|
||||
.add(DirectionalPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000000A")
|
||||
.name("mixy.jclouds.org.")
|
||||
.type(Type.MIXED)
|
||||
.tieBreak(TieBreak.GEOLOCATION)
|
||||
.description("mixy").build())
|
||||
.add(DirectionalPool.builder()
|
||||
.zoneId("0000000000000002")
|
||||
.id("000000000000000B")
|
||||
.name("geo.jclouds.org.").build()).build());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<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">2142</errorCode>
|
||||
<errorDescription xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">No Pool or Multiple pools of same type exists for the PoolName : foo.jclouds.org.</errorDescription>
|
||||
</ns1:UltraWSException>
|
||||
</detail>
|
||||
</soap:Fault>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,14 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns1:getDirectionalPoolsOfZoneResponse
|
||||
xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/">
|
||||
<DirectionalPoolList xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">
|
||||
<ns2:DirectionalPoolData dirpoolid="000000000000000A"
|
||||
Zoneid="0000000000000001" Pooldname="mixy.jclouds.org."
|
||||
DirPoolType="MIXED" TieBreak="GEOLOCATION" Description="mixy" />
|
||||
<ns2:DirectionalPoolData dirpoolid="000000000000000B"
|
||||
Zoneid="0000000000000002" Pooldname="geo.jclouds.org." />
|
||||
</DirectionalPoolList>
|
||||
</ns1:getDirectionalPoolsOfZoneResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,19 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<getDirectionalDNSRecordsForHostResponse
|
||||
xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/">
|
||||
<DirectionalDNSRecordDetailList
|
||||
ZoneName="directional-example.com." DName="chaos.directional-example.com.">
|
||||
<DirectionalDNSRecordDetail
|
||||
GeolocationGroupName="Geolocation field" GeolocationGroupId="06093C2D10CB1CB2"
|
||||
SourceIPGroupName="172.16.1.0/24" SourceIPGroupId="06093C2D10CB1CB4"
|
||||
TerritoriesCount="8" DirPoolRecordId="06093C2D10CB1CB1">
|
||||
<DirectionalDNSRecord recordType="A" TTL="60"
|
||||
noResponseRecord="false">
|
||||
<InfoValues Info1Value="172.16.1.1" />
|
||||
</DirectionalDNSRecord>
|
||||
</DirectionalDNSRecordDetail>
|
||||
</DirectionalDNSRecordDetailList>
|
||||
</getDirectionalDNSRecordsForHostResponse>
|
||||
</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:getDirectionalPoolsOfZone><zoneName>jclouds.org.</zoneName></v01:getDirectionalPoolsOfZone></soapenv:Body></soapenv: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:getDirectionalDNSRecordsForHost><zoneName>jclouds.org.</zoneName><hostName>www.jclouds.org.</hostName><poolRecordType>1</poolRecordType></v01:getDirectionalDNSRecordsForHost></soapenv:Body></soapenv:Envelope>
|
Loading…
Reference in New Issue