mirror of https://github.com/apache/jclouds.git
Merge pull request #342 from aplowe/master
GleSYS provider: updates to match GleSYS API Beta v0.1.7
This commit is contained in:
commit
ec6796883d
|
@ -28,6 +28,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
import org.jclouds.PropertiesBuilder;
|
||||||
import static org.jclouds.glesys.reference.GleSYSConstants.PROPERTY_GLESYS_DEFAULT_DC;
|
import static org.jclouds.glesys.reference.GleSYSConstants.PROPERTY_GLESYS_DEFAULT_DC;
|
||||||
|
import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in GleSYS Clients
|
* Builds properties used in GleSYS Clients
|
||||||
|
@ -41,7 +42,8 @@ public class GleSYSPropertiesBuilder extends PropertiesBuilder {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://api.glesys.com");
|
properties.setProperty(PROPERTY_ENDPOINT, "https://api.glesys.com");
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "1");
|
properties.setProperty(PROPERTY_API_VERSION, "1");
|
||||||
properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA,US-VA,BR-SP");
|
properties.setProperty(PROPERTY_ZONES, "Amsterdam,Falkenberg,New York City,Stockholm");
|
||||||
|
properties.setProperty(PROPERTY_ISO3166_CODES, "NL-NH,SE-N,US-NY,SE-AB");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".Amsterdam." + ISO3166_CODES, "NL-NH");
|
properties.setProperty(PROPERTY_ZONE + ".Amsterdam." + ISO3166_CODES, "NL-NH");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".Falkenberg." + ISO3166_CODES, "SE-N");
|
properties.setProperty(PROPERTY_ZONE + ".Falkenberg." + ISO3166_CODES, "SE-N");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".New York City." + ISO3166_CODES, "US-NY");
|
properties.setProperty(PROPERTY_ZONE + ".New York City." + ISO3166_CODES, "US-NY");
|
||||||
|
|
|
@ -33,7 +33,7 @@ import com.google.common.net.InetAddresses;
|
||||||
* Contains options supported by the
|
* Contains options supported by the
|
||||||
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and
|
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and
|
||||||
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} operations on the
|
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} operations on the
|
||||||
* <em>gogrid</em> provider.
|
* <em>glesys</em> provider.
|
||||||
*
|
*
|
||||||
* <h2>Usage</h2> The recommended way to instantiate a {@link GleSYSTemplateOptions} object is to
|
* <h2>Usage</h2> The recommended way to instantiate a {@link GleSYSTemplateOptions} object is to
|
||||||
* statically import {@code GleSYSTemplateOptions.*} and invoke a static creation method followed by
|
* statically import {@code GleSYSTemplateOptions.*} and invoke a static creation method followed by
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class Domain implements Comparable<Domain> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private String domain;
|
private String domainName;
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
private int recordCount;
|
private int recordCount;
|
||||||
private boolean glesysNameServer;
|
private boolean useGlesysNameServer;
|
||||||
|
|
||||||
public Builder domain(String domain) {
|
public Builder domainName(String domainName) {
|
||||||
this.domain = domain;
|
this.domainName = domainName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,38 +55,39 @@ public class Domain implements Comparable<Domain> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder glesysNameServer(boolean glesysNameServer) {
|
public Builder useGlesysNameServer(boolean useGlesysNameServer) {
|
||||||
this.glesysNameServer = glesysNameServer;
|
this.useGlesysNameServer = useGlesysNameServer;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Domain build() {
|
public Domain build() {
|
||||||
return new Domain(domain, createTime, recordCount, glesysNameServer);
|
return new Domain(domainName, createTime, recordCount, useGlesysNameServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromDomain(Domain in) {
|
public Builder fromDomain(Domain in) {
|
||||||
return new Builder();
|
return new Builder().domainName(in.getDomainName()).createTime(in.getCreateTime()).recordCount(in.getRecordCount()).useGlesysNameServer(in.isGlesysNameServer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String domain;
|
@SerializedName("domainname")
|
||||||
@SerializedName("create_time")
|
private final String domainName;
|
||||||
|
@SerializedName("createtime")
|
||||||
private final Date createTime;
|
private final Date createTime;
|
||||||
@SerializedName("count")
|
@SerializedName("recordcount")
|
||||||
private final int recordCount;
|
private final int recordCount;
|
||||||
@SerializedName("glesysnameserver")
|
@SerializedName("usingglesysnameserver")
|
||||||
private final boolean glesysNameServer;
|
private final boolean useGlesysNameServer;
|
||||||
|
|
||||||
public Domain(String domain, Date createTime, int recordCount, boolean glesysNameServer) {
|
public Domain(String domainName, Date createTime, int recordCount, boolean useGlesysNameServer) {
|
||||||
this.domain = domain;
|
this.domainName = domainName;
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
this.recordCount = recordCount;
|
this.recordCount = recordCount;
|
||||||
this.glesysNameServer = glesysNameServer;
|
this.useGlesysNameServer = useGlesysNameServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the domain name, ex. "jclouds.org" */
|
/** @return the domain name, ex. "jclouds.org" */
|
||||||
public String getDomain() {
|
public String getDomainName() {
|
||||||
return domain;
|
return domainName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the date the domain was registered with GleSYS */
|
/** @return the date the domain was registered with GleSYS */
|
||||||
|
@ -100,18 +101,18 @@ public class Domain implements Comparable<Domain> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return true if a GleSYS nameserver holds the records */
|
/** @return true if a GleSYS nameserver holds the records */
|
||||||
public boolean getGlesysNameServer() {
|
public boolean isGlesysNameServer() {
|
||||||
return glesysNameServer;
|
return useGlesysNameServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(domain);
|
return Objects.hashCode(domainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Domain other) {
|
public int compareTo(Domain other) {
|
||||||
return domain.compareTo(other.getDomain());
|
return domainName.compareTo(other.getDomainName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,7 +121,7 @@ public class Domain implements Comparable<Domain> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (object instanceof Domain) {
|
if (object instanceof Domain) {
|
||||||
return Objects.equal(domain, ((Domain) object).domain);
|
return Objects.equal(domainName, ((Domain) object).domainName);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +129,7 @@ public class Domain implements Comparable<Domain> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("[domain=%s, createTime=%s, count=%d, glesysnameserver=%b]", domain, createTime, recordCount, glesysNameServer);
|
return String.format("[domainname=%s, createtime=%s, count=%d, useglesysnameserver=%b]", domainName, createTime, recordCount, useGlesysNameServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -33,7 +33,7 @@ public class DomainRecord implements Comparable<DomainRecord> {
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private String id;
|
private String id;
|
||||||
private String zone;
|
private String domainname;
|
||||||
private String host;
|
private String host;
|
||||||
private String type;
|
private String type;
|
||||||
private String data;
|
private String data;
|
||||||
|
@ -44,9 +44,8 @@ public class DomainRecord implements Comparable<DomainRecord> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder domainname(String domainname) {
|
||||||
public Builder zone(String zone) {
|
this.domainname = domainname;
|
||||||
this.zone = zone;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,24 +70,24 @@ public class DomainRecord implements Comparable<DomainRecord> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DomainRecord build() {
|
public DomainRecord build() {
|
||||||
return new DomainRecord(id, zone, host, type, data, ttl);
|
return new DomainRecord(id, domainname, host, type, data, ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromDomainRecord(DomainRecord in) {
|
public Builder fromDomainRecord(DomainRecord in) {
|
||||||
return new Builder().id(in.getId()).zone(in.getZone()).host(in.getHost()).type(in.getType()).data(in.getData()).ttl(in.getTtl());
|
return new Builder().id(in.getId()).domainname(in.getDomainName()).host(in.getHost()).type(in.getType()).data(in.getData()).ttl(in.getTtl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final String zone;
|
private final String domainname;
|
||||||
private final String host;
|
private final String host;
|
||||||
private final String type;
|
private final String type;
|
||||||
private final String data;
|
private final String data;
|
||||||
private final int ttl;
|
private final int ttl;
|
||||||
|
|
||||||
public DomainRecord(String id, String zone, String host, String type, String data, int ttl) {
|
public DomainRecord(String id, String domainname, String host, String type, String data, int ttl) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.zone = zone;
|
this.domainname = domainname;
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
@ -106,8 +105,8 @@ public class DomainRecord implements Comparable<DomainRecord> {
|
||||||
/**
|
/**
|
||||||
* @return the zone content of the record
|
* @return the zone content of the record
|
||||||
*/
|
*/
|
||||||
public String getZone() {
|
public String getDomainName() {
|
||||||
return zone;
|
return domainname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +162,7 @@ public class DomainRecord implements Comparable<DomainRecord> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("[id=%s, zone=%s, host=%s, type=%s, data=%s, ttl=%d]", id, zone, host, type, data, ttl);
|
return String.format("[id=%s, domainname=%s, host=%s, type=%s, data=%s, ttl=%d]", id, domainname, host, type, data, ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -42,9 +42,9 @@ public class ServerDetails extends Server {
|
||||||
private String description;
|
private String description;
|
||||||
private String templateName;
|
private String templateName;
|
||||||
private int cpuCores;
|
private int cpuCores;
|
||||||
private int memorySize;
|
private int memorySizeMB;
|
||||||
private int diskSize;
|
private int diskSizeGB;
|
||||||
private int transfer;
|
private int transferGB;
|
||||||
private Cost cost;
|
private Cost cost;
|
||||||
private List<Ip> ips;
|
private List<Ip> ips;
|
||||||
|
|
||||||
|
@ -63,18 +63,18 @@ public class ServerDetails extends Server {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder memorySize(int memorySize) {
|
public Builder memorySizeMB(int memorySizeMB) {
|
||||||
this.memorySize = memorySize;
|
this.memorySizeMB = memorySizeMB;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder diskSize(int diskSize) {
|
public Builder diskSizeGB(int diskSizeGB) {
|
||||||
this.diskSize = diskSize;
|
this.diskSizeGB = diskSizeGB;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder transfer(int transfer) {
|
public Builder transferGB(int transferGB) {
|
||||||
this.transfer = transfer;
|
this.transferGB = transferGB;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,12 +93,12 @@ public class ServerDetails extends Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerDetails build() {
|
public ServerDetails build() {
|
||||||
return new ServerDetails(id, hostname, datacenter, platform, templateName, description, cpuCores, memorySize, diskSize, transfer, cost, ips);
|
return new ServerDetails(id, hostname, datacenter, platform, templateName, description, cpuCores, memorySizeMB, diskSizeGB, transferGB, cost, ips);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromServerDetails(ServerDetails in) {
|
public Builder fromServerDetails(ServerDetails in) {
|
||||||
return fromServer(in).templateName(in.getTemplateName()).memorySize(in.getMemorySizeMB()).diskSize(in.getDiskSizeGB()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
return fromServer(in).templateName(in.getTemplateName()).memorySizeMB(in.getMemorySizeMB()).diskSizeGB(in.getDiskSizeGB()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
||||||
.description(in.getDescription()).ips(in.getIps());
|
.transferGB(in.getTransferGB()).description(in.getDescription()).ips(in.getIps());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -133,23 +133,24 @@ public class ServerDetails extends Server {
|
||||||
@SerializedName("cpucores")
|
@SerializedName("cpucores")
|
||||||
private final int cpuCores;
|
private final int cpuCores;
|
||||||
@SerializedName("memorysize")
|
@SerializedName("memorysize")
|
||||||
private final int memorySize;
|
private final int memorySizeMB;
|
||||||
@SerializedName("disksize")
|
@SerializedName("disksize")
|
||||||
private final int diskSize;
|
private final int diskSizeGB;
|
||||||
private final int transfer;
|
@SerializedName("transfer")
|
||||||
|
private final int transferGB;
|
||||||
private final Cost cost;
|
private final Cost cost;
|
||||||
@SerializedName("iplist")
|
@SerializedName("iplist")
|
||||||
private final List<Ip> ips;
|
private final List<Ip> ips;
|
||||||
|
|
||||||
public ServerDetails(String id, String hostname, String datacenter, String platform, String templateName,
|
public ServerDetails(String id, String hostname, String datacenter, String platform, String templateName,
|
||||||
String description, int cpuCores, int memorySize, int diskSize, int transfer, Cost cost, List<Ip> ips) {
|
String description, int cpuCores, int memorySizeMB, int diskSizeGB, int transferGB, Cost cost, List<Ip> ips) {
|
||||||
super(id, hostname, datacenter, platform);
|
super(id, hostname, datacenter, platform);
|
||||||
this.templateName = checkNotNull(templateName, "template");
|
this.templateName = checkNotNull(templateName, "template");
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.cpuCores = cpuCores;
|
this.cpuCores = cpuCores;
|
||||||
this.memorySize = memorySize;
|
this.memorySizeMB = memorySizeMB;
|
||||||
this.diskSize = diskSize;
|
this.diskSizeGB = diskSizeGB;
|
||||||
this.transfer = transfer;
|
this.transferGB = transferGB;
|
||||||
this.cost = checkNotNull(cost, "cost");
|
this.cost = checkNotNull(cost, "cost");
|
||||||
this.ips = ips == null ? ImmutableList.<Ip>of() : ips;
|
this.ips = ips == null ? ImmutableList.<Ip>of() : ips;
|
||||||
}
|
}
|
||||||
|
@ -172,21 +173,21 @@ public class ServerDetails extends Server {
|
||||||
* @return the disk of the server in GB
|
* @return the disk of the server in GB
|
||||||
*/
|
*/
|
||||||
public int getDiskSizeGB() {
|
public int getDiskSizeGB() {
|
||||||
return diskSize;
|
return diskSizeGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the memory of the server in MB
|
* @return the memory of the server in MB
|
||||||
*/
|
*/
|
||||||
public int getMemorySizeMB() {
|
public int getMemorySizeMB() {
|
||||||
return memorySize;
|
return memorySizeMB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the transfer of the server
|
* @return the transfer of the server
|
||||||
*/
|
*/
|
||||||
public int getTransferGB() {
|
public int getTransferGB() {
|
||||||
return transfer;
|
return transferGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -213,8 +214,8 @@ public class ServerDetails extends Server {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(
|
return String.format(
|
||||||
"[id=%s, hostname=%s, datacenter=%s, platform=%s, templateName=%s, description=%s, cpuCores=%d, memorySize=%d, diskSize=%d, transfer=%d, cost=%s, ips=%s]", id,
|
"[id=%s, hostname=%s, datacenter=%s, platform=%s, templateName=%s, description=%s, cpuCores=%d, memorySizeMB=%d, diskSizeGB=%d, transferGB=%d, cost=%s, ips=%s]", id,
|
||||||
hostname, datacenter, platform, templateName, description, cpuCores, memorySize, diskSize, transfer, cost, ips);
|
hostname, datacenter, platform, templateName, description, cpuCores, memorySizeMB, diskSizeGB, transferGB, cost, ips);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,14 +64,14 @@ public interface DomainAsyncClient {
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/domain/add/format/json")
|
@Path("/domain/add/format/json")
|
||||||
ListenableFuture<Void> addDomain(@FormParam("name") String name, AddDomainOptions... options);
|
ListenableFuture<Void> addDomain(@FormParam("domainname") String name, AddDomainOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DomainClient#editDomain
|
* @see DomainClient#editDomain
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/domain/edit/format/json")
|
@Path("/domain/edit/format/json")
|
||||||
ListenableFuture<Void> editDomain(@FormParam("domain") String domain, DomainOptions... options);
|
ListenableFuture<Void> editDomain(@FormParam("domainname") String domain, DomainOptions... options);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,23 +79,23 @@ public interface DomainAsyncClient {
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/domain/delete/format/json")
|
@Path("/domain/delete/format/json")
|
||||||
ListenableFuture<Void> deleteDomain(@FormParam("domain") String domain);
|
ListenableFuture<Void> deleteDomain(@FormParam("domainname") String domain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DomainClient#listRecords
|
* @see DomainClient#listRecords
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/domain/list_records/format/json")
|
@Path("/domain/listrecords/format/json")
|
||||||
@SelectJson("records")
|
@SelectJson("records")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
ListenableFuture<Set<DomainRecord>> listRecords(@FormParam("domain") String domain);
|
ListenableFuture<Set<DomainRecord>> listRecords(@FormParam("domainname") String domain);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DomainClient#addRecord
|
* @see DomainClient#addRecord
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/domain/add_record/format/json")
|
@Path("/domain/addrecord/format/json")
|
||||||
ListenableFuture<Void> addRecord(@FormParam("domain") String domain, @FormParam("host") String host,
|
ListenableFuture<Void> addRecord(@FormParam("domainname") String domain, @FormParam("host") String host,
|
||||||
@FormParam("type") String type, @FormParam("data") String data,
|
@FormParam("type") String type, @FormParam("data") String data,
|
||||||
AddRecordOptions... options);
|
AddRecordOptions... options);
|
||||||
|
|
||||||
|
@ -103,14 +103,14 @@ public interface DomainAsyncClient {
|
||||||
* @see DomainClient#editRecord
|
* @see DomainClient#editRecord
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/domain/update_record/format/json")
|
@Path("/domain/updaterecord/format/json")
|
||||||
ListenableFuture<Void> editRecord(@FormParam("record_id") String record_id, EditRecordOptions... options);
|
ListenableFuture<Void> editRecord(@FormParam("recordid") String record_id, EditRecordOptions... options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see DomainClient#deleteRecord
|
* @see DomainClient#deleteRecord
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/domain/delete_record/format/json")
|
@Path("/domain/deleterecord/format/json")
|
||||||
ListenableFuture<Void> deleteRecord(@FormParam("record_id") String recordId);
|
ListenableFuture<Void> deleteRecord(@FormParam("recordid") String recordId);
|
||||||
|
|
||||||
}
|
}
|
|
@ -128,7 +128,7 @@ public interface ServerAsyncClient {
|
||||||
ListenableFuture<Map<String, AllowedArgumentsForCreateServer>> getAllowedArgumentsForCreateServerByPlatform();
|
ListenableFuture<Map<String, AllowedArgumentsForCreateServer>> getAllowedArgumentsForCreateServerByPlatform();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerClient#getTemplates
|
* @see ServerClient#listTemplates
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/server/templates/format/json")
|
@Path("/server/templates/format/json")
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.Date;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
|
@ -35,20 +37,35 @@ import com.google.gson.stream.JsonWriter;
|
||||||
/**
|
/**
|
||||||
* Parser for Glesys Date formats
|
* Parser for Glesys Date formats
|
||||||
*
|
*
|
||||||
|
* @deprecated this should be replaced by standard ISO8601 parser in the next week or so
|
||||||
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class GlesysDateAdapter extends GsonModule.DateAdapter {
|
public class GlesysDateAdapter extends GsonModule.DateAdapter {
|
||||||
private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
private final DateService standardDateService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public GlesysDateAdapter(DateService service) {
|
||||||
|
this.standardDateService = service;
|
||||||
|
}
|
||||||
|
|
||||||
public void write(JsonWriter writer, Date value) throws IOException {
|
public void write(JsonWriter writer, Date value) throws IOException {
|
||||||
|
try {
|
||||||
|
writer.value(standardDateService.iso8601SecondsDateFormat(value));
|
||||||
|
} catch (Exception ex) {
|
||||||
synchronized (dateFormat) {
|
synchronized (dateFormat) {
|
||||||
writer.value(dateFormat.format(value));
|
writer.value(dateFormat.format(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Date read(JsonReader reader) throws IOException {
|
public Date read(JsonReader reader) throws IOException {
|
||||||
String toParse = reader.nextString();
|
String toParse = reader.nextString();
|
||||||
|
try {
|
||||||
|
return standardDateService.iso8601SecondsDateParse(toParse);
|
||||||
|
} catch (Exception ex) {
|
||||||
try {
|
try {
|
||||||
synchronized (dateFormat) {
|
synchronized (dateFormat) {
|
||||||
return dateFormat.parse(toParse);
|
return dateFormat.parse(toParse);
|
||||||
|
@ -57,4 +74,5 @@ public class GlesysDateAdapter extends GsonModule.DateAdapter {
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class AddDomainOptions extends DomainOptions {
|
||||||
* Ensure only NS and SOA records will be created by default, when this option is not used a number of default records will be created on the domain.
|
* Ensure only NS and SOA records will be created by default, when this option is not used a number of default records will be created on the domain.
|
||||||
*/
|
*/
|
||||||
public DomainOptions minimalRecords() {
|
public DomainOptions minimalRecords() {
|
||||||
formParameters.put("create_records", "0");
|
formParameters.put("createrecords", "0");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,6 @@ public class AddRecordOptions extends BaseHttpRequestOptions {
|
||||||
AddRecordOptions options = new AddRecordOptions();
|
AddRecordOptions options = new AddRecordOptions();
|
||||||
return options.ttl(ttl);
|
return options.ttl(ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see AddRecordOptions#mxPriority
|
|
||||||
*/
|
|
||||||
public static AddRecordOptions mxPriority(int mxPriority) {
|
|
||||||
AddRecordOptions options = new AddRecordOptions();
|
|
||||||
return options.mxPriority(mxPriority);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure TTL/Time-to-live for record */
|
/** Configure TTL/Time-to-live for record */
|
||||||
|
@ -48,11 +40,4 @@ public class AddRecordOptions extends BaseHttpRequestOptions {
|
||||||
formParameters.put("ttl", Integer.toString(ttl));
|
formParameters.put("ttl", Integer.toString(ttl));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure the priority of an MX record */
|
|
||||||
public AddRecordOptions mxPriority(int mxPriority) {
|
|
||||||
formParameters.put("mx_priority", Integer.toString(mxPriority));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,31 +24,31 @@ package org.jclouds.glesys.options;
|
||||||
public class CloneServerOptions extends EditServerOptions {
|
public class CloneServerOptions extends EditServerOptions {
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.glesys.options.CloneServerOptions#disksize
|
* @see org.jclouds.glesys.options.CloneServerOptions#diskSizeGB
|
||||||
*/
|
*/
|
||||||
public static CloneServerOptions disksize(int disksize) {
|
public static CloneServerOptions diskSizeGB(int diskSizeGB) {
|
||||||
return CloneServerOptions.class.cast(new CloneServerOptions().disksize(disksize));
|
return CloneServerOptions.class.cast(new CloneServerOptions().diskSizeGB(diskSizeGB));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.glesys.options.CloneServerOptions#memorysize
|
* @see org.jclouds.glesys.options.CloneServerOptions#memorySizeMB
|
||||||
*/
|
*/
|
||||||
public static CloneServerOptions memorysize(int memorysize) {
|
public static CloneServerOptions memorySizeMB(int memorySizeMB) {
|
||||||
return CloneServerOptions.class.cast(new CloneServerOptions().memorysize(memorysize));
|
return CloneServerOptions.class.cast(new CloneServerOptions().memorySizeMB(memorySizeMB));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.glesys.options.CloneServerOptions#cpucores
|
* @see org.jclouds.glesys.options.CloneServerOptions#cpuCores
|
||||||
*/
|
*/
|
||||||
public static CloneServerOptions cpucores(int cpucores) {
|
public static CloneServerOptions cpucores(int cpucores) {
|
||||||
return CloneServerOptions.class.cast(new CloneServerOptions().cpucores(cpucores));
|
return CloneServerOptions.class.cast(new CloneServerOptions().cpuCores(cpucores));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.glesys.options.CloneServerOptions#cpucores
|
* @see org.jclouds.glesys.options.CloneServerOptions#transferGB
|
||||||
*/
|
*/
|
||||||
public static CloneServerOptions transfer(int transfer) {
|
public static CloneServerOptions transferGB(int transferGB) {
|
||||||
return CloneServerOptions.class.cast(new CloneServerOptions().transfer(transfer));
|
return CloneServerOptions.class.cast(new CloneServerOptions().transferGB(transferGB));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class DomainOptions extends BaseHttpRequestOptions {
|
||||||
* Configure the primary DNS server for this domain.
|
* Configure the primary DNS server for this domain.
|
||||||
*/
|
*/
|
||||||
public DomainOptions primaryNameServer(String primaryNameServer) {
|
public DomainOptions primaryNameServer(String primaryNameServer) {
|
||||||
formParameters.put("primary_ns", primaryNameServer);
|
formParameters.put("primarynameserver", primaryNameServer);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class DomainOptions extends BaseHttpRequestOptions {
|
||||||
if (!responsiblePerson.endsWith(".")) {
|
if (!responsiblePerson.endsWith(".")) {
|
||||||
responsiblePerson = responsiblePerson + ".";
|
responsiblePerson = responsiblePerson + ".";
|
||||||
}
|
}
|
||||||
formParameters.put("resp_person", responsiblePerson);
|
formParameters.put("responsibleperson", responsiblePerson);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,13 +51,6 @@ public class EditRecordOptions extends AddRecordOptions {
|
||||||
public static EditRecordOptions ttl(int ttl) {
|
public static EditRecordOptions ttl(int ttl) {
|
||||||
return EditRecordOptions.class.cast(new EditRecordOptions().ttl(ttl));
|
return EditRecordOptions.class.cast(new EditRecordOptions().ttl(ttl));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see EditRecordOptions#mxPriority
|
|
||||||
*/
|
|
||||||
public static EditRecordOptions mxPriority(int mxPriority) {
|
|
||||||
return EditRecordOptions.class.cast(new EditRecordOptions().mxPriority(mxPriority));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,35 +28,32 @@ public class EditServerOptions extends BaseHttpRequestOptions {
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.glesys.options.EditServerOptions#disksize
|
* @see org.jclouds.glesys.options.EditServerOptions#diskSizeGB
|
||||||
*/
|
*/
|
||||||
public static EditServerOptions disksize(int disksize) {
|
public static EditServerOptions disksizeGB(int disksizeGB) {
|
||||||
EditServerOptions options = new EditServerOptions();
|
return new EditServerOptions().diskSizeGB(disksizeGB);
|
||||||
return options.disksize(disksize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.glesys.options.EditServerOptions#memorysize
|
* @see org.jclouds.glesys.options.EditServerOptions#memorySizeMB
|
||||||
*/
|
*/
|
||||||
public static EditServerOptions memorysize(int memorysize) {
|
public static EditServerOptions memorysizeMB(int memorysizeMB) {
|
||||||
EditServerOptions options = new EditServerOptions();
|
return new EditServerOptions().memorySizeMB(memorysizeMB);
|
||||||
return options.memorysize(memorysize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.glesys.options.EditServerOptions#cpucores
|
* @see org.jclouds.glesys.options.EditServerOptions#cpuCores
|
||||||
*/
|
*/
|
||||||
public static EditServerOptions cpucores(int cpucores) {
|
public static EditServerOptions cpucores(int cpucores) {
|
||||||
EditServerOptions options = new EditServerOptions();
|
EditServerOptions options = new EditServerOptions();
|
||||||
return options.cpucores(cpucores);
|
return options.cpuCores(cpucores);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.glesys.options.EditServerOptions#cpucores
|
* @see org.jclouds.glesys.options.EditServerOptions#transferGB
|
||||||
*/
|
*/
|
||||||
public static EditServerOptions transfer(int transfer) {
|
public static EditServerOptions transferGB(int transferGB) {
|
||||||
EditServerOptions options = new EditServerOptions();
|
return new EditServerOptions().transferGB(transferGB);
|
||||||
return options.transfer(transfer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,26 +74,26 @@ public class EditServerOptions extends BaseHttpRequestOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure the size of the disk, in GB, of the server */
|
/** Configure the size of the disk, in GB, of the server */
|
||||||
public EditServerOptions disksize(int disksize) {
|
public EditServerOptions diskSizeGB(int diskSizeGB) {
|
||||||
formParameters.put("disksize", Integer.toString(disksize));
|
formParameters.put("disksize", Integer.toString(diskSizeGB));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure the amount of RAM, in MB, allocated to the server */
|
/** Configure the amount of RAM, in MB, allocated to the server */
|
||||||
public EditServerOptions memorysize(int memorysize) {
|
public EditServerOptions memorySizeMB(int memorySizeMB) {
|
||||||
formParameters.put("memorysize", Integer.toString(memorysize));
|
formParameters.put("memorysize", Integer.toString(memorySizeMB));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure the number of CPU cores allocated to the server */
|
/** Configure the number of CPU cores allocated to the server */
|
||||||
public EditServerOptions cpucores(int cpucores) {
|
public EditServerOptions cpuCores(int cpucores) {
|
||||||
formParameters.put("cpucores", Integer.toString(cpucores));
|
formParameters.put("cpucores", Integer.toString(cpucores));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configure the transfer setting for the server */
|
/** Configure the transfer setting for the server */
|
||||||
public EditServerOptions transfer(int transfer) {
|
public EditServerOptions transferGB(int transferGB) {
|
||||||
formParameters.put("cpucores", Integer.toString(transfer));
|
formParameters.put("transfer", Integer.toString(transferGB));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,6 @@ public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<String> getIso3166Codes() {
|
protected Set<String> getIso3166Codes() {
|
||||||
return ImmutableSet.<String> of("US-CA", "US-VA", "BR-SP");
|
return ImmutableSet.<String> of("NL-NH","SE-N","US-NY","SE-AB");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,12 +21,18 @@ package org.jclouds.glesys.features;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import org.apache.log4j.helpers.ISO8601DateFormat;
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.glesys.GleSYSClient;
|
import org.jclouds.glesys.GleSYSClient;
|
||||||
import org.jclouds.glesys.domain.Domain;
|
import org.jclouds.glesys.domain.Domain;
|
||||||
import org.jclouds.glesys.domain.DomainRecord;
|
import org.jclouds.glesys.domain.DomainRecord;
|
||||||
import org.jclouds.glesys.options.AddDomainOptions;
|
import org.jclouds.glesys.options.AddDomainOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.jclouds.rest.BaseRestClientExpectTest;
|
import org.jclouds.rest.BaseRestClientExpectTest;
|
||||||
import org.jclouds.rest.ResourceNotFoundException;
|
import org.jclouds.rest.ResourceNotFoundException;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -46,6 +52,8 @@ import static org.testng.Assert.assertTrue;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "DomainClientExpectTest")
|
@Test(groups = "unit", testName = "DomainClientExpectTest")
|
||||||
public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClient> {
|
public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClient> {
|
||||||
|
private DateService dateService = new SimpleDateFormatDateService();
|
||||||
|
|
||||||
public DomainClientExpectTest() {
|
public DomainClientExpectTest() {
|
||||||
provider = "glesys";
|
provider = "glesys";
|
||||||
}
|
}
|
||||||
|
@ -59,10 +67,12 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
.build(),
|
.build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/domain_list.json")).build()).getDomainClient();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/domain_list.json")).build()).getDomainClient();
|
||||||
|
|
||||||
Set<Domain> expected = ImmutableSet.of(
|
Domain expected =
|
||||||
Domain.builder().domain("adamlowe.net").createTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2011-12-20 10:58:51")).build());
|
Domain.builder().domainName("testglesys.jclouds.org").createTime(dateService.iso8601SecondsDateParse("2012-01-31T12:19:03+01:00")).build();
|
||||||
|
|
||||||
assertEquals(client.listDomains(), expected);
|
Domain actual = Iterables.getOnlyElement(client.listDomains());
|
||||||
|
assertEquals(expected.getDomainName(), actual.getDomainName());
|
||||||
|
assertEquals(expected.getCreateTime(), actual.getCreateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListDomainsWhenResponseIs4xxReturnsEmpty() throws Exception {
|
public void testListDomainsWhenResponseIs4xxReturnsEmpty() throws Exception {
|
||||||
|
@ -79,28 +89,38 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
|
|
||||||
public void testListDomainRecordsWhenResponseIs2xx() throws Exception {
|
public void testListDomainRecordsWhenResponseIs2xx() throws Exception {
|
||||||
DomainClient client = requestSendsResponse(
|
DomainClient client = requestSendsResponse(
|
||||||
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/domain/list_records/format/json"))
|
HttpRequest.builder().method("POST").endpoint(URI.create("https://api.glesys.com/domain/listrecords/format/json"))
|
||||||
.headers(ImmutableMultimap.<String, String>builder()
|
.headers(ImmutableMultimap.<String, String>builder()
|
||||||
.put("Accept", "application/json")
|
.put("Accept", "application/json")
|
||||||
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
.put("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||||
.put("domain", "adamlowe.net").build())).build(),
|
.put("domainname", "testglesys.jclouds.org").build())).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/domain_list_records.json")).build()).getDomainClient();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/domain_list_records.json")).build()).getDomainClient();
|
||||||
|
|
||||||
Set<DomainRecord> expected = ImmutableSortedSet.of(
|
Set<DomainRecord> expected = ImmutableSortedSet.of(
|
||||||
DomainRecord.builder().id("213227").zone("adamlowe.net").host("@").type("NS").data("ns1.namesystem.se.").ttl(3600).build(),
|
DomainRecord.builder().id("224538").domainname("testglesys.jclouds.org").host("@").type("NS").data("ns1.namesystem.se.").ttl(3600).build(),
|
||||||
DomainRecord.builder().id("213228").zone("adamlowe.net").host("@").type("NS").data("ns2.namesystem.se.").ttl(3600).build(),
|
DomainRecord.builder().id("224539").domainname("testglesys.jclouds.org").host("@").type("NS").data("ns2.namesystem.se.").ttl(3600).build(),
|
||||||
DomainRecord.builder().id("213229").zone("adamlowe.net").host("@").type("NS").data("ns3.namesystem.se.").ttl(3600).build(),
|
DomainRecord.builder().id("224540").domainname("testglesys.jclouds.org").host("@").type("NS").data("ns3.namesystem.se.").ttl(3600).build(),
|
||||||
DomainRecord.builder().id("213230").zone("adamlowe.net").host("@").type("A").data("127.0.0.1").ttl(3600).build(),
|
DomainRecord.builder().id("224541").domainname("testglesys.jclouds.org").host("@").type("A").data("127.0.0.1").ttl(3600).build(),
|
||||||
DomainRecord.builder().id("213231").zone("adamlowe.net").host("www").type("A").data("127.0.0.1").ttl(3600).build(),
|
DomainRecord.builder().id("224542").domainname("testglesys.jclouds.org").host("www").type("A").data("127.0.0.1").ttl(3600).build(),
|
||||||
DomainRecord.builder().id("213232").zone("adamlowe.net").host("mail").type("A").data("79.99.4.40").ttl(3600).build(),
|
DomainRecord.builder().id("224543").domainname("testglesys.jclouds.org").host("mail").type("A").data("79.99.4.40").ttl(3600).build(),
|
||||||
DomainRecord.builder().id("213233").zone("adamlowe.net").host("@").type("MX").data("mx01.glesys.se.").ttl(3600).build(),
|
DomainRecord.builder().id("224544").domainname("testglesys.jclouds.org").host("@").type("MX").data("10 mx01.glesys.se.").ttl(3600).build(),
|
||||||
DomainRecord.builder().id("213234").zone("adamlowe.net").host("@").type("MX").data("mx02.glesys.se.").ttl(3600).build(),
|
DomainRecord.builder().id("224545").domainname("testglesys.jclouds.org").host("@").type("MX").data("20 mx02.glesys.se.").ttl(3600).build(),
|
||||||
DomainRecord.builder().id("213235").zone("adamlowe.net").host("@").type("TXT").data("v=spf1 include:spf.glesys.se -all").ttl(3600).build()
|
DomainRecord.builder().id("224546").domainname("testglesys.jclouds.org").host("@").type("TXT").data("v=spf1 include:spf.glesys.se -all").ttl(3600).build()
|
||||||
);
|
);
|
||||||
assertEquals(client.listRecords("adamlowe.net"), expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Set<DomainRecord> actual = client.listRecords("testglesys.jclouds.org");
|
||||||
|
|
||||||
|
assertEquals(actual, expected);
|
||||||
|
|
||||||
|
for(DomainRecord result : actual) {
|
||||||
|
for(DomainRecord expect : expected) {
|
||||||
|
if (result.equals(expect)) {
|
||||||
|
assertEquals(result.toString(), expect.toString(), "Deep comparison using toString() failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testListDomainRecordsWhenResponseIs4xxReturnsEmpty() throws Exception {
|
public void testListDomainRecordsWhenResponseIs4xxReturnsEmpty() throws Exception {
|
||||||
DomainClient client = requestSendsResponse(
|
DomainClient client = requestSendsResponse(
|
||||||
|
@ -120,7 +140,7 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put(
|
.headers(ImmutableMultimap.<String, String>builder().put(
|
||||||
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||||
.put("name", "cl66666_x").build())).build(),
|
.put("domainname", "cl66666_x").build())).build(),
|
||||||
HttpResponse.builder().statusCode(200).build()).getDomainClient();
|
HttpResponse.builder().statusCode(200).build()).getDomainClient();
|
||||||
|
|
||||||
client.addDomain("cl66666_x");
|
client.addDomain("cl66666_x");
|
||||||
|
@ -133,12 +153,12 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put(
|
.headers(ImmutableMultimap.<String, String>builder().put(
|
||||||
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||||
.put("name", "cl66666_x")
|
.put("domainname", "cl66666_x")
|
||||||
.put("primary_ns", "ns1.somewhere.x")
|
.put("primarynameserver", "ns1.somewhere.x")
|
||||||
.put("expire", "1")
|
.put("expire", "1")
|
||||||
.put("minimum", "1")
|
.put("minimum", "1")
|
||||||
.put("refresh", "1")
|
.put("refresh", "1")
|
||||||
.put("resp_person", "Tester.")
|
.put("responsibleperson", "Tester.")
|
||||||
.put("retry", "1")
|
.put("retry", "1")
|
||||||
.put("ttl", "1")
|
.put("ttl", "1")
|
||||||
.build())).build(),
|
.build())).build(),
|
||||||
|
@ -155,7 +175,7 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put(
|
.headers(ImmutableMultimap.<String, String>builder().put(
|
||||||
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||||
.put("domain", "x").build())).build(),
|
.put("domainname", "x").build())).build(),
|
||||||
HttpResponse.builder().statusCode(200).build()).getDomainClient();
|
HttpResponse.builder().statusCode(200).build()).getDomainClient();
|
||||||
|
|
||||||
client.editDomain("x");
|
client.editDomain("x");
|
||||||
|
@ -168,7 +188,7 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put(
|
.headers(ImmutableMultimap.<String, String>builder().put(
|
||||||
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||||
.put("domain", "x").build())).build(),
|
.put("domainname", "x").build())).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()).getDomainClient();
|
HttpResponse.builder().statusCode(404).build()).getDomainClient();
|
||||||
|
|
||||||
client.editDomain("x");
|
client.editDomain("x");
|
||||||
|
@ -180,7 +200,7 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put(
|
.headers(ImmutableMultimap.<String, String>builder().put(
|
||||||
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||||
.put("domain", "x").build())).build(),
|
.put("domainname", "x").build())).build(),
|
||||||
HttpResponse.builder().statusCode(200).build()).getDomainClient();
|
HttpResponse.builder().statusCode(200).build()).getDomainClient();
|
||||||
|
|
||||||
client.deleteDomain("x");
|
client.deleteDomain("x");
|
||||||
|
@ -193,7 +213,7 @@ public class DomainClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
.headers(ImmutableMultimap.<String, String>builder().put(
|
.headers(ImmutableMultimap.<String, String>builder().put(
|
||||||
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
|
||||||
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
.payload(newUrlEncodedFormPayload(ImmutableMultimap.<String, String>builder()
|
||||||
.put("domain", "x").build())).build(),
|
.put("domainname", "x").build())).build(),
|
||||||
HttpResponse.builder().statusCode(404).build()).getDomainClient();
|
HttpResponse.builder().statusCode(404).build()).getDomainClient();
|
||||||
|
|
||||||
client.deleteDomain("x");
|
client.deleteDomain("x");
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
@Test
|
@Test
|
||||||
public void testEditDomain() throws Exception {
|
public void testEditDomain() throws Exception {
|
||||||
client.editDomain(testDomain, DomainOptions.Builder.responsiblePerson("tester.jclouds.org"));
|
client.editDomain(testDomain, DomainOptions.Builder.responsiblePerson("tester.jclouds.org"));
|
||||||
assertTrue(client.listDomains().contains(Domain.builder().domain(testDomain).build()));
|
assertTrue(client.listDomains().contains(Domain.builder().domainName(testDomain).build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -156,8 +156,8 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
private ServerDetails expectedServerDetails() {
|
private ServerDetails expectedServerDetails() {
|
||||||
Ip ip = Ip.builder().version4().ip("31.192.226.45").cost(2.0).build();
|
Ip ip = Ip.builder().version4().ip("31.192.226.45").cost(2.0).build();
|
||||||
Cost cost = Cost.builder().amount(6.38).currency("EUR").timePeriod("month").build();
|
Cost cost = Cost.builder().amount(6.38).currency("EUR").timePeriod("month").build();
|
||||||
return ServerDetails.builder().id("vz1375882").transfer(50).hostname("jclouds-unit").cpuCores(1).memorySize(128)
|
return ServerDetails.builder().id("vz1375882").transferGB(50).hostname("jclouds-unit").cpuCores(1).memorySizeMB(128)
|
||||||
.diskSize(5).description("unit test server").datacenter("Falkenberg").platform("OpenVZ")
|
.diskSizeGB(5).description("unit test server").datacenter("Falkenberg").platform("OpenVZ")
|
||||||
.templateName("Debian 6.0 64-bit").cost(cost).ips(ip).build();
|
.templateName("Debian 6.0 64-bit").cost(cost).ips(ip).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
|
|
||||||
Cost cost = Cost.builder().amount(6.38).currency("EUR").timePeriod("month").build();
|
Cost cost = Cost.builder().amount(6.38).currency("EUR").timePeriod("month").build();
|
||||||
ServerDetails expected = ServerDetails.builder().id("vz1541880").hostname("mammamia").datacenter("Falkenberg").platform("OpenVZ")
|
ServerDetails expected = ServerDetails.builder().id("vz1541880").hostname("mammamia").datacenter("Falkenberg").platform("OpenVZ")
|
||||||
.templateName("Ubuntu 11.04 64-bit").description("description").cpuCores(1).memorySize(128).diskSize(5).transfer(50).cost(cost).build();
|
.templateName("Ubuntu 11.04 64-bit").description("description").cpuCores(1).memorySizeMB(128).diskSizeGB(5).transferGB(50).cost(cost).build();
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
client.createServerWithHostnameAndRootPassword(
|
client.createServerWithHostnameAndRootPassword(
|
||||||
|
@ -267,7 +267,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
HttpResponse.builder().statusCode(200).build()).getServerClient();
|
HttpResponse.builder().statusCode(200).build()).getServerClient();
|
||||||
|
|
||||||
EditServerOptions options =
|
EditServerOptions options =
|
||||||
EditServerOptions.Builder.description("Description-of-server").disksize(1).memorysize(512).cpucores(1).hostname("jclouds-test");
|
EditServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1).hostname("jclouds-test");
|
||||||
|
|
||||||
client.editServer("server111", options);
|
client.editServer("server111", options);
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ public class ServerClientExpectTest extends BaseRestClientExpectTest<GleSYSClien
|
||||||
.put("memorysize", "512")
|
.put("memorysize", "512")
|
||||||
.put("cpucores", "1").build())).build(),
|
.put("cpucores", "1").build())).build(),
|
||||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerClient();
|
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerClient();
|
||||||
CloneServerOptions options = (CloneServerOptions) CloneServerOptions.Builder.description("Description-of-server").disksize(1).memorysize(512).cpucores(1);
|
CloneServerOptions options = (CloneServerOptions) CloneServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1);
|
||||||
|
|
||||||
assertEquals(client.cloneServer("server111", "hostname1", options), expectedServerDetails());
|
assertEquals(client.cloneServer("server111", "hostname1", options), expectedServerDetails());
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,10 @@ public class BaseGleSYSClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
protected ComputeServiceContext computeContext;
|
protected ComputeServiceContext computeContext;
|
||||||
protected RestContext<GleSYSClient, GleSYSAsyncClient> context;
|
protected RestContext<GleSYSClient, GleSYSAsyncClient> context;
|
||||||
|
|
||||||
|
public BaseGleSYSClientLiveTest() {
|
||||||
|
provider = "glesys";
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"response":{"status":{"code":"200","text":"OK"},"domains":[{"domain":"adamlowe.net","create_time":"2011-12-20 10:58:51","count":"9","glesysnameserver":false}],"debug":{"input":[]}}}
|
{"response":{"status":{"code":200,"text":"OK"},"domains":[{"domainname":"testglesys.jclouds.org","createtime":"2012-01-31T12:19:03+01:00","recordcount":9,"usingglesysnameserver":"no"}],"debug":{"input":[]}}}
|
|
@ -1 +1 @@
|
||||||
{"response":{"status":{"code":"200","text":"OK"},"records":[{"id":"213227","zone":"adamlowe.net","host":"@","type":"NS","data":"ns1.namesystem.se.","ttl":"3600"},{"id":"213228","zone":"adamlowe.net","host":"@","type":"NS","data":"ns2.namesystem.se.","ttl":"3600"},{"id":"213229","zone":"adamlowe.net","host":"@","type":"NS","data":"ns3.namesystem.se.","ttl":"3600"},{"id":"213230","zone":"adamlowe.net","host":"@","type":"A","data":"127.0.0.1","ttl":"3600"},{"id":"213231","zone":"adamlowe.net","host":"www","type":"A","data":"127.0.0.1","ttl":"3600"},{"id":"213232","zone":"adamlowe.net","host":"mail","type":"A","data":"79.99.4.40","ttl":"3600"},{"id":"213233","zone":"adamlowe.net","host":"@","type":"MX","data":"mx01.glesys.se.","ttl":"3600"},{"id":"213234","zone":"adamlowe.net","host":"@","type":"MX","data":"mx02.glesys.se.","ttl":"3600"},{"id":"213235","zone":"adamlowe.net","host":"@","type":"TXT","data":"v=spf1 include:spf.glesys.se -all","ttl":"3600"}],"debug":{"input":{"domain":"adamlowe.net"}}}}
|
{"response":{"status":{"code":200,"text":"OK"},"records":[{"id":224546,"domainname":"testglesys.jclouds.org","host":"@","type":"TXT","data":"v=spf1 include:spf.glesys.se -all","ttl":3600},{"id":224545,"domainname":"testglesys.jclouds.org","host":"@","type":"MX","data":"20 mx02.glesys.se.","ttl":3600},{"id":224543,"domainname":"testglesys.jclouds.org","host":"mail","type":"A","data":"79.99.4.40","ttl":3600},{"id":224544,"domainname":"testglesys.jclouds.org","host":"@","type":"MX","data":"10 mx01.glesys.se.","ttl":3600},{"id":224542,"domainname":"testglesys.jclouds.org","host":"www","type":"A","data":"127.0.0.1","ttl":3600},{"id":224541,"domainname":"testglesys.jclouds.org","host":"@","type":"A","data":"127.0.0.1","ttl":3600},{"id":224540,"domainname":"testglesys.jclouds.org","host":"@","type":"NS","data":"ns3.namesystem.se.","ttl":3600},{"id":224539,"domainname":"testglesys.jclouds.org","host":"@","type":"NS","data":"ns2.namesystem.se.","ttl":3600},{"id":224538,"domainname":"testglesys.jclouds.org","host":"@","type":"NS","data":"ns1.namesystem.se.","ttl":3600}],"debug":{"input":{"domainname":"testglesys.jclouds.org"}}}}
|
Loading…
Reference in New Issue