mirror of https://github.com/apache/jclouds.git
Merge pull request #283 from aplowe/master
GleSYS provider - adding E-Mail service
This commit is contained in:
commit
23ce04fc91
|
@ -18,10 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.glesys;
|
package org.jclouds.glesys;
|
||||||
|
|
||||||
import org.jclouds.glesys.features.ArchiveAsyncClient;
|
import org.jclouds.glesys.features.*;
|
||||||
import org.jclouds.glesys.features.DomainAsyncClient;
|
|
||||||
import org.jclouds.glesys.features.IpAsyncClient;
|
|
||||||
import org.jclouds.glesys.features.ServerAsyncClient;
|
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,4 +55,10 @@ public interface GleSYSAsyncClient {
|
||||||
@Delegate
|
@Delegate
|
||||||
DomainAsyncClient getDomainClient();
|
DomainAsyncClient getDomainClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to E-Mail features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
EmailAsyncClient getEmailClient();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,7 @@
|
||||||
package org.jclouds.glesys;
|
package org.jclouds.glesys;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.glesys.features.ArchiveClient;
|
import org.jclouds.glesys.features.*;
|
||||||
import org.jclouds.glesys.features.DomainClient;
|
|
||||||
import org.jclouds.glesys.features.IpClient;
|
|
||||||
import org.jclouds.glesys.features.ServerClient;
|
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -61,4 +58,11 @@ public interface GleSYSClient {
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
DomainClient getDomainClient();
|
DomainClient getDomainClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to E-Mail features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
EmailClient getEmailClient();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class GleSYSRestClientModule extends RestClientModule<GleSYSClient, GleSY
|
||||||
.put(IpClient.class, IpAsyncClient.class)//
|
.put(IpClient.class, IpAsyncClient.class)//
|
||||||
.put(ArchiveClient.class, ArchiveAsyncClient.class)//
|
.put(ArchiveClient.class, ArchiveAsyncClient.class)//
|
||||||
.put(DomainClient.class, DomainAsyncClient.class)//
|
.put(DomainClient.class, DomainAsyncClient.class)//
|
||||||
|
.put(EmailClient.class, EmailAsyncClient.class)//
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public GleSYSRestClientModule() {
|
public GleSYSRestClientModule() {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import com.google.gson.annotations.SerializedName;
|
||||||
* Information about an archive
|
* Information about an archive
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#archive_details" />
|
* @see <a href= "https://customer.glesys.com/api.php?a=doc#archive_list" />
|
||||||
*/
|
*/
|
||||||
public class Archive implements Comparable<Archive> {
|
public class Archive implements Comparable<Archive> {
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Date;
|
||||||
* Domain data for a Glesys account.
|
* Domain data for a Glesys account.
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
|
* @see <a href= "https://customer.glesys.com/api.php?a=doc#domain_list" />
|
||||||
*/
|
*/
|
||||||
public class Domain implements Comparable<Domain> {
|
public class Domain implements Comparable<Domain> {
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.google.common.base.Objects;
|
||||||
* DNS record data.
|
* DNS record data.
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
|
* @see <a href= "https://customer.glesys.com/api.php?a=doc#domain_list_records" />
|
||||||
*/
|
*/
|
||||||
public class DomainRecord implements Comparable<DomainRecord> {
|
public class DomainRecord implements Comparable<DomainRecord> {
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
|
|
@ -0,0 +1,213 @@
|
||||||
|
/**
|
||||||
|
* 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.domain;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detailed information on an Email Account
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_list" />
|
||||||
|
*/
|
||||||
|
public class Email implements Comparable<Email> {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String account;
|
||||||
|
private String quota;
|
||||||
|
private String usedQuota;
|
||||||
|
private int antispamLevel;
|
||||||
|
private boolean antiVirus;
|
||||||
|
private boolean autoRespond;
|
||||||
|
private String autoRespondMessage;
|
||||||
|
private boolean autoRespondSaveEmail;
|
||||||
|
private Date created;
|
||||||
|
private Date modified;
|
||||||
|
|
||||||
|
public Builder account(String account) {
|
||||||
|
this.account = account;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder quota(String quota) {
|
||||||
|
this.quota = quota;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder usedQuota(String usedQuota) {
|
||||||
|
this.usedQuota = usedQuota;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder antispamLevel(int antispamLevel) {
|
||||||
|
this.antispamLevel = antispamLevel;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder antiVirus(boolean antiVirus) {
|
||||||
|
this.antiVirus = antiVirus;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder autoRespond(boolean autoRespond) {
|
||||||
|
this.autoRespond = autoRespond;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder autoRespondMessage(String autoRespondMessage) {
|
||||||
|
this.autoRespondMessage = autoRespondMessage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder autoRespondSaveEmail(boolean autoRespondSaveEmail) {
|
||||||
|
this.autoRespondSaveEmail = autoRespondSaveEmail;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder created(Date created) {
|
||||||
|
this.created = created;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder modified(Date modified) {
|
||||||
|
this.modified = modified;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Email build() {
|
||||||
|
return new Email(account, quota, usedQuota, antispamLevel, antiVirus, autoRespond, autoRespondMessage,
|
||||||
|
autoRespondSaveEmail, created, modified);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromEmail(Email in) {
|
||||||
|
return account(in.getAccount()).quota(in.getQuota()).usedQuota(in.getUsedQuota()).antispamLevel(in.getAntispamLevel()).
|
||||||
|
antiVirus(in.getAntiVirus()).autoRespond(in.getAutoRespond()).autoRespondMessage(in.getAutoRespondMessage()).
|
||||||
|
autoRespondSaveEmail(in.getAutoRespondSaveEmail()).created(in.getCreated()).modified(in.getModified());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SerializedName("emailaccount")
|
||||||
|
private final String account;
|
||||||
|
private final String quota;
|
||||||
|
@SerializedName("usedquota")
|
||||||
|
private final String usedQuota;
|
||||||
|
@SerializedName("antispamlevel")
|
||||||
|
private final int antispamLevel;
|
||||||
|
@SerializedName("antivirus")
|
||||||
|
private final boolean antiVirus;
|
||||||
|
@SerializedName("autorespond")
|
||||||
|
private final boolean autoRespond;
|
||||||
|
@SerializedName("autorespondmessage")
|
||||||
|
private final String autoRespondMessage;
|
||||||
|
@SerializedName("autorespondsaveemail")
|
||||||
|
private final boolean autoRespondSaveEmail;
|
||||||
|
private final Date created;
|
||||||
|
private final Date modified;
|
||||||
|
|
||||||
|
public Email(String account, String quota, String usedQuota, int antispamLevel, boolean antiVirus, boolean autoRespond, String autoRespondMessage, boolean autoRespondSaveEmail, Date created, Date modified) {
|
||||||
|
this.account = account;
|
||||||
|
this.quota = quota;
|
||||||
|
this.usedQuota = usedQuota;
|
||||||
|
this.antispamLevel = antispamLevel;
|
||||||
|
this.antiVirus = antiVirus;
|
||||||
|
this.autoRespond = autoRespond;
|
||||||
|
this.autoRespondMessage = autoRespondMessage;
|
||||||
|
this.autoRespondSaveEmail = autoRespondSaveEmail;
|
||||||
|
this.created = created;
|
||||||
|
this.modified = modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccount() {
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQuota() {
|
||||||
|
return quota;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsedQuota() {
|
||||||
|
return usedQuota;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAntispamLevel() {
|
||||||
|
return antispamLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAntiVirus() {
|
||||||
|
return antiVirus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAutoRespond() {
|
||||||
|
return autoRespond;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAutoRespondMessage() {
|
||||||
|
return autoRespondMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAutoRespondSaveEmail() {
|
||||||
|
return autoRespondSaveEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getModified() {
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Email other) {
|
||||||
|
return account.compareTo(other.getAccount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (this == object) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (object instanceof Email) {
|
||||||
|
Email other = (Email) object;
|
||||||
|
return Objects.equal(account, other.account);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(account);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("account=%s, quota=%s, usedquota=%s, antispamLevel=%d, " +
|
||||||
|
"antiVirus=%b, autoRespond=%b, autoRespondMessage=%s, autoRespondSaveEmail=%b, " +
|
||||||
|
"created=%s, modified=%s", account, quota, usedQuota, antispamLevel, antiVirus, autoRespond, autoRespondMessage,
|
||||||
|
autoRespondSaveEmail, created.toString(), modified.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package org.jclouds.glesys.domain;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_overview" />
|
||||||
|
*/
|
||||||
|
public class EmailOverview {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private EmailOverviewSummary summary;
|
||||||
|
private Set<EmailOverviewDomain> domains;
|
||||||
|
|
||||||
|
public Builder summary(EmailOverviewSummary summary) {
|
||||||
|
this.summary = summary;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder domains(Set<EmailOverviewDomain> domains) {
|
||||||
|
this.domains = domains;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder domains(EmailOverviewDomain... domains) {
|
||||||
|
return domains(ImmutableSet.copyOf(domains));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailOverview build() {
|
||||||
|
return new EmailOverview(summary, domains);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromEmailOverview(EmailOverview in) {
|
||||||
|
return summary(in.getSummary()).domains(in.getDomains());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private EmailOverviewSummary summary;
|
||||||
|
private Set<EmailOverviewDomain> domains;
|
||||||
|
|
||||||
|
public EmailOverview(EmailOverviewSummary summary, Set<EmailOverviewDomain> domains) {
|
||||||
|
this.summary = summary;
|
||||||
|
this.domains = domains;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailOverviewSummary getSummary() {
|
||||||
|
return summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<EmailOverviewDomain> getDomains() {
|
||||||
|
return domains == null ? ImmutableSet.<EmailOverviewDomain>of() : domains;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(summary, domains);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (object == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (object instanceof EmailOverview) {
|
||||||
|
EmailOverview other = (EmailOverview) object;
|
||||||
|
return Objects.equal(summary, other.summary)
|
||||||
|
&& Objects.equal(domains, other.domains);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
Joiner commaJoiner = Joiner.on(", ");
|
||||||
|
return String.format("summary=%s, domains=[%s]", summary, commaJoiner.join(getDomains()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package org.jclouds.glesys.domain;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_overview" />
|
||||||
|
*/
|
||||||
|
public class EmailOverviewDomain {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String domain;
|
||||||
|
private int accounts;
|
||||||
|
private int aliases;
|
||||||
|
|
||||||
|
public Builder domain(String domain) {
|
||||||
|
this.domain = domain;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder accounts(int accounts) {
|
||||||
|
this.accounts = accounts;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder aliases(int aliases) {
|
||||||
|
this.aliases = aliases;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailOverviewDomain build() {
|
||||||
|
return new EmailOverviewDomain(domain, accounts, aliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromEmailOverview(EmailOverviewDomain in) {
|
||||||
|
return domain(domain).accounts(in.getAccounts()).aliases(in.getAliases());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String domain;
|
||||||
|
private final int accounts;
|
||||||
|
private final int aliases;
|
||||||
|
|
||||||
|
public EmailOverviewDomain(String domain, int accounts, int aliases) {
|
||||||
|
this.domain = domain;
|
||||||
|
this.accounts = accounts;
|
||||||
|
this.aliases = aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDomain() {
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAccounts() {
|
||||||
|
return accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAliases() {
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (object == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (object instanceof EmailOverviewDomain) {
|
||||||
|
EmailOverviewDomain other = (EmailOverviewDomain) object;
|
||||||
|
return Objects.equal(domain, other.domain);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("domain=%s, accounts=%d, aliases=%d", domain, accounts, aliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
package org.jclouds.glesys.domain;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_overview" />
|
||||||
|
*/
|
||||||
|
public class EmailOverviewSummary {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private int accounts;
|
||||||
|
private int maxAccounts;
|
||||||
|
private int aliases;
|
||||||
|
private int maxAliases;
|
||||||
|
|
||||||
|
public Builder accounts(int accounts) {
|
||||||
|
this.accounts = accounts;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder maxAccounts(int maxAccounts) {
|
||||||
|
this.maxAccounts = maxAccounts;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder aliases(int aliases) {
|
||||||
|
this.aliases = aliases;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder maxAliases(int maxAliases) {
|
||||||
|
this.maxAliases = maxAliases;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailOverviewSummary build() {
|
||||||
|
return new EmailOverviewSummary(accounts, maxAccounts, aliases, maxAliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromEmailOverview(EmailOverviewSummary in) {
|
||||||
|
return accounts(in.getAccounts()).maxAccounts(in.getMaxAccounts()).aliases(in.getAliases()).maxAliases(in.getMaxAliases());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int accounts;
|
||||||
|
@SerializedName("maxaccounts")
|
||||||
|
private final int maxAccounts;
|
||||||
|
private final int aliases;
|
||||||
|
@SerializedName("maxaliases")
|
||||||
|
private final int maxAliases;
|
||||||
|
|
||||||
|
public EmailOverviewSummary(int accounts, int maxAccounts, int aliases, int maxAliases) {
|
||||||
|
this.accounts = accounts;
|
||||||
|
this.maxAccounts = maxAccounts;
|
||||||
|
this.aliases = aliases;
|
||||||
|
this.maxAliases = maxAliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAccounts() {
|
||||||
|
return accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxAccounts() {
|
||||||
|
return maxAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAliases() {
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxAliases() {
|
||||||
|
return maxAliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(accounts, maxAccounts, aliases, maxAliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (object == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (object instanceof EmailOverviewSummary) {
|
||||||
|
EmailOverviewSummary other = (EmailOverviewSummary) object;
|
||||||
|
return Objects.equal(accounts, other.accounts)
|
||||||
|
&& Objects.equal(maxAccounts, other.maxAccounts)
|
||||||
|
&& Objects.equal(aliases, other.aliases)
|
||||||
|
&& Objects.equal(maxAliases, other.maxAliases);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
Joiner commaJoiner = Joiner.on(", ");
|
||||||
|
return String.format("accounts=%d, maxAccounts=%d, aliases=%d, maxAliases=%d", accounts, maxAccounts, aliases, maxAliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ import org.jclouds.javax.annotation.Nullable;
|
||||||
* Connection information to connect to a server with VNC.
|
* Connection information to connect to a server with VNC.
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_console" />
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_create" />
|
||||||
*/
|
*/
|
||||||
public class ServerCreated {
|
public class ServerCreated {
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
|
|
|
@ -38,11 +38,19 @@ public class ServerCreatedIp {
|
||||||
protected int version;
|
protected int version;
|
||||||
protected double cost;
|
protected double cost;
|
||||||
|
|
||||||
public Builder version(int version) {
|
protected Builder version(int version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder version4() {
|
||||||
|
return version(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder version6() {
|
||||||
|
return version(6);
|
||||||
|
}
|
||||||
|
|
||||||
public Builder ip(String ip) {
|
public Builder ip(String ip) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -55,14 +55,14 @@ public interface ArchiveAsyncClient {
|
||||||
ListenableFuture<Set<Archive>> listArchives();
|
ListenableFuture<Set<Archive>> listArchives();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ArchiveClient#archiveDetails
|
* @see ArchiveClient#getArchiveDetails
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/archive/details/format/json")
|
@Path("/archive/details/format/json")
|
||||||
@SelectJson("details")
|
@SelectJson("details")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<ArchiveDetails> archiveDetails(@FormParam("username") String username);
|
ListenableFuture<ArchiveDetails> getArchiveDetails(@FormParam("username") String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ArchiveClient#createArchive
|
* @see ArchiveClient#createArchive
|
||||||
|
@ -84,7 +84,7 @@ public interface ArchiveAsyncClient {
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/archive/resize/format/json")
|
@Path("/archive/resize/format/json")
|
||||||
ListenableFuture<Void> resizeArchive(@FormParam("username") String username, @FormParam("size")int size);
|
ListenableFuture<Void> resizeArchive(@FormParam("username") String username, @FormParam("size") int size);
|
||||||
/**
|
/**
|
||||||
* @see ArchiveClient#changeArchivePassword
|
* @see ArchiveClient#changeArchivePassword
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -48,7 +48,7 @@ public interface ArchiveClient {
|
||||||
* @param username the username associated with the archive
|
* @param username the username associated with the archive
|
||||||
* @return the archive information or null if not found
|
* @return the archive information or null if not found
|
||||||
*/
|
*/
|
||||||
ArchiveDetails archiveDetails(String username);
|
ArchiveDetails getArchiveDetails(String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new backup volume.
|
* Create a new backup volume.
|
||||||
|
@ -73,7 +73,7 @@ public interface ArchiveClient {
|
||||||
* Then delete the old volume.
|
* Then delete the old volume.
|
||||||
*
|
*
|
||||||
* @param username the username associated with the archive
|
* @param username the username associated with the archive
|
||||||
* @param size the new size required in GB
|
* @param size the new size required, see #getArchiveAllowedArguments for valid values
|
||||||
*/
|
*/
|
||||||
void resizeArchive(String username, int size);
|
void resizeArchive(String username, int size);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
/**
|
||||||
|
* 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.util.concurrent.ListenableFuture;
|
||||||
|
import org.jclouds.glesys.domain.*;
|
||||||
|
import org.jclouds.glesys.options.EmailCreateOptions;
|
||||||
|
import org.jclouds.glesys.options.EmailEditOptions;
|
||||||
|
import org.jclouds.http.filters.BasicAuthentication;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to E-Mail data via the Glesys REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see org.jclouds.glesys.features.EmailClient
|
||||||
|
* @see <a href="https://customer.glesys.com/api.php" />
|
||||||
|
*/
|
||||||
|
@RequestFilters(BasicAuthentication.class)
|
||||||
|
public interface EmailAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.glesys.features.EmailClient#emailOverview
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/email/overview/format/json")
|
||||||
|
@SelectJson("response")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<EmailOverview> getEmailOverview();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.glesys.features.EmailClient#listAccounts
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/email/list/format/json")
|
||||||
|
@SelectJson("emailaccounts")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Set<Email>> listAccounts(@FormParam("domain") String domain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.glesys.features.EmailClient#createAccount
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/email/createaccount/format/json")
|
||||||
|
ListenableFuture<Void> createAccount(@FormParam("emailaccount") String accountAddress, @FormParam("password") String password, EmailCreateOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.glesys.features.EmailClient#createAlias
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/email/createalias/format/json")
|
||||||
|
ListenableFuture<Void> createAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.glesys.features.EmailClient#editAccount
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/email/editaccount/format/json")
|
||||||
|
ListenableFuture<Void> editAccount(@FormParam("emailaccount") String accountAddress, EmailEditOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.glesys.features.EmailClient#editAlias
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/email/editalias/format/json")
|
||||||
|
ListenableFuture<Void> editAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.glesys.features.EmailClient#delete
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/email/delete/format/json")
|
||||||
|
ListenableFuture<Void> delete(@FormParam("email") String accountAddress);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.jclouds.glesys.features;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.glesys.domain.Email;
|
||||||
|
import org.jclouds.glesys.domain.EmailOverview;
|
||||||
|
import org.jclouds.glesys.options.EmailCreateOptions;
|
||||||
|
import org.jclouds.glesys.options.EmailEditOptions;
|
||||||
|
|
||||||
|
import javax.ws.rs.FormParam;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides synchronous access to E-Mail requests.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see org.jclouds.glesys.features.DomainAsyncClient
|
||||||
|
* @see <a href="https://customer.glesys.com/api.php" />
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface EmailClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a summary of e-mail accounts associated with this Glesys account
|
||||||
|
*
|
||||||
|
* @return the relevant summary data
|
||||||
|
*/
|
||||||
|
EmailOverview getEmailOverview();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Set<Email> listAccounts(String domain);
|
||||||
|
|
||||||
|
void createAccount(String accountAddress, String password, EmailCreateOptions... options);
|
||||||
|
|
||||||
|
void createAlias(String aliasAddress, String toEmailAddress);
|
||||||
|
|
||||||
|
void editAccount(String accountAddress, EmailEditOptions... options);
|
||||||
|
|
||||||
|
void editAlias(String aliasAddress, String toEmailAddress);
|
||||||
|
|
||||||
|
void delete(String accountAddress);
|
||||||
|
|
||||||
|
}
|
|
@ -90,7 +90,7 @@ public interface ServerAsyncClient {
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/server/console/format/json")
|
@Path("/server/console/format/json")
|
||||||
@SelectJson("server")
|
@SelectJson("remote")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<ServerConsole> getServerConsole(@FormParam("serverid") String id);
|
ListenableFuture<ServerConsole> getServerConsole(@FormParam("serverid") String id);
|
||||||
|
@ -183,7 +183,7 @@ public interface ServerAsyncClient {
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/server/destroy/format/json")
|
@Path("/server/destroy/format/json")
|
||||||
ListenableFuture<Void> destroyServer(@FormParam("serverid") String id, @FormParam("keepip") int keepIp);
|
ListenableFuture<Void> destroyServer(@FormParam("serverid") String id, ServerDestroyOptions keepIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerClient#resetPassword
|
* @see ServerClient#resetPassword
|
||||||
|
|
|
@ -169,9 +169,9 @@ public interface ServerClient {
|
||||||
* Destroy a server
|
* Destroy a server
|
||||||
*
|
*
|
||||||
* @param id the id of the server
|
* @param id the id of the server
|
||||||
* @param keepIp if 1 the servers ip will be retained for use in your Glesys account
|
* @param keepIp if ServerDestroyOptions.keepIp(true) the servers ip will be retained for use in your GleSYS account
|
||||||
*/
|
*/
|
||||||
void destroyServer(String id, int keepIp);
|
void destroyServer(String id, ServerDestroyOptions keepIp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the root password of a server
|
* Reset the root password of a server
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
package org.jclouds.glesys.options;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_createaccount" />
|
||||||
|
*/
|
||||||
|
public class EmailCreateOptions extends BaseHttpRequestOptions {
|
||||||
|
public static class Builder {
|
||||||
|
/**
|
||||||
|
* @see EmailCreateOptions#antispamLevel
|
||||||
|
*/
|
||||||
|
public static EmailCreateOptions antispamLevel(int antispamLevel) {
|
||||||
|
return new EmailCreateOptions().antispamLevel(antispamLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EmailCreateOptions#antiVirus
|
||||||
|
*/
|
||||||
|
public static EmailCreateOptions antiVirus(boolean antiVirus) {
|
||||||
|
return new EmailCreateOptions().antiVirus(antiVirus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EmailCreateOptions#autorespond
|
||||||
|
*/
|
||||||
|
public static EmailCreateOptions autorespond(boolean autorespond) {
|
||||||
|
return new EmailCreateOptions().autorespond(autorespond);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EmailCreateOptions#autorespondSaveEmail
|
||||||
|
*/
|
||||||
|
public static EmailCreateOptions autorespondSaveEmail(boolean autorespondSaveEmail) {
|
||||||
|
return new EmailCreateOptions().autorespondSaveEmail(autorespondSaveEmail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see EmailCreateOptions#autorespondMessage
|
||||||
|
*/
|
||||||
|
public static EmailCreateOptions autorespondMessage(boolean autorespondMessage) {
|
||||||
|
return new EmailCreateOptions().autorespondMessage(autorespondMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailCreateOptions antispamLevel(int antispamLevel) {
|
||||||
|
formParameters.put("antispamlevel", Integer.toString(antispamLevel));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailCreateOptions antiVirus(boolean antiVirus) {
|
||||||
|
formParameters.put("antivirus", Integer.toString(antiVirus ? 1 : 0));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailCreateOptions autorespond(boolean autorespond) {
|
||||||
|
formParameters.put("autorespond", Integer.toString(autorespond ? 1 : 0));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.jclouds.glesys.options;
|
||||||
|
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_editaccount" />
|
||||||
|
*/
|
||||||
|
public class EmailEditOptions extends EmailCreateOptions {
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
public static EmailEditOptions antispamLevel(int antispamLevel) {
|
||||||
|
return EmailEditOptions.class.cast(new EmailEditOptions().antispamLevel(antispamLevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EmailEditOptions antiVirus(boolean antiVirus) {
|
||||||
|
return EmailEditOptions.class.cast(new EmailEditOptions().antiVirus(antiVirus));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EmailEditOptions autorespond(boolean autorespond) {
|
||||||
|
return EmailEditOptions.class.cast(new EmailEditOptions().autorespond(autorespond));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EmailEditOptions autorespondSaveEmail(boolean autorespondSaveEmail) {
|
||||||
|
return EmailEditOptions.class.cast(new EmailEditOptions().autorespondSaveEmail(autorespondSaveEmail));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EmailEditOptions autorespondMessage(boolean autorespondMessage) {
|
||||||
|
return EmailEditOptions.class.cast(new EmailEditOptions().autorespondMessage(autorespondMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EmailEditOptions autorespondMessage(String password) {
|
||||||
|
return new EmailEditOptions().password(password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailEditOptions password(String password) {
|
||||||
|
formParameters.put("password", password);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.jclouds.glesys.options;
|
||||||
|
|
||||||
|
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
public class ServerDestroyOptions extends BaseHttpRequestOptions {
|
||||||
|
public static class Builder {
|
||||||
|
/**
|
||||||
|
* Discard the server's ip on destroy
|
||||||
|
*/
|
||||||
|
public static ServerDestroyOptions keepIp() {
|
||||||
|
return new ServerDestroyOptions().keepIp(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discard the server's ip on destroy
|
||||||
|
*/
|
||||||
|
public static ServerDestroyOptions discardIp() {
|
||||||
|
return new ServerDestroyOptions().keepIp(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether to keep the server's ip attached to your account when destroying a server
|
||||||
|
*
|
||||||
|
* @param keepIp if true, keep the ip address
|
||||||
|
*/
|
||||||
|
public ServerDestroyOptions keepIp(boolean keepIp) {
|
||||||
|
formParameters.put("keepip", Integer.toString(keepIp ? 1 : 0));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,7 +47,7 @@ public class ArchiveAsyncClientTest extends BaseGleSYSAsyncClientTest<ArchiveAsy
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testArchiveDetails() throws Exception {
|
public void testArchiveDetails() throws Exception {
|
||||||
testMethod("archiveDetails", "details", "POST", true, ReturnNullOnNotFoundOr404.class, userName);
|
testMethod("getArchiveDetails", "details", "POST", true, ReturnNullOnNotFoundOr404.class, userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateArchive() throws Exception {
|
public void testCreateArchive() throws Exception {
|
||||||
|
@ -61,7 +61,7 @@ public class ArchiveAsyncClientTest extends BaseGleSYSAsyncClientTest<ArchiveAsy
|
||||||
|
|
||||||
public void testResizeArchive() throws Exception {
|
public void testResizeArchive() throws Exception {
|
||||||
testMethod("resizeArchive", "resize", "POST", false, MapHttp4xxCodesToExceptions.class, userName,
|
testMethod("resizeArchive", "resize", "POST", false, MapHttp4xxCodesToExceptions.class, userName,
|
||||||
newEntry("size", 5));
|
newEntry("size", "5 GB"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testChangeArchivePassword() throws Exception {
|
public void testChangeArchivePassword() throws Exception {
|
||||||
|
|
|
@ -39,7 +39,7 @@ import static org.testng.Assert.*;
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "ArchiveClientLiveTest")
|
@Test(groups = "live", testName = "ArchiveClientLiveTest", singleThreaded = true)
|
||||||
public class ArchiveClientLiveTest extends BaseGleSYSClientLiveTest {
|
public class ArchiveClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = {"live"})
|
@BeforeGroups(groups = {"live"})
|
||||||
|
@ -97,7 +97,7 @@ public class ArchiveClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateArchive")
|
@Test(dependsOnMethods = "testCreateArchive")
|
||||||
public void testArchiveDetails() throws Exception {
|
public void testArchiveDetails() throws Exception {
|
||||||
ArchiveDetails details = client.archiveDetails(archiveUser);
|
ArchiveDetails details = client.getArchiveDetails(archiveUser);
|
||||||
assertEquals(details.getUsername(), archiveUser);
|
assertEquals(details.getUsername(), archiveUser);
|
||||||
assertNotNull(details.getFreeSize());
|
assertNotNull(details.getFreeSize());
|
||||||
assertNotNull(details.getTotalSize());
|
assertNotNull(details.getTotalSize());
|
||||||
|
@ -109,15 +109,14 @@ public class ArchiveClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
// TODO assert something useful!
|
// TODO assert something useful!
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO enable this once issue is resolved
|
@Test(dependsOnMethods = "testCreateArchive")
|
||||||
@Test(enabled=false, dependsOnMethods = "testCreateArchive")
|
|
||||||
public void testResizeArchive() throws Exception {
|
public void testResizeArchive() throws Exception {
|
||||||
client.resizeArchive(archiveUser, 30);
|
client.resizeArchive(archiveUser, 20);
|
||||||
|
|
||||||
assertTrue(new RetryablePredicate<String>(
|
assertTrue(new RetryablePredicate<String>(
|
||||||
new Predicate<String>() {
|
new Predicate<String>() {
|
||||||
public boolean apply(String value){
|
public boolean apply(String value){
|
||||||
return client.archiveDetails(archiveUser) != null && value.equals(client.archiveDetails(archiveUser).getTotalSize());
|
return client.getArchiveDetails(archiveUser) != null && value.equals(client.getArchiveDetails(archiveUser).getTotalSize());
|
||||||
}
|
}
|
||||||
}, 30, 1, TimeUnit.SECONDS).apply("20 GB"));
|
}, 30, 1, TimeUnit.SECONDS).apply("20 GB"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.rest.RestContextSpec;
|
import org.jclouds.rest.RestContextSpec;
|
||||||
|
import org.jclouds.util.Strings2;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -66,8 +67,6 @@ public abstract class BaseGleSYSAsyncClientTest<T> extends RestClientTest<T> {
|
||||||
/**
|
/**
|
||||||
* Test that a method call is annotated correctly.
|
* Test that a method call is annotated correctly.
|
||||||
* <p/>
|
* <p/>
|
||||||
* TODO de-code ampersands and spaces in args properly
|
|
||||||
*
|
|
||||||
* @param localMethod the method to call in asyncClientClass
|
* @param localMethod the method to call in asyncClientClass
|
||||||
* @param remoteCall the name of the expected call on the remote server
|
* @param remoteCall the name of the expected call on the remote server
|
||||||
* @param httpMethod "GET" or "POST"
|
* @param httpMethod "GET" or "POST"
|
||||||
|
@ -87,7 +86,7 @@ public abstract class BaseGleSYSAsyncClientTest<T> extends RestClientTest<T> {
|
||||||
argValues.add(arg);
|
argValues.add(arg);
|
||||||
} else {
|
} else {
|
||||||
Map.Entry<String, String> entry = (Map.Entry<String, String>) arg;
|
Map.Entry<String, String> entry = (Map.Entry<String, String>) arg;
|
||||||
argStrings.add(entry.getKey() + "=" + entry.getValue());
|
argStrings.add(entry.getKey() + "=" + Strings2.urlEncode(entry.getValue()));
|
||||||
argValues.add(entry.getValue());
|
argValues.add(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,17 @@
|
||||||
package org.jclouds.glesys.features;
|
package org.jclouds.glesys.features;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
import org.jclouds.glesys.GleSYSAsyncClient;
|
import org.jclouds.glesys.GleSYSAsyncClient;
|
||||||
import org.jclouds.glesys.GleSYSClient;
|
import org.jclouds.glesys.GleSYSClient;
|
||||||
|
import org.jclouds.glesys.domain.ServerCreated;
|
||||||
|
import org.jclouds.glesys.domain.ServerState;
|
||||||
|
import org.jclouds.glesys.domain.ServerStatus;
|
||||||
|
import org.jclouds.glesys.options.ServerStatusOptions;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
@ -33,10 +40,12 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GleSYSClient}
|
* Tests behavior of {@code GleSYSClient}
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole, Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseGleSYSClientLiveTest {
|
public class BaseGleSYSClientLiveTest {
|
||||||
|
@ -45,18 +54,67 @@ public class BaseGleSYSClientLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
String identity = checkNotNull(System.getProperty("test.glesys.identity"), "test.glesys.identity");
|
if (context == null) {
|
||||||
String credential = checkNotNull(System.getProperty("test.glesys.credential"), "test.glesys.credential");
|
String identity = checkNotNull(System.getProperty("test.glesys.identity"), "test.glesys.identity");
|
||||||
|
String credential = checkNotNull(System.getProperty("test.glesys.credential"), "test.glesys.credential");
|
||||||
context = new RestContextFactory().createContext("glesys", identity, credential,
|
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()));
|
|
||||||
|
|
||||||
|
context = new RestContextFactory().createContext("glesys", identity, credential,
|
||||||
|
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if (context != null)
|
if (context != null) {
|
||||||
context.close();
|
context.close();
|
||||||
|
context = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void createDomain(String domain) {
|
||||||
|
final DomainClient client = context.getApi().getDomainClient();
|
||||||
|
int before = client.listDomains().size();
|
||||||
|
client.addDomain(domain);
|
||||||
|
RetryablePredicate<Integer> result = new RetryablePredicate<Integer>(
|
||||||
|
new Predicate<Integer>() {
|
||||||
|
public boolean apply(Integer value) {
|
||||||
|
return client.listDomains().size() == value;
|
||||||
|
}
|
||||||
|
}, 30, 1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
assertTrue(result.apply(before + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected ServerStatusChecker createServer(String hostName) {
|
||||||
|
ServerClient client = context.getApi().getServerClient();
|
||||||
|
ServerCreated testServer = client.createServer("Falkenberg", "OpenVZ", hostName, "Ubuntu 10.04 LTS 32-bit", 5, 512, 1, "password", 50);
|
||||||
|
|
||||||
|
assertNotNull(testServer.getId());
|
||||||
|
assertEquals(testServer.getHostname(), hostName);
|
||||||
|
assertFalse(testServer.getIps().isEmpty());
|
||||||
|
|
||||||
|
ServerStatusChecker runningServerCounter = new ServerStatusChecker(client, testServer.getId(), 180, 10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
assertTrue(runningServerCounter.apply(ServerState.RUNNING));
|
||||||
|
return runningServerCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ServerStatusChecker extends RetryablePredicate<ServerState> {
|
||||||
|
private final String serverId;
|
||||||
|
public String getServerId() {
|
||||||
|
return serverId;
|
||||||
|
}
|
||||||
|
public ServerStatusChecker(final ServerClient client, final String serverId, long maxWait, long period, TimeUnit unit) {
|
||||||
|
super(new Predicate<ServerState>() {
|
||||||
|
|
||||||
|
public boolean apply(ServerState value) {
|
||||||
|
ServerStatus status = client.getServerStatus(serverId, ServerStatusOptions.Builder.state());
|
||||||
|
return status.getState() == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}, maxWait, period, unit);
|
||||||
|
this.serverId = serverId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,9 @@ import static org.testng.Assert.assertTrue;
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "DomainClientLiveTest")
|
@Test(groups = "live", testName = "DomainClientLiveTest", singleThreaded = true)
|
||||||
public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
|
public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
|
public final String testDomain = "glesystest.jclouds.org";
|
||||||
|
|
||||||
@BeforeGroups(groups = {"live"})
|
@BeforeGroups(groups = {"live"})
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
|
@ -55,6 +56,13 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
return client.listRecords(testDomain).size() == value;
|
return client.listRecords(testDomain).size() == value;
|
||||||
}
|
}
|
||||||
}, 30, 1, TimeUnit.SECONDS);
|
}, 30, 1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
try {
|
||||||
|
client.deleteDomain(testDomain);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
|
|
||||||
|
createDomain(testDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = {"live"})
|
@AfterGroups(groups = {"live"})
|
||||||
|
@ -67,24 +75,11 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DomainClient client;
|
private DomainClient client;
|
||||||
private String testDomain = "glesystest.jclouds.org";
|
|
||||||
private String testRecordId;
|
private String testRecordId;
|
||||||
private RetryablePredicate<Integer> domainCounter;
|
private RetryablePredicate<Integer> domainCounter;
|
||||||
private RetryablePredicate<Integer> recordCounter;
|
private RetryablePredicate<Integer> recordCounter;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateDomain() throws Exception {
|
|
||||||
try {
|
|
||||||
client.deleteDomain(testDomain);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
}
|
|
||||||
|
|
||||||
int before = client.listDomains().size();
|
|
||||||
client.addDomain(testDomain);
|
|
||||||
assertTrue(domainCounter.apply(before + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateDomain")
|
|
||||||
public void testCreateRecord() throws Exception {
|
public void testCreateRecord() throws Exception {
|
||||||
int before = client.listRecords(testDomain).size();
|
int before = client.listRecords(testDomain).size();
|
||||||
|
|
||||||
|
@ -93,7 +88,7 @@ public class DomainClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
assertTrue(recordCounter.apply(before + 1));
|
assertTrue(recordCounter.apply(before + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateRecord")
|
@Test
|
||||||
public void testDeleteRecord() throws Exception {
|
public void testDeleteRecord() throws Exception {
|
||||||
Set<DomainRecord> domainRecords = client.listRecords(testDomain);
|
Set<DomainRecord> domainRecords = client.listRecords(testDomain);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/**
|
||||||
|
* 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.inject.TypeLiteral;
|
||||||
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
|
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests annotation parsing of {@code ArchiveAsyncClient}
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "EmailAsyncClientTest")
|
||||||
|
public class EmailAsyncClientTest extends BaseGleSYSAsyncClientTest<EmailAsyncClient> {
|
||||||
|
public EmailAsyncClientTest() {
|
||||||
|
asyncClientClass = EmailAsyncClient.class;
|
||||||
|
remoteServicePrefix = "email";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testList() throws Exception {
|
||||||
|
testMethod("listAccounts", "list", "POST", true, ReturnEmptySetOnNotFoundOr404.class, newEntry("domain","test"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOverview() throws Exception {
|
||||||
|
testMethod("getEmailOverview", "overview", "POST", true, ReturnEmptySetOnNotFoundOr404.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCreateAccount() throws Exception {
|
||||||
|
testMethod("createAccount", "createaccount", "POST", false, MapHttp4xxCodesToExceptions.class,
|
||||||
|
newEntry("emailaccount", "jclouds.org"), newEntry("password", "test@jclouds.org"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCreateAlias() throws Exception {
|
||||||
|
testMethod("createAlias", "createalias", "POST", false, MapHttp4xxCodesToExceptions.class,
|
||||||
|
newEntry("emailalias", "test2@jclouds.org"), newEntry("goto", "test@jclouds.org"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testEditAlias() throws Exception {
|
||||||
|
testMethod("editAlias", "editalias", "POST", false, MapHttp4xxCodesToExceptions.class,
|
||||||
|
newEntry("emailalias", "test2@jclouds.org"), newEntry("goto", "test1@jclouds.org"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeLiteral<RestAnnotationProcessor<EmailAsyncClient>> createTypeLiteral() {
|
||||||
|
return new TypeLiteral<RestAnnotationProcessor<EmailAsyncClient>>() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
import org.jclouds.glesys.domain.*;
|
||||||
|
import org.jclouds.glesys.options.EmailCreateOptions;
|
||||||
|
import org.jclouds.glesys.options.EmailEditOptions;
|
||||||
|
import org.jclouds.glesys.options.ServerDestroyOptions;
|
||||||
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
import org.testng.annotations.AfterGroups;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code EmailClient}
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", testName = "EmailClientLiveTest", singleThreaded = true)
|
||||||
|
public class EmailClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
|
|
||||||
|
@BeforeGroups(groups = {"live"})
|
||||||
|
public void setupClient() {
|
||||||
|
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<Integer>(
|
||||||
|
new Predicate<Integer>() {
|
||||||
|
public boolean apply(Integer value) {
|
||||||
|
return client.listAccounts(testDomain).size() == value;
|
||||||
|
}
|
||||||
|
}, 30, 1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@AfterGroups(groups = {"live"})
|
||||||
|
public void tearDown() {
|
||||||
|
client.delete("test@" + 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<Integer> emailAccountCounter;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createEmail() {
|
||||||
|
client.createAccount("test@" + testDomain, "password", EmailCreateOptions.Builder.antiVirus(true));
|
||||||
|
assertTrue(emailAccountCounter.apply(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dependsOnMethods = "createEmail")
|
||||||
|
public void createAlias() {
|
||||||
|
client.createAlias("test2@" + testDomain, "test@" + testDomain);
|
||||||
|
EmailOverview overview = client.getEmailOverview();
|
||||||
|
assertTrue(overview.getSummary().getAliases() == 1);
|
||||||
|
client.delete("test2@" + testDomain);
|
||||||
|
overview = client.getEmailOverview();
|
||||||
|
assertTrue(overview.getSummary().getAliases() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dependsOnMethods = "createEmail")
|
||||||
|
public void testOverview() throws Exception {
|
||||||
|
EmailOverview overview = client.getEmailOverview();
|
||||||
|
assertNotNull(overview.getSummary());
|
||||||
|
assertTrue(overview.getSummary().getAccounts() >= 1);
|
||||||
|
assertTrue(overview.getSummary().getAliases() == 0);
|
||||||
|
assertTrue(overview.getSummary().getMaxAccounts() > 0);
|
||||||
|
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")
|
||||||
|
public void testListAccounts() throws Exception {
|
||||||
|
Set<Email> accounts = client.listAccounts(testDomain);
|
||||||
|
assertTrue(accounts.size() >= 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dependsOnMethods = "createEmail")
|
||||||
|
public void testEditAccount() throws Exception {
|
||||||
|
Set<Email> accounts = client.listAccounts(testDomain);
|
||||||
|
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) {
|
||||||
|
if (account.getAccount().equals("test@" + testDomain)) {
|
||||||
|
assertFalse(account.getAntiVirus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -120,6 +120,11 @@ public class ServerAsyncClientTest extends BaseGleSYSAsyncClientTest<ServerAsync
|
||||||
testMethod("rebootServer", "reboot", "POST", false, MapHttp4xxCodesToExceptions.class, serverIdOnly);
|
testMethod("rebootServer", "reboot", "POST", false, MapHttp4xxCodesToExceptions.class, serverIdOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDestroyServer() throws Exception {
|
||||||
|
testMethod("destroyServer", "destroy", "POST", false, MapHttp4xxCodesToExceptions.class, serverIdOnly, ServerDestroyOptions.Builder.keepIp());
|
||||||
|
testMethod("destroyServer", "destroy", "POST", false, MapHttp4xxCodesToExceptions.class, serverIdOnly, ServerDestroyOptions.Builder.discardIp());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ServerAsyncClient>> createTypeLiteral() {
|
protected TypeLiteral<RestAnnotationProcessor<ServerAsyncClient>> createTypeLiteral() {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ServerAsyncClient>>() {
|
return new TypeLiteral<RestAnnotationProcessor<ServerAsyncClient>>() {
|
||||||
|
|
|
@ -21,10 +21,12 @@ package org.jclouds.glesys.features;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import org.jclouds.glesys.domain.*;
|
import org.jclouds.glesys.domain.*;
|
||||||
import org.jclouds.glesys.options.ServerCloneOptions;
|
import org.jclouds.glesys.options.ServerCloneOptions;
|
||||||
|
import org.jclouds.glesys.options.ServerDestroyOptions;
|
||||||
import org.jclouds.glesys.options.ServerStatusOptions;
|
import org.jclouds.glesys.options.ServerStatusOptions;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -41,39 +43,34 @@ import static org.testng.Assert.*;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "ServerClientLiveTest")
|
@Test(groups = "live", testName = "ServerClientLiveTest")
|
||||||
public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
|
public static final String testHostName1 = "jclouds-test";
|
||||||
|
public static final String testHostName2 = "jclouds-test2";
|
||||||
|
|
||||||
@BeforeGroups(groups = {"live"})
|
@BeforeGroups(groups = {"live"})
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
super.setupClient();
|
super.setupClient();
|
||||||
client = context.getApi().getServerClient();
|
client = context.getApi().getServerClient();
|
||||||
|
serverStatusChecker = createServer(testHostName1);
|
||||||
|
testServerId = serverStatusChecker.getServerId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = {"live"})
|
@AfterGroups(groups = {"live"})
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
client.destroyServer(testServer.getId(), 0);
|
client.destroyServer(testServerId, ServerDestroyOptions.Builder.discardIp());
|
||||||
if (testServer2 != null) {
|
if (testServerId2 != null) {
|
||||||
client.destroyServer(testServer2.getId(), 0);
|
client.destroyServer(testServerId2, ServerDestroyOptions.Builder.discardIp());
|
||||||
}
|
}
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerClient client;
|
private ServerClient client;
|
||||||
private ServerCreated testServer;
|
private ServerStatusChecker serverStatusChecker;
|
||||||
private ServerCreated testServer2;
|
private String testServerId;
|
||||||
// note this is initialized by testCreateServer()
|
private String testServerId2;
|
||||||
private RetryablePredicate<ServerState> runningServerCounter;
|
|
||||||
|
|
||||||
@Test
|
@BeforeMethod
|
||||||
public void testCreateServer() throws Exception {
|
public void makeSureServerIsRunning() throws Exception {
|
||||||
testServer = client.createServer("Falkenberg", "OpenVZ", "jclouds-test", "Ubuntu 10.04 LTS 32-bit", 5, 512, 1, "password", 50);
|
serverStatusChecker.apply(ServerState.RUNNING);
|
||||||
|
|
||||||
assertNotNull(testServer.getId());
|
|
||||||
assertEquals(testServer.getHostname(), "jclouds-test");
|
|
||||||
assertFalse(testServer.getIps().isEmpty());
|
|
||||||
|
|
||||||
runningServerCounter = new ServerStatusChecker(testServer.getId(), 120, 2, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
assertTrue(runningServerCounter.apply(ServerState.RUNNING));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -125,7 +122,7 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
assert t.getMinMemSize() > 0 : t;
|
assert t.getMinMemSize() > 0 : t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateServer")
|
@Test
|
||||||
public void testListServers() throws Exception {
|
public void testListServers() throws Exception {
|
||||||
Set<Server> response = client.listServers();
|
Set<Server> response = client.listServers();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
|
@ -141,35 +138,48 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateServer")
|
@Test
|
||||||
public void testServerDetails() throws Exception {
|
public void testServerDetails() throws Exception {
|
||||||
ServerStatus newStatus = client.getServerStatus(testServer.getId());
|
ServerStatus newStatus = client.getServerStatus(testServerId);
|
||||||
checkStatus(newStatus);
|
checkStatus(newStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateServer")
|
@Test(enabled=false) // TODO work a better plan
|
||||||
public void testRebootServer() throws Exception {
|
public void testRebootServer() throws Exception {
|
||||||
client.rebootServer(testServer.getId());
|
long uptime = 0;
|
||||||
|
|
||||||
assertTrue(runningServerCounter.apply(ServerState.STOPPED));
|
while(uptime < 20) {
|
||||||
assertTrue(runningServerCounter.apply(ServerState.RUNNING));
|
uptime = client.getServerStatus(testServerId).getUptime();
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(uptime > 19);
|
||||||
|
|
||||||
|
client.rebootServer(testServerId);
|
||||||
|
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
uptime = client.getServerStatus(testServerId).getUptime();
|
||||||
|
|
||||||
|
assertTrue(uptime < 20);
|
||||||
|
|
||||||
|
assertTrue(serverStatusChecker.apply(ServerState.RUNNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateServer")
|
@Test(enabled=false) // TODO
|
||||||
public void testStopAndStartServer() throws Exception {
|
public void testStopAndStartServer() throws Exception {
|
||||||
client.stopServer(testServer.getId());
|
client.stopServer(testServerId);
|
||||||
|
|
||||||
assertTrue(runningServerCounter.apply(ServerState.STOPPED));
|
assertTrue(serverStatusChecker.apply(ServerState.STOPPED));
|
||||||
|
|
||||||
client.startServer(testServer.getId());
|
client.startServer(testServerId);
|
||||||
|
|
||||||
assertTrue(runningServerCounter.apply(ServerState.RUNNING));
|
assertTrue(serverStatusChecker.apply(ServerState.RUNNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateServer")
|
@Test
|
||||||
public void testServerLimits() throws Exception {
|
public void testServerLimits() throws Exception {
|
||||||
Map<String, ServerLimit> limits = client.getServerLimits(testServer.getId());
|
Map<String, ServerLimit> limits = client.getServerLimits(testServerId);
|
||||||
assertNotNull(limits);
|
assertNotNull(limits);
|
||||||
for (Map.Entry<String, ServerLimit> entry : limits.entrySet()) {
|
for (Map.Entry<String, ServerLimit> entry : limits.entrySet()) {
|
||||||
assertNotNull(entry.getKey());
|
assertNotNull(entry.getKey());
|
||||||
|
@ -183,27 +193,27 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO in progress
|
@Test
|
||||||
@Test(enabled=false, dependsOnMethods = "testCreateServer")
|
|
||||||
public void testServerConsole() throws Exception {
|
public void testServerConsole() throws Exception {
|
||||||
ServerConsole console = client.getServerConsole(testServer.getId());
|
ServerConsole console = client.getServerConsole(testServerId);
|
||||||
assertNotNull(console);
|
assertNotNull(console);
|
||||||
assertNotNull(console.getHost());
|
assertNotNull(console.getHost());
|
||||||
assertTrue(console.getPort() > 0 && console.getPort() < 65537);
|
assertTrue(console.getPort() > 0 && console.getPort() < 65537);
|
||||||
assertNotNull(console.getPassword());
|
assertNotNull(console.getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
// takes a few minutes
|
// takes a few minutes and requires an extra server (using 2 already)
|
||||||
@Test(enabled=false, dependsOnMethods = "testCreateServer")
|
@Test(enabled=false)
|
||||||
public void testCloneServer() throws Exception {
|
public void testCloneServer() throws Exception {
|
||||||
testServer2 = client.cloneServer(testServer.getId(), "jclouds-test2", ServerCloneOptions.Builder.cpucores(1));
|
ServerCreated testServer2 = client.cloneServer(testServerId, testHostName2, ServerCloneOptions.Builder.cpucores(1));
|
||||||
|
|
||||||
assertNotNull(testServer2.getId());
|
assertNotNull(testServer2.getId());
|
||||||
assertEquals(testServer2.getHostname(), "jclouds-test2");
|
assertEquals(testServer2.getHostname(), "jclouds-test2");
|
||||||
assertTrue(testServer2.getIps().isEmpty());
|
assertTrue(testServer2.getIps().isEmpty());
|
||||||
|
|
||||||
RetryablePredicate<ServerState> cloneChecker = new ServerStatusChecker(testServer2.getId(), 300, 10, TimeUnit.SECONDS);
|
testServerId2 = testServer2.getId();
|
||||||
|
|
||||||
|
RetryablePredicate<ServerState> cloneChecker = new ServerStatusChecker(client, testServerId2, 300, 10, TimeUnit.SECONDS);
|
||||||
assertTrue(cloneChecker.apply(ServerState.STOPPED));
|
assertTrue(cloneChecker.apply(ServerState.STOPPED));
|
||||||
|
|
||||||
client.startServer(testServer2.getId());
|
client.startServer(testServer2.getId());
|
||||||
|
@ -213,12 +223,12 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
new Predicate<ServerState>() {
|
new Predicate<ServerState>() {
|
||||||
|
|
||||||
public boolean apply(ServerState value) {
|
public boolean apply(ServerState value) {
|
||||||
ServerStatus status = client.getServerStatus(testServer2.getId(), ServerStatusOptions.Builder.state());
|
ServerStatus status = client.getServerStatus(testServerId2, ServerStatusOptions.Builder.state());
|
||||||
if (status.getState() == value) {
|
if (status.getState() == value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.startServer(testServer2.getId());
|
client.startServer(testServerId2);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,17 +275,4 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
assert status.getMemory().getUsage() >= 0 : status;
|
assert status.getMemory().getUsage() >= 0 : status;
|
||||||
assertNotNull(status.getMemory().getUnit());
|
assertNotNull(status.getMemory().getUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ServerStatusChecker extends RetryablePredicate<ServerState> {
|
|
||||||
public ServerStatusChecker(final String serverId, long maxWait, long period, TimeUnit unit) {
|
|
||||||
super(new Predicate<ServerState>() {
|
|
||||||
|
|
||||||
public boolean apply(ServerState value) {
|
|
||||||
ServerStatus status = client.getServerStatus(serverId, ServerStatusOptions.Builder.state());
|
|
||||||
return status.getState() == value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, maxWait, period, unit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
* 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.parse;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||||
|
import org.jclouds.glesys.domain.Email;
|
||||||
|
import org.jclouds.json.BaseSetParserTest;
|
||||||
|
import org.jclouds.json.config.GsonModule;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "ParseEmailListTest")
|
||||||
|
public class ParseEmailListTest extends BaseSetParserTest<Email> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resource() {
|
||||||
|
return "/email_list.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SelectJson("emailaccounts")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public Set<Email> expected() {
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
|
Email.Builder builder = Email.builder().quota("200 MB").usedQuota("0 MB").antispamLevel(3).antiVirus(true).autoRespond(false).autoRespondSaveEmail(true).autoRespondMessage("false");
|
||||||
|
try {
|
||||||
|
return ImmutableSet.of(
|
||||||
|
builder.account("test@adamlowe.net").created(dateFormat.parse("2011-12-22T12:13:14")).modified(dateFormat.parse("2011-12-22T12:13:35")).build(),
|
||||||
|
builder.account("test2@adamlowe.net").created(dateFormat.parse("2011-12-22T12:14:29")).modified(dateFormat.parse("2011-12-22T12:14:31")).build()
|
||||||
|
);
|
||||||
|
} catch(ParseException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Injector injector() {
|
||||||
|
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/**
|
||||||
|
* 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.parse;
|
||||||
|
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||||
|
import org.jclouds.glesys.domain.EmailOverview;
|
||||||
|
import org.jclouds.glesys.domain.EmailOverviewDomain;
|
||||||
|
import org.jclouds.glesys.domain.EmailOverviewSummary;
|
||||||
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
|
import org.jclouds.json.config.GsonModule;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "ParseEmailListTest")
|
||||||
|
public class ParseEmailOverviewTest extends BaseItemParserTest<EmailOverview> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resource() {
|
||||||
|
return "/email_overview.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SelectJson("response")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public EmailOverview expected() {
|
||||||
|
return EmailOverview.builder().summary(EmailOverviewSummary.builder().accounts(2).aliases(0).maxAccounts(50).maxAliases(1000).build()).domains(EmailOverviewDomain.builder().accounts(2).aliases(0).domain("adamlowe.net").build()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Injector injector() {
|
||||||
|
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/**
|
||||||
|
* 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.parse;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import org.jclouds.glesys.config.GleSYSParserModule;
|
||||||
|
import org.jclouds.glesys.domain.ServerConsole;
|
||||||
|
import org.jclouds.glesys.domain.ServerCreated;
|
||||||
|
import org.jclouds.glesys.domain.ServerCreatedIp;
|
||||||
|
import org.jclouds.json.BaseItemParserTest;
|
||||||
|
import org.jclouds.json.config.GsonModule;
|
||||||
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adam Lowe
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "ParseServerCreatedTest")
|
||||||
|
public class ParseServerConsoleTest extends BaseItemParserTest<ServerConsole> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resource() {
|
||||||
|
return "/server_console.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SelectJson("remote")
|
||||||
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
public ServerConsole expected() {
|
||||||
|
return ServerConsole.builder().host("79.99.2.147").port(59478).password("1476897311").build();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Injector injector() {
|
||||||
|
return Guice.createInjector(new GleSYSParserModule(), new GsonModule());
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,7 +47,7 @@ public class ParseServerCreatedTest extends BaseItemParserTest<ServerCreated> {
|
||||||
@SelectJson("server")
|
@SelectJson("server")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public ServerCreated expected() {
|
public ServerCreated expected() {
|
||||||
return ServerCreated.builder().id("xm3630641").hostname("jclouds-test-host").ips(ServerCreatedIp.builder().ip("109.74.10.27").version(4).cost(2.00).build()).build();
|
return ServerCreated.builder().id("xm3630641").hostname("jclouds-test-host").ips(ServerCreatedIp.builder().ip("109.74.10.27").version4().cost(2.00).build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{"response":{"status":{"code":"200","text":"OK"},"list":{"emailaccounts":[{"emailaccount":"test2@adamlowe.net","quota":"200 MB","usedquota":"0 MB","antispamlevel":3,"antivirus":true,"autorespond":false,"autorespondmessage":false,"autorespondsaveemail":true,"created":"2011-12-22 12:14:29","modified":"2011-12-22 12:14:31"},{"emailaccount":"test@adamlowe.net","quota":"200 MB","usedquota":"0 MB","antispamlevel":3,"antivirus":true,"autorespond":false,"autorespondmessage":false,"autorespondsaveemail":true,"created":"2011-12-22 12:13:14","modified":"2011-12-22 12:13:35"}]},"debug":{"input":{"domain":"adamlowe.net"}}}}
|
|
@ -0,0 +1 @@
|
||||||
|
{"response":{"status":{"code":"200","text":"OK"},"summary":{"accounts":2,"maxaccounts":"50","aliases":0,"maxaliases":1000},"domains":[{"domain":"adamlowe.net","accounts":2,"aliases":0}],"debug":{"input":[]}}}
|
|
@ -0,0 +1 @@
|
||||||
|
{"response":{"status":{"code":"200","text":"OK"},"remote":{"host":"79.99.2.147","port":"59478","password":"1476897311"},"debug":{"input":{"serverid":"vz1842554"}}}}
|
Loading…
Reference in New Issue