Added nameServers to IpDetails in glesys provider.

This commit is contained in:
Mattias Holmqvist 2011-12-10 21:30:17 +01:00
parent 0ca95e50eb
commit 678ab8a6ec
4 changed files with 28 additions and 7 deletions

View File

@ -20,11 +20,13 @@
package org.jclouds.glesys.domain;
import com.google.gson.annotations.SerializedName;
import org.jclouds.javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
/**
* Represents detailed information about an available IP address.
*
* @author Mattias Holmqvist
*/
public class IpDetails {
@ -41,6 +43,7 @@ public class IpDetails {
protected String netmask;
protected String broadcast;
protected String gateway;
protected List<String> nameservers;
public Builder datacenter(String datacenter) {
this.datacenter = datacenter;
@ -64,7 +67,7 @@ public class IpDetails {
public IpDetails build() {
return new IpDetails(datacenter, ipversion, ptr, platform,
address, netmask, broadcast, gateway);
address, netmask, broadcast, gateway, nameservers);
}
public Builder address(String address) {
@ -86,6 +89,11 @@ public class IpDetails {
this.gateway = gateway;
return this;
}
public Builder nameServers(String... nameServers) {
this.nameservers = Arrays.asList(nameServers);
return this;
}
}
protected String datacenter;
@ -97,9 +105,12 @@ public class IpDetails {
protected String netmask;
protected String broadcast;
protected String gateway;
protected List<String> nameservers;
public IpDetails(String datacenter, String ipversion, String ptr, String platform,
String address, String netmask, String broadcast, String gateway) {
@Nullable String address, @Nullable String netmask,
@Nullable String broadcast, @Nullable String gateway,
@Nullable List<String> nameservers) {
this.datacenter = datacenter;
this.ipversion = ipversion;
this.ptr = ptr;
@ -108,6 +119,7 @@ public class IpDetails {
this.netmask = netmask;
this.broadcast = broadcast;
this.gateway = gateway;
this.nameservers = nameservers;
}
public String getDatacenter() {
@ -142,6 +154,10 @@ public class IpDetails {
return gateway;
}
public List<String> getNameServers() {
return nameservers;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -157,6 +173,8 @@ public class IpDetails {
if (netmask != null ? !netmask.equals(ipDetails.netmask) : ipDetails.netmask != null) return false;
if (platform != null ? !platform.equals(ipDetails.platform) : ipDetails.platform != null) return false;
if (ptr != null ? !ptr.equals(ipDetails.ptr) : ipDetails.ptr != null) return false;
if (nameservers != null ? !nameservers.equals(ipDetails.nameservers) : ipDetails.nameservers != null)
return false;
return true;
}

View File

@ -22,6 +22,7 @@ import org.jclouds.glesys.domain.IpDetails;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import java.util.List;
import java.util.Set;
import static org.testng.Assert.assertEquals;
@ -78,6 +79,8 @@ public class IpClientLiveTest extends BaseGleSYSClientLiveTest {
assertNotNull(ipDetails.getBroadcast());
assertNotNull(ipDetails.getGateway());
assertNotNull(ipDetails.getNetmask());
List<String> nameServers = ipDetails.getNameServers();
assertNotNull(nameServers);
}
}

View File

@ -42,8 +42,8 @@ public class ParseFullIpDetailsTest extends BaseItemParserTest<IpDetails> {
@Consumes(MediaType.APPLICATION_JSON)
public IpDetails expected() {
return IpDetails.builder().datacenter("Falkenberg").ipversion("4").platform("Xen")
.ptr("109-74-10-64-static.serverhotell.net.").address("109.74.10.64").netmask("255.255.254.0")
.broadcast("109.74.11.255").gateway("109.74.10.1").build();
.ptr("109-74-10-146-static.serverhotell.net.").address("109.74.10.146").netmask("255.255.254.0")
.broadcast("109.74.11.255").gateway("109.74.10.1").nameServers("79.99.4.100", "79.99.4.103").build();
}
protected Injector injector() {

View File

@ -1 +1 @@
{"response":{"status":{"code":"200","text":"OK"},"details":{"datacenter":"Falkenberg","ipversion":4,"PTR":"109-74-10-64-static.serverhotell.net.","address":"109.74.10.64","netmask":"255.255.254.0","broadcast":"109.74.11.255","gateway":"109.74.10.1","nameservers":"79.99.4.100 79.99.4.101","platform":"Xen"},"debug":{"input":{"ipaddress":"109.74.10.64"}}}}
{"response":{"status":{"code":"200","text":"OK"},"details":{"datacenter":"Falkenberg","ipversion":4,"PTR":"109-74-10-146-static.serverhotell.net.","address":"109.74.10.146","netmask":"255.255.254.0","broadcast":"109.74.11.255","gateway":"109.74.10.1","nameservers":["79.99.4.100","79.99.4.103"],"platform":"Xen"},"debug":{"input":{"ipaddress":"109.74.10.146"}}}}