diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Archive.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Archive.java index 1d87820fb8..cfbb059b87 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Archive.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Archive.java @@ -74,18 +74,22 @@ public class Archive implements Comparable { private final String freeSize; private final boolean locked; + /** @return the name (username) of the archive */ public String getUsername() { return username; } + /** @return the total size of the archive, ex. "10 GB" */ public String getTotalSize() { return totalSize; } + /** @return the free space left of the archive */ public String getFreeSize() { return freeSize; } + /** @return true if the archive is locked */ public boolean isLocked() { return locked; } @@ -97,7 +101,6 @@ public class Archive implements Comparable { this.locked = locked; } - @Override public int hashCode() { return Objects.hashCode(username); diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Domain.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Domain.java index bdee0df871..5aa645dfed 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Domain.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Domain.java @@ -84,18 +84,22 @@ public class Domain implements Comparable { this.glesysNameServer = glesysNameServer; } + /** @return the domain name, ex. "jclouds.org" */ public String getDomain() { return domain; } + /** @return the date the domain was registered with GleSYS */ public Date getCreateTime() { return createTime; } + /** @return the number of DNS records for this domain */ public int getRecordCount() { return recordCount; } + /** @return true if a GleSYS nameserver holds the records */ public boolean getGlesysNameServer() { return glesysNameServer; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/DomainRecord.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/DomainRecord.java index 86b4fe6487..3ea489648b 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/DomainRecord.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/DomainRecord.java @@ -95,26 +95,45 @@ public class DomainRecord implements Comparable { this.ttl = ttl; } + /** + * @return the id of the record used to modify it via the API + * @see org.jclouds.glesys.features.DomainClient + */ public String getId() { return id; } + /** + * @return the zone content of the record + */ public String getZone() { return zone; } + /** + * @return the host content of the record + */ public String getHost() { return host; } + /** + * @return the type of the record, ex. "A" + */ public String getType() { return type; } + /** + * @return the data content of the record + */ public String getData() { return data; } + /** + * @return the TTL/Time-to-live for the record + */ public int getTtl() { return ttl; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Email.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Email.java index 3846c4e197..af6accd5da 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Email.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/Email.java @@ -139,26 +139,32 @@ public class Email implements Comparable { this.modified = modified; } + /** @return the e-mail address for this e-mail account */ public String getAccount() { return account; } + /** @return the quota for this e-mail account */ public String getQuota() { return quota; } + /** @return the amount of quota currently in use */ public String getUsedQuota() { return usedQuota; } + /** @return the antispam level of the e-mail account */ public int getAntispamLevel() { return antispamLevel; } + /** @return true if antivirus is enabled for this e-mail account */ public boolean getAntiVirus() { return antiVirus; } + /** @return true if auto-respond is enabled for this e-mail account */ public boolean getAutoRespond() { return autoRespond; } @@ -167,14 +173,17 @@ public class Email implements Comparable { return autoRespondMessage; } + /** @return true if saving is enabled for auto-respond e-mails */ public boolean getAutoRespondSaveEmail() { return autoRespondSaveEmail; } + /** @return when this account was created */ public Date getCreated() { return created; } + /** @return when this account was last modified */ public Date getModified() { return modified; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverview.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverview.java index 708dcc1a62..f37ee3db56 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverview.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverview.java @@ -25,6 +25,8 @@ import com.google.common.collect.ImmutableSet; import java.util.Set; /** + * Structure containing all information about e-mail addresses for a GleSYS account + * * @author Adam Lowe * @see */ @@ -68,10 +70,12 @@ public class EmailOverview { this.domains = domains; } + /** @return summary information about the account */ public EmailOverviewSummary getSummary() { return summary; } + /** @return the set of detailed information about the e-mail addresses and aliases for each domain */ public Set getDomains() { return domains == null ? ImmutableSet.of() : domains; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewDomain.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewDomain.java index 0836645591..6475bf46b4 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewDomain.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewDomain.java @@ -21,6 +21,8 @@ package org.jclouds.glesys.domain; import com.google.common.base.Objects; /** + * Detailed information about e-mail settings for a single domain + * * @author Adam Lowe * @see */ @@ -68,14 +70,17 @@ public class EmailOverviewDomain { this.aliases = aliases; } + /** @return the domain name */ public String getDomain() { return domain; } + /** @return the number of e-mail accounts in the domain */ public int getAccounts() { return accounts; } + /** @return the number of e-mail aliases in the domain */ public int getAliases() { return aliases; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewSummary.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewSummary.java index 06bf11419f..d8553bd0d8 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewSummary.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/EmailOverviewSummary.java @@ -22,6 +22,8 @@ import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; /** + * Summary information of e-mail settings and limits for a GleSYS account + * * @author Adam Lowe * @see */ @@ -79,18 +81,22 @@ public class EmailOverviewSummary { this.maxAliases = maxAliases; } + /** @return the number of e-mail accounts */ public int getAccounts() { return accounts; } + /** @return the maximum number of e-mail accounts */ public int getMaxAccounts() { return maxAccounts; } + /** @return the number of e-mail aliases */ public int getAliases() { return aliases; } + /** @return the maximum number of e-mail aliases */ public int getMaxAliases() { return maxAliases; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java index 07aa87b352..7f02659c96 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerCreated.java @@ -30,8 +30,8 @@ import com.google.common.collect.ImmutableList; import com.google.gson.annotations.SerializedName; /** - * Connection information to connect to a server with VNC. - * + * Information about a new server + * * @author Adam Lowe * @see */ @@ -44,11 +44,12 @@ public class ServerCreated { private String id; private String hostname; private List ips; - + public Builder id(String id) { this.id = id; return this; } + public Builder ips(List ips) { this.ips = ips; return this; @@ -57,16 +58,16 @@ public class ServerCreated { public Builder ips(ServerCreatedIp... ips) { return ips(Arrays.asList(ips)); } - + public Builder hostname(String hostname) { this.hostname = hostname; return this; } - + public ServerCreated build() { return new ServerCreated(id, hostname, ips); } - + public Builder fromServerCreated(ServerCreated in) { return id(in.getId()).hostname(in.getHostname()).ips(in.getIps()); } @@ -85,14 +86,20 @@ public class ServerCreated { this.ips = ips; } + /** + * @return the id of the server (used for other calls to identify the server. + * @see org.jclouds.glesys.features.ServerClient + */ public String getId() { return id; } + /** @return the hostname of the server */ public String getHostname() { return hostname; } + /** @return the IP addresses assigned to the server */ public List getIps() { return ips == null ? ImmutableList.of() : ips; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerUptime.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerUptime.java index 24ab2a9792..7eefe11bf9 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerUptime.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/domain/ServerUptime.java @@ -81,6 +81,9 @@ public class ServerUptime { return new ServerUptime(time); } + /** + * @return the number of seconds the server has been up + */ public long getTime() { return time; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/DomainAsyncClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/DomainAsyncClient.java index c0ba9e5e32..d719a24c7f 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/DomainAsyncClient.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/DomainAsyncClient.java @@ -21,9 +21,10 @@ package org.jclouds.glesys.features; import com.google.common.util.concurrent.ListenableFuture; import org.jclouds.glesys.domain.Domain; import org.jclouds.glesys.domain.DomainRecord; +import org.jclouds.glesys.options.DomainAddOptions; import org.jclouds.glesys.options.DomainOptions; import org.jclouds.glesys.options.DomainRecordAddOptions; -import org.jclouds.glesys.options.DomainRecordModifyOptions; +import org.jclouds.glesys.options.DomainRecordEditOptions; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; @@ -63,7 +64,7 @@ public interface DomainAsyncClient { */ @POST @Path("/domain/add/format/json") - ListenableFuture addDomain(@FormParam("name") String name, DomainOptions... options); + ListenableFuture addDomain(@FormParam("name") String name, DomainAddOptions... options); /** * @see DomainClient#editDomain @@ -72,26 +73,42 @@ public interface DomainAsyncClient { @Path("/domain/edit/format/json") ListenableFuture editDomain(@FormParam("domain") String domain, DomainOptions... options); + + /** + * @see DomainClient#deleteDomain + */ @POST @Path("/domain/delete/format/json") ListenableFuture deleteDomain(@FormParam("domain") String domain); + /** + * @see DomainClient#listRecords + */ @POST @Path("/domain/list_records/format/json") @SelectJson("records") @Consumes(MediaType.APPLICATION_JSON) ListenableFuture> listRecords(@FormParam("domain") String domain); + /** + * @see DomainClient#addRecord + */ @POST @Path("/domain/add_record/format/json") ListenableFuture addRecord(@FormParam("domain") String domain, @FormParam("host") String host, @FormParam("type") String type, @FormParam("data") String data, DomainRecordAddOptions... options); + /** + * @see DomainClient#editRecord + */ @POST @Path("/domain/update_record/format/json") - ListenableFuture editRecord(@FormParam("record_id") String record_id, DomainRecordModifyOptions... options); + ListenableFuture editRecord(@FormParam("record_id") String record_id, DomainRecordEditOptions... options); + /** + * @see DomainClient#deleteRecord + */ @POST @Path("/domain/delete_record/format/json") ListenableFuture deleteRecord(@FormParam("record_id") String recordId); diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/DomainClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/DomainClient.java index 80d0b3e90e..f02a776ad7 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/DomainClient.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/DomainClient.java @@ -21,15 +21,16 @@ package org.jclouds.glesys.features; import org.jclouds.concurrent.Timeout; import org.jclouds.glesys.domain.Domain; import org.jclouds.glesys.domain.DomainRecord; +import org.jclouds.glesys.options.DomainAddOptions; import org.jclouds.glesys.options.DomainOptions; import org.jclouds.glesys.options.DomainRecordAddOptions; -import org.jclouds.glesys.options.DomainRecordModifyOptions; +import org.jclouds.glesys.options.DomainRecordEditOptions; import java.util.Set; import java.util.concurrent.TimeUnit; /** - * Provides synchronous access to Invoice requests. + * Provides synchronous access to Domain requests. *

* * @author Adam Lowe @@ -52,7 +53,7 @@ public interface DomainClient { * @param domain the name of the domain to add. * @param options optional parameters */ - void addDomain(String domain, DomainOptions... options); + void addDomain(String domain, DomainAddOptions... options); /** * Add a domain to the Glesys dns-system @@ -94,7 +95,7 @@ public interface DomainClient { * @param options the settings to change * @see #listRecords to retrieve the necessary ids */ - void editRecord(String recordId, DomainRecordModifyOptions... options); + void editRecord(String recordId, DomainRecordEditOptions... options); /** * Delete a DNS record diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAsyncClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAsyncClient.java index 7d88a81c32..cd940087bd 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAsyncClient.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAsyncClient.java @@ -50,7 +50,7 @@ import com.google.common.util.concurrent.ListenableFuture; public interface EmailAsyncClient { /** - * @see org.jclouds.glesys.features.EmailClient#emailOverview + * @see org.jclouds.glesys.features.EmailClient#getEmailOverview */ @POST @Path("/email/overview/format/json") diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailClient.java index b2304e4a8a..f224bbcff5 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailClient.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/EmailClient.java @@ -46,19 +46,52 @@ public interface EmailClient { EmailOverview getEmailOverview(); /** - * - * @return + * Get the set of detailed information about e-mail accounts + * + * @return the relevant set of details */ Set listAccounts(String domain); + /** + * Create a new e-mail account + * + * @param accountAddress the e-mail address to use (the domain should already exist) + * @param password the password to use for the mailbox + * @param options optional parameters + * @see DomainClient#addDomain + */ void createAccount(String accountAddress, String password, EmailCreateOptions... options); + /** + * Create an e-mail alias for an e-mail account + * + * @param aliasAddress the address to use for the alias (the domain should already exist) + * @param toEmailAddress the existing e-mail account address the alias should forward to + * @see DomainClient#addDomain + */ void createAlias(String aliasAddress, String toEmailAddress); + /** + * Adjust an e-mail account's settings + * + * @param accountAddress the existing e-mail account address + * @param options optional parameters + */ void editAccount(String accountAddress, EmailEditOptions... options); - + + /** + * Adjust (re-target) an e-mail alias + * + * @param aliasAddress the existing alias e-mail address + * @param toEmailAddress the existing e-mail account address the alias should forward to + */ void editAlias(String aliasAddress, String toEmailAddress); + /** + * Delete an e-mail account or alias + * + * @param accountAddress the existing alias e-mail account or alias address + */ void delete(String accountAddress); } \ No newline at end of file diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/ServerClient.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/ServerClient.java index 8d0b96602a..251d1a32ed 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/ServerClient.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/features/ServerClient.java @@ -100,9 +100,9 @@ public interface ServerClient { /** * Get information about the OS templates available * - * @return a map of templates, keyed on platform + * @return the set of information about each template */ - Map> getTemplates(); + Set getTemplates(); /** * Get information about valid arguments to #createServer for each platform diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainAddOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainAddOptions.java new file mode 100644 index 0000000000..cba2b0b0c3 --- /dev/null +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainAddOptions.java @@ -0,0 +1,75 @@ +package org.jclouds.glesys.options; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +/** + * @author Adam Lowe + */ +public class DomainAddOptions extends DomainOptions { + public static class Builder { + /** + * @see DomainAddOptions#primaryNameServer + */ + public static DomainAddOptions primaryNameServer(String primaryNameServer) { + return DomainAddOptions.class.cast(new DomainAddOptions().primaryNameServer(primaryNameServer)); + } + + /** + * @see DomainAddOptions#responsiblePerson + */ + public static DomainAddOptions responsiblePerson(String responsiblePerson) { + return DomainAddOptions.class.cast(new DomainAddOptions().responsiblePerson(responsiblePerson)); + } + + /** + * @see DomainAddOptions#ttl + */ + public static DomainAddOptions ttl(int ttl) { + return DomainAddOptions.class.cast(new DomainAddOptions().ttl(ttl)); + } + + /** + * @see DomainAddOptions#refresh + */ + public static DomainAddOptions refresh(int refresh) { + return DomainAddOptions.class.cast(new DomainAddOptions().refresh(refresh)); + } + + /** + * @see DomainAddOptions#retry + */ + public static DomainAddOptions retry(int retry) { + return DomainAddOptions.class.cast(new DomainAddOptions().retry(retry)); + } + + /** + * @see DomainAddOptions#expire + */ + public static DomainAddOptions expire(int expire) { + return DomainAddOptions.class.cast(new DomainAddOptions().expire(expire)); + } + + /** + * @see DomainAddOptions#minimum + */ + public static DomainAddOptions minimum(int minimum) { + return DomainAddOptions.class.cast(new DomainAddOptions().minimum(minimum)); + } + + /** + * @see DomainAddOptions#minimalRecords + */ + public static DomainAddOptions minimalRecords() { + return DomainAddOptions.class.cast(new DomainAddOptions().minimalRecords()); + } + } + + /** + * 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() { + formParameters.put("create_records", "0"); + return this; + } + +} \ No newline at end of file diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainOptions.java index 6bc47aa8bf..0a322890f5 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainOptions.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainOptions.java @@ -52,7 +52,7 @@ public class DomainOptions extends BaseHttpRequestOptions { /** * @see DomainOptions#refresh */ - public static DomainOptions refresh(String refresh) { + public static DomainOptions refresh(int refresh) { DomainOptions options = new DomainOptions(); return options.refresh(refresh); } @@ -60,7 +60,7 @@ public class DomainOptions extends BaseHttpRequestOptions { /** * @see DomainOptions#retry */ - public static DomainOptions retry(String retry) { + public static DomainOptions retry(int retry) { DomainOptions options = new DomainOptions(); return options.retry(retry); } @@ -68,7 +68,7 @@ public class DomainOptions extends BaseHttpRequestOptions { /** * @see DomainOptions#expire */ - public static DomainOptions expire(String expire) { + public static DomainOptions expire(int expire) { DomainOptions options = new DomainOptions(); return options.expire(expire); } @@ -76,44 +76,71 @@ public class DomainOptions extends BaseHttpRequestOptions { /** * @see DomainOptions#minimum */ - public static DomainOptions minimum(String minimum) { + public static DomainOptions minimum(int minimum) { DomainOptions options = new DomainOptions(); return options.minimum(minimum); } } + /** + * Configure the primary DNS server for this domain. + */ public DomainOptions primaryNameServer(String primaryNameServer) { formParameters.put("primary_ns", primaryNameServer); return this; } + /** + * Configure the E-mail address of the person responsible for this domain (usually attached to MX records). + */ public DomainOptions responsiblePerson(String responsiblePerson) { + responsiblePerson = responsiblePerson.replaceAll("@", "."); + if (!responsiblePerson.endsWith(".")) { + responsiblePerson = responsiblePerson + "."; + } formParameters.put("resp_person", responsiblePerson); return this; } + /** + * TTL (time to live). The number of seconds a domain name is cached locally before expiration and return to authoritative nameservers for updates + */ public DomainOptions ttl(int ttl) { formParameters.put("ttl", Integer.toString(ttl)); return this; } - public DomainOptions refresh(String refresh) { - formParameters.put("refresh", refresh); + /** + * Configure the number of seconds between update requests from secondary and slave name servers + */ + public DomainOptions refresh(int refresh) { + formParameters.put("refresh", Integer.toString(refresh)); return this; } - public DomainOptions retry(String retry) { - formParameters.put("retry", retry); + /** + * Configure the number of seconds the secondary/slave will wait before retrying when the last attempt failed + */ + public DomainOptions retry(int retry) { + formParameters.put("retry", Integer.toString(retry)); return this; } - public DomainOptions expire(String expire) { - formParameters.put("primary_ns", expire); + /** + * Configure the number of seconds a master or slave will wait before considering the data stale if it cannot reach the primary name server + */ + public DomainOptions expire(int expire) { + formParameters.put("primary_ns", Integer.toString(expire)); return this; } - public DomainOptions minimum(String minimum) { - formParameters.put("minimum", minimum); + /** + * Configure the minimum/default TTL if the domain does not specify ttl + * + * @see #ttl + */ + public DomainOptions minimum(int minimum) { + formParameters.put("minimum", Integer.toString(minimum)); return this; } } \ No newline at end of file diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordAddOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordAddOptions.java index fc304b841e..281cfbdf48 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordAddOptions.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordAddOptions.java @@ -37,24 +37,21 @@ public class DomainRecordAddOptions extends BaseHttpRequestOptions { /** * @see DomainRecordAddOptions#mxPriority */ - public static DomainRecordAddOptions mxPriority(String mxPriority) { + public static DomainRecordAddOptions mxPriority(int mxPriority) { DomainRecordAddOptions options = new DomainRecordAddOptions(); return options.mxPriority(mxPriority); } } - public DomainRecordAddOptions host(String host) { - formParameters.put("host", host); - return this; - } - + /** Configure TTL/Time-to-live for record */ public DomainRecordAddOptions ttl(int ttl) { formParameters.put("ttl", Integer.toString(ttl)); return this; } - public DomainRecordAddOptions mxPriority(String mxPriority) { - formParameters.put("mx_priority", mxPriority); + /** Configure the priority of an MX record */ + public DomainRecordAddOptions mxPriority(int mxPriority) { + formParameters.put("mx_priority", Integer.toString(mxPriority)); return this; } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordEditOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordEditOptions.java new file mode 100644 index 0000000000..f375375320 --- /dev/null +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordEditOptions.java @@ -0,0 +1,63 @@ +package org.jclouds.glesys.options; + +/** + * @author Adam Lowe + */ +public class DomainRecordEditOptions extends DomainRecordAddOptions { + + public static class Builder { + /** + * @see DomainRecordEditOptions#host + */ + public static DomainRecordEditOptions host(String host) { + return new DomainRecordEditOptions().host(host); + } + + /** + * @see DomainRecordEditOptions#type + */ + public static DomainRecordEditOptions type(String type) { + return new DomainRecordEditOptions().type(type); + } + + /** + * @see DomainRecordEditOptions#data + */ + public static DomainRecordEditOptions data(String data) { + return new DomainRecordEditOptions().data(data); + } + + /** + * @see DomainRecordEditOptions#ttl + */ + public static DomainRecordEditOptions ttl(int ttl) { + return DomainRecordEditOptions.class.cast(new DomainRecordEditOptions().ttl(ttl)); + } + + /** + * @see DomainRecordEditOptions#mxPriority + */ + public static DomainRecordEditOptions mxPriority(int mxPriority) { + return DomainRecordEditOptions.class.cast(new DomainRecordEditOptions().mxPriority(mxPriority)); + } + } + + + /** Configure the hostname attached to this record */ + public DomainRecordEditOptions host(String host) { + formParameters.put("host", host); + return this; + } + + /** Configure the type of record, ex. "A", "CNAME" or "MX" */ + public DomainRecordEditOptions type(String type) { + formParameters.put("type", type); + return this; + } + + /** Set the content of this record (depending on type, for an "A" record this would be an ip address) */ + public DomainRecordEditOptions data(String data) { + formParameters.put("data", data); + return this; + } +} \ No newline at end of file diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordModifyOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordModifyOptions.java deleted file mode 100644 index 50e46d9de9..0000000000 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/DomainRecordModifyOptions.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * 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.glesys.options; - -/** - * @author Adam Lowe - */ -public class DomainRecordModifyOptions extends DomainRecordAddOptions { - - public static class Builder { - /** - * @see org.jclouds.glesys.options.DomainRecordAddOptions#host - */ - public static DomainRecordModifyOptions host(String host) { - DomainRecordModifyOptions options = new DomainRecordModifyOptions(); - return options.host(host); - } - - /** - * @see org.jclouds.glesys.options.DomainRecordModifyOptions#type - */ - public static DomainRecordModifyOptions type(String type) { - DomainRecordModifyOptions options = new DomainRecordModifyOptions(); - return options.type(type); - } - - /** - * @see org.jclouds.glesys.options.DomainRecordModifyOptions#data - */ - public static DomainRecordModifyOptions data(String data) { - DomainRecordModifyOptions options = new DomainRecordModifyOptions(); - return options.data(data); - } - - /** - * @see org.jclouds.glesys.options.DomainRecordModifyOptions#ttl - */ - public static DomainRecordModifyOptions ttl(int ttl) { - DomainRecordModifyOptions options = new DomainRecordModifyOptions(); - return DomainRecordModifyOptions.class.cast(options.ttl(ttl)); - } - - /** - * @see org.jclouds.glesys.options.DomainRecordModifyOptions#mxPriority - */ - public static DomainRecordModifyOptions mxPriority(String mxPriority) { - DomainRecordModifyOptions options = new DomainRecordModifyOptions(); - return DomainRecordModifyOptions.class.cast(options.mxPriority(mxPriority)); - } - } - - public DomainRecordModifyOptions host(String host) { - formParameters.put("host", host); - return this; - } - - - public DomainRecordModifyOptions type(String type) { - formParameters.put("type", type); - return this; - } - - public DomainRecordModifyOptions data(String data) { - formParameters.put("data", data); - return this; - } -} \ No newline at end of file diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailCreateOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailCreateOptions.java index b253f6ca76..a3c74ca975 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailCreateOptions.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailCreateOptions.java @@ -57,33 +57,38 @@ public class EmailCreateOptions extends BaseHttpRequestOptions { /** * @see EmailCreateOptions#autorespondMessage */ - public static EmailCreateOptions autorespondMessage(boolean autorespondMessage) { + public static EmailCreateOptions autorespondMessage(String autorespondMessage) { return new EmailCreateOptions().autorespondMessage(autorespondMessage); } } + /** Configure the antispam level of the account */ public EmailCreateOptions antispamLevel(int antispamLevel) { formParameters.put("antispamlevel", Integer.toString(antispamLevel)); return this; } + /** Enable or disable virus checking */ public EmailCreateOptions antiVirus(boolean antiVirus) { formParameters.put("antivirus", Integer.toString(antiVirus ? 1 : 0)); return this; } + /** Enable or disable auto-respond */ public EmailCreateOptions autorespond(boolean autorespond) { formParameters.put("autorespond", Integer.toString(autorespond ? 1 : 0)); return this; } + /** Enable or disable saving of auto-respond e-mails */ public EmailCreateOptions autorespondSaveEmail(boolean autorespondSaveEmail) { formParameters.put("autorespondsaveemail", Integer.toString(autorespondSaveEmail ? 1 : 0)); return this; } - public EmailCreateOptions autorespondMessage(boolean autorespondMessage) { - formParameters.put("autorespondmessage", Integer.toString(autorespondMessage ? 1 : 0)); + /** Configure the auto-respond message */ + public EmailCreateOptions autorespondMessage(String autorespondMessage) { + formParameters.put("autorespondmessage", autorespondMessage); return this; } } diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailEditOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailEditOptions.java index 97f0e90c5d..7e07600067 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailEditOptions.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/EmailEditOptions.java @@ -26,31 +26,50 @@ package org.jclouds.glesys.options; public class EmailEditOptions extends EmailCreateOptions { public static class Builder { + /** + * @see org.jclouds.glesys.options.EmailEditOptions#antispamLevel + */ public static EmailEditOptions antispamLevel(int antispamLevel) { return EmailEditOptions.class.cast(new EmailEditOptions().antispamLevel(antispamLevel)); } + /** + * @see org.jclouds.glesys.options.EmailEditOptions#antiVirus + */ public static EmailEditOptions antiVirus(boolean antiVirus) { return EmailEditOptions.class.cast(new EmailEditOptions().antiVirus(antiVirus)); } + /** + * @see org.jclouds.glesys.options.EmailEditOptions#autorespond + */ public static EmailEditOptions autorespond(boolean autorespond) { return EmailEditOptions.class.cast(new EmailEditOptions().autorespond(autorespond)); } + /** + * @see org.jclouds.glesys.options.EmailEditOptions#autorespondSaveEmail + */ public static EmailEditOptions autorespondSaveEmail(boolean autorespondSaveEmail) { return EmailEditOptions.class.cast(new EmailEditOptions().autorespondSaveEmail(autorespondSaveEmail)); } - public static EmailEditOptions autorespondMessage(boolean autorespondMessage) { + /** + * @see org.jclouds.glesys.options.EmailEditOptions#autorespondMessage + */ + public static EmailEditOptions autorespondMessage(String autorespondMessage) { return EmailEditOptions.class.cast(new EmailEditOptions().autorespondMessage(autorespondMessage)); } - public static EmailEditOptions autorespondMessage(String password) { + /** + * @see org.jclouds.glesys.options.EmailEditOptions#password + */ + public static EmailEditOptions password(String password) { return new EmailEditOptions().password(password); } } + /** Reset the password for this account */ public EmailEditOptions password(String password) { formParameters.put("password", password); return this; diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/ServerCloneOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/ServerCloneOptions.java index 388a49d632..6ae8aaf54d 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/ServerCloneOptions.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/ServerCloneOptions.java @@ -27,59 +27,55 @@ public class ServerCloneOptions extends ServerEditOptions { * @see org.jclouds.glesys.options.ServerCloneOptions#disksize */ public static ServerCloneOptions disksize(int disksize) { - ServerCloneOptions options = new ServerCloneOptions(); - return ServerCloneOptions.class.cast(options.disksize(disksize)); + return ServerCloneOptions.class.cast(new ServerCloneOptions().disksize(disksize)); } /** * @see org.jclouds.glesys.options.ServerCloneOptions#memorysize */ public static ServerCloneOptions memorysize(int memorysize) { - ServerCloneOptions options = new ServerCloneOptions(); - return ServerCloneOptions.class.cast(options.memorysize(memorysize)); + return ServerCloneOptions.class.cast(new ServerCloneOptions().memorysize(memorysize)); } /** * @see org.jclouds.glesys.options.ServerCloneOptions#cpucores */ public static ServerCloneOptions cpucores(int cpucores) { - ServerCloneOptions options = new ServerCloneOptions(); - return ServerCloneOptions.class.cast(options.cpucores(cpucores)); + return ServerCloneOptions.class.cast(new ServerCloneOptions().cpucores(cpucores)); } /** * @see org.jclouds.glesys.options.ServerCloneOptions#cpucores */ public static ServerCloneOptions transfer(int transfer) { - ServerCloneOptions options = new ServerCloneOptions(); - return ServerCloneOptions.class.cast(options.transfer(transfer)); + return ServerCloneOptions.class.cast(new ServerCloneOptions().transfer(transfer)); } /** * @see org.jclouds.glesys.options.ServerCloneOptions#hostname */ public static ServerCloneOptions hostname(String hostname) { - ServerCloneOptions options = new ServerCloneOptions(); - return ServerCloneOptions.class.cast(options.hostname(hostname)); + return ServerCloneOptions.class.cast(new ServerCloneOptions().hostname(hostname)); } /** * @see org.jclouds.glesys.options.ServerEditOptions#description */ public static ServerCloneOptions description(String description) { - ServerCloneOptions options = new ServerCloneOptions(); - return ServerCloneOptions.class.cast(options.description(description)); + return ServerCloneOptions.class.cast(new ServerCloneOptions().description(description)); } /** * @see org.jclouds.glesys.options.ServerCloneOptions#dataCenter */ public static ServerCloneOptions dataCenter(String dataCenter) { - ServerCloneOptions options = new ServerCloneOptions(); - return options.dataCenter(dataCenter); + return new ServerCloneOptions().dataCenter(dataCenter); } } + /** + * Configure which datacenter to create the clone in + */ public ServerCloneOptions dataCenter(String dataCenter) { formParameters.put("datacenter", dataCenter); return this; diff --git a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/ServerEditOptions.java b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/ServerEditOptions.java index b45070b9d7..ba8a0ffe36 100644 --- a/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/ServerEditOptions.java +++ b/sandbox-providers/glesys/src/main/java/org/jclouds/glesys/options/ServerEditOptions.java @@ -76,31 +76,37 @@ public class ServerEditOptions extends BaseHttpRequestOptions { } } + /** Configure the size of the disk, in GB, of the server */ public ServerEditOptions disksize(int disksize) { formParameters.put("disksize", Integer.toString(disksize)); return this; } + /** Configure the amount of RAM, in MB, allocated to the server */ public ServerEditOptions memorysize(int memorysize) { formParameters.put("memorysize", Integer.toString(memorysize)); return this; } + /** Configure the number of CPU cores allocated to the server */ public ServerEditOptions cpucores(int cpucores) { formParameters.put("cpucores", Integer.toString(cpucores)); return this; } + /** Configure the transfer setting for the server */ public ServerEditOptions transfer(int transfer) { formParameters.put("cpucores", Integer.toString(transfer)); return this; } + /** Configure the host name of the server (must be unique within the GleSYS account) */ public ServerEditOptions hostname(String hostname) { formParameters.put("hostname", hostname); return this; } + /** Configure the description of the server */ public ServerEditOptions description(String description) { formParameters.put("description", description); return this; diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainAsyncClientTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainAsyncClientTest.java index e945854a6c..78dcafa6bc 100644 --- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainAsyncClientTest.java +++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/DomainAsyncClientTest.java @@ -48,8 +48,8 @@ public class DomainAsyncClientTest extends BaseGleSYSAsyncClientTest domainCounter; private RetryablePredicate recordCounter; + @Test + public void testEditDomain() throws Exception { + client.editDomain(testDomain, DomainOptions.Builder.responsiblePerson("tester.jclouds.org")); + assertTrue(client.listDomains().contains(Domain.builder().domain(testDomain).build())); + } + @Test public void testCreateRecord() throws Exception { int before = client.listRecords(testDomain).size(); @@ -86,6 +97,46 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest { client.addRecord(testDomain, "test", "A", "127.0.0.1"); assertTrue(recordCounter.apply(before + 1)); + + for(DomainRecord record : client.listRecords(testDomain)) { + if ("test".equals(record.getHost())) { + assertEquals(record.getType(), "A"); + assertEquals(record.getData(), "127.0.0.1"); + } + } + } + + @Test + public void testEditRecord() throws Exception { + int before = client.listRecords(testDomain).size(); + + client.addRecord(testDomain, "testeditbefore", "A", "127.0.0.1"); + + assertTrue(recordCounter.apply(before + 1)); + + String recordId = null; + for(DomainRecord record : client.listRecords(testDomain)) { + if ("testeditbefore".equals(record.getHost())) { + assertEquals(record.getType(), "A"); + assertEquals(record.getData(), "127.0.0.1"); + recordId = record.getId(); + } + } + + assertNotNull(recordId); + + client.editRecord(recordId, DomainRecordEditOptions.Builder.host("testeditafter")); + + boolean found = false; + for(DomainRecord record : client.listRecords(testDomain)) { + if (recordId.equals(record.getId())) { + assertEquals(record.getHost(), "testeditafter"); + assertEquals(record.getType(), "A"); + assertEquals(record.getData(), "127.0.0.1"); + found = true; + } + } + assertTrue(found); } @Test diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java index 845d17396e..108c608b1c 100644 --- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java +++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/EmailClientLiveTest.java @@ -16,24 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -/** -* 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.glesys.features; import com.google.common.base.Predicate; @@ -52,10 +34,10 @@ import java.util.concurrent.TimeUnit; import static org.testng.Assert.*; /** -* Tests behavior of {@code EmailClient} -* -* @author Adam Lowe -*/ + * Tests behavior of {@code EmailClient} + * + * @author Adam Lowe + */ @Test(groups = "live", testName = "EmailClientLiveTest", singleThreaded = true) public class EmailClientLiveTest extends BaseGleSYSClientLiveTest { @@ -64,15 +46,8 @@ public class EmailClientLiveTest extends BaseGleSYSClientLiveTest { super.setupClient(); client = context.getApi().getEmailClient(); - try { - client.delete("test@" + testDomain); - client.delete("test2@" + testDomain); - context.getApi().getDomainClient().deleteDomain(testDomain); - } catch(Exception e) { - } - serverId = createServer("test-email-jclouds").getServerId(); - + createDomain(testDomain); emailAccountCounter = new RetryablePredicate( @@ -80,42 +55,55 @@ public class EmailClientLiveTest extends BaseGleSYSClientLiveTest { public boolean apply(Integer value) { return client.listAccounts(testDomain).size() == value; } - }, 30, 1, TimeUnit.SECONDS); - + }, 90, 5, TimeUnit.SECONDS); + + assertTrue(emailAccountCounter.apply(0)); } - @AfterGroups(groups = {"live"}) public void tearDown() { client.delete("test@" + testDomain); + client.delete("test1@" + testDomain); assertTrue(emailAccountCounter.apply(0)); context.getApi().getDomainClient().deleteDomain(testDomain); context.getApi().getServerClient().destroyServer(serverId, ServerDestroyOptions.Builder.discardIp()); super.tearDown(); } - + private EmailClient client; private String serverId; private final String testDomain = "email-test.jclouds.org"; private RetryablePredicate emailAccountCounter; - + @Test - public void createEmail() { - client.createAccount("test@" + testDomain, "password", EmailCreateOptions.Builder.antiVirus(true)); + public void testCreateEmail() { + client.createAccount("test@" + testDomain, "password", + EmailCreateOptions.Builder.antiVirus(true).autorespond(true).autorespondMessage("out of office")); + assertTrue(emailAccountCounter.apply(1)); + + client.createAccount("test1@" + testDomain, "password"); + + assertTrue(emailAccountCounter.apply(2)); } - @Test(dependsOnMethods = "createEmail") - public void createAlias() { + @Test(dependsOnMethods = "testCreateEmail") + public void testAliases() { client.createAlias("test2@" + testDomain, "test@" + testDomain); EmailOverview overview = client.getEmailOverview(); assertTrue(overview.getSummary().getAliases() == 1); + + // TODO verify the result of editing the alias + client.editAlias("test2@" + testDomain, "test1@" + testDomain); + overview = client.getEmailOverview(); + assertTrue(overview.getSummary().getAliases() == 1); + client.delete("test2@" + testDomain); overview = client.getEmailOverview(); assertTrue(overview.getSummary().getAliases() == 0); } - - @Test(dependsOnMethods = "createEmail") + + @Test(dependsOnMethods = "testCreateEmail") public void testOverview() throws Exception { EmailOverview overview = client.getEmailOverview(); assertNotNull(overview.getSummary()); @@ -125,30 +113,30 @@ public class EmailClientLiveTest extends BaseGleSYSClientLiveTest { assertTrue(overview.getSummary().getMaxAliases() > 0); assertNotNull(overview.getDomains()); assertFalse(overview.getDomains().isEmpty()); - + EmailOverviewDomain domain = EmailOverviewDomain.builder().domain(testDomain).accounts(1).build(); assertTrue(overview.getDomains().contains(domain)); } - @Test(dependsOnMethods = "createEmail") + @Test(dependsOnMethods = "testCreateEmail") public void testListAccounts() throws Exception { Set accounts = client.listAccounts(testDomain); assertTrue(accounts.size() >= 1); } - @Test(dependsOnMethods = "createEmail") + @Test(dependsOnMethods = "testCreateEmail") public void testEditAccount() throws Exception { Set accounts = client.listAccounts(testDomain); - for(Email account : accounts) { + for (Email account : accounts) { if (account.getAccount().equals("test@" + testDomain)) { assertTrue(account.getAntiVirus()); } } - + client.editAccount("test@" + testDomain, EmailEditOptions.Builder.antiVirus(false)); - + accounts = client.listAccounts(testDomain); - for(Email account : accounts) { + for (Email account : accounts) { if (account.getAccount().equals("test@" + testDomain)) { assertFalse(account.getAntiVirus()); } diff --git a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java index ee0230ebdf..6f28007fdf 100644 --- a/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java +++ b/sandbox-providers/glesys/src/test/java/org/jclouds/glesys/features/ServerClientLiveTest.java @@ -98,26 +98,19 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest { @Test public void testListTemplates() throws Exception { - Map> templates = client.getTemplates(); + Set templates = client.getTemplates(); - assertTrue(templates.containsKey("OpenVZ")); - assertTrue(templates.containsKey("Xen")); - - for(ServerTemplate template : templates.get("OpenVZ")) { - checkTemplate(template, "OpenVZ"); - } - - for(ServerTemplate template : templates.get("Xen")) { - checkTemplate(template, "Xen"); + for(ServerTemplate template : templates) { + checkTemplate(template); } } - private void checkTemplate(ServerTemplate t, String platform) { + private void checkTemplate(ServerTemplate t) { assertNotNull(t); assertNotNull(t.getName()); assertNotNull(t.getOs()); - assertEquals(t.getPlatform(), platform); + assertNotNull(t.getPlatform()); assert t.getMinDiskSize() > 0 : t; assert t.getMinMemSize() > 0 : t; }