mirror of https://github.com/apache/jclouds.git
Merge pull request #1447 from jclouds/ultradns-tcpool-list
added base TrafficControllerPoolApi with list() implemented
This commit is contained in:
commit
a8bb4a8b46
|
@ -21,9 +21,10 @@ package org.jclouds.ultradns.ws;
|
|||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordApi;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.TaskApi;
|
||||
import org.jclouds.ultradns.ws.features.TrafficControllerPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.ZoneApi;
|
||||
|
||||
/**
|
||||
|
@ -64,6 +65,15 @@ public interface UltraDNSWSApi {
|
|||
@Delegate
|
||||
RoundRobinPoolApi getRoundRobinPoolApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Traffic Controller Pool features.
|
||||
*
|
||||
* @param zoneName
|
||||
* zoneName including a trailing dot
|
||||
*/
|
||||
@Delegate
|
||||
TrafficControllerPoolApi getTrafficControllerPoolApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Task features.
|
||||
*/
|
||||
|
|
|
@ -28,9 +28,10 @@ import org.jclouds.rest.annotations.RequestFilters;
|
|||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.TaskAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.TrafficControllerPoolAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.ZoneAsyncApi;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.AccountHandler;
|
||||
|
@ -82,6 +83,15 @@ public interface UltraDNSWSAsyncApi {
|
|||
@Delegate
|
||||
RoundRobinPoolAsyncApi getRoundRobinPoolApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Traffic Controller Pool features.
|
||||
*
|
||||
* @param zoneName
|
||||
* zoneName including a trailing dot
|
||||
*/
|
||||
@Delegate
|
||||
TrafficControllerPoolAsyncApi getTrafficControllerPoolApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Task features.
|
||||
*/
|
||||
|
|
|
@ -29,12 +29,14 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
import org.jclouds.rest.config.RestClientModule;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSApi;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.RoundRobinPoolAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.TaskApi;
|
||||
import org.jclouds.ultradns.ws.features.TaskAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.TrafficControllerPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.TrafficControllerPoolAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.ZoneApi;
|
||||
import org.jclouds.ultradns.ws.features.ZoneAsyncApi;
|
||||
import org.jclouds.ultradns.ws.handlers.UltraDNSWSErrorHandler;
|
||||
|
@ -53,6 +55,7 @@ public class UltraDNSWSRestClientModule extends RestClientModule<UltraDNSWSApi,
|
|||
.put(ZoneApi.class, ZoneAsyncApi.class)
|
||||
.put(ResourceRecordApi.class, ResourceRecordAsyncApi.class)
|
||||
.put(RoundRobinPoolApi.class, RoundRobinPoolAsyncApi.class)
|
||||
.put(TrafficControllerPoolApi.class, TrafficControllerPoolAsyncApi.class)
|
||||
.put(TaskApi.class, TaskAsyncApi.class).build();
|
||||
|
||||
public UltraDNSWSRestClientModule() {
|
||||
|
|
|
@ -0,0 +1,209 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Traffic Controller pools are used to create weighted {@code A} and {@code CNAME} records.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class TrafficControllerPool {
|
||||
|
||||
private final String zoneId;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final String dname;
|
||||
private final int statusCode;
|
||||
private final boolean failOverEnabled;
|
||||
private final boolean probingEnabled;
|
||||
|
||||
private TrafficControllerPool(String zoneId, String id, String name, String dname, int statusCode,
|
||||
boolean failOverEnabled, boolean probingEnabled) {
|
||||
this.zoneId = checkNotNull(zoneId, "zoneId");
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name for %s", id);
|
||||
this.dname = checkNotNull(dname, "dname for %s", id);
|
||||
this.statusCode = statusCode;
|
||||
this.failOverEnabled = failOverEnabled;
|
||||
this.probingEnabled = probingEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the zone.
|
||||
*/
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the pool.
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the pool. ex. {@code My Pool}
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The dname of the pool. ex. {@code jclouds.org.}
|
||||
*/
|
||||
public String getDName() {
|
||||
return dname;
|
||||
}
|
||||
|
||||
/**
|
||||
* status of the pool
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code true} if the pool is active and serving records.
|
||||
*/
|
||||
public boolean isFailOverEnabled() {
|
||||
return failOverEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code true} indicates the pool is functioning normally. {@code false}
|
||||
* indicates testing only—probing records and reporting results, but not
|
||||
* acting on the results
|
||||
*/
|
||||
public boolean isProbingEnabled() {
|
||||
return probingEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(zoneId, id, name, dname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TrafficControllerPool that = TrafficControllerPool.class.cast(obj);
|
||||
return Objects.equal(this.zoneId, that.zoneId) && Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.name, that.name) && Objects.equal(this.dname, that.dname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("zoneId", zoneId).add("id", id).add("name", name)
|
||||
.add("dname", dname).add("status", statusCode).add("failOverEnabled", failOverEnabled)
|
||||
.add("probingEnabled", probingEnabled).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 String name;
|
||||
private String dname;
|
||||
private int statusCode;
|
||||
private boolean failOverEnabled;
|
||||
private boolean probingEnabled;
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPool#getZoneId()
|
||||
*/
|
||||
public Builder zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPool#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPool#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPool#getDName()
|
||||
*/
|
||||
public Builder dname(String dname) {
|
||||
this.dname = dname;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPool#getStatusCode()
|
||||
*/
|
||||
public Builder statusCode(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPool#isFailOverEnabled()
|
||||
*/
|
||||
public Builder failOverEnabled(boolean failOverEnabled) {
|
||||
this.failOverEnabled = failOverEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPool#isProbingEnabled()
|
||||
*/
|
||||
public Builder probingEnabled(boolean probingEnabled) {
|
||||
this.probingEnabled = probingEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TrafficControllerPool build() {
|
||||
return new TrafficControllerPool(zoneId, id, name, dname, statusCode, failOverEnabled, probingEnabled);
|
||||
}
|
||||
|
||||
public Builder from(TrafficControllerPool in) {
|
||||
return this.zoneId(in.zoneId).id(in.id).name(in.name).dname(in.dname).statusCode(in.statusCode)
|
||||
.failOverEnabled(in.failOverEnabled).probingEnabled(in.probingEnabled);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* 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 org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPoolAsyncApi
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface TrafficControllerPoolApi {
|
||||
|
||||
/**
|
||||
* Returns all traffic controller pools in the zone.
|
||||
*
|
||||
* @throws ResourceNotFoundException
|
||||
* if the zone doesn't exist
|
||||
*/
|
||||
FluentIterable<TrafficControllerPool> list() throws ResourceNotFoundException;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* 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.rest.ResourceNotFoundException;
|
||||
import org.jclouds.rest.annotations.Payload;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.TrafficControllerPoolListHandler;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPoolApi
|
||||
* @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 TrafficControllerPoolAsyncApi {
|
||||
|
||||
/**
|
||||
* @see TrafficControllerPoolApi#list()
|
||||
*/
|
||||
@Named("getLoadBalancingPoolsByZone")
|
||||
@POST
|
||||
@XMLResponseParser(TrafficControllerPoolListHandler.class)
|
||||
@Payload("<v01:getLoadBalancingPoolsByZone><zoneName>{zoneName}</zoneName><lbPoolType>TC</lbPoolType></v01:getLoadBalancingPoolsByZone>")
|
||||
ListenableFuture<FluentIterable<TrafficControllerPool>> list() throws ResourceNotFoundException;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* 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.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool.Builder;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class TrafficControllerPoolHandler extends ParseSax.HandlerForGeneratedRequestWithResult<TrafficControllerPool> {
|
||||
|
||||
private Builder pool = TrafficControllerPool.builder();
|
||||
|
||||
@Override
|
||||
public TrafficControllerPool getResult() {
|
||||
try {
|
||||
return pool.build();
|
||||
} finally {
|
||||
pool = TrafficControllerPool.builder();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
if (equalsOrSuffix(qName, "LBPoolData")) {
|
||||
pool.zoneId(attributes.get("zoneid"));
|
||||
} else if (equalsOrSuffix(qName, "PoolData")) {
|
||||
pool.id(attributes.get("PoolId")).name(attributes.get("PoolName")).dname(attributes.get("PoolDName"));
|
||||
pool.statusCode(Integer.parseInt(attributes.get("PoolStatus")));
|
||||
pool.failOverEnabled("Enabled".equalsIgnoreCase(attributes.get("FailOver")));
|
||||
pool.probingEnabled("Enabled".equalsIgnoreCase(attributes.get("Probing")));
|
||||
// MaxActiveServers is always 0 for TC
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* 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.TrafficControllerPool;
|
||||
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 TrafficControllerPoolListHandler extends ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<TrafficControllerPool>> {
|
||||
|
||||
private final TrafficControllerPoolHandler poolHandler;
|
||||
|
||||
private final Builder<TrafficControllerPool> pools = ImmutableSet.<TrafficControllerPool> builder();
|
||||
|
||||
@Inject
|
||||
public TrafficControllerPoolListHandler(TrafficControllerPoolHandler poolHandler) {
|
||||
this.poolHandler = poolHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluentIterable<TrafficControllerPool> getResult() {
|
||||
return FluentIterable.from(pools.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) {
|
||||
if (equalsOrSuffix(qName, "LBPoolData") || equalsOrSuffix(qName, "PoolData")) {
|
||||
poolHandler.startElement(url, name, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (equalsOrSuffix(qName, "LBPoolData")) {
|
||||
pools.add(poolHandler.getResult());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ import org.jclouds.http.HttpResponse;
|
|||
import org.jclouds.ultradns.ws.UltraDNSWSApi;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSExceptions.ResourceAlreadyExistsException;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiExpectTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetLoadBalancingPoolsByZoneResponseTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetRRLoadBalancingPoolsByZoneResponseTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetResourceRecordsOfResourceRecordResponseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
|
||||
assertEquals(
|
||||
success.getRoundRobinPoolApiForZone("jclouds.org.").list().toString(),
|
||||
new GetLoadBalancingPoolsByZoneResponseTest().expected().toString());
|
||||
new GetRRLoadBalancingPoolsByZoneResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest listRecords = HttpRequest.builder().method("POST")
|
||||
|
@ -108,7 +108,7 @@ public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
|
||||
public void testDeleteWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(delete, deleteResponse);
|
||||
success.getZoneApi().delete("04053D8E57C7931F");
|
||||
success.getRoundRobinPoolApiForZone("jclouds.org.").delete("04053D8E57C7931F");
|
||||
}
|
||||
|
||||
HttpResponse poolDoesntExist = HttpResponse.builder().message("Server Epoolor").statusCode(500)
|
||||
|
@ -116,6 +116,6 @@ public class RoundRobinPoolApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
|
||||
public void testDeleteWhenResponseRRNotFound() {
|
||||
UltraDNSWSApi notFound = requestSendsResponse(delete, poolDoesntExist);
|
||||
notFound.getZoneApi().delete("04053D8E57C7931F");
|
||||
notFound.getRoundRobinPoolApiForZone("jclouds.org.").delete("04053D8E57C7931F");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,17 +61,18 @@ public class RoundRobinPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
|||
context.getApi().getZoneApi().createInAccount(zoneName, account.getId());
|
||||
}
|
||||
|
||||
private void checkLBPool(RoundRobinPool pool) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListRRPools() {
|
||||
for (Zone zone : context.getApi().getZoneApi().listByAccount(account.getId())) {
|
||||
for (RoundRobinPool pool : api(zone.getName()).list()) {
|
||||
checkLBPool(pool);
|
||||
checkRRPool(pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* 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.GetTCLoadBalancingPoolsByZoneResponseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "TrafficControllerPoolApiExpectTest")
|
||||
public class TrafficControllerPoolApiExpectTest 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_tcpools.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/tcpools.xml", "application/xml")).build();
|
||||
|
||||
public void testListWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(list, listResponse);
|
||||
|
||||
assertEquals(success.getTrafficControllerPoolApiForZone("jclouds.org.").list().toString(),
|
||||
new GetTCLoadBalancingPoolsByZoneResponseTest().expected().toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* 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 com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.domain.Zone;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", singleThreaded = true, testName = "TrafficControllerPoolApiLiveTest")
|
||||
public class TrafficControllerPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private Account account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
account = context.getApi().getCurrentAccount();
|
||||
}
|
||||
|
||||
private void checkTCPool(TrafficControllerPool pool) {
|
||||
checkNotNull(pool.getZoneId(), "ZoneId cannot be null for a TrafficControllerPool %s", pool);
|
||||
checkNotNull(pool.getId(), "Id cannot be null for a TrafficControllerPool %s", pool);
|
||||
checkNotNull(pool.getName(), "Name cannot be null for a TrafficControllerPool %s", pool);
|
||||
checkNotNull(pool.getDName(), "DName cannot be null for a TrafficControllerPool %s", pool);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListTCPools() {
|
||||
for (Zone zone : context.getApi().getZoneApi().listByAccount(account.getId())) {
|
||||
for (TrafficControllerPool pool : api(zone.getName()).list()) {
|
||||
checkTCPool(pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Zone does not exist in the system.")
|
||||
public void testListTCPoolsWhenZoneIdNotFound() {
|
||||
api("AAAAAAAAAAAAAAAA").list();
|
||||
}
|
||||
|
||||
private TrafficControllerPoolApi api(String zoneName) {
|
||||
return context.getApi().getTrafficControllerPoolApiForZone(zoneName);
|
||||
}
|
||||
}
|
|
@ -33,8 +33,8 @@ import com.google.common.collect.ImmutableList;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "GetLoadBalancingPoolsByZoneResponseTest")
|
||||
public class GetLoadBalancingPoolsByZoneResponseTest extends BaseHandlerTest {
|
||||
@Test(testName = "GetRRLoadBalancingPoolsByZoneResponseTest")
|
||||
public class GetRRLoadBalancingPoolsByZoneResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/rrpools.xml");
|
||||
|
@ -50,19 +50,19 @@ public class GetLoadBalancingPoolsByZoneResponseTest extends BaseHandlerTest {
|
|||
public FluentIterable<RoundRobinPool> expected() {
|
||||
return FluentIterable.from(ImmutableList.<RoundRobinPool> builder()
|
||||
.add(RoundRobinPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000002")
|
||||
.name("app-uswest1.jclouds.org.")
|
||||
.dname("app-uswest1.jclouds.org.").build())
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000002")
|
||||
.name("app-uswest1.jclouds.org.")
|
||||
.dname("app-uswest1.jclouds.org.").build())
|
||||
.add(RoundRobinPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000003")
|
||||
.name("app-uswest2.jclouds.org.")
|
||||
.dname("app-uswest2.jclouds.org.").build())
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000003")
|
||||
.name("app-uswest2.jclouds.org.")
|
||||
.dname("app-uswest2.jclouds.org.").build())
|
||||
.add(RoundRobinPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000004")
|
||||
.name("app-euwest.jclouds.org.")
|
||||
.dname("app-euwest.jclouds.org.").build()).build());
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000004")
|
||||
.name("app-euwest.jclouds.org.")
|
||||
.dname("app-euwest.jclouds.org.").build()).build());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* 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.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.domain.TrafficControllerPool;
|
||||
import org.jclouds.ultradns.ws.xml.TrafficControllerPoolListHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "GetTCLoadBalancingPoolsByZoneResponseTest")
|
||||
public class GetTCLoadBalancingPoolsByZoneResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/tcpools.xml");
|
||||
|
||||
FluentIterable<TrafficControllerPool> expected = expected();
|
||||
|
||||
TrafficControllerPoolListHandler handler = injector.getInstance(TrafficControllerPoolListHandler.class);
|
||||
FluentIterable<TrafficControllerPool> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toSet().toString(), expected.toSet().toString());
|
||||
}
|
||||
|
||||
public FluentIterable<TrafficControllerPool> expected() {
|
||||
return FluentIterable.from(ImmutableList.<TrafficControllerPool> builder()
|
||||
.add(TrafficControllerPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000002")
|
||||
.name("us-west-1c.discovery.jclouds.org.")
|
||||
.dname("us-west-1c.discovery.jclouds.org.")
|
||||
.statusCode(1)
|
||||
.failOverEnabled(true)
|
||||
.probingEnabled(true).build()).build());
|
||||
}
|
||||
}
|
|
@ -1 +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:deleteZone><transactionID /><zoneName>04053D8E57C7931F</zoneName></v01:deleteZone></soapenv:Body></soapenv:Envelope>
|
||||
<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:deleteLBPool><transactionID /><lbPoolID>04053D8E57C7931F</lbPoolID><DeleteAll>Yes</DeleteAll><retainRecordId /></v01:deleteLBPool></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:getLoadBalancingPoolsByZone><zoneName>jclouds.org.</zoneName><lbPoolType>TC</lbPoolType></v01:getLoadBalancingPoolsByZone></soapenv:Body></soapenv:Envelope>
|
|
@ -0,0 +1,15 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns1:getLoadBalancingPoolsByZoneResponse
|
||||
xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/">
|
||||
<LBPoolList xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">
|
||||
<ns2:LBPoolData zoneid="0000000000000001">
|
||||
<ns2:PoolData PoolName="us-west-1c.discovery.jclouds.org."
|
||||
PoolId="000000000000002" PoolType="TC" PoolStatus="1"
|
||||
PoolDName="us-west-1c.discovery.jclouds.org." FailOver="Enabled"
|
||||
Probing="Enabled" MaxActiveServers="0" />
|
||||
</ns2:LBPoolData>
|
||||
</LBPoolList>
|
||||
</ns1:getLoadBalancingPoolsByZoneResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
Loading…
Reference in New Issue