Improving javadocs for Archive, Domain, Email and Server GleSYS clients

This commit is contained in:
Adam Lowe 2012-01-09 13:01:24 +00:00
parent c151e5bdd7
commit 602002660a
27 changed files with 452 additions and 204 deletions

View File

@ -74,18 +74,22 @@ public class Archive implements Comparable<Archive> {
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<Archive> {
this.locked = locked;
}
@Override
public int hashCode() {
return Objects.hashCode(username);

View File

@ -84,18 +84,22 @@ public class Domain implements Comparable<Domain> {
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;
}

View File

@ -95,26 +95,45 @@ public class DomainRecord implements Comparable<DomainRecord> {
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;
}

View File

@ -139,26 +139,32 @@ public class Email implements Comparable<Email> {
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<Email> {
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;
}

View File

@ -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 <a href="https://customer.glesys.com/api.php?a=doc#email_overview" />
*/
@ -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<EmailOverviewDomain> getDomains() {
return domains == null ? ImmutableSet.<EmailOverviewDomain>of() : domains;
}

View File

@ -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 <a href="https://customer.glesys.com/api.php?a=doc#email_overview" />
*/
@ -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;
}

View File

@ -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 <a href="https://customer.glesys.com/api.php?a=doc#email_overview" />
*/
@ -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;
}

View File

@ -30,7 +30,7 @@ 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 <a href="https://customer.glesys.com/api.php?a=doc#server_create" />
@ -49,6 +49,7 @@ public class ServerCreated {
this.id = id;
return this;
}
public Builder ips(List<ServerCreatedIp> ips) {
this.ips = ips;
return this;
@ -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<ServerCreatedIp> getIps() {
return ips == null ? ImmutableList.<ServerCreatedIp>of() : ips;
}

View File

@ -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;
}

View File

@ -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<Void> addDomain(@FormParam("name") String name, DomainOptions... options);
ListenableFuture<Void> addDomain(@FormParam("name") String name, DomainAddOptions... options);
/**
* @see DomainClient#editDomain
@ -72,26 +73,42 @@ public interface DomainAsyncClient {
@Path("/domain/edit/format/json")
ListenableFuture<Void> editDomain(@FormParam("domain") String domain, DomainOptions... options);
/**
* @see DomainClient#deleteDomain
*/
@POST
@Path("/domain/delete/format/json")
ListenableFuture<Void> deleteDomain(@FormParam("domain") String domain);
/**
* @see DomainClient#listRecords
*/
@POST
@Path("/domain/list_records/format/json")
@SelectJson("records")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Set<DomainRecord>> listRecords(@FormParam("domain") String domain);
/**
* @see DomainClient#addRecord
*/
@POST
@Path("/domain/add_record/format/json")
ListenableFuture<Void> 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<Void> editRecord(@FormParam("record_id") String record_id, DomainRecordModifyOptions... options);
ListenableFuture<Void> editRecord(@FormParam("record_id") String record_id, DomainRecordEditOptions... options);
/**
* @see DomainClient#deleteRecord
*/
@POST
@Path("/domain/delete_record/format/json")
ListenableFuture<Void> deleteRecord(@FormParam("record_id") String recordId);

View File

@ -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.
* <p/>
*
* @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

View File

@ -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")

View File

@ -46,19 +46,52 @@ public interface EmailClient {
EmailOverview getEmailOverview();
/**
* Get the set of detailed information about e-mail accounts
*
* @return
* @return the relevant set of details
*/
Set<Email> 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);
}

View File

@ -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<String, Set<ServerTemplate>> getTemplates();
Set<ServerTemplate> getTemplates();
/**
* Get information about valid arguments to #createServer for each platform

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -48,8 +48,8 @@ public class DomainAsyncClientTest extends BaseGleSYSAsyncClientTest<DomainAsync
public void testAddDomain() throws Exception {
testMethod("addDomain", "add", "POST", false, MapHttp4xxCodesToExceptions.class, newEntry("name", "cl66666_x"),
DomainOptions.Builder.primaryNameServer("ns1.somewhere.x").expire("1").minimum("1").refresh("1").
responsiblePerson("Tester").retry("1").ttl(1));
DomainOptions.Builder.primaryNameServer("ns1.somewhere.x").expire(1).minimum(1).refresh(1).
responsiblePerson("Tester").retry(1).ttl(1));
testMethod("addDomain", "add", "POST", false, MapHttp4xxCodesToExceptions.class, newEntry("name", "cl66666_x"));
}

View File

@ -18,12 +18,17 @@
*/
package org.jclouds.glesys.features;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.glesys.domain.Domain;
import org.jclouds.glesys.domain.DomainRecord;
import org.jclouds.glesys.options.DomainOptions;
import org.jclouds.glesys.options.DomainRecordEditOptions;
import org.jclouds.predicates.RetryablePredicate;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
@ -79,6 +84,12 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
private RetryablePredicate<Integer> domainCounter;
private RetryablePredicate<Integer> 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

View File

@ -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,13 +46,6 @@ 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);
@ -80,14 +55,15 @@ 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());
@ -100,22 +76,34 @@ public class EmailClientLiveTest extends BaseGleSYSClientLiveTest {
private RetryablePredicate<Integer> 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());
@ -130,16 +118,16 @@ public class EmailClientLiveTest extends BaseGleSYSClientLiveTest {
assertTrue(overview.getDomains().contains(domain));
}
@Test(dependsOnMethods = "createEmail")
@Test(dependsOnMethods = "testCreateEmail")
public void testListAccounts() throws Exception {
Set<Email> accounts = client.listAccounts(testDomain);
assertTrue(accounts.size() >= 1);
}
@Test(dependsOnMethods = "createEmail")
@Test(dependsOnMethods = "testCreateEmail")
public void testEditAccount() throws Exception {
Set<Email> accounts = client.listAccounts(testDomain);
for(Email account : accounts) {
for (Email account : accounts) {
if (account.getAccount().equals("test@" + testDomain)) {
assertTrue(account.getAntiVirus());
}
@ -148,7 +136,7 @@ public class EmailClientLiveTest extends BaseGleSYSClientLiveTest {
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());
}

View File

@ -98,26 +98,19 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
@Test
public void testListTemplates() throws Exception {
Map<String,Set<ServerTemplate>> templates = client.getTemplates();
Set<ServerTemplate> 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;
}