mirror of https://github.com/apache/jclouds.git
Merge pull request #1390 from jclouds/ultra-lbpool
initial start on lbpool for ultra
This commit is contained in:
commit
e48f0e3f3d
|
@ -21,6 +21,7 @@ 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.LBPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordApi;
|
||||
import org.jclouds.ultradns.ws.features.TaskApi;
|
||||
import org.jclouds.ultradns.ws.features.ZoneApi;
|
||||
|
@ -54,6 +55,15 @@ public interface UltraDNSWSApi {
|
|||
@Delegate
|
||||
ResourceRecordApi getResourceRecordApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Load Balancing Pool features.
|
||||
*
|
||||
* @param zoneName
|
||||
* zoneName including a trailing dot
|
||||
*/
|
||||
@Delegate
|
||||
LBPoolApi getLBPoolApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Task features.
|
||||
*/
|
||||
|
|
|
@ -66,7 +66,7 @@ public class UltraDNSWSApiMetadata extends BaseRestApiMetadata {
|
|||
.identityName("Username")
|
||||
.credentialName("Password")
|
||||
.version("v01")
|
||||
.documentation(URI.create("https://www.ultradns.net/api/NUS_API_XML_SOAP.pdf"))
|
||||
.documentation(URI.create("https://portal.ultradns.com/static/docs/NUS_API_XML_SOAP.pdf"))
|
||||
.defaultEndpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.defaultProperties(UltraDNSWSApiMetadata.defaultProperties())
|
||||
.defaultModule(UltraDNSWSRestClientModule.class);
|
||||
|
|
|
@ -28,6 +28,7 @@ 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.LBPoolAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.TaskAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.ZoneAsyncApi;
|
||||
|
@ -72,6 +73,15 @@ public interface UltraDNSWSAsyncApi {
|
|||
@Delegate
|
||||
ResourceRecordAsyncApi getResourceRecordApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Load Balancing Pool features.
|
||||
*
|
||||
* @param zoneName
|
||||
* zoneName including a trailing dot
|
||||
*/
|
||||
@Delegate
|
||||
LBPoolAsyncApi getLBPoolApiForZone(@PayloadParam("zoneName") String zoneName);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Task features.
|
||||
*/
|
||||
|
|
|
@ -61,7 +61,7 @@ public class UltraDNSWSProviderMetadata extends BaseProviderMetadata {
|
|||
.name("Neustar UltraDNS WS")
|
||||
.apiMetadata(new UltraDNSWSApiMetadata())
|
||||
.homepage(URI.create("http://www.neustar.biz/enterprise/dns-services/what-is-external-dns"))
|
||||
.console(URI.create("https://www.ultradns.net"))
|
||||
.console(URI.create("https://portal.ultradns.com"))
|
||||
.iso3166Codes("US-CA", "US-VA") // TODO
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.defaultProperties(UltraDNSWSProviderMetadata.defaultProperties());
|
||||
|
|
|
@ -29,6 +29,8 @@ 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.LBPoolApi;
|
||||
import org.jclouds.ultradns.ws.features.LBPoolAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordApi;
|
||||
import org.jclouds.ultradns.ws.features.ResourceRecordAsyncApi;
|
||||
import org.jclouds.ultradns.ws.features.TaskApi;
|
||||
|
@ -50,6 +52,7 @@ public class UltraDNSWSRestClientModule extends RestClientModule<UltraDNSWSApi,
|
|||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
||||
.put(ZoneApi.class, ZoneAsyncApi.class)
|
||||
.put(ResourceRecordApi.class, ResourceRecordAsyncApi.class)
|
||||
.put(LBPoolApi.class, LBPoolAsyncApi.class)
|
||||
.put(TaskApi.class, TaskAsyncApi.class).build();
|
||||
|
||||
public UltraDNSWSRestClientModule() {
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class LBPool {
|
||||
|
||||
private final String zoneId;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final Type type;
|
||||
private final Optional<Type> responseMethod;
|
||||
|
||||
private LBPool(String zoneId, String id, String name, Type type, Optional<Type> responseMethod) {
|
||||
this.zoneId = checkNotNull(zoneId, "zoneId");
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name for %s", id);
|
||||
this.type = checkNotNull(type, "type for %s", name);
|
||||
this.responseMethod = checkNotNull(responseMethod, "responseMethod for %s", name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 jclouds.org.}
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the pool
|
||||
*/
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The response method
|
||||
*/
|
||||
public Optional<Type> getResponseMethod() {
|
||||
return responseMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(zoneId, id, name, type, responseMethod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
LBPool that = LBPool.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.type, that.type)
|
||||
&& Objects.equal(this.responseMethod, that.responseMethod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("zoneId", zoneId).add("id", id).add("name", name)
|
||||
.add("type", type).add("responseMethod", responseMethod.orNull()).toString();
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
|
||||
RD, RR, SB, TC, UNRECOGNIZED;
|
||||
|
||||
public static Type fromValue(String type) {
|
||||
try {
|
||||
return valueOf(checkNotNull(type, "type"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 Type type;
|
||||
private Optional<Type> responseMethod = Optional.absent();
|
||||
|
||||
/**
|
||||
* @see LBPool#getZoneId()
|
||||
*/
|
||||
public Builder zoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LBPool#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LBPool#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LBPool#getType()
|
||||
*/
|
||||
public Builder type(Type type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LBPool#getResponseMethod()
|
||||
*/
|
||||
public Builder responseMethod(Type responseMethod) {
|
||||
this.responseMethod = Optional.fromNullable(responseMethod);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LBPool build() {
|
||||
return new LBPool(zoneId, id, name, type, responseMethod);
|
||||
}
|
||||
|
||||
public Builder from(LBPool in) {
|
||||
return this.zoneId(in.zoneId).id(in.id).name(in.name).type(in.type).responseMethod(in.responseMethod.orNull());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class PoolRecord {
|
||||
|
||||
private final String poolId;
|
||||
private final String id;
|
||||
private final String description;
|
||||
private final String type;
|
||||
private final String pointsTo;
|
||||
|
||||
private PoolRecord(String poolId, String id, String description, String type, String pointsTo) {
|
||||
this.poolId = checkNotNull(poolId, "poolId");
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.description = checkNotNull(description, "description for %s", id);
|
||||
this.type = checkNotNull(type, "type for %s", description);
|
||||
this.pointsTo = checkNotNull(pointsTo, "pointsTo for %s", description);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the pool.
|
||||
*/
|
||||
public String getPoolId() {
|
||||
return poolId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the record.
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of the record. ex. {@code SiteBacker pool via API}
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the record ex. ex. {@code A}
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* What the record points to ex. {@code 172.16.8.1}
|
||||
*/
|
||||
public String getPointsTo() {
|
||||
return pointsTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(poolId, id, description, type, pointsTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PoolRecord that = PoolRecord.class.cast(obj);
|
||||
return Objects.equal(this.poolId, that.poolId) && Objects.equal(this.id, that.id)
|
||||
&& Objects.equal(this.description, that.description) && Objects.equal(this.type, that.type)
|
||||
&& Objects.equal(this.pointsTo, that.pointsTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("poolId", poolId).add("id", id).add("description", description)
|
||||
.add("type", type).add("pointsTo", pointsTo).toString();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return builder().from(this);
|
||||
}
|
||||
|
||||
public final static class Builder {
|
||||
private String poolId;
|
||||
private String id;
|
||||
private String description;
|
||||
private String type;
|
||||
private String pointsTo;
|
||||
|
||||
/**
|
||||
* @see PoolRecord#getPoolId()
|
||||
*/
|
||||
public Builder poolId(String poolId) {
|
||||
this.poolId = poolId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PoolRecord#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PoolRecord#getDescription()
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PoolRecord#getType()
|
||||
*/
|
||||
public Builder type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PoolRecord#getPointsTo()
|
||||
*/
|
||||
public Builder pointsTo(String pointsTo) {
|
||||
this.pointsTo = pointsTo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PoolRecord build() {
|
||||
return new PoolRecord(poolId, id, description, type, pointsTo);
|
||||
}
|
||||
|
||||
public Builder from(PoolRecord in) {
|
||||
return this.poolId(in.poolId).id(in.id).description(in.description).type(in.type).pointsTo(in.pointsTo);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 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.LBPool;
|
||||
import org.jclouds.ultradns.ws.domain.LBPool.Type;
|
||||
import org.jclouds.ultradns.ws.domain.PoolRecord;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
/**
|
||||
* @see LBPoolAsyncApi
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface LBPoolApi {
|
||||
|
||||
/**
|
||||
* Returns all pools in the zone.
|
||||
*
|
||||
* @throws ResourceNotFoundException
|
||||
* if the zone doesn't exist
|
||||
*/
|
||||
FluentIterable<LBPool> list() throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* Returns all records in the pool.
|
||||
*
|
||||
* @throws ResourceNotFoundException
|
||||
* if the pool doesn't exist
|
||||
*/
|
||||
FluentIterable<PoolRecord> listRecords(String poolId) throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* Returns all pools with the specified {@link LBPool#getType()}
|
||||
*
|
||||
* @param type
|
||||
* the {@link LBPool#getType() type}
|
||||
* @throws ResourceNotFoundException
|
||||
* if the zone doesn't exist
|
||||
*/
|
||||
FluentIterable<LBPool> listByType(Type type) throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* removes a pool and all its records and probes
|
||||
*
|
||||
* @param id the {@link LBPool#getId() id}
|
||||
*/
|
||||
void delete(String id);
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* 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.VoidOnNotFoundOr404;
|
||||
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.LBPool;
|
||||
import org.jclouds.ultradns.ws.domain.LBPool.Type;
|
||||
import org.jclouds.ultradns.ws.domain.PoolRecord;
|
||||
import org.jclouds.ultradns.ws.filters.SOAPWrapWithPasswordAuth;
|
||||
import org.jclouds.ultradns.ws.xml.LBPoolListHandler;
|
||||
import org.jclouds.ultradns.ws.xml.PoolRecordListHandler;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* @see LBPoolApi
|
||||
* @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 LBPoolAsyncApi {
|
||||
|
||||
/**
|
||||
* @see LBPoolApi#list()
|
||||
*/
|
||||
@Named("getLoadBalancingPoolsByZone")
|
||||
@POST
|
||||
@XMLResponseParser(LBPoolListHandler.class)
|
||||
@Payload("<v01:getLoadBalancingPoolsByZone><zoneName>{zoneName}</zoneName><lbPoolType>all</lbPoolType></v01:getLoadBalancingPoolsByZone>")
|
||||
ListenableFuture<FluentIterable<LBPool>> list() throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* @see LBPoolApi#listRecords(String)
|
||||
*/
|
||||
@Named("getPoolRecords")
|
||||
@POST
|
||||
@XMLResponseParser(PoolRecordListHandler.class)
|
||||
@Payload("<v01:getPoolRecords><poolId>{poolId}</poolId></v01:getPoolRecords>")
|
||||
ListenableFuture<FluentIterable<PoolRecord>> listRecords(@PayloadParam("poolId") String poolId) throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* @see LBPoolApi#listByType(String)
|
||||
*/
|
||||
@Named("getLoadBalancingPoolsByZone")
|
||||
@POST
|
||||
@XMLResponseParser(LBPoolListHandler.class)
|
||||
@Payload("<v01:getLoadBalancingPoolsByZone><zoneName>{zoneName}</zoneName><lbPoolType>{type}</lbPoolType></v01:getLoadBalancingPoolsByZone>")
|
||||
ListenableFuture<FluentIterable<LBPool>> listByType(@PayloadParam("type") Type type)
|
||||
throws ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* @see LBPoolApi#delete(String)
|
||||
*/
|
||||
@Named("deleteLBPool")
|
||||
@POST
|
||||
@Payload("<v01:deleteLBPool><transactionID /><lbPoolID>{lbPoolID}</lbPoolID><DeleteAll>Yes</DeleteAll></v01:deleteLBPool>")
|
||||
@Fallback(VoidOnNotFoundOr404.class)
|
||||
ListenableFuture<Void> delete(@PayloadParam("lbPoolID") String id);
|
||||
}
|
|
@ -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.LBPool;
|
||||
import org.jclouds.ultradns.ws.domain.LBPool.Builder;
|
||||
import org.jclouds.ultradns.ws.domain.LBPool.Type;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class LBPoolHandler extends ParseSax.HandlerForGeneratedRequestWithResult<LBPool> {
|
||||
|
||||
private Builder pool = LBPool.builder();
|
||||
|
||||
@Override
|
||||
public LBPool getResult() {
|
||||
try {
|
||||
return pool.build();
|
||||
} finally {
|
||||
pool = LBPool.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")) {
|
||||
Type responseMethod = attributes.containsKey("ResponseMethod") ? Type.fromValue(attributes
|
||||
.get("ResponseMethod")) : null;
|
||||
pool.id(attributes.get("PoolId")).name(attributes.get("PoolName"))
|
||||
.type(Type.fromValue(attributes.get("PoolType"))).responseMethod(responseMethod);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.LBPool;
|
||||
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 LBPoolListHandler extends ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<LBPool>> {
|
||||
|
||||
private final LBPoolHandler poolHandler;
|
||||
|
||||
private Builder<LBPool> pools = ImmutableSet.<LBPool> builder();
|
||||
|
||||
@Inject
|
||||
public LBPoolListHandler(LBPoolHandler poolHandler) {
|
||||
this.poolHandler = poolHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluentIterable<LBPool> 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* 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.PoolRecord;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class PoolRecordHandler extends ParseSax.HandlerForGeneratedRequestWithResult<PoolRecord> {
|
||||
|
||||
private PoolRecord poolRecord;
|
||||
|
||||
@Override
|
||||
public PoolRecord getResult() {
|
||||
try {
|
||||
return poolRecord;
|
||||
} finally {
|
||||
poolRecord = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
if (equalsOrSuffix(qName, "PoolRecordData")) {
|
||||
poolRecord = PoolRecord.builder()
|
||||
.poolId(attributes.get("poolId"))
|
||||
.id(attributes.get("poolRecordID"))
|
||||
.description(attributes.get("description"))
|
||||
.type(attributes.get("recordType"))
|
||||
.pointsTo(attributes.get("pointsTo")).build();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.PoolRecord;
|
||||
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 PoolRecordListHandler extends ParseSax.HandlerForGeneratedRequestWithResult<FluentIterable<PoolRecord>> {
|
||||
|
||||
private final PoolRecordHandler zoneHandler;
|
||||
|
||||
private Builder<PoolRecord> zones = ImmutableSet.<PoolRecord> builder();
|
||||
|
||||
@Inject
|
||||
public PoolRecordListHandler(PoolRecordHandler zoneHandler) {
|
||||
this.zoneHandler = zoneHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluentIterable<PoolRecord> getResult() {
|
||||
return FluentIterable.from(zones.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) {
|
||||
if (equalsOrSuffix(qName, "PoolRecordData")) {
|
||||
zoneHandler.startElement(url, name, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (equalsOrSuffix(qName, "PoolRecordData")) {
|
||||
zones.add(zoneHandler.getResult());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* 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.domain.LBPool.Type;
|
||||
import org.jclouds.ultradns.ws.internal.BaseUltraDNSWSApiExpectTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetLoadBalancingPoolsByZoneResponseTest;
|
||||
import org.jclouds.ultradns.ws.parse.GetPoolRecordsResponseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "LBPoolApiExpectTest")
|
||||
public class LBPoolApiExpectTest 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_lbpools.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/lbpools.xml", "application/xml")).build();
|
||||
|
||||
public void testListWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(list, listResponse);
|
||||
|
||||
assertEquals(
|
||||
success.getLBPoolApiForZone("jclouds.org.").list().toString(),
|
||||
new GetLoadBalancingPoolsByZoneResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest listByType = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/list_lbpools_by_type.xml", "application/xml")).build();
|
||||
|
||||
public void testListByTypeWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(listByType, listResponse);
|
||||
|
||||
assertEquals(
|
||||
success.getLBPoolApiForZone("jclouds.org.").listByType(Type.RD).toString(),
|
||||
new GetLoadBalancingPoolsByZoneResponseTest().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_poolrecords.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse listRecordsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/poolrecords.xml", "application/xml")).build();
|
||||
|
||||
public void testListRecordsWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(listRecords, listRecordsResponse);
|
||||
|
||||
assertEquals(
|
||||
success.getLBPoolApiForZone("jclouds.org.").listRecords("04053D8E57C7931F").toString(),
|
||||
new GetPoolRecordsResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/delete_lbpool.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResourceWithContentType("/lbpool_deleted.xml", "application/xml")).build();
|
||||
|
||||
public void testDeleteWhenResponseIs2xx() {
|
||||
UltraDNSWSApi success = requestSendsResponse(delete, deleteResponse);
|
||||
success.getZoneApi().delete("04053D8E57C7931F");
|
||||
}
|
||||
|
||||
HttpResponse poolDoesntExist = HttpResponse.builder().message("Server Epoolor").statusCode(500)
|
||||
.payload(payloadFromResource("/lbpool_doesnt_exist.xml")).build();
|
||||
|
||||
public void testDeleteWhenResponseRRNotFound() {
|
||||
UltraDNSWSApi notFound = requestSendsResponse(delete, poolDoesntExist);
|
||||
notFound.getZoneApi().delete("04053D8E57C7931F");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* 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 com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.domain.Account;
|
||||
import org.jclouds.ultradns.ws.domain.LBPool;
|
||||
import org.jclouds.ultradns.ws.domain.LBPool.Type;
|
||||
import org.jclouds.ultradns.ws.domain.PoolRecord;
|
||||
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 = "LBPoolApiLiveTest")
|
||||
public class LBPoolApiLiveTest extends BaseUltraDNSWSApiLiveTest {
|
||||
|
||||
private Account account;
|
||||
|
||||
@Override
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
public void setupContext() {
|
||||
super.setupContext();
|
||||
account = context.getApi().getCurrentAccount();
|
||||
}
|
||||
|
||||
private void checkLBPool(LBPool pool) {
|
||||
checkNotNull(pool.getZoneId(), "ZoneId cannot be null for a LBPool %s", pool);
|
||||
checkNotNull(pool.getId(), "Id cannot be null for a LBPool %s", pool);
|
||||
checkNotNull(pool.getName(), "Name cannot be null for a LBPool %s", pool);
|
||||
checkNotNull(pool.getType(), "Type cannot be null for a LBPool %s", pool);
|
||||
checkNotNull(pool.getResponseMethod(), "ResponseMethod cannot be null for a LBPool %s", pool);
|
||||
}
|
||||
|
||||
private void checkPoolRecord(PoolRecord record) {
|
||||
checkNotNull(record.getPoolId(), "PoolId cannot be null for a PoolRecord %s", record);
|
||||
checkNotNull(record.getId(), "Id cannot be null for a PoolRecord %s", record);
|
||||
checkNotNull(record.getDescription(), "Description cannot be null for a PoolRecord %s", record);
|
||||
checkNotNull(record.getPointsTo(), "PointsTo cannot be null for a PoolRecord %s", record);
|
||||
checkNotNull(record.getType(), "Type cannot be null for a PoolRecord %s", record);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListLBPools() {
|
||||
for (Zone zone : context.getApi().getZoneApi().listByAccount(account.getId())) {
|
||||
for (LBPool pool : api(zone.getName()).list()) {
|
||||
checkLBPool(pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListLBPoolsByType() {
|
||||
for (Zone zone : context.getApi().getZoneApi().listByAccount(account.getId())) {
|
||||
for (LBPool pool : api(zone.getName()).list()) {
|
||||
assertTrue(api(zone.getName()).listByType(pool.getType()).contains(pool));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListLBPoolRecords() {
|
||||
for (Zone zone : context.getApi().getZoneApi().listByAccount(account.getId())) {
|
||||
for (LBPool pool : api(zone.getName()).listByType(Type.RR)) {
|
||||
for (PoolRecord record : api(zone.getName()).listRecords(pool.getId())) {
|
||||
checkPoolRecord(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class, expectedExceptionsMessageRegExp = "Zone does not exist in the system.")
|
||||
public void testListLBPoolsWhenZoneIdNotFound() {
|
||||
api("AAAAAAAAAAAAAAAA").list();
|
||||
}
|
||||
|
||||
private LBPoolApi api(String zoneName) {
|
||||
return context.getApi().getLBPoolApiForZone(zoneName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* 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.LBPool;
|
||||
import org.jclouds.ultradns.ws.domain.LBPool.Type;
|
||||
import org.jclouds.ultradns.ws.xml.LBPoolListHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "GetLoadBalancingPoolsByZoneResponseTest")
|
||||
public class GetLoadBalancingPoolsByZoneResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/lbpools.xml");
|
||||
|
||||
FluentIterable<LBPool> expected = expected();
|
||||
|
||||
LBPoolListHandler handler = injector.getInstance(LBPoolListHandler.class);
|
||||
FluentIterable<LBPool> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toSet().toString(), expected.toSet().toString());
|
||||
}
|
||||
|
||||
public FluentIterable<LBPool> expected() {
|
||||
return FluentIterable.from(ImmutableList.<LBPool> builder()
|
||||
.add(LBPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000001")
|
||||
.name("us-west-1c.app.jclouds.org.")
|
||||
.type(Type.TC).build())
|
||||
.add(LBPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000002")
|
||||
.name("app-uswest1.jclouds.org.")
|
||||
.type(Type.RD)
|
||||
.responseMethod(Type.RR).build())
|
||||
.add(LBPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000003")
|
||||
.name("app-uswest2.jclouds.org.")
|
||||
.type(Type.RD)
|
||||
.responseMethod(Type.RR).build())
|
||||
.add(LBPool.builder()
|
||||
.zoneId("0000000000000001")
|
||||
.id("000000000000004")
|
||||
.name("app-euwest.jclouds.org.")
|
||||
.type(Type.RD)
|
||||
.responseMethod(Type.RR).build()).build());
|
||||
}
|
||||
}
|
|
@ -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.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.domain.PoolRecord;
|
||||
import org.jclouds.ultradns.ws.xml.PoolRecordListHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "GetPoolRecordsResponseTest")
|
||||
public class GetPoolRecordsResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/poolrecords.xml");
|
||||
|
||||
FluentIterable<PoolRecord> expected = expected();
|
||||
|
||||
PoolRecordListHandler handler = injector.getInstance(PoolRecordListHandler.class);
|
||||
FluentIterable<PoolRecord> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toSet().toString(), expected.toSet().toString());
|
||||
}
|
||||
|
||||
public FluentIterable<PoolRecord> expected() {
|
||||
return FluentIterable.from(ImmutableSet.<PoolRecord> builder()
|
||||
.add(PoolRecord.builder()
|
||||
.poolId("0603399D0413BC46")
|
||||
.id("0603399D0413BC47")
|
||||
.description("SiteBacker pool via API")
|
||||
.type("A")
|
||||
.pointsTo("172.16.8.1").build())
|
||||
.add(PoolRecord.builder()
|
||||
.poolId("0603399D0413BC46")
|
||||
.id("060339A30416430C")
|
||||
.description("SiteBacker pool via API")
|
||||
.type("A")
|
||||
.pointsTo("172.16.8.2").build()).build());
|
||||
}
|
||||
}
|
|
@ -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:deleteZone><transactionID /><zoneName>04053D8E57C7931F</zoneName></v01:deleteZone></soapenv:Body></soapenv:Envelope>
|
|
@ -0,0 +1 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:deleteResourceRecordResponse xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/"><result xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">Successful</result></ns1:deleteResourceRecordResponse></soap:Body></soap:Envelope>
|
|
@ -0,0 +1 @@
|
|||
<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">2103</errorCode><errorDescription xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">No Resource Record with GUID found in the system AAAAAAAAAAAAAAAA</errorDescription></ns1:UltraWSException></detail></soap:Fault></soap:Body></soap:Envelope>
|
|
@ -0,0 +1,30 @@
|
|||
<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.app.jclouds.org."
|
||||
PoolId="000000000000001" PoolType="TC" PoolStatus="0"
|
||||
PoolDName="us-west-1c.app.jclouds.org." FailOver="Enabled"
|
||||
Probing="Enabled" MaxActiveServers="0" />
|
||||
</ns2:LBPoolData>
|
||||
<ns2:LBPoolData zoneid="0000000000000001">
|
||||
<ns2:PoolData PoolName="app-uswest1.jclouds.org."
|
||||
PoolId="000000000000002" PoolType="RD" PoolDName="app-uswest1.jclouds.org."
|
||||
ResponseMethod="RR" />
|
||||
</ns2:LBPoolData>
|
||||
<ns2:LBPoolData zoneid="0000000000000001">
|
||||
<ns2:PoolData PoolName="app-uswest2.jclouds.org."
|
||||
PoolId="000000000000003" PoolType="RD" PoolDName="app-uswest2.jclouds.org."
|
||||
ResponseMethod="RR" />
|
||||
</ns2:LBPoolData>
|
||||
<ns2:LBPoolData zoneid="0000000000000001">
|
||||
<ns2:PoolData PoolName="app-euwest.jclouds.org."
|
||||
PoolId="000000000000004" PoolType="RD" PoolDName="app-euwest.jclouds.org."
|
||||
ResponseMethod="RR" />
|
||||
</ns2:LBPoolData>
|
||||
</LBPoolList>
|
||||
</ns1:getLoadBalancingPoolsByZoneResponse>
|
||||
</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:getLoadBalancingPoolsByZone><zoneName>jclouds.org.</zoneName><lbPoolType>all</lbPoolType></v01:getLoadBalancingPoolsByZone></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>RD</lbPoolType></v01:getLoadBalancingPoolsByZone></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:getPoolRecords><poolId>04053D8E57C7931F</poolId></v01:getPoolRecords></soapenv:Body></soapenv:Envelope>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns1:getPoolRecordsResponse
|
||||
xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/">
|
||||
<PoolRecordsList xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">
|
||||
<ns2:PoolRecordData description="SiteBacker pool via API"
|
||||
serving="No" status="Failure" probing="ENABLED" forceAnswer="Normal"
|
||||
recordType="A" priority="1" pointsTo="172.16.8.1" poolId="0603399D0413BC46"
|
||||
poolRecordID="0603399D0413BC47" />
|
||||
<ns2:PoolRecordData description="SiteBacker pool via API"
|
||||
serving="No" status="DISABLED" probing="ENABLED" forceAnswer="Normal"
|
||||
recordType="A" priority="0" pointsTo="172.16.8.2" poolId="0603399D0413BC46"
|
||||
poolRecordID="060339A30416430C" />
|
||||
</PoolRecordsList>
|
||||
</ns1:getPoolRecordsResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
Loading…
Reference in New Issue