conventions update for glesys

This commit is contained in:
Adrian Cole 2012-09-16 16:20:07 -07:00
parent e4a41e49fa
commit 171c0804e0
39 changed files with 575 additions and 563 deletions

View File

@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.glesys.features.ArchiveApi; import org.jclouds.glesys.features.ArchiveApi;
import org.jclouds.glesys.features.DomainApi; import org.jclouds.glesys.features.DomainApi;
import org.jclouds.glesys.features.EmailApi; import org.jclouds.glesys.features.EmailAccountApi;
import org.jclouds.glesys.features.IpApi; import org.jclouds.glesys.features.IpApi;
import org.jclouds.glesys.features.ServerApi; import org.jclouds.glesys.features.ServerApi;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
@ -67,6 +67,6 @@ public interface GleSYSApi {
* Provides synchronous access to E-Mail features. * Provides synchronous access to E-Mail features.
*/ */
@Delegate @Delegate
EmailApi getEmailApi(); EmailAccountApi getEmailAccountApi();
} }

View File

@ -20,7 +20,7 @@ package org.jclouds.glesys;
import org.jclouds.glesys.features.ArchiveAsyncApi; import org.jclouds.glesys.features.ArchiveAsyncApi;
import org.jclouds.glesys.features.DomainAsyncApi; import org.jclouds.glesys.features.DomainAsyncApi;
import org.jclouds.glesys.features.EmailAsyncApi; import org.jclouds.glesys.features.EmailAccountAsyncApi;
import org.jclouds.glesys.features.IpAsyncApi; import org.jclouds.glesys.features.IpAsyncApi;
import org.jclouds.glesys.features.ServerAsyncApi; import org.jclouds.glesys.features.ServerAsyncApi;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
@ -63,6 +63,6 @@ public interface GleSYSAsyncApi {
* Provides asynchronous access to E-Mail features. * Provides asynchronous access to E-Mail features.
*/ */
@Delegate @Delegate
EmailAsyncApi getEmailApi(); EmailAccountAsyncApi getEmailAccountApi();
} }

View File

@ -132,7 +132,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
// and set if present // and set if present
logger.debug(">> creating new Server spec(%s) name(%s) options(%s)", spec, name, createServerOptions); logger.debug(">> creating new Server spec(%s) name(%s) options(%s)", spec, name, createServerOptions);
ServerDetails result = api.getServerApi().createServerWithHostnameAndRootPassword(spec, name, password, ServerDetails result = api.getServerApi().createWithHostnameAndRootPassword(spec, name, password,
createServerOptions); createServerOptions);
logger.trace("<< server(%s)", result.getId()); logger.trace("<< server(%s)", result.getId());
@ -163,7 +163,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
Set<OSTemplate> images = listImages(); Set<OSTemplate> images = listImages();
for (Entry<String, AllowedArgumentsForCreateServer> platformToArgs : api.getServerApi() for (Entry<String, AllowedArgumentsForCreateServer> platformToArgs : api.getServerApi()
.getAllowedArgumentsForCreateServerByPlatform().entrySet()) .getAllowedArgumentsForCreateByPlatform().entrySet())
for (String datacenter : platformToArgs.getValue().getDataCenters()) for (String datacenter : platformToArgs.getValue().getDataCenters())
for (int diskSizeGB : platformToArgs.getValue().getDiskSizesInGB()) for (int diskSizeGB : platformToArgs.getValue().getDiskSizesInGB())
for (int cpuCores : platformToArgs.getValue().getCpuCoreOptions()) for (int cpuCores : platformToArgs.getValue().getCpuCoreOptions())
@ -192,7 +192,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override @Override
public Set<OSTemplate> listImages() { public Set<OSTemplate> listImages() {
return api.getServerApi().listTemplates(); return api.getServerApi().listTemplates().toImmutableSet();
} }
// cheat until we have a getTemplate command // cheat until we have a getTemplate command
@ -210,10 +210,10 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override @Override
public Iterable<ServerDetails> listNodes() { public Iterable<ServerDetails> listNodes() {
return Iterables2.concreteCopy(transformParallel(api.getServerApi().listServers(), new Function<Server, Future<? extends ServerDetails>>() { return Iterables2.concreteCopy(transformParallel(api.getServerApi().list(), new Function<Server, Future<? extends ServerDetails>>() {
@Override @Override
public Future<ServerDetails> apply(Server from) { public Future<ServerDetails> apply(Server from) {
return aapi.getServerApi().getServerDetails(from.getId()); return aapi.getServerApi().get(from.getId());
} }
}, userThreads, null, logger, "server details")); }, userThreads, null, logger, "server details"));
@ -222,7 +222,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override @Override
public Set<String> listLocations() { public Set<String> listLocations() {
return ImmutableSet.copyOf(Iterables.concat(Iterables.transform(api.getServerApi() return ImmutableSet.copyOf(Iterables.concat(Iterables.transform(api.getServerApi()
.getAllowedArgumentsForCreateServerByPlatform().values(), .getAllowedArgumentsForCreateByPlatform().values(),
new Function<AllowedArgumentsForCreateServer, Set<String>>() { new Function<AllowedArgumentsForCreateServer, Set<String>>() {
@Override @Override
@ -235,7 +235,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override @Override
public ServerDetails getNode(String id) { public ServerDetails getNode(String id) {
return api.getServerApi().getServerDetails(id); return api.getServerApi().get(id);
} }
@Override @Override
@ -245,7 +245,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override @Override
public boolean apply(String arg0) { public boolean apply(String arg0) {
try { try {
api.getServerApi().destroyServer(arg0, DestroyServerOptions.Builder.discardIp()); api.getServerApi().destroy(arg0, DestroyServerOptions.Builder.discardIp());
return true; return true;
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
return false; return false;
@ -257,16 +257,16 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override @Override
public void rebootNode(String id) { public void rebootNode(String id) {
api.getServerApi().rebootServer(id); api.getServerApi().reboot(id);
} }
@Override @Override
public void resumeNode(String id) { public void resumeNode(String id) {
api.getServerApi().startServer(id); api.getServerApi().start(id);
} }
@Override @Override
public void suspendNode(String id) { public void suspendNode(String id) {
api.getServerApi().stopServer(id); api.getServerApi().stop(id);
} }
} }

View File

@ -70,7 +70,7 @@ public class GleSYSTemplateOptions extends TemplateOptions implements Cloneable
/** /**
* *
* @see ServerApi#createServerWithHostnameAndRootPassword * @see ServerApi#createWithHostnameAndRootPassword
* @see InetAddresses#isInetAddress * @see InetAddresses#isInetAddress
*/ */
public TemplateOptions ip(String ip) { public TemplateOptions ip(String ip) {

View File

@ -26,8 +26,8 @@ import org.jclouds.glesys.features.ArchiveApi;
import org.jclouds.glesys.features.ArchiveAsyncApi; import org.jclouds.glesys.features.ArchiveAsyncApi;
import org.jclouds.glesys.features.DomainApi; import org.jclouds.glesys.features.DomainApi;
import org.jclouds.glesys.features.DomainAsyncApi; import org.jclouds.glesys.features.DomainAsyncApi;
import org.jclouds.glesys.features.EmailApi; import org.jclouds.glesys.features.EmailAccountApi;
import org.jclouds.glesys.features.EmailAsyncApi; import org.jclouds.glesys.features.EmailAccountAsyncApi;
import org.jclouds.glesys.features.IpApi; import org.jclouds.glesys.features.IpApi;
import org.jclouds.glesys.features.IpAsyncApi; import org.jclouds.glesys.features.IpAsyncApi;
import org.jclouds.glesys.features.ServerApi; import org.jclouds.glesys.features.ServerApi;
@ -60,7 +60,7 @@ public class GleSYSRestClientModule extends RestClientModule<GleSYSApi, GleSYSAs
.put(IpApi.class, IpAsyncApi.class)// .put(IpApi.class, IpAsyncApi.class)//
.put(ArchiveApi.class, ArchiveAsyncApi.class)// .put(ArchiveApi.class, ArchiveAsyncApi.class)//
.put(DomainApi.class, DomainAsyncApi.class)// .put(DomainApi.class, DomainAsyncApi.class)//
.put(EmailApi.class, EmailAsyncApi.class)// .put(EmailAccountApi.class, EmailAccountAsyncApi.class)//
.build(); .build();
public GleSYSRestClientModule() { public GleSYSRestClientModule() {

View File

@ -49,7 +49,7 @@ public class ArchiveAllowedArguments {
protected List<Integer> archiveSizes = ImmutableList.of(); protected List<Integer> archiveSizes = ImmutableList.of();
/** /**
* @see ArchiveAllowedArguments#getArchiveSizes() * @see ArchiveAllowedArguments#getSizes()
*/ */
public T archiveSizes(List<Integer> archiveSizes) { public T archiveSizes(List<Integer> archiveSizes) {
this.archiveSizes = ImmutableList.copyOf(checkNotNull(archiveSizes, "archiveSizes")); this.archiveSizes = ImmutableList.copyOf(checkNotNull(archiveSizes, "archiveSizes"));
@ -65,7 +65,7 @@ public class ArchiveAllowedArguments {
} }
public T fromArchiveAllowedArguments(ArchiveAllowedArguments in) { public T fromArchiveAllowedArguments(ArchiveAllowedArguments in) {
return this.archiveSizes(in.getArchiveSizes()); return this.archiveSizes(in.getSizes());
} }
} }
@ -88,7 +88,7 @@ public class ArchiveAllowedArguments {
/** /**
* @return the list of allowed archive sizes, in GB * @return the list of allowed archive sizes, in GB
*/ */
public List<Integer> getArchiveSizes() { public List<Integer> getSizes() {
return this.archiveSizes; return this.archiveSizes;
} }

View File

@ -60,7 +60,7 @@ public class Domain {
protected int minimum; protected int minimum;
/** /**
* @see Domain#getDomainName() * @see Domain#getName()
*/ */
public T domainName(String domainName) { public T domainName(String domainName) {
this.domainName = checkNotNull(domainName, "domainName"); this.domainName = checkNotNull(domainName, "domainName");
@ -152,7 +152,7 @@ public class Domain {
} }
public T fromDomain(Domain in) { public T fromDomain(Domain in) {
return this.domainName(in.getDomainName()) return this.domainName(in.getName())
.createTime(in.getCreateTime()) .createTime(in.getCreateTime())
.recordCount(in.getRecordCount()) .recordCount(in.getRecordCount())
.useGlesysNameServer(in.isUseGlesysNameServer()) .useGlesysNameServer(in.isUseGlesysNameServer())
@ -207,7 +207,7 @@ public class Domain {
/** /**
* @return the domain name, ex. "jclouds.org" * @return the domain name, ex. "jclouds.org"
*/ */
public String getDomainName() { public String getName() {
return this.domainName; return this.domainName;
} }

View File

@ -62,7 +62,7 @@ public class DomainRecord {
} }
/** /**
* @see DomainRecord#getDomainname() * @see DomainRecord#getname()
*/ */
public T domainname(String domainname) { public T domainname(String domainname) {
this.domainname = checkNotNull(domainname, "domainname"); this.domainname = checkNotNull(domainname, "domainname");
@ -107,7 +107,7 @@ public class DomainRecord {
public T fromDomainRecord(DomainRecord in) { public T fromDomainRecord(DomainRecord in) {
return this.id(in.getId()) return this.id(in.getId())
.domainname(in.getDomainname()) .domainname(in.getname())
.host(in.getHost()) .host(in.getHost())
.type(in.getType()) .type(in.getType())
.data(in.getData()) .data(in.getData())
@ -152,7 +152,7 @@ public class DomainRecord {
/** /**
* @return the zone content of the record * @return the zone content of the record
*/ */
public String getDomainname() { public String getname() {
return this.domainname; return this.domainname;
} }

View File

@ -61,7 +61,7 @@ public class EmailOverview {
} }
/** /**
* @see EmailOverview#getDomains() * @see EmailOverview#gets()
*/ */
public T domains(Set<EmailOverviewDomain> domains) { public T domains(Set<EmailOverviewDomain> domains) {
this.domains = ImmutableSet.copyOf(checkNotNull(domains, "domains")); this.domains = ImmutableSet.copyOf(checkNotNull(domains, "domains"));
@ -77,7 +77,7 @@ public class EmailOverview {
} }
public T fromEmailOverview(EmailOverview in) { public T fromEmailOverview(EmailOverview in) {
return this.summary(in.getSummary()).domains(in.getDomains()); return this.summary(in.getSummary()).domains(in.gets());
} }
} }
@ -109,7 +109,7 @@ public class EmailOverview {
/** /**
* @return the set of detailed information about the e-mail addresses and aliases for each domain * @return the set of detailed information about the e-mail addresses and aliases for each domain
*/ */
public Set<EmailOverviewDomain> getDomains() { public Set<EmailOverviewDomain> gets() {
return this.domains; return this.domains;
} }

View File

@ -51,7 +51,7 @@ public class EmailOverviewDomain {
protected int aliases; protected int aliases;
/** /**
* @see EmailOverviewDomain#getDomain() * @see EmailOverviewDomain#get()
*/ */
public T domain(String domain) { public T domain(String domain) {
this.domain = checkNotNull(domain, "domain"); this.domain = checkNotNull(domain, "domain");
@ -79,7 +79,7 @@ public class EmailOverviewDomain {
} }
public T fromEmailOverviewDomain(EmailOverviewDomain in) { public T fromEmailOverviewDomain(EmailOverviewDomain in) {
return this.domain(in.getDomain()).accounts(in.getAccounts()).aliases(in.getAliases()); return this.domain(in.get()).accounts(in.getAccounts()).aliases(in.getAliases());
} }
} }
@ -104,7 +104,7 @@ public class EmailOverviewDomain {
} }
/** @return the domain name */ /** @return the domain name */
public String getDomain() { public String get() {
return this.domain; return this.domain;
} }

View File

@ -18,13 +18,14 @@
*/ */
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.glesys.domain.Archive; import org.jclouds.glesys.domain.Archive;
import org.jclouds.glesys.domain.ArchiveAllowedArguments; import org.jclouds.glesys.domain.ArchiveAllowedArguments;
import com.google.common.collect.FluentIterable;
/** /**
* Provides synchronous access to Archive requests. * Provides synchronous access to Archive requests.
* <p/> * <p/>
@ -39,7 +40,7 @@ public interface ArchiveApi {
/** /**
* Lists all active disks on this account. * Lists all active disks on this account.
*/ */
Set<Archive> listArchives(); FluentIterable<Archive> list();
/** /**
* Get detailed information about an archive volume. * Get detailed information about an archive volume.
@ -47,7 +48,7 @@ public interface ArchiveApi {
* @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
*/ */
Archive getArchive(String username); Archive get(String username);
/** /**
* Create a new backup volume. * Create a new backup volume.
@ -57,14 +58,14 @@ public interface ArchiveApi {
* @param password the new password * @param password the new password
* @param size the new size required in GB * @param size the new size required in GB
*/ */
Archive createArchive(String username, String password, int size); Archive createWithCredentialsAndSize(String username, String password, int size);
/** /**
* Delete an archive volume. All files on the volume * Delete an archive volume. All files on the volume
* *
* @param username the username associated with the archive * @param username the username associated with the archive
*/ */
void deleteArchive(String username); void delete(String username);
/** /**
* Resize an archive volume. It is only possible to upgrade the size of the disk. Downgrading is currently not * Resize an archive volume. It is only possible to upgrade the size of the disk. Downgrading is currently not
@ -72,9 +73,9 @@ public interface ArchiveApi {
* 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, see #getArchiveAllowedArguments for valid values * @param size the new size required, see #getAllowedArguments for valid values
*/ */
Archive resizeArchive(String username, int size); Archive resize(String username, int size);
/** /**
* Change the password for an archive user. * Change the password for an archive user.
@ -82,11 +83,11 @@ public interface ArchiveApi {
* @param username the archive username * @param username the archive username
* @param password the new password * @param password the new password
*/ */
Archive changeArchivePassword(String username, String password); Archive changePassword(String username, String password);
/** /**
* Lists the allowed arguments for some of the functions in this module such as archive size. * Lists the allowed arguments for some of the functions in this module such as archive size.
*/ */
ArchiveAllowedArguments getArchiveAllowedArguments(); ArchiveAllowedArguments getAllowedArguments();
} }

View File

@ -18,8 +18,6 @@
*/ */
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import java.util.Set;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam; import javax.ws.rs.FormParam;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@ -33,9 +31,10 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptyFluentIterableOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
@ -50,67 +49,67 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface ArchiveAsyncApi { public interface ArchiveAsyncApi {
/** /**
* @see ArchiveApi#listArchives * @see ArchiveApi#list
*/ */
@POST @POST
@Path("/archive/list/format/json") @Path("/archive/list/format/json")
@SelectJson("archives") @SelectJson("archives")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<Set<Archive>> listArchives(); ListenableFuture<FluentIterable<Archive>> list();
/** /**
* @see ArchiveApi#getArchive * @see ArchiveApi#get
*/ */
@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<Archive> getArchive(@FormParam("username") String username); ListenableFuture<Archive> get(@FormParam("username") String username);
/** /**
* @see ArchiveApi#createArchive * @see ArchiveApi#createWithCredentialsAndSize
*/ */
@POST @POST
@Path("/archive/create/format/json") @Path("/archive/create/format/json")
@SelectJson("details") @SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Archive> createArchive(@FormParam("username") String username, @FormParam("password") String password, ListenableFuture<Archive> createWithCredentialsAndSize(@FormParam("username") String username, @FormParam("password") String password,
@FormParam("size")int size); @FormParam("size")int size);
/** /**
* @see ArchiveApi#deleteArchive * @see ArchiveApi#delete
*/ */
@POST @POST
@Path("/archive/delete/format/json") @Path("/archive/delete/format/json")
ListenableFuture<Void> deleteArchive(@FormParam("username") String username); ListenableFuture<Void> delete(@FormParam("username") String username);
/** /**
* @see ArchiveApi#resizeArchive * @see ArchiveApi#resize
*/ */
@POST @POST
@Path("/archive/resize/format/json") @Path("/archive/resize/format/json")
@SelectJson("details") @SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Archive> resizeArchive(@FormParam("username") String username, @FormParam("size") int size); ListenableFuture<Archive> resize(@FormParam("username") String username, @FormParam("size") int size);
/** /**
* @see ArchiveApi#changeArchivePassword * @see ArchiveApi#changePassword
*/ */
@POST @POST
@Path("/archive/changepassword/format/json") @Path("/archive/changepassword/format/json")
@SelectJson("details") @SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Archive> changeArchivePassword(@FormParam("username") String username, @FormParam("password") String password); ListenableFuture<Archive> changePassword(@FormParam("username") String username, @FormParam("password") String password);
/** /**
* @see org.jclouds.glesys.features.ArchiveApi#getArchiveAllowedArguments * @see org.jclouds.glesys.features.ArchiveApi#getAllowedArguments
*/ */
@GET @GET
@Path("/archive/allowedarguments/format/json") @Path("/archive/allowedarguments/format/json")
@SelectJson("argumentslist") @SelectJson("argumentslist")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ArchiveAllowedArguments> getArchiveAllowedArguments(); ListenableFuture<ArchiveAllowedArguments> getAllowedArguments();
} }

View File

@ -27,7 +27,9 @@ import org.jclouds.glesys.domain.DomainRecord;
import org.jclouds.glesys.options.AddDomainOptions; import org.jclouds.glesys.options.AddDomainOptions;
import org.jclouds.glesys.options.AddRecordOptions; import org.jclouds.glesys.options.AddRecordOptions;
import org.jclouds.glesys.options.DomainOptions; import org.jclouds.glesys.options.DomainOptions;
import org.jclouds.glesys.options.EditRecordOptions; import org.jclouds.glesys.options.UpdateRecordOptions;
import com.google.common.collect.FluentIterable;
/** /**
* Provides synchronous access to Domain requests. * Provides synchronous access to Domain requests.
@ -45,14 +47,14 @@ public interface DomainApi {
* *
* @return an account's associated domain objects. * @return an account's associated domain objects.
*/ */
Set<Domain> listDomains(); FluentIterable<Domain> list();
/** /**
* Get a specific domain. * Get a specific domain.
* *
* @return the requested domain object. * @return the requested domain object.
*/ */
Domain getDomain(String domain); Domain get(String domain);
/** /**
* Add a domain to the Glesys dns-system * Add a domain to the Glesys dns-system
@ -61,23 +63,23 @@ public interface DomainApi {
* @param options optional parameters * @param options optional parameters
* @return information about the added domain * @return information about the added domain
*/ */
Domain addDomain(String domain, AddDomainOptions... options); Domain create(String domain, AddDomainOptions... options);
/** /**
* Edit a domain to the Glesys dns-system * Update a domain to the Glesys dns-system
* *
* @param domain the name of the domain to add. * @param domain the name of the domain to add.
* @param options optional parameters * @param options optional parameters
* @return information about the modified domain * @return information about the modified domain
*/ */
Domain editDomain(String domain, DomainOptions... options); Domain update(String domain, DomainOptions options);
/** /**
* Remove a domain to the Glesys dns-system * Remove a domain to the Glesys dns-system
* *
* @param domain the name of the domain to remove * @param domain the name of the domain to remove
*/ */
void deleteDomain(String domain); void delete(String domain);
/** /**
* Retrieve the DNS records for a given domain * Retrieve the DNS records for a given domain
@ -92,7 +94,7 @@ public interface DomainApi {
* @param domain the domain to add the record to * @param domain the domain to add the record to
* @param options optional settings for the record * @param options optional settings for the record
*/ */
DomainRecord addRecord(String domain, String host, String type, String data, AddRecordOptions... options); DomainRecord createRecord(String domain, String host, String type, String data, AddRecordOptions... options);
/** /**
* Modify a specific DNS Record * Modify a specific DNS Record
@ -101,7 +103,7 @@ public interface DomainApi {
* @param options the settings to change * @param options the settings to change
* @see #listRecords to retrieve the necessary ids * @see #listRecords to retrieve the necessary ids
*/ */
DomainRecord editRecord(String recordId, EditRecordOptions... options); DomainRecord updateRecord(String recordId, UpdateRecordOptions options);
/** /**
* Delete a DNS record * Delete a DNS record

View File

@ -31,14 +31,15 @@ import org.jclouds.glesys.domain.DomainRecord;
import org.jclouds.glesys.options.AddDomainOptions; import org.jclouds.glesys.options.AddDomainOptions;
import org.jclouds.glesys.options.AddRecordOptions; import org.jclouds.glesys.options.AddRecordOptions;
import org.jclouds.glesys.options.DomainOptions; import org.jclouds.glesys.options.DomainOptions;
import org.jclouds.glesys.options.EditRecordOptions; import org.jclouds.glesys.options.UpdateRecordOptions;
import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptyFluentIterableOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
@ -53,50 +54,50 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface DomainAsyncApi { public interface DomainAsyncApi {
/** /**
* @see org.jclouds.glesys.features.DomainApi#listDomains * @see org.jclouds.glesys.features.DomainApi#list
*/ */
@POST @POST
@Path("/domain/list/format/json") @Path("/domain/list/format/json")
@SelectJson("domains") @SelectJson("domains")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<Set<Domain>> listDomains(); ListenableFuture<FluentIterable<Domain>> list();
/** /**
* @see org.jclouds.glesys.features.DomainApi#getDomain * @see org.jclouds.glesys.features.DomainApi#get
*/ */
@POST @POST
@Path("/domain/details/format/json") @Path("/domain/details/format/json")
@SelectJson("domain") @SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Domain> getDomain(@FormParam("domainname") String name); ListenableFuture<Domain> get(@FormParam("domainname") String name);
/** /**
* @see DomainApi#addDomain * @see DomainApi#create
*/ */
@POST @POST
@Path("/domain/add/format/json") @Path("/domain/add/format/json")
@SelectJson("domain") @SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Domain> addDomain(@FormParam("domainname") String name, AddDomainOptions... options); ListenableFuture<Domain> create(@FormParam("domainname") String name, AddDomainOptions... options);
/** /**
* @see DomainApi#editDomain * @see DomainApi#update
*/ */
@POST @POST
@Path("/domain/edit/format/json") @Path("/domain/edit/format/json")
@SelectJson("domain") @SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Domain> editDomain(@FormParam("domainname") String domain, DomainOptions... options); ListenableFuture<Domain> update(@FormParam("domainname") String domain, DomainOptions options);
/** /**
* @see DomainApi#deleteDomain * @see DomainApi#delete
*/ */
@POST @POST
@Path("/domain/delete/format/json") @Path("/domain/delete/format/json")
ListenableFuture<Void> deleteDomain(@FormParam("domainname") String domain); ListenableFuture<Void> delete(@FormParam("domainname") String domain);
/** /**
* @see DomainApi#listRecords * @see DomainApi#listRecords
@ -108,24 +109,24 @@ public interface DomainAsyncApi {
ListenableFuture<Set<DomainRecord>> listRecords(@FormParam("domainname") String domain); ListenableFuture<Set<DomainRecord>> listRecords(@FormParam("domainname") String domain);
/** /**
* @see DomainApi#addRecord * @see DomainApi#createRecord
*/ */
@POST @POST
@Path("/domain/addrecord/format/json") @Path("/domain/addrecord/format/json")
@SelectJson("record") @SelectJson("record")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<DomainRecord> addRecord(@FormParam("domainname") String domain, @FormParam("host") String host, ListenableFuture<DomainRecord> createRecord(@FormParam("domainname") String domain, @FormParam("host") String host,
@FormParam("type") String type, @FormParam("data") String data, @FormParam("type") String type, @FormParam("data") String data,
AddRecordOptions... options); AddRecordOptions... options);
/** /**
* @see DomainApi#editRecord * @see DomainApi#updateRecord
*/ */
@POST @POST
@Path("/domain/updaterecord/format/json") @Path("/domain/updaterecord/format/json")
@SelectJson("record") @SelectJson("record")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<DomainRecord> editRecord(@FormParam("recordid") String record_id, EditRecordOptions... options); ListenableFuture<DomainRecord> updateRecord(@FormParam("recordid") String record_id, UpdateRecordOptions options);
/** /**
* @see DomainApi#deleteRecord * @see DomainApi#deleteRecord

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
@ -26,39 +25,41 @@ import org.jclouds.glesys.domain.EmailAccount;
import org.jclouds.glesys.domain.EmailAlias; import org.jclouds.glesys.domain.EmailAlias;
import org.jclouds.glesys.domain.EmailOverview; import org.jclouds.glesys.domain.EmailOverview;
import org.jclouds.glesys.options.CreateAccountOptions; import org.jclouds.glesys.options.CreateAccountOptions;
import org.jclouds.glesys.options.EditAccountOptions; import org.jclouds.glesys.options.UpdateAccountOptions;
import com.google.common.collect.FluentIterable;
/** /**
* Provides synchronous access to E-Mail requests. * Provides synchronous access to E-Mail requests.
* <p/> * <p/>
* *
* @author Adam Lowe * @author Adam Lowe
* @see org.jclouds.glesys.features.EmailAsyncApi * @see org.jclouds.glesys.features.EmailAccountAsyncApi
* @see <a href="https://customer.glesys.com/api.php" /> * @see <a href="https://customer.glesys.com/api.php" />
*/ */
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface EmailApi { public interface EmailAccountApi {
/** /**
* Get a summary of e-mail accounts associated with this Glesys account * Get a summary of e-mail accounts associated with this Glesys account
* *
* @return the relevant summary data * @return the relevant summary data
*/ */
EmailOverview getEmailOverview(); EmailOverview getOverview();
/** /**
* Get the set of detailed information about e-mail accounts * Get the set of detailed information about e-mail accounts
* *
* @return the relevant set of details * @return the relevant set of details
*/ */
Set<EmailAccount> listAccounts(String domain); FluentIterable<EmailAccount> listDomain(String domain);
/** /**
* Get the set of details about e-mail aliases * Get the set of details about e-mail aliases
* *
* @return the relevant set of details * @return the relevant set of details
*/ */
Set<EmailAlias> listAliases(String domain); FluentIterable<EmailAlias> listAliasesInDomain(String domain);
/** /**
* Create a new e-mail account * Create a new e-mail account
@ -66,16 +67,16 @@ public interface EmailApi {
* @param accountAddress the e-mail address to use (the domain should already exist) * @param accountAddress the e-mail address to use (the domain should already exist)
* @param password the password to use for the mailbox * @param password the password to use for the mailbox
* @param options optional parameters * @param options optional parameters
* @see DomainApi#addDomain * @see DomainApi#create
*/ */
EmailAccount createAccount(String accountAddress, String password, CreateAccountOptions... options); EmailAccount createWithPassword(String accountAddress, String password, CreateAccountOptions... options);
/** /**
* Create an e-mail alias for an e-mail account * 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 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 * @param toEmailAddress the existing e-mail account address the alias should forward to
* @see DomainApi#addDomain * @see DomainApi#create
*/ */
EmailAlias createAlias(String aliasAddress, String toEmailAddress); EmailAlias createAlias(String aliasAddress, String toEmailAddress);
@ -85,7 +86,7 @@ public interface EmailApi {
* @param accountAddress the existing e-mail account address * @param accountAddress the existing e-mail account address
* @param options optional parameters * @param options optional parameters
*/ */
EmailAccount editAccount(String accountAddress, EditAccountOptions... options); EmailAccount update(String accountAddress, UpdateAccountOptions... options);
/** /**
* Adjust (re-target) an e-mail alias * Adjust (re-target) an e-mail alias
@ -93,7 +94,7 @@ public interface EmailApi {
* @param aliasAddress the existing alias e-mail address * @param aliasAddress the existing alias e-mail address
* @param toEmailAddress the existing e-mail account address the alias should forward to * @param toEmailAddress the existing e-mail account address the alias should forward to
*/ */
EmailAlias editAlias(String aliasAddress, String toEmailAddress); EmailAlias updateAlias(String aliasAddress, String toEmailAddress);
/** /**
* Delete an e-mail account or alias * Delete an e-mail account or alias

View File

@ -18,8 +18,6 @@
*/ */
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import java.util.Set;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam; import javax.ws.rs.FormParam;
import javax.ws.rs.POST; import javax.ws.rs.POST;
@ -30,14 +28,15 @@ import org.jclouds.glesys.domain.EmailAccount;
import org.jclouds.glesys.domain.EmailAlias; import org.jclouds.glesys.domain.EmailAlias;
import org.jclouds.glesys.domain.EmailOverview; import org.jclouds.glesys.domain.EmailOverview;
import org.jclouds.glesys.options.CreateAccountOptions; import org.jclouds.glesys.options.CreateAccountOptions;
import org.jclouds.glesys.options.EditAccountOptions; import org.jclouds.glesys.options.UpdateAccountOptions;
import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptyFluentIterableOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
@ -45,53 +44,53 @@ import com.google.common.util.concurrent.ListenableFuture;
* <p/> * <p/>
* *
* @author Adam Lowe * @author Adam Lowe
* @see org.jclouds.glesys.features.EmailApi * @see org.jclouds.glesys.features.EmailAccountApi
* @see <a href="https://customer.glesys.com/api.php" /> * @see <a href="https://customer.glesys.com/api.php" />
*/ */
@RequestFilters(BasicAuthentication.class) @RequestFilters(BasicAuthentication.class)
public interface EmailAsyncApi { public interface EmailAccountAsyncApi {
/** /**
* @see org.jclouds.glesys.features.EmailApi#getEmailOverview * @see org.jclouds.glesys.features.EmailAccountApi#getOverview
*/ */
@POST @POST
@Path("/email/overview/format/json") @Path("/email/overview/format/json")
@SelectJson("overview") @SelectJson("overview")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<EmailOverview> getEmailOverview(); ListenableFuture<EmailOverview> getOverview();
/** /**
* @see org.jclouds.glesys.features.EmailApi#listAccounts * @see org.jclouds.glesys.features.EmailAccountApi#listDomain
*/ */
@POST @POST
@Path("/email/list/format/json") @Path("/email/list/format/json")
@SelectJson("emailaccounts") @SelectJson("emailaccounts")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<Set<EmailAccount>> listAccounts(@FormParam("domainname") String domain); ListenableFuture<FluentIterable<EmailAccount>> listDomain(@FormParam("domainname") String domain);
/** /**
* @see org.jclouds.glesys.features.EmailApi#listAccounts * @see org.jclouds.glesys.features.EmailAccountApi#listAliasesInDomain
*/ */
@POST @POST
@Path("/email/list/format/json") @Path("/email/list/format/json")
@SelectJson("emailaliases") @SelectJson("emailaliases")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<Set<EmailAlias>> listAliases(@FormParam("domainname") String domain); ListenableFuture<FluentIterable<EmailAlias>> listAliasesInDomain(@FormParam("domainname") String domain);
/** /**
* @see org.jclouds.glesys.features.EmailApi#createAccount * @see org.jclouds.glesys.features.EmailAccountApi#createWithPassword
*/ */
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@SelectJson("emailaccount") @SelectJson("emailaccount")
@Path("/email/createaccount/format/json") @Path("/email/createaccount/format/json")
ListenableFuture<EmailAccount> createAccount(@FormParam("emailaccount") String accountAddress, @FormParam("password") String password, CreateAccountOptions... options); ListenableFuture<EmailAccount> createWithPassword(@FormParam("emailaccount") String accountAddress, @FormParam("password") String password, CreateAccountOptions... options);
/** /**
* @see org.jclouds.glesys.features.EmailApi#createAlias * @see org.jclouds.glesys.features.EmailAccountApi#createAlias
*/ */
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ -100,25 +99,25 @@ public interface EmailAsyncApi {
ListenableFuture<EmailAlias> createAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress); ListenableFuture<EmailAlias> createAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
/** /**
* @see org.jclouds.glesys.features.EmailApi#editAccount * @see org.jclouds.glesys.features.EmailAccountApi#update
*/ */
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@SelectJson("emailaccount") @SelectJson("emailaccount")
@Path("/email/editaccount/format/json") @Path("/email/editaccount/format/json")
ListenableFuture<EmailAccount> editAccount(@FormParam("emailaccount") String accountAddress, EditAccountOptions... options); ListenableFuture<EmailAccount> update(@FormParam("emailaccount") String accountAddress, UpdateAccountOptions... options);
/** /**
* @see org.jclouds.glesys.features.EmailApi#editAlias * @see org.jclouds.glesys.features.EmailAccountApi#updateAlias
*/ */
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@SelectJson("alias") @SelectJson("alias")
@Path("/email/editalias/format/json") @Path("/email/editalias/format/json")
ListenableFuture<EmailAlias> editAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress); ListenableFuture<EmailAlias> updateAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
/** /**
* @see org.jclouds.glesys.features.EmailApi#delete * @see org.jclouds.glesys.features.EmailAccountApi#delete
*/ */
@POST @POST
@Path("/email/delete/format/json") @Path("/email/delete/format/json")

View File

@ -18,13 +18,14 @@
*/ */
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.glesys.domain.IpDetails; import org.jclouds.glesys.domain.IpDetails;
import org.jclouds.glesys.options.ListIpOptions; import org.jclouds.glesys.options.ListIpOptions;
import com.google.common.collect.FluentIterable;
/** /**
* Provides synchronous access to IP Addresses. * Provides synchronous access to IP Addresses.
* <p/> * <p/>
@ -43,7 +44,7 @@ public interface IpApi {
* @param platform the platform * @param platform the platform
* @return a set of free IP addresses * @return a set of free IP addresses
*/ */
Set<String> listFree(int ipVersion, String datacenter, String platform); FluentIterable<String> listFree(int ipVersion, String datacenter, String platform);
/** /**
* Take a free IP address and add it to this account. You can list free IP addresses with the function listFree(). * Take a free IP address and add it to this account. You can list free IP addresses with the function listFree().
@ -67,7 +68,7 @@ public interface IpApi {
* @param options options to filter the results (by IPV4/6, serverId, etc) * @param options options to filter the results (by IPV4/6, serverId, etc)
* @return the set of IP addresses * @return the set of IP addresses
*/ */
Set<IpDetails> listIps(ListIpOptions... options); FluentIterable<IpDetails> list(ListIpOptions... options);
/** /**
* Get details about the given IP address such as gateway and netmask. Different details are available * Get details about the given IP address such as gateway and netmask. Different details are available
@ -76,7 +77,7 @@ public interface IpApi {
* @param ipAddress the ip address * @param ipAddress the ip address
* @return details about the given IP address * @return details about the given IP address
*/ */
IpDetails getIp(String ipAddress); IpDetails get(String ipAddress);
/** /**
* Add an IP address to an server. The IP has to be free, but reserved to this account. You are able to list such addresses * Add an IP address to an server. The IP has to be free, but reserved to this account. You are able to list such addresses
@ -87,27 +88,27 @@ public interface IpApi {
* @param ipAddress the IP address to remove * @param ipAddress the IP address to remove
* @param serverId the server to add the IP address to * @param serverId the server to add the IP address to
*/ */
IpDetails addIpToServer(String ipAddress, String serverId); IpDetails addToServer(String ipAddress, String serverId);
/** /**
* Remove an IP address from a server. This does not release it back to GleSYS pool of free ips. The address will be * Remove an IP address from a server. This does not release it back to GleSYS pool of free ips. The address will be
* kept on the account so that you can use it for other servers or the same server at a later time. To completely remove * kept on the account so that you can use it for other servers or the same server at a later time. To completely remove
* the IP address from this account, use removeIpFromServerAndRelease to do so * the IP address from this account, use removeFromServerAndRelease to do so
* *
* @param ipAddress the IP address to remove * @param ipAddress the IP address to remove
* @param serverId the server to remove the IP address from * @param serverId the server to remove the IP address from
* @see #removeIpFromServerAndRelease * @see #removeFromServerAndRelease
*/ */
IpDetails removeIpFromServer(String ipAddress, String serverId); IpDetails removeFromServer(String ipAddress, String serverId);
/** /**
* Remove an IP address from a server and release it back to GleSYS pool of free ips. * Remove an IP address from a server and release it back to GleSYS pool of free ips.
* *
* @param ipAddress the IP address to remove * @param ipAddress the IP address to remove
* @param serverId the server to remove the IP address from * @param serverId the server to remove the IP address from
* @see #removeIpFromServer * @see #removeFromServer
*/ */
IpDetails removeIpFromServerAndRelease(String ipAddress, String serverId); IpDetails removeFromServerAndRelease(String ipAddress, String serverId);
/** /**
* Sets PTR data for an IP. Use ip/listown or ip/details to get current PTR data * Sets PTR data for an IP. Use ip/listown or ip/details to get current PTR data

View File

@ -18,8 +18,6 @@
*/ */
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import java.util.Set;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam; import javax.ws.rs.FormParam;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@ -35,9 +33,10 @@ import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.FormParams; import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptyFluentIterableOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
@ -57,8 +56,8 @@ public interface IpAsyncApi {
@Path("/ip/listfree/ipversion/{ipversion}/datacenter/{datacenter}/platform/{platform}/format/json") @Path("/ip/listfree/ipversion/{ipversion}/datacenter/{datacenter}/platform/{platform}/format/json")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@SelectJson("ipaddresses") @SelectJson("ipaddresses")
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<Set<String>> listFree(@PathParam("ipversion") int ipversion, ListenableFuture<FluentIterable<String>> listFree(@PathParam("ipversion") int ipversion,
@PathParam("datacenter") String datacenter, @PathParam("datacenter") String datacenter,
@PathParam("platform") String platform); @PathParam("platform") String platform);
@ -81,54 +80,54 @@ public interface IpAsyncApi {
ListenableFuture<IpDetails> release(@FormParam("ipaddress") String ipAddress); ListenableFuture<IpDetails> release(@FormParam("ipaddress") String ipAddress);
/** /**
* @see IpApi#listIps * @see IpApi#list
*/ */
@GET @GET
@Path("/ip/listown/format/json") @Path("/ip/listown/format/json")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@SelectJson("iplist") @SelectJson("iplist")
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<Set<IpDetails>> listIps(ListIpOptions... options); ListenableFuture<FluentIterable<IpDetails>> list(ListIpOptions... options);
/** /**
* @see IpApi#getIp * @see IpApi#get
*/ */
@GET @GET
@Path("/ip/details/ipaddress/{ipaddress}/format/json") @Path("/ip/details/ipaddress/{ipaddress}/format/json")
@SelectJson("details") @SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<IpDetails> getIp(@PathParam("ipaddress") String ipAddress); ListenableFuture<IpDetails> get(@PathParam("ipaddress") String ipAddress);
/** /**
* @see IpApi#addIpToServer * @see IpApi#addToServer
*/ */
@POST @POST
@Path("/ip/add/format/json") @Path("/ip/add/format/json")
@SelectJson("details") @SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> addIpToServer(@FormParam("ipaddress") String ipAddress, ListenableFuture<IpDetails> addToServer(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId); @FormParam("serverid") String serverId);
/** /**
* @see IpApi#removeIpFromServer * @see IpApi#removeFromServer
*/ */
@POST @POST
@Path("/ip/remove/format/json") @Path("/ip/remove/format/json")
@SelectJson("details") @SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> removeIpFromServer(@FormParam("ipaddress") String ipAddress, ListenableFuture<IpDetails> removeFromServer(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId); @FormParam("serverid") String serverId);
/** /**
* @see IpApi#removeIpFromServer * @see IpApi#removeFromServer
*/ */
@POST @POST
@FormParams(keys = "release", values = "true") @FormParams(keys = "release", values = "true")
@Path("/ip/remove/format/json") @Path("/ip/remove/format/json")
@SelectJson("details") @SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> removeIpFromServerAndRelease(@FormParam("ipaddress") String ipAddress, ListenableFuture<IpDetails> removeFromServerAndRelease(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId); @FormParam("serverid") String serverId);
/** /**

View File

@ -19,7 +19,6 @@
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
@ -35,10 +34,11 @@ import org.jclouds.glesys.domain.ServerStatus;
import org.jclouds.glesys.options.CloneServerOptions; import org.jclouds.glesys.options.CloneServerOptions;
import org.jclouds.glesys.options.CreateServerOptions; import org.jclouds.glesys.options.CreateServerOptions;
import org.jclouds.glesys.options.DestroyServerOptions; import org.jclouds.glesys.options.DestroyServerOptions;
import org.jclouds.glesys.options.EditServerOptions; import org.jclouds.glesys.options.UpdateServerOptions;
import org.jclouds.glesys.options.ServerStatusOptions; import org.jclouds.glesys.options.ServerStatusOptions;
import com.google.common.annotations.Beta; import com.google.common.annotations.Beta;
import com.google.common.collect.FluentIterable;
/** /**
* Provides synchronous access to Server. * Provides synchronous access to Server.
@ -57,7 +57,7 @@ public interface ServerApi {
* *
* @return an account's associated server objects. * @return an account's associated server objects.
*/ */
Set<Server> listServers(); FluentIterable<Server> list();
/** /**
* Get detailed information about a server such as hostname, hardware * Get detailed information about a server such as hostname, hardware
@ -67,7 +67,7 @@ public interface ServerApi {
* @param id id of the server * @param id id of the server
* @return server or null if not found * @return server or null if not found
*/ */
ServerDetails getServerDetails(String id); ServerDetails get(String id);
/** /**
* Get detailed information about a server status including up-time and * Get detailed information about a server status including up-time and
@ -77,7 +77,7 @@ public interface ServerApi {
* @param options optional parameters * @param options optional parameters
* @return the status of the server or null if not found * @return the status of the server or null if not found
*/ */
ServerStatus getServerStatus(String id, ServerStatusOptions... options); ServerStatus getStatus(String id, ServerStatusOptions... options);
/** /**
* Get detailed information about a server's limits (for OpenVZ only). * Get detailed information about a server's limits (for OpenVZ only).
@ -86,7 +86,7 @@ public interface ServerApi {
* @param id id of the server * @param id id of the server
* @return the requested information about the server or null if not found * @return the requested information about the server or null if not found
*/ */
Map<String, ServerLimit> getServerLimits(String id); Map<String, ServerLimit> getLimits(String id);
/** /**
* Get information about how to connect to a server via VNC * Get information about how to connect to a server via VNC
@ -101,14 +101,14 @@ public interface ServerApi {
* *
* @return the set of information about each template * @return the set of information about each template
*/ */
Set<OSTemplate> listTemplates(); FluentIterable<OSTemplate> listTemplates();
/** /**
* Get information about valid arguments to #createServer for each platform * Get information about valid arguments to #createServer for each platform
* *
* @return a map of argument lists, keyed on platform * @return a map of argument lists, keyed on platform
*/ */
Map<String, AllowedArgumentsForCreateServer> getAllowedArgumentsForCreateServerByPlatform(); Map<String, AllowedArgumentsForCreateServer> getAllowedArgumentsForCreateByPlatform();
/** /**
* Reset the fail count for a server limit (for OpenVZ only). * Reset the fail count for a server limit (for OpenVZ only).
@ -116,35 +116,35 @@ public interface ServerApi {
* @param id id of the server * @param id id of the server
* @param type the type of limit to reset * @param type the type of limit to reset
*/ */
Map<String, ServerLimit> resetServerLimit(String id, String type); Map<String, ServerLimit> resetLimit(String id, String type);
/** /**
* Reboot a server * Reboot a server
* *
* @param id id of the server * @param id id of the server
*/ */
ServerDetails rebootServer(String id); ServerDetails reboot(String id);
/** /**
* Start a server * Start a server
* *
* @param id id of the server * @param id id of the server
*/ */
ServerDetails startServer(String id); ServerDetails start(String id);
/** /**
* Stop a server * Stop a server
* *
* @param id id of the server * @param id id of the server
*/ */
ServerDetails stopServer(String id); ServerDetails stop(String id);
/** /**
* hard stop a server * hard stop a server
* *
* @param id id of the server * @param id id of the server
*/ */
ServerDetails hardStopServer(String id); ServerDetails hardStop(String id);
/** /**
* Create a new server * Create a new server
@ -154,16 +154,16 @@ public interface ServerApi {
* @param options optional settings ex. description * @param options optional settings ex. description
*/ */
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
ServerDetails createServerWithHostnameAndRootPassword(ServerSpec serverSpec, String hostname, String rootPassword, ServerDetails createWithHostnameAndRootPassword(ServerSpec serverSpec, String hostname, String rootPassword,
CreateServerOptions... options); CreateServerOptions... options);
/** /**
* Edit the configuration of a server * Update the configuration of a server
* *
* @param serverid the serverId of the server to edit * @param serverid the serverId of the server to edit
* @param options the settings to change * @param options the settings to change
*/ */
ServerDetails editServer(String serverid, EditServerOptions... options); ServerDetails update(String serverid, UpdateServerOptions options);
/** /**
* Clone a server * Clone a server
@ -173,7 +173,7 @@ public interface ServerApi {
* @param options the settings to change * @param options the settings to change
*/ */
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
ServerDetails cloneServer(String serverid, String hostname, CloneServerOptions... options); ServerDetails clone(String serverid, String hostname, CloneServerOptions... options);
/** /**
* Destroy a server * Destroy a server
@ -181,7 +181,7 @@ public interface ServerApi {
* @param id the id of the server * @param id the id of the server
* @param keepIp if DestroyServerOptions.keepIp(true) the servers ip will be retained for use in your GleSYS account * @param keepIp if DestroyServerOptions.keepIp(true) the servers ip will be retained for use in your GleSYS account
*/ */
ServerDetails destroyServer(String id, DestroyServerOptions keepIp); ServerDetails destroy(String id, DestroyServerOptions keepIp);
/** /**
* Reset the root password of a server * Reset the root password of a server

View File

@ -19,7 +19,6 @@
package org.jclouds.glesys.features; package org.jclouds.glesys.features;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.SortedMap; import java.util.SortedMap;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -42,7 +41,7 @@ import org.jclouds.glesys.functions.ParseTemplatesFromHttpResponse;
import org.jclouds.glesys.options.CloneServerOptions; import org.jclouds.glesys.options.CloneServerOptions;
import org.jclouds.glesys.options.CreateServerOptions; import org.jclouds.glesys.options.CreateServerOptions;
import org.jclouds.glesys.options.DestroyServerOptions; import org.jclouds.glesys.options.DestroyServerOptions;
import org.jclouds.glesys.options.EditServerOptions; import org.jclouds.glesys.options.UpdateServerOptions;
import org.jclouds.glesys.options.ServerStatusOptions; import org.jclouds.glesys.options.ServerStatusOptions;
import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
@ -52,9 +51,10 @@ import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson; import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptyFluentIterableOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
/** /**
@ -70,17 +70,17 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface ServerAsyncApi { public interface ServerAsyncApi {
/** /**
* @see ServerApi#listServers * @see ServerApi#list
*/ */
@POST @POST
@Path("/server/list/format/json") @Path("/server/list/format/json")
@SelectJson("servers") @SelectJson("servers")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<Set<Server>> listServers(); ListenableFuture<FluentIterable<Server>> list();
/** /**
* @see ServerApi#getServerDetails * @see ServerApi#get
*/ */
@POST @POST
@Path("/server/details/format/json") @Path("/server/details/format/json")
@ -88,27 +88,27 @@ public interface ServerAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@FormParams(keys = "includestate", values = "true") @FormParams(keys = "includestate", values = "true")
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ServerDetails> getServerDetails(@FormParam("serverid") String id); ListenableFuture<ServerDetails> get(@FormParam("serverid") String id);
/** /**
* @see ServerApi#getServerStatus * @see ServerApi#getStatus
*/ */
@POST @POST
@Path("/server/status/format/json") @Path("/server/status/format/json")
@SelectJson("server") @SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<ServerStatus> getServerStatus(@FormParam("serverid") String id, ServerStatusOptions... options); ListenableFuture<ServerStatus> getStatus(@FormParam("serverid") String id, ServerStatusOptions... options);
/** /**
* @see ServerApi#getServerLimits * @see ServerApi#getLimits
*/ */
@POST @POST
@Path("/server/limits/format/json") @Path("/server/limits/format/json")
@SelectJson("limits") @SelectJson("limits")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<SortedMap<String, ServerLimit>> getServerLimits(@FormParam("serverid") String id); ListenableFuture<SortedMap<String, ServerLimit>> getLimits(@FormParam("serverid") String id);
/** /**
* @see ServerApi#getConsole * @see ServerApi#getConsole
@ -121,13 +121,13 @@ public interface ServerAsyncApi {
ListenableFuture<Console> getConsole(@FormParam("serverid") String id); ListenableFuture<Console> getConsole(@FormParam("serverid") String id);
/** /**
* @see ServerApi#getAllowedArgumentsForCreateServerByPlatform * @see ServerApi#getAllowedArgumentsForCreateByPlatform
*/ */
@GET @GET
@Path("/server/allowedarguments/format/json") @Path("/server/allowedarguments/format/json")
@SelectJson("argumentslist") @SelectJson("argumentslist")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Map<String, AllowedArgumentsForCreateServer>> getAllowedArgumentsForCreateServerByPlatform(); ListenableFuture<Map<String, AllowedArgumentsForCreateServer>> getAllowedArgumentsForCreateByPlatform();
/** /**
* @see ServerApi#listTemplates * @see ServerApi#listTemplates
@ -135,92 +135,93 @@ public interface ServerAsyncApi {
@GET @GET
@Path("/server/templates/format/json") @Path("/server/templates/format/json")
@ResponseParser(ParseTemplatesFromHttpResponse.class) @ResponseParser(ParseTemplatesFromHttpResponse.class)
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Set<OSTemplate>> listTemplates(); ListenableFuture<FluentIterable<OSTemplate>> listTemplates();
/** /**
* @see ServerApi#stopServer * @see ServerApi#stop
*/ */
@POST @POST
@Path("/server/resetlimit/format/json") @Path("/server/resetlimit/format/json")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<SortedMap<String, ServerLimit>> resetServerLimit(@FormParam("serverid") String id, ListenableFuture<SortedMap<String, ServerLimit>> resetLimit(@FormParam("serverid") String id,
@FormParam("type") String type); @FormParam("type") String type);
/** /**
* @see ServerApi#rebootServer * @see ServerApi#reboot
*/ */
@POST @POST
@SelectJson("server") @SelectJson("server")
@Path("/server/reboot/format/json") @Path("/server/reboot/format/json")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> rebootServer(@FormParam("serverid") String id); ListenableFuture<ServerDetails> reboot(@FormParam("serverid") String id);
/** /**
* @see ServerApi#startServer * @see ServerApi#start
*/ */
@POST @POST
@SelectJson("server") @SelectJson("server")
@Path("/server/start/format/json") @Path("/server/start/format/json")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> startServer(@FormParam("serverid") String id); ListenableFuture<ServerDetails> start(@FormParam("serverid") String id);
/** /**
* @see ServerApi#stopServer * @see ServerApi#stop
*/ */
@POST @POST
@SelectJson("server") @SelectJson("server")
@Path("/server/stop/format/json") @Path("/server/stop/format/json")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> stopServer(@FormParam("serverid") String id); ListenableFuture<ServerDetails> stop(@FormParam("serverid") String id);
/** /**
* @see ServerApi#hardStopServer * @see ServerApi#hardStop
*/ */
@POST @POST
@SelectJson("server") @SelectJson("server")
@Path("/server/stop/format/json") @Path("/server/stop/format/json")
@FormParams(keys = "type", values = "hard") @FormParams(keys = "type", values = "hard")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> hardStopServer(@FormParam("serverid") String id); ListenableFuture<ServerDetails> hardStop(@FormParam("serverid") String id);
/** /**
* @see ServerApi#createServerWithHostnameAndRootPassword * @see ServerApi#createWithHostnameAndRootPassword
*/ */
@POST @POST
@SelectJson("server") @SelectJson("server")
@Path("/server/create/format/json") @Path("/server/create/format/json")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@MapBinder(CreateServerOptions.class) @MapBinder(CreateServerOptions.class)
ListenableFuture<ServerDetails> createServerWithHostnameAndRootPassword(ServerSpec serverSpec, ListenableFuture<ServerDetails> createWithHostnameAndRootPassword(ServerSpec serverSpec,
@PayloadParam("hostname") String hostname, @PayloadParam("rootpassword") String rootPassword, @PayloadParam("hostname") String hostname, @PayloadParam("rootpassword") String rootPassword,
CreateServerOptions... options); CreateServerOptions... options);
/** /**
* @see ServerApi#cloneServer * @see ServerApi#clone
*/ */
@POST @POST
@Path("/server/clone/format/json") @Path("/server/clone/format/json")
@SelectJson("server") @SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> cloneServer(@FormParam("serverid") String serverid, ListenableFuture<ServerDetails> clone(@FormParam("serverid") String serverid,
@FormParam("hostname") String hostname, CloneServerOptions... options); @FormParam("hostname") String hostname, CloneServerOptions... options);
/** /**
* @see ServerApi#editServer * @see ServerApi#update
*/ */
@POST @POST
@Path("/server/edit/format/json") @Path("/server/edit/format/json")
@SelectJson("server") @SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> editServer(@FormParam("serverid") String serverid, EditServerOptions... options); ListenableFuture<ServerDetails> update(@FormParam("serverid") String serverid, UpdateServerOptions options);
/** /**
* @see ServerApi#destroyServer * @see ServerApi#destroy
*/ */
@POST @POST
@Path("/server/destroy/format/json") @Path("/server/destroy/format/json")
ListenableFuture<Void> destroyServer(@FormParam("serverid") String id, DestroyServerOptions keepIp); ListenableFuture<Void> destroy(@FormParam("serverid") String id, DestroyServerOptions keepIp);
/** /**
* @see ServerApi#resetPassword * @see ServerApi#resetPassword

View File

@ -31,7 +31,7 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
import org.jclouds.json.internal.GsonWrapper; import org.jclouds.json.internal.GsonWrapper;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
@ -40,7 +40,7 @@ import com.google.inject.TypeLiteral;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class ParseTemplatesFromHttpResponse implements Function<HttpResponse, Set<OSTemplate>> { public class ParseTemplatesFromHttpResponse implements Function<HttpResponse, FluentIterable<OSTemplate>> {
private final ParseFirstJsonValueNamed<Map<String, Set<OSTemplate>>> parser; private final ParseFirstJsonValueNamed<Map<String, Set<OSTemplate>>> parser;
@Inject @Inject
@ -50,10 +50,10 @@ public class ParseTemplatesFromHttpResponse implements Function<HttpResponse, Se
}, "templates"); }, "templates");
} }
public Set<OSTemplate> apply(HttpResponse response) { public FluentIterable<OSTemplate> apply(HttpResponse response) {
checkNotNull(response, "response"); checkNotNull(response, "response");
Map<String, Set<OSTemplate>> toParse = parser.apply(response); Map<String, Set<OSTemplate>> toParse = parser.apply(response);
checkNotNull(toParse, "parsed result from %s", response); checkNotNull(toParse, "parsed result from %s", response);
return ImmutableSet.copyOf(Iterables.concat(toParse.values())); return FluentIterable.from(Iterables.concat(toParse.values()));
} }
} }

View File

@ -21,7 +21,7 @@ package org.jclouds.glesys.options;
/** /**
* @author Adam Lowe * @author Adam Lowe
*/ */
public class CloneServerOptions extends EditServerOptions { public class CloneServerOptions extends UpdateServerOptions {
public static class Builder { public static class Builder {
/** /**
* @see org.jclouds.glesys.options.CloneServerOptions#diskSizeGB * @see org.jclouds.glesys.options.CloneServerOptions#diskSizeGB
@ -52,7 +52,7 @@ public class CloneServerOptions extends EditServerOptions {
} }
/** /**
* @see org.jclouds.glesys.options.EditServerOptions#description * @see org.jclouds.glesys.options.UpdateServerOptions#description
*/ */
public static CloneServerOptions description(String description) { public static CloneServerOptions description(String description) {
return CloneServerOptions.class.cast(new CloneServerOptions().description(description)); return CloneServerOptions.class.cast(new CloneServerOptions().description(description));

View File

@ -1,77 +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
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_editaccount" />
*/
public class EditAccountOptions extends CreateAccountOptions {
public static class Builder {
/**
* @see org.jclouds.glesys.options.EditAccountOptions#antispamLevel
*/
public static EditAccountOptions antispamLevel(int antispamLevel) {
return EditAccountOptions.class.cast(new EditAccountOptions().antispamLevel(antispamLevel));
}
/**
* @see org.jclouds.glesys.options.EditAccountOptions#antiVirus
*/
public static EditAccountOptions antiVirus(boolean antiVirus) {
return EditAccountOptions.class.cast(new EditAccountOptions().antiVirus(antiVirus));
}
/**
* @see org.jclouds.glesys.options.EditAccountOptions#autorespond
*/
public static EditAccountOptions autorespond(boolean autorespond) {
return EditAccountOptions.class.cast(new EditAccountOptions().autorespond(autorespond));
}
/**
* @see org.jclouds.glesys.options.EditAccountOptions#autorespondSaveEmail
*/
public static EditAccountOptions autorespondSaveEmail(boolean autorespondSaveEmail) {
return EditAccountOptions.class.cast(new EditAccountOptions().autorespondSaveEmail(autorespondSaveEmail));
}
/**
* @see org.jclouds.glesys.options.EditAccountOptions#autorespondMessage
*/
public static EditAccountOptions autorespondMessage(String autorespondMessage) {
return EditAccountOptions.class.cast(new EditAccountOptions().autorespondMessage(autorespondMessage));
}
/**
* @see org.jclouds.glesys.options.EditAccountOptions#password
*/
public static EditAccountOptions password(String password) {
return new EditAccountOptions().password(password);
}
}
/** Reset the password for this account */
public EditAccountOptions password(String password) {
formParameters.put("password", password);
return this;
}
}

View File

@ -0,0 +1,77 @@
/**
* 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
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_editaccount" />
*/
public class UpdateAccountOptions extends CreateAccountOptions {
public static class Builder {
/**
* @see org.jclouds.glesys.options.UpdateAccountOptions#antispamLevel
*/
public static UpdateAccountOptions antispamLevel(int antispamLevel) {
return UpdateAccountOptions.class.cast(new UpdateAccountOptions().antispamLevel(antispamLevel));
}
/**
* @see org.jclouds.glesys.options.UpdateAccountOptions#antiVirus
*/
public static UpdateAccountOptions antiVirus(boolean antiVirus) {
return UpdateAccountOptions.class.cast(new UpdateAccountOptions().antiVirus(antiVirus));
}
/**
* @see org.jclouds.glesys.options.UpdateAccountOptions#autorespond
*/
public static UpdateAccountOptions autorespond(boolean autorespond) {
return UpdateAccountOptions.class.cast(new UpdateAccountOptions().autorespond(autorespond));
}
/**
* @see org.jclouds.glesys.options.UpdateAccountOptions#autorespondSaveEmail
*/
public static UpdateAccountOptions autorespondSaveEmail(boolean autorespondSaveEmail) {
return UpdateAccountOptions.class.cast(new UpdateAccountOptions().autorespondSaveEmail(autorespondSaveEmail));
}
/**
* @see org.jclouds.glesys.options.UpdateAccountOptions#autorespondMessage
*/
public static UpdateAccountOptions autorespondMessage(String autorespondMessage) {
return UpdateAccountOptions.class.cast(new UpdateAccountOptions().autorespondMessage(autorespondMessage));
}
/**
* @see org.jclouds.glesys.options.UpdateAccountOptions#password
*/
public static UpdateAccountOptions password(String password) {
return new UpdateAccountOptions().password(password);
}
}
/** Reset the password for this account */
public UpdateAccountOptions password(String password) {
formParameters.put("password", password);
return this;
}
}

View File

@ -21,54 +21,59 @@ package org.jclouds.glesys.options;
/** /**
* @author Adam Lowe * @author Adam Lowe
*/ */
public class EditRecordOptions extends AddRecordOptions { public class UpdateRecordOptions extends AddRecordOptions {
public static class Builder { public static class Builder {
/** /**
* @see EditRecordOptions#host * @see UpdateRecordOptions#host
*/ */
public static EditRecordOptions host(String host) { public static UpdateRecordOptions host(String host) {
return new EditRecordOptions().host(host); return new UpdateRecordOptions().host(host);
} }
/** /**
* @see EditRecordOptions#type * @see UpdateRecordOptions#type
*/ */
public static EditRecordOptions type(String type) { public static UpdateRecordOptions type(String type) {
return new EditRecordOptions().type(type); return new UpdateRecordOptions().type(type);
} }
/** /**
* @see EditRecordOptions#data * @see UpdateRecordOptions#data
*/ */
public static EditRecordOptions data(String data) { public static UpdateRecordOptions data(String data) {
return new EditRecordOptions().data(data); return new UpdateRecordOptions().data(data);
} }
/** /**
* @see EditRecordOptions#ttl * @see UpdateRecordOptions#ttl
*/ */
public static EditRecordOptions ttl(int ttl) { public static UpdateRecordOptions ttl(int ttl) {
return EditRecordOptions.class.cast(new EditRecordOptions().ttl(ttl)); return UpdateRecordOptions.class.cast(new UpdateRecordOptions().ttl(ttl));
} }
} }
/** Configure the hostname attached to this record */ /** Configure the hostname attached to this record */
public EditRecordOptions host(String host) { public UpdateRecordOptions host(String host) {
formParameters.put("host", host); formParameters.put("host", host);
return this; return this;
} }
/** Configure the type of record, ex. "A", "CNAME" or "MX" */ /** Configure the type of record, ex. "A", "CNAME" or "MX" */
public EditRecordOptions type(String type) { public UpdateRecordOptions type(String type) {
formParameters.put("type", type); formParameters.put("type", type);
return this; return this;
} }
/** Set the content of this record (depending on type, for an "A" record this would be an ip address) */ /** Set the content of this record (depending on type, for an "A" record this would be an ip address) */
public EditRecordOptions data(String data) { public UpdateRecordOptions data(String data) {
formParameters.put("data", data); formParameters.put("data", data);
return this; return this;
} }
@Override
public UpdateRecordOptions ttl(int ttl) {
return UpdateRecordOptions.class.cast(super.ttl(ttl));
}
} }

View File

@ -24,87 +24,87 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
* *
* @author Adam Lowe * @author Adam Lowe
*/ */
public class EditServerOptions extends BaseHttpRequestOptions { public class UpdateServerOptions extends BaseHttpRequestOptions {
public static class Builder { public static class Builder {
/** /**
* @see org.jclouds.glesys.options.EditServerOptions#diskSizeGB * @see org.jclouds.glesys.options.UpdateServerOptions#diskSizeGB
*/ */
public static EditServerOptions disksizeGB(int disksizeGB) { public static UpdateServerOptions disksizeGB(int disksizeGB) {
return new EditServerOptions().diskSizeGB(disksizeGB); return new UpdateServerOptions().diskSizeGB(disksizeGB);
} }
/** /**
* @see org.jclouds.glesys.options.EditServerOptions#memorySizeMB * @see org.jclouds.glesys.options.UpdateServerOptions#memorySizeMB
*/ */
public static EditServerOptions memorysizeMB(int memorysizeMB) { public static UpdateServerOptions memorysizeMB(int memorysizeMB) {
return new EditServerOptions().memorySizeMB(memorysizeMB); return new UpdateServerOptions().memorySizeMB(memorysizeMB);
} }
/** /**
* @see org.jclouds.glesys.options.EditServerOptions#cpuCores * @see org.jclouds.glesys.options.UpdateServerOptions#cpuCores
*/ */
public static EditServerOptions cpucores(int cpucores) { public static UpdateServerOptions cpucores(int cpucores) {
EditServerOptions options = new EditServerOptions(); UpdateServerOptions options = new UpdateServerOptions();
return options.cpuCores(cpucores); return options.cpuCores(cpucores);
} }
/** /**
* @see org.jclouds.glesys.options.EditServerOptions#transferGB * @see org.jclouds.glesys.options.UpdateServerOptions#transferGB
*/ */
public static EditServerOptions transferGB(int transferGB) { public static UpdateServerOptions transferGB(int transferGB) {
return new EditServerOptions().transferGB(transferGB); return new UpdateServerOptions().transferGB(transferGB);
} }
/** /**
* @see org.jclouds.glesys.options.EditServerOptions#hostname * @see org.jclouds.glesys.options.UpdateServerOptions#hostname
*/ */
public static EditServerOptions hostname(String hostname) { public static UpdateServerOptions hostname(String hostname) {
EditServerOptions options = new EditServerOptions(); UpdateServerOptions options = new UpdateServerOptions();
return options.hostname(hostname); return options.hostname(hostname);
} }
/** /**
* @see org.jclouds.glesys.options.EditServerOptions#description * @see org.jclouds.glesys.options.UpdateServerOptions#description
*/ */
public static EditServerOptions description(String description) { public static UpdateServerOptions description(String description) {
EditServerOptions options = new EditServerOptions(); UpdateServerOptions options = new UpdateServerOptions();
return options.description(description); return options.description(description);
} }
} }
/** Configure the size of the disk, in GB, of the server */ /** Configure the size of the disk, in GB, of the server */
public EditServerOptions diskSizeGB(int diskSizeGB) { public UpdateServerOptions diskSizeGB(int diskSizeGB) {
formParameters.put("disksize", Integer.toString(diskSizeGB)); formParameters.put("disksize", Integer.toString(diskSizeGB));
return this; return this;
} }
/** Configure the amount of RAM, in MB, allocated to the server */ /** Configure the amount of RAM, in MB, allocated to the server */
public EditServerOptions memorySizeMB(int memorySizeMB) { public UpdateServerOptions memorySizeMB(int memorySizeMB) {
formParameters.put("memorysize", Integer.toString(memorySizeMB)); formParameters.put("memorysize", Integer.toString(memorySizeMB));
return this; return this;
} }
/** Configure the number of CPU cores allocated to the server */ /** Configure the number of CPU cores allocated to the server */
public EditServerOptions cpuCores(int cpucores) { public UpdateServerOptions cpuCores(int cpucores) {
formParameters.put("cpucores", Integer.toString(cpucores)); formParameters.put("cpucores", Integer.toString(cpucores));
return this; return this;
} }
/** Configure the transfer setting for the server */ /** Configure the transfer setting for the server */
public EditServerOptions transferGB(int transferGB) { public UpdateServerOptions transferGB(int transferGB) {
formParameters.put("transfer", Integer.toString(transferGB)); formParameters.put("transfer", Integer.toString(transferGB));
return this; return this;
} }
/** Configure the host name of the server (must be unique within the GleSYS account) */ /** Configure the host name of the server (must be unique within the GleSYS account) */
public EditServerOptions hostname(String hostname) { public UpdateServerOptions hostname(String hostname) {
formParameters.put("hostname", hostname); formParameters.put("hostname", hostname);
return this; return this;
} }
/** Configure the description of the server */ /** Configure the description of the server */
public EditServerOptions description(String description) { public UpdateServerOptions description(String description) {
formParameters.put("description", description); formParameters.put("description", description);
return this; return this;
} }

View File

@ -50,15 +50,15 @@ public class GleSYSAsyncApiTest extends BaseAsyncApiTest<GleSYSAsyncApi> {
public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
assert syncApi.getServerApi() != null; assert syncApi.getServerApi() != null;
assert syncApi.getIpApi() != null; assert syncApi.getIpApi() != null;
assert syncApi.getArchiveApi() != null;
assert syncApi.getDomainApi() != null; assert syncApi.getDomainApi() != null;
assert syncApi.getArchiveApi() != null;
} }
public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
assert asyncApi.getServerApi() != null; assert asyncApi.getServerApi() != null;
assert asyncApi.getIpApi() != null; assert asyncApi.getIpApi() != null;
assert asyncApi.getArchiveApi() != null;
assert asyncApi.getDomainApi() != null; assert asyncApi.getDomainApi() != null;
assert asyncApi.getArchiveApi() != null;
} }
@Override @Override

View File

@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.List; import java.util.Set;
import org.jclouds.glesys.domain.Archive; import org.jclouds.glesys.domain.Archive;
import org.jclouds.glesys.domain.ArchiveAllowedArguments; import org.jclouds.glesys.domain.ArchiveAllowedArguments;
@ -33,8 +33,8 @@ import org.jclouds.http.HttpResponseException;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
/** /**
* Tests parsing of {@code ArchiveAsyncApi} * Tests parsing of {@code ArchiveAsyncApi}
@ -52,10 +52,10 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_list.json")).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_list.json")).build())
.getArchiveApi(); .getArchiveApi();
List<Archive> expected = ImmutableList.of( Set<Archive> expected = ImmutableSet.of(
Archive.builder().username("xxxxx_test1").freeSize("20 GB").totalSize("30 GB").locked(false).build()); Archive.builder().username("xxxxx_test1").freeSize("20 GB").totalSize("30 GB").locked(false).build());
assertEquals(api.listArchives(), expected); assertEquals(api.list().toImmutableSet(), expected);
} }
public void testListArchivesWhenResponseIs4xxReturnsEmpty() { public void testListArchivesWhenResponseIs4xxReturnsEmpty() {
@ -65,7 +65,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(404).build()).getArchiveApi(); HttpResponse.builder().statusCode(404).build()).getArchiveApi();
assertTrue(api.listArchives().isEmpty()); assertTrue(api.list().isEmpty());
} }
public void testArchiveDetailsWhenResponseIs2xx() throws Exception { public void testArchiveDetailsWhenResponseIs2xx() throws Exception {
@ -77,7 +77,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build())
.getArchiveApi(); .getArchiveApi();
assertEquals(api.getArchive("xxxxxx_test1"), detailsInArchiveDetails()); assertEquals(api.get("xxxxxx_test1"), detailsInArchiveDetails());
} }
private Archive detailsInArchiveDetails() { private Archive detailsInArchiveDetails() {
@ -92,7 +92,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("username", "xxxxxx_test1").build(), .addFormParam("username", "xxxxxx_test1").build(),
HttpResponse.builder().statusCode(404).build()) HttpResponse.builder().statusCode(404).build())
.getArchiveApi(); .getArchiveApi();
assertNull(api.getArchive("xxxxxx_test1")); assertNull(api.get("xxxxxx_test1"));
} }
public void testCreateArchiveWhenResponseIs2xx() throws Exception { public void testCreateArchiveWhenResponseIs2xx() throws Exception {
@ -105,7 +105,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.put("size", "5") .put("size", "5")
.put("password", "somepass").build()).build(), .put("password", "somepass").build()).build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build()).getArchiveApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build()).getArchiveApi();
assertEquals(api.createArchive("xxxxxx_test1", "somepass", 5), detailsInArchiveDetails()); assertEquals(api.createWithCredentialsAndSize("xxxxxx_test1", "somepass", 5), detailsInArchiveDetails());
} }
public void testDeleteArchiveWhenResponseIs2xx() throws Exception { public void testDeleteArchiveWhenResponseIs2xx() throws Exception {
@ -115,7 +115,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("username", "xxxxxx_test1").build(), .addFormParam("username", "xxxxxx_test1").build(),
HttpResponse.builder().statusCode(200).build()).getArchiveApi(); HttpResponse.builder().statusCode(200).build()).getArchiveApi();
api.deleteArchive("xxxxxx_test1"); api.delete("xxxxxx_test1");
} }
@Test(expectedExceptions = {HttpResponseException.class}) @Test(expectedExceptions = {HttpResponseException.class})
@ -125,7 +125,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("username", "xxxxxx_test1").build(), .addFormParam("username", "xxxxxx_test1").build(),
HttpResponse.builder().statusCode(402).build()).getArchiveApi(); HttpResponse.builder().statusCode(402).build()).getArchiveApi();
api.deleteArchive("xxxxxx_test1"); api.delete("xxxxxx_test1");
} }
public void testResizeArchiveWhenResponseIs2xx() throws Exception { public void testResizeArchiveWhenResponseIs2xx() throws Exception {
@ -137,7 +137,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("size", "5").build(), .addFormParam("size", "5").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build()).getArchiveApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build()).getArchiveApi();
assertEquals(api.resizeArchive("username1", 5), detailsInArchiveDetails()); assertEquals(api.resize("username1", 5), detailsInArchiveDetails());
} }
@Test(expectedExceptions = {ResourceNotFoundException.class}) @Test(expectedExceptions = {ResourceNotFoundException.class})
@ -150,7 +150,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("size", "5").build(), .addFormParam("size", "5").build(),
HttpResponse.builder().statusCode(404).build()).getArchiveApi(); HttpResponse.builder().statusCode(404).build()).getArchiveApi();
api.resizeArchive("username1", 5); api.resize("username1", 5);
} }
public void testChangeArchivePasswordWhenResponseIs2xx() throws Exception { public void testChangeArchivePasswordWhenResponseIs2xx() throws Exception {
@ -163,7 +163,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("password", "newpass").build(), .addFormParam("password", "newpass").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build()).getArchiveApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build()).getArchiveApi();
assertEquals(api.changeArchivePassword("username", "newpass"), detailsInArchiveDetails()); assertEquals(api.changePassword("username", "newpass"), detailsInArchiveDetails());
} }
@Test(expectedExceptions = {ResourceNotFoundException.class}) @Test(expectedExceptions = {ResourceNotFoundException.class})
@ -177,7 +177,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("password", "newpass").build(), .addFormParam("password", "newpass").build(),
HttpResponse.builder().statusCode(404).build()).getArchiveApi(); HttpResponse.builder().statusCode(404).build()).getArchiveApi();
api.changeArchivePassword("username", "newpass"); api.changePassword("username", "newpass");
} }
public void testGetArchiveAllowedArgumentsWhenResponseIs2xx() throws Exception { public void testGetArchiveAllowedArgumentsWhenResponseIs2xx() throws Exception {
@ -189,7 +189,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_allowed_arguments.json")).build()).getArchiveApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_allowed_arguments.json")).build()).getArchiveApi();
ArchiveAllowedArguments expected = ArchiveAllowedArguments.builder().archiveSizes(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000).build(); ArchiveAllowedArguments expected = ArchiveAllowedArguments.builder().archiveSizes(10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000).build();
assertEquals(api.getArchiveAllowedArguments(), expected); assertEquals(api.getAllowedArguments(), expected);
} }
public void testGetArchiveAllowedArguments4xxWhenResponseIs2xx() throws Exception { public void testGetArchiveAllowedArguments4xxWhenResponseIs2xx() throws Exception {
@ -200,6 +200,6 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(404).build()).getArchiveApi(); HttpResponse.builder().statusCode(404).build()).getArchiveApi();
assertNull(api.getArchiveAllowedArguments()); assertNull(api.getAllowedArguments());
} }
} }

View File

@ -51,15 +51,15 @@ public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
archiveCounter = new RetryablePredicate<Integer>( archiveCounter = new RetryablePredicate<Integer>(
new Predicate<Integer>() { new Predicate<Integer>() {
public boolean apply(Integer value){ public boolean apply(Integer value){
return api.listArchives().size() == value; return api.list().size() == value;
} }
}, 30, 1, TimeUnit.SECONDS); }, 30, 1, TimeUnit.SECONDS);
} }
@AfterClass(groups = { "integration", "live" }) @AfterClass(groups = { "integration", "live" })
protected void tearDownContext() { protected void tearDownContext() {
int before = api.listArchives().size(); int before = api.list().size();
api.deleteArchive(archiveUser); api.delete(archiveUser);
assertTrue(archiveCounter.apply(before - 1)); assertTrue(archiveCounter.apply(before - 1));
super.tearDownContext(); super.tearDownContext();
@ -71,12 +71,12 @@ public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
@Test @Test
public void testAllowedArguments() throws Exception { public void testAllowedArguments() throws Exception {
ArchiveAllowedArguments args = api.getArchiveAllowedArguments(); ArchiveAllowedArguments args = api.getAllowedArguments();
assertNotNull(args); assertNotNull(args);
assertNotNull(args.getArchiveSizes()); assertNotNull(args.getSizes());
assertTrue(args.getArchiveSizes().size() > 0); assertTrue(args.getSizes().size() > 0);
for (int size : args.getArchiveSizes()) { for (int size : args.getSizes()) {
assertTrue(size > 0); assertTrue(size > 0);
} }
} }
@ -84,37 +84,37 @@ public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
@Test @Test
public void testCreateArchive() throws Exception { public void testCreateArchive() throws Exception {
try { try {
api.deleteArchive(archiveUser); api.delete(archiveUser);
} catch(Exception ex) { } catch(Exception ex) {
} }
int before = api.listArchives().size(); int before = api.list().size();
api.createArchive(archiveUser, "password", 10); api.createWithCredentialsAndSize(archiveUser, "password", 10);
assertTrue(archiveCounter.apply(before + 1)); assertTrue(archiveCounter.apply(before + 1));
} }
@Test(dependsOnMethods = "testCreateArchive") @Test(dependsOnMethods = "testCreateArchive")
public void testArchiveDetails() throws Exception { public void testArchiveDetails() throws Exception {
Archive details = api.getArchive(archiveUser); Archive details = api.get(archiveUser);
assertEquals(details.getUsername(), archiveUser); assertEquals(details.getUsername(), archiveUser);
} }
@Test(dependsOnMethods = "testCreateArchive") @Test(dependsOnMethods = "testCreateArchive")
public void testChangePassword() throws Exception { public void testChangePassword() throws Exception {
api.changeArchivePassword(archiveUser, "newpassword"); api.changePassword(archiveUser, "newpassword");
// TODO assert something useful! // TODO assert something useful!
} }
@Test(dependsOnMethods = "testCreateArchive") @Test(dependsOnMethods = "testCreateArchive")
public void testResizeArchive() throws Exception { public void testResizeArchive() throws Exception {
api.resizeArchive(archiveUser, 20); api.resize(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 api.getArchive(archiveUser) != null && value.equals(api.getArchive(archiveUser).getTotalSize()); return api.get(archiveUser) != null && value.equals(api.get(archiveUser).getTotalSize());
} }
}, 30, 1, TimeUnit.SECONDS).apply("20 GB")); }, 30, 1, TimeUnit.SECONDS).apply("20 GB"));
} }

View File

@ -30,7 +30,8 @@ import org.jclouds.glesys.domain.Domain;
import org.jclouds.glesys.domain.DomainRecord; import org.jclouds.glesys.domain.DomainRecord;
import org.jclouds.glesys.internal.BaseGleSYSApiExpectTest; import org.jclouds.glesys.internal.BaseGleSYSApiExpectTest;
import org.jclouds.glesys.options.AddDomainOptions; import org.jclouds.glesys.options.AddDomainOptions;
import org.jclouds.glesys.options.EditRecordOptions; import org.jclouds.glesys.options.DomainOptions;
import org.jclouds.glesys.options.UpdateRecordOptions;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
@ -57,8 +58,8 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
Domain expected = Domain expected =
Domain.builder().domainName("testglesys.jclouds.org").createTime(dateService.iso8601SecondsDateParse("2012-01-31T12:19:03+01:00")).build(); Domain.builder().domainName("testglesys.jclouds.org").createTime(dateService.iso8601SecondsDateParse("2012-01-31T12:19:03+01:00")).build();
Domain actual = Iterables.getOnlyElement(api.listDomains()); Domain actual = Iterables.getOnlyElement(api.list());
assertEquals(expected.getDomainName(), actual.getDomainName()); assertEquals(expected.getName(), actual.getName());
assertEquals(expected.getCreateTime(), actual.getCreateTime()); assertEquals(expected.getCreateTime(), actual.getCreateTime());
} }
@ -69,7 +70,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(404).build()).getDomainApi(); HttpResponse.builder().statusCode(404).build()).getDomainApi();
assertTrue(api.listDomains().isEmpty()); assertTrue(api.list().isEmpty());
} }
public void testListDomainRecordsWhenResponseIs2xx() throws Exception { public void testListDomainRecordsWhenResponseIs2xx() throws Exception {
@ -112,7 +113,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(404).build()).getDomainApi(); HttpResponse.builder().statusCode(404).build()).getDomainApi();
assertTrue(api.listDomains().isEmpty()); assertTrue(api.list().isEmpty());
} }
public void testAddDomainRecordsWhenResponseIs2xx() throws Exception { public void testAddDomainRecordsWhenResponseIs2xx() throws Exception {
@ -128,7 +129,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.payload(payloadFromResourceWithContentType("/domain_record.json", MediaType.APPLICATION_JSON)).build()) .payload(payloadFromResourceWithContentType("/domain_record.json", MediaType.APPLICATION_JSON)).build())
.getDomainApi(); .getDomainApi();
assertEquals(api.addRecord("jclouds.org", "jclouds.org", "A", ""), recordInDomainRecord()); assertEquals(api.createRecord("jclouds.org", "jclouds.org", "A", ""), recordInDomainRecord());
} }
protected DomainRecord recordInDomainRecord() { protected DomainRecord recordInDomainRecord() {
@ -147,10 +148,10 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("data", "").build(), .addFormParam("data", "").build(),
HttpResponse.builder().statusCode(404).build()).getDomainApi(); HttpResponse.builder().statusCode(404).build()).getDomainApi();
api.addRecord("jclouds.org", "jclouds.org", "A", ""); api.createRecord("jclouds.org", "jclouds.org", "A", "");
} }
public void testEditDomainRecordsWhenResponseIs2xx() throws Exception { public void testUpdateDomainRecordsWhenResponseIs2xx() throws Exception {
DomainApi api = requestSendsResponse( DomainApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/updaterecord/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/updaterecord/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
@ -162,11 +163,11 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.payload(payloadFromResourceWithContentType("/domain_record.json", MediaType.APPLICATION_JSON)).build()) .payload(payloadFromResourceWithContentType("/domain_record.json", MediaType.APPLICATION_JSON)).build())
.getDomainApi(); .getDomainApi();
assertEquals(api.editRecord("256151", EditRecordOptions.Builder.host("somehost"), EditRecordOptions.Builder.ttl(1800)), recordInDomainRecord()); assertEquals(api.updateRecord("256151", UpdateRecordOptions.Builder.host("somehost").ttl(1800)), recordInDomainRecord());
} }
@Test(expectedExceptions = ResourceNotFoundException.class) @Test(expectedExceptions = ResourceNotFoundException.class)
public void testEditDomainRecordsWhenResponseIs4xx() throws Exception { public void testUpdateDomainRecordsWhenResponseIs4xx() throws Exception {
DomainApi api = requestSendsResponse( DomainApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/updaterecord/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/updaterecord/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
@ -176,7 +177,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("ttl", "1800").build(), .addFormParam("ttl", "1800").build(),
HttpResponse.builder().statusCode(404).build()).getDomainApi(); HttpResponse.builder().statusCode(404).build()).getDomainApi();
api.editRecord("256151", EditRecordOptions.Builder.host("somehost"), EditRecordOptions.Builder.ttl(1800)); api.updateRecord("256151", UpdateRecordOptions.Builder.host("somehost").ttl(1800));
} }
public void testDeleteDomainRecordsWhenResponseIs2xx() throws Exception { public void testDeleteDomainRecordsWhenResponseIs2xx() throws Exception {
@ -212,7 +213,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build()) .payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build())
.getDomainApi(); .getDomainApi();
assertEquals(api.getDomain("cl66666_x"), domainInDomainDetails()); assertEquals(api.get("cl66666_x"), domainInDomainDetails());
} }
@ -225,7 +226,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(404).build()) HttpResponse.builder().statusCode(404).build())
.getDomainApi(); .getDomainApi();
assertNull(api.getDomain("cl66666_x")); assertNull(api.get("cl66666_x"));
} }
protected Domain domainInDomainDetails() { protected Domain domainInDomainDetails() {
@ -242,7 +243,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build()) .payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build())
.getDomainApi(); .getDomainApi();
assertEquals(api.addDomain("cl66666_x"), domainInDomainDetails()); assertEquals(api.create("cl66666_x"), domainInDomainDetails());
} }
public void testAddDomainWithOptsWhenResponseIs2xx() throws Exception { public void testAddDomainWithOptsWhenResponseIs2xx() throws Exception {
@ -264,32 +265,34 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
AddDomainOptions options = (AddDomainOptions) AddDomainOptions.Builder.primaryNameServer("ns1.somewhere.x") AddDomainOptions options = (AddDomainOptions) AddDomainOptions.Builder.primaryNameServer("ns1.somewhere.x")
.expire(1).minimum(1).refresh(1).responsiblePerson("Tester").retry(1).ttl(1); .expire(1).minimum(1).refresh(1).responsiblePerson("Tester").retry(1).ttl(1);
assertEquals(api.addDomain("cl66666_x", options), domainInDomainDetails()); assertEquals(api.create("cl66666_x", options), domainInDomainDetails());
} }
public void testEditDomainWhenResponseIs2xx() throws Exception { public void testUpdateDomainWhenResponseIs2xx() throws Exception {
DomainApi api = requestSendsResponse( DomainApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/edit/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/edit/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("domainname", "x").build(), .addFormParam("domainname", "x")
.addFormParam("expire", "1").build(),
HttpResponse.builder().statusCode(200) HttpResponse.builder().statusCode(200)
.payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build()) .payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build())
.getDomainApi(); .getDomainApi();
assertEquals(api.editDomain("x"), domainInDomainDetails()); assertEquals(api.update("x", DomainOptions.Builder.expire(1)), domainInDomainDetails());
} }
@Test(expectedExceptions = {ResourceNotFoundException.class}) @Test(expectedExceptions = {ResourceNotFoundException.class})
public void testEditDomainWhenResponseIs4xxThrows() throws Exception { public void testUpdateDomainWhenResponseIs4xxThrows() throws Exception {
DomainApi api = requestSendsResponse( DomainApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/edit/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/edit/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("domainname", "x").build(), .addFormParam("domainname", "x")
.addFormParam("expire", "1").build(),
HttpResponse.builder().statusCode(404).build()).getDomainApi(); HttpResponse.builder().statusCode(404).build()).getDomainApi();
api.editDomain("x"); api.update("x", DomainOptions.Builder.expire(1));
} }
public void testDeleteDomainWhenResponseIs2xx() throws Exception { public void testDeleteDomainWhenResponseIs2xx() throws Exception {
@ -299,7 +302,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("domainname", "x").build(), .addFormParam("domainname", "x").build(),
HttpResponse.builder().statusCode(200).build()).getDomainApi(); HttpResponse.builder().statusCode(200).build()).getDomainApi();
api.deleteDomain("x"); api.delete("x");
} }
@Test(expectedExceptions = {ResourceNotFoundException.class}) @Test(expectedExceptions = {ResourceNotFoundException.class})
@ -310,6 +313,6 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("domainname", "x").build(), .addFormParam("domainname", "x").build(),
HttpResponse.builder().statusCode(404).build()).getDomainApi(); HttpResponse.builder().statusCode(404).build()).getDomainApi();
api.deleteDomain("x"); api.delete("x");
} }
} }

View File

@ -29,7 +29,7 @@ import org.jclouds.glesys.domain.Domain;
import org.jclouds.glesys.domain.DomainRecord; import org.jclouds.glesys.domain.DomainRecord;
import org.jclouds.glesys.internal.BaseGleSYSApiLiveTest; import org.jclouds.glesys.internal.BaseGleSYSApiLiveTest;
import org.jclouds.glesys.options.DomainOptions; import org.jclouds.glesys.options.DomainOptions;
import org.jclouds.glesys.options.EditRecordOptions; import org.jclouds.glesys.options.UpdateRecordOptions;
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;
@ -54,7 +54,7 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
domainCounter = new RetryablePredicate<Integer>( domainCounter = new RetryablePredicate<Integer>(
new Predicate<Integer>() { new Predicate<Integer>() {
public boolean apply(Integer value) { public boolean apply(Integer value) {
return api.listDomains().size() == value; return api.list().size() == value;
} }
}, 30, 1, TimeUnit.SECONDS); }, 30, 1, TimeUnit.SECONDS);
recordCounter = new RetryablePredicate<Integer>( recordCounter = new RetryablePredicate<Integer>(
@ -65,7 +65,7 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
}, 30, 1, TimeUnit.SECONDS); }, 30, 1, TimeUnit.SECONDS);
try { try {
api.deleteDomain(testDomain); api.delete(testDomain);
} catch (Exception ex) { } catch (Exception ex) {
} }
@ -74,8 +74,8 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
@AfterGroups(groups = {"live"}) @AfterGroups(groups = {"live"})
public void tearDownContext() { public void tearDownContext() {
int before = api.listDomains().size(); int before = api.list().size();
api.deleteDomain(testDomain); api.delete(testDomain);
assertTrue(domainCounter.apply(before - 1)); assertTrue(domainCounter.apply(before - 1));
super.tearDownContext(); super.tearDownContext();
@ -87,16 +87,16 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
@Test @Test
public void testGetDomain() throws Exception { public void testGetDomain() throws Exception {
Domain domain = api.getDomain(testDomain); Domain domain = api.get(testDomain);
assertNotNull(domain); assertNotNull(domain);
assertEquals(domain.getDomainName(), testDomain); assertEquals(domain.getName(), testDomain);
assertNotNull(domain.getCreateTime()); assertNotNull(domain.getCreateTime());
} }
@Test @Test
public void testEditDomain() throws Exception { public void testUpdateDomain() throws Exception {
api.editDomain(testDomain, DomainOptions.Builder.responsiblePerson("another-tester.jclouds.org.")); api.update(testDomain, DomainOptions.Builder.responsiblePerson("another-tester.jclouds.org."));
Domain domain = api.getDomain(testDomain); Domain domain = api.get(testDomain);
assertEquals(domain.getResponsiblePerson(), "another-tester.jclouds.org."); assertEquals(domain.getResponsiblePerson(), "another-tester.jclouds.org.");
} }
@ -104,7 +104,7 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
public void testCreateRecord() throws Exception { public void testCreateRecord() throws Exception {
int before = api.listRecords(testDomain).size(); int before = api.listRecords(testDomain).size();
api.addRecord(testDomain, "test", "A", "127.0.0.1"); api.createRecord(testDomain, "test", "A", "127.0.0.1");
assertTrue(recordCounter.apply(before + 1)); assertTrue(recordCounter.apply(before + 1));
@ -117,10 +117,10 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
} }
@Test @Test
public void testEditRecord() throws Exception { public void testUpdateRecord() throws Exception {
int before = api.listRecords(testDomain).size(); int before = api.listRecords(testDomain).size();
api.addRecord(testDomain, "testeditbefore", "A", "127.0.0.1"); api.createRecord(testDomain, "testeditbefore", "A", "127.0.0.1");
assertTrue(recordCounter.apply(before + 1)); assertTrue(recordCounter.apply(before + 1));
@ -135,7 +135,7 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
assertNotNull(recordId); assertNotNull(recordId);
api.editRecord(recordId, EditRecordOptions.Builder.host("testeditafter")); api.updateRecord(recordId, UpdateRecordOptions.Builder.host("testeditafter"));
boolean found = false; boolean found = false;
for(DomainRecord record : api.listRecords(testDomain)) { for(DomainRecord record : api.listRecords(testDomain)) {

View File

@ -33,7 +33,7 @@ import org.jclouds.glesys.domain.EmailOverviewDomain;
import org.jclouds.glesys.domain.EmailOverviewSummary; import org.jclouds.glesys.domain.EmailOverviewSummary;
import org.jclouds.glesys.domain.EmailQuota; import org.jclouds.glesys.domain.EmailQuota;
import org.jclouds.glesys.internal.BaseGleSYSApiExpectTest; import org.jclouds.glesys.internal.BaseGleSYSApiExpectTest;
import org.jclouds.glesys.options.EditAccountOptions; import org.jclouds.glesys.options.UpdateAccountOptions;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
@ -44,20 +44,20 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
/** /**
* Tests annotation parsing of {@code EmailApi} * Tests annotation parsing of {@code EmailAccountApi}
* *
* @author Adam Lowe * @author Adam Lowe
*/ */
@Test(groups = "unit", testName = "EmailAsyncApiTest") @Test(groups = "unit", testName = "EmailAccountAsyncApiTest")
public class EmailApiExpectTest extends BaseGleSYSApiExpectTest { public class EmailAccountApiExpectTest extends BaseGleSYSApiExpectTest {
public void testListWhenResponseIs2xx() throws Exception { public void testListWhenResponseIs2xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("domainname", "cl13016.test.jclouds.org").build(), .addFormParam("domainname", "cl13016.test.jclouds.org").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/email_list.json")).build()).getEmailApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/email_list.json")).build()).getEmailAccountApi();
EmailAccount.Builder<?> builder = EmailAccount.builder().quota(EmailQuota.builder().max(200).unit("MB").build()).antispamLevel(3).antiVirus(true).autoRespond(false).autoRespondSaveEmail(true); EmailAccount.Builder<?> builder = EmailAccount.builder().quota(EmailQuota.builder().max(200).unit("MB").build()).antispamLevel(3).antiVirus(true).autoRespond(false).autoRespondSaveEmail(true);
Set<EmailAccount> expected = Set<EmailAccount> expected =
@ -69,108 +69,108 @@ public class EmailApiExpectTest extends BaseGleSYSApiExpectTest {
.modified(dateService.iso8601SecondsDateParse("2012-06-24T11:53:48+02:00")).build() .modified(dateService.iso8601SecondsDateParse("2012-06-24T11:53:48+02:00")).build()
); );
Set<EmailAccount> actual = api.listAccounts("cl13016.test.jclouds.org"); Set<EmailAccount> actual = api.listDomain("cl13016.test.jclouds.org").toImmutableSet();
assertEquals(actual, expected); assertEquals(actual, expected);
assertEquals(Iterables.get(actual, 0).toString(), Iterables.get(expected, 0).toString()); assertEquals(Iterables.get(actual, 0).toString(), Iterables.get(expected, 0).toString());
} }
public void testListWhenResponseIs404IsEmpty() throws Exception { public void testListWhenResponseIs404IsEmpty() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("domainname", "test").build(), .addFormParam("domainname", "test").build(),
HttpResponse.builder().statusCode(404).build()).getEmailApi(); HttpResponse.builder().statusCode(404).build()).getEmailAccountApi();
assertTrue(api.listAccounts("test").isEmpty()); assertTrue(api.listDomain("test").isEmpty());
} }
public void testListAliasesWhenResponseIs2xx() throws Exception { public void testListAliasesWhenResponseIs2xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("domainname", "cl13016.test.jclouds.org").build(), .addFormParam("domainname", "cl13016.test.jclouds.org").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/email_list.json")).build()).getEmailApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/email_list.json")).build()).getEmailAccountApi();
EmailAlias expected = EmailAlias.builder().alias("test2@cl13016.test.jclouds.org").forwardTo("test2@cl13016.test.jclouds.org").build(); EmailAlias expected = EmailAlias.builder().alias("test2@cl13016.test.jclouds.org").forwardTo("test2@cl13016.test.jclouds.org").build();
EmailAlias actual = Iterables.getOnlyElement(api.listAliases("cl13016.test.jclouds.org")); EmailAlias actual = Iterables.getOnlyElement(api.listAliasesInDomain("cl13016.test.jclouds.org"));
assertEquals(actual, expected); assertEquals(actual, expected);
} }
public void testListAliasesWhenResponseIs404IsEmpty() throws Exception { public void testListAliasesWhenResponseIs404IsEmpty() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("domainname", "test").build(), .addFormParam("domainname", "test").build(),
HttpResponse.builder().statusCode(404).build()).getEmailApi(); HttpResponse.builder().statusCode(404).build()).getEmailAccountApi();
assertTrue(api.listAliases("test").isEmpty()); assertTrue(api.listAliasesInDomain("test").isEmpty());
} }
public void testOverviewWhenResponseIs2xx() throws Exception { public void testOverviewWhenResponseIs2xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/overview/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/overview/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/email_overview.json")).build()).getEmailApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/email_overview.json")).build()).getEmailAccountApi();
EmailOverviewSummary summary = EmailOverviewSummary.builder().accounts(2).maxAccounts(50).aliases(1).maxAliases(1000).build(); EmailOverviewSummary summary = EmailOverviewSummary.builder().accounts(2).maxAccounts(50).aliases(1).maxAliases(1000).build();
EmailOverviewDomain domain = EmailOverviewDomain.builder().domain("cl13016.test.jclouds.org").accounts(2).aliases(0).build(); EmailOverviewDomain domain = EmailOverviewDomain.builder().domain("cl13016.test.jclouds.org").accounts(2).aliases(0).build();
EmailOverview expected = EmailOverview.builder().summary(summary).domains(domain).build(); EmailOverview expected = EmailOverview.builder().summary(summary).domains(domain).build();
assertEquals(api.getEmailOverview(), expected); assertEquals(api.getOverview(), expected);
} }
public void testOverviewWhenResponseIs404ReturnsNull() throws Exception { public void testOverviewWhenResponseIs404ReturnsNull() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/overview/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/overview/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(404).build()).getEmailApi(); HttpResponse.builder().statusCode(404).build()).getEmailAccountApi();
assertNull(api.getEmailOverview()); assertNull(api.getOverview());
} }
public void testCreateAccountWhenResponseIs2xx() throws Exception { public void testCreateAccountWhenResponseIs2xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createaccount/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createaccount/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("emailaccount", "test@jclouds.org") .addFormParam("emailaccount", "test@jclouds.org")
.addFormParam("password", "newpass").build(), .addFormParam("password", "newpass").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/email_details.json", MediaType.APPLICATION_JSON)).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/email_details.json", MediaType.APPLICATION_JSON)).build())
.getEmailApi(); .getEmailAccountApi();
assertEquals(api.createAccount("test@jclouds.org", "newpass").toString(), getEmailAccountInDetails().toString()); assertEquals(api.createWithPassword("test@jclouds.org", "newpass").toString(), getEmailAccountInDetails().toString());
} }
public void testEditAccountWhenResponseIs2xx() throws Exception { public void testUpdateAccountWhenResponseIs2xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editaccount/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editaccount/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("emailaccount", "test@jclouds.org") .addFormParam("emailaccount", "test@jclouds.org")
.addFormParam("password", "anotherpass").build(), .addFormParam("password", "anotherpass").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/email_details.json", MediaType.APPLICATION_JSON)).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/email_details.json", MediaType.APPLICATION_JSON)).build())
.getEmailApi(); .getEmailAccountApi();
assertEquals(api.editAccount("test@jclouds.org", EditAccountOptions.Builder.password("anotherpass")).toString(), getEmailAccountInDetails().toString()); assertEquals(api.update("test@jclouds.org", UpdateAccountOptions.Builder.password("anotherpass")).toString(), getEmailAccountInDetails().toString());
} }
@Test(expectedExceptions = ResourceNotFoundException.class) @Test(expectedExceptions = ResourceNotFoundException.class)
public void testEditAccountWhenResponseIs4xx() throws Exception { public void testUpdateAccountWhenResponseIs4xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editaccount/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editaccount/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("emailaccount", "test@jclouds.org") .addFormParam("emailaccount", "test@jclouds.org")
.addFormParam("password", "anotherpass").build(), .addFormParam("password", "anotherpass").build(),
HttpResponse.builder().statusCode(404).build()) HttpResponse.builder().statusCode(404).build())
.getEmailApi(); .getEmailAccountApi();
assertEquals(api.editAccount("test@jclouds.org", EditAccountOptions.Builder.password("anotherpass")).toString(), getEmailAccountInDetails().toString()); assertEquals(api.update("test@jclouds.org", UpdateAccountOptions.Builder.password("anotherpass")).toString(), getEmailAccountInDetails().toString());
} }
private EmailAccount getEmailAccountInDetails() { private EmailAccount getEmailAccountInDetails() {
@ -184,84 +184,84 @@ public class EmailApiExpectTest extends BaseGleSYSApiExpectTest {
@Test(expectedExceptions = {ResourceNotFoundException.class}) @Test(expectedExceptions = {ResourceNotFoundException.class})
public void testCreateAccountWhenResponseIs4xxThrows() throws Exception { public void testCreateAccountWhenResponseIs4xxThrows() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createaccount/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createaccount/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("emailaccount", "test@jclouds.org") .addFormParam("emailaccount", "test@jclouds.org")
.addFormParam("password", "newpass").build(), .addFormParam("password", "newpass").build(),
HttpResponse.builder().statusCode(404).build()).getEmailApi(); HttpResponse.builder().statusCode(404).build()).getEmailAccountApi();
api.createAccount("test@jclouds.org", "newpass"); api.createWithPassword("test@jclouds.org", "newpass");
} }
public void testCreateAliasWhenResponseIs2xx() throws Exception { public void testCreateAliasWhenResponseIs2xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createalias/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createalias/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("emailalias", "test2@jclouds.org") .addFormParam("emailalias", "test2@jclouds.org")
.addFormParam("goto", "test@jclouds.org").build(), .addFormParam("goto", "test@jclouds.org").build(),
HttpResponse.builder().statusCode(200).build()).getEmailApi(); HttpResponse.builder().statusCode(200).build()).getEmailAccountApi();
api.createAlias("test2@jclouds.org", "test@jclouds.org"); api.createAlias("test2@jclouds.org", "test@jclouds.org");
} }
@Test(expectedExceptions = {AuthorizationException.class}) @Test(expectedExceptions = {AuthorizationException.class})
public void testCreateAliasWhenResponseIs4xxThrows() throws Exception { public void testCreateAliasWhenResponseIs4xxThrows() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createalias/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createalias/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("emailalias", "test2@jclouds.org") .addFormParam("emailalias", "test2@jclouds.org")
.addFormParam("goto", "test@jclouds.org").build(), .addFormParam("goto", "test@jclouds.org").build(),
HttpResponse.builder().statusCode(401).build()).getEmailApi(); HttpResponse.builder().statusCode(401).build()).getEmailAccountApi();
api.createAlias("test2@jclouds.org", "test@jclouds.org"); api.createAlias("test2@jclouds.org", "test@jclouds.org");
} }
public void testEditAliasWhenResponseIs2xx() throws Exception { public void testUpdateAliasWhenResponseIs2xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editalias/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editalias/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("emailalias", "test2@jclouds.org") .addFormParam("emailalias", "test2@jclouds.org")
.addFormParam("goto", "test@jclouds.org").build(), .addFormParam("goto", "test@jclouds.org").build(),
HttpResponse.builder().statusCode(200).build()).getEmailApi(); HttpResponse.builder().statusCode(200).build()).getEmailAccountApi();
api.editAlias("test2@jclouds.org", "test@jclouds.org"); api.updateAlias("test2@jclouds.org", "test@jclouds.org");
} }
@Test(expectedExceptions = {ResourceNotFoundException.class}) @Test(expectedExceptions = {ResourceNotFoundException.class})
public void testEditAliasWhenResponseIs4xxThrows() throws Exception { public void testUpdateAliasWhenResponseIs4xxThrows() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editalias/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editalias/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("emailalias", "test2@jclouds.org") .addFormParam("emailalias", "test2@jclouds.org")
.addFormParam("goto", "test@jclouds.org").build(), .addFormParam("goto", "test@jclouds.org").build(),
HttpResponse.builder().statusCode(404).build()).getEmailApi(); HttpResponse.builder().statusCode(404).build()).getEmailAccountApi();
api.editAlias("test2@jclouds.org", "test@jclouds.org"); api.updateAlias("test2@jclouds.org", "test@jclouds.org");
} }
public void testDeleteWhenResponseIs2xx() throws Exception { public void testDeleteWhenResponseIs2xx() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/delete/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/delete/format/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("email", "test2@jclouds.org").build(), .addFormParam("email", "test2@jclouds.org").build(),
HttpResponse.builder().statusCode(200).build()).getEmailApi(); HttpResponse.builder().statusCode(200).build()).getEmailAccountApi();
api.delete("test2@jclouds.org"); api.delete("test2@jclouds.org");
} }
@Test(expectedExceptions = {ResourceNotFoundException.class}) @Test(expectedExceptions = {ResourceNotFoundException.class})
public void testDeleteWhenResponseIs4xxThrows() throws Exception { public void testDeleteWhenResponseIs4xxThrows() throws Exception {
EmailApi api = requestSendsResponse( EmailAccountApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/delete/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/delete/format/json")
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
.addFormParam("email", "test2@jclouds.org").build(), .addFormParam("email", "test2@jclouds.org").build(),
HttpResponse.builder().statusCode(404).build()).getEmailApi(); HttpResponse.builder().statusCode(404).build()).getEmailAccountApi();
api.delete("test2@jclouds.org"); api.delete("test2@jclouds.org");
} }

View File

@ -23,7 +23,6 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.glesys.domain.EmailAccount; import org.jclouds.glesys.domain.EmailAccount;
@ -32,34 +31,35 @@ import org.jclouds.glesys.domain.EmailOverview;
import org.jclouds.glesys.domain.EmailOverviewDomain; import org.jclouds.glesys.domain.EmailOverviewDomain;
import org.jclouds.glesys.internal.BaseGleSYSApiWithAServerLiveTest; import org.jclouds.glesys.internal.BaseGleSYSApiWithAServerLiveTest;
import org.jclouds.glesys.options.CreateAccountOptions; import org.jclouds.glesys.options.CreateAccountOptions;
import org.jclouds.glesys.options.EditAccountOptions; import org.jclouds.glesys.options.UpdateAccountOptions;
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.Test; import org.testng.annotations.Test;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
/** /**
* Tests behavior of {@code EmailApi} * Tests behavior of {@code EmailAccountApi}
* *
* @author Adam Lowe * @author Adam Lowe
*/ */
@Test(groups = "live", testName = "EmailApiLiveTest", singleThreaded = true) @Test(groups = "live", testName = "EmailAccountApiLiveTest", singleThreaded = true)
public class EmailApiLiveTest extends BaseGleSYSApiWithAServerLiveTest { public class EmailAccountApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@BeforeGroups(groups = {"live"}) @BeforeGroups(groups = {"live"})
public void setupDomains() { public void setupDomains() {
testDomain = identity + ".test.jclouds.org"; testDomain = identity + ".test.jclouds.org";
api = gleContext.getApi().getEmailApi(); api = gleContext.getApi().getEmailAccountApi();
createDomain(testDomain); createDomain(testDomain);
emailAccountCounter = new RetryablePredicate<Integer>( emailAccountCounter = new RetryablePredicate<Integer>(
new Predicate<Integer>() { new Predicate<Integer>() {
public boolean apply(Integer value) { public boolean apply(Integer value) {
return api.listAccounts(testDomain).size() == value; return api.listDomain(testDomain).size() == value;
} }
}, 180, 5, TimeUnit.SECONDS); }, 180, 5, TimeUnit.SECONDS);
@ -76,84 +76,84 @@ public class EmailApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
api.delete("test@" + testDomain); api.delete("test@" + testDomain);
api.delete("test1@" + testDomain); api.delete("test1@" + testDomain);
assertTrue(emailAccountCounter.apply(0)); assertTrue(emailAccountCounter.apply(0));
gleContext.getApi().getDomainApi().deleteDomain(testDomain); gleContext.getApi().getEmailAccountApi().delete(testDomain);
} }
private EmailApi api; private EmailAccountApi api;
private String testDomain; private String testDomain;
private RetryablePredicate<Integer> emailAccountCounter; private RetryablePredicate<Integer> emailAccountCounter;
@Test @Test
public void testCreateEmail() { public void testCreateEmail() {
api.createAccount("test@" + testDomain, "password", api.createWithPassword("test@" + testDomain, "password",
CreateAccountOptions.Builder.antiVirus(true).autorespond(true).autorespondMessage("out of office")); CreateAccountOptions.Builder.antiVirus(true).autorespond(true).autorespondMessage("out of office"));
assertTrue(emailAccountCounter.apply(1)); assertTrue(emailAccountCounter.apply(1));
api.createAccount("test1@" + testDomain, "password"); api.createWithPassword("test1@" + testDomain, "password");
assertTrue(emailAccountCounter.apply(2)); assertTrue(emailAccountCounter.apply(2));
} }
@Test(dependsOnMethods = "testCreateEmail") @Test(dependsOnMethods = "testCreateEmail")
public void testAliases() { public void testAliases() {
assertTrue(api.listAliases(testDomain).isEmpty()); assertTrue(api.listAliasesInDomain(testDomain).isEmpty());
EmailAlias alias = api.createAlias("test2@" + testDomain, "test@" + testDomain); EmailAlias alias = api.createAlias("test2@" + testDomain, "test@" + testDomain);
assertEquals(alias.getAlias(), "test2@" + testDomain); assertEquals(alias.getAlias(), "test2@" + testDomain);
assertEquals(alias.getForwardTo(), "test@" + testDomain); assertEquals(alias.getForwardTo(), "test@" + testDomain);
EmailAlias aliasFromList = Iterables.getOnlyElement(api.listAliases(testDomain)); EmailAlias aliasFromList = Iterables.getOnlyElement(api.listAliasesInDomain(testDomain));
assertEquals(aliasFromList, alias); assertEquals(aliasFromList, alias);
EmailOverview overview = api.getEmailOverview(); EmailOverview overview = api.getOverview();
assertTrue(overview.getSummary().getAliases() == 1); assertTrue(overview.getSummary().getAliases() == 1);
alias = api.editAlias("test2@" + testDomain, "test1@" + testDomain); alias = api.updateAlias("test2@" + testDomain, "test1@" + testDomain);
overview = api.getEmailOverview(); overview = api.getOverview();
assertTrue(overview.getSummary().getAliases() == 1); assertTrue(overview.getSummary().getAliases() == 1);
aliasFromList = Iterables.getOnlyElement(api.listAliases(testDomain)); aliasFromList = Iterables.getOnlyElement(api.listAliasesInDomain(testDomain));
assertEquals(aliasFromList, alias); assertEquals(aliasFromList, alias);
api.delete("test2@" + testDomain); api.delete("test2@" + testDomain);
overview = api.getEmailOverview(); overview = api.getOverview();
assertTrue(overview.getSummary().getAliases() == 0); assertTrue(overview.getSummary().getAliases() == 0);
} }
@Test(dependsOnMethods = "testCreateEmail") @Test(dependsOnMethods = "testCreateEmail")
public void testOverview() throws Exception { public void testOverview() throws Exception {
EmailOverview overview = api.getEmailOverview(); EmailOverview overview = api.getOverview();
assertNotNull(overview.getSummary()); assertNotNull(overview.getSummary());
assertTrue(overview.getSummary().getAccounts() > 0); assertTrue(overview.getSummary().getAccounts() > 0);
assertTrue(overview.getSummary().getAliases() > -1); assertTrue(overview.getSummary().getAliases() > -1);
assertTrue(overview.getSummary().getMaxAccounts() > 0); assertTrue(overview.getSummary().getMaxAccounts() > 0);
assertTrue(overview.getSummary().getMaxAliases() > 0); assertTrue(overview.getSummary().getMaxAliases() > 0);
assertNotNull(overview.getDomains()); assertNotNull(overview.gets());
assertFalse(overview.getDomains().isEmpty()); assertFalse(overview.gets().isEmpty());
EmailOverviewDomain domain = EmailOverviewDomain.builder().domain(testDomain).accounts(1).build(); EmailOverviewDomain domain = EmailOverviewDomain.builder().domain(testDomain).accounts(1).build();
assertTrue(overview.getDomains().contains(domain)); assertTrue(overview.gets().contains(domain));
} }
@Test(dependsOnMethods = "testCreateEmail") @Test(dependsOnMethods = "testCreateEmail")
public void testListAccounts() throws Exception { public void testListAccounts() throws Exception {
Set<EmailAccount> accounts = api.listAccounts(testDomain); FluentIterable<EmailAccount> accounts = api.listDomain(testDomain);
assertTrue(accounts.size() >= 1); assertTrue(accounts.size() >= 1);
} }
@Test(dependsOnMethods = "testCreateEmail") @Test(dependsOnMethods = "testCreateEmail")
public void testEditAccount() throws Exception { public void testUpdateAccount() throws Exception {
Set<EmailAccount> accounts = api.listAccounts(testDomain); FluentIterable<EmailAccount> accounts = api.listDomain(testDomain);
for (EmailAccount account : accounts) { for (EmailAccount account : accounts) {
if (account.getAccount().equals("test@" + testDomain)) { if (account.getAccount().equals("test@" + testDomain)) {
assertTrue(account.isAntiVirus()); assertTrue(account.isAntiVirus());
} }
} }
api.editAccount("test@" + testDomain, EditAccountOptions.Builder.antiVirus(false)); api.update("test@" + testDomain, UpdateAccountOptions.Builder.antiVirus(false));
accounts = api.listAccounts(testDomain); accounts = api.listDomain(testDomain);
for (EmailAccount account : accounts) { for (EmailAccount account : accounts) {
if (account.getAccount().equals("test@" + testDomain)) { if (account.getAccount().equals("test@" + testDomain)) {
assertFalse(account.isAntiVirus()); assertFalse(account.isAntiVirus());

View File

@ -58,7 +58,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
.nameServers("79.99.4.100", "79.99.4.101") .nameServers("79.99.4.100", "79.99.4.101")
.cost(Cost.builder().amount(2.0).currency("EUR").timePeriod("month").build()); .cost(Cost.builder().amount(2.0).currency("EUR").timePeriod("month").build());
assertEquals(api.listIps().toString(), ImmutableSet.of( assertEquals(api.list().toString(), ImmutableSet.of(
builder.ptr("31-192-230-68-static.serverhotell.net.").address("31.192.230.68").serverId(null).build(), builder.ptr("31-192-230-68-static.serverhotell.net.").address("31.192.230.68").serverId(null).build(),
builder.ptr("31-192-231-148-static.serverhotell.net.").address("31.192.231.148").serverId("vz1609110").build()).toString()); builder.ptr("31-192-231-148-static.serverhotell.net.").address("31.192.231.148").serverId("vz1609110").build()).toString());
} }
@ -70,7 +70,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(404).build()).getIpApi(); HttpResponse.builder().statusCode(404).build()).getIpApi();
assertTrue(api.listIps().isEmpty()); assertTrue(api.list().isEmpty());
} }
public void testGetIpDetailsWhenResponseIs2xx() { public void testGetIpDetailsWhenResponseIs2xx() {
@ -81,7 +81,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/ip_get_details.json")).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResource("/ip_get_details.json")).build())
.getIpApi(); .getIpApi();
assertEquals(api.getIp("31.192.227.113"), getIpInIpDetails()); assertEquals(api.get("31.192.227.113"), getIpInIpDetails());
} }
protected IpDetails getIpInIpDetails() { protected IpDetails getIpInIpDetails() {
@ -100,7 +100,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(404).build()).getIpApi(); HttpResponse.builder().statusCode(404).build()).getIpApi();
assertEquals(api.getIp("31.192.227.37"), null); assertEquals(api.get("31.192.227.37"), null);
} }
public void testTakeWhenResponseIs2xx() { public void testTakeWhenResponseIs2xx() {
@ -159,7 +159,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/ip_list_free.json")).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResource("/ip_list_free.json")).build())
.getIpApi(); .getIpApi();
assertEquals(api.listFree(4, "Falkenberg", "OpenVZ"), ParseIpAddressFromResponseTest.EXPECTED_IPS); assertEquals(api.listFree(4, "Falkenberg", "OpenVZ").toImmutableSet(), ParseIpAddressFromResponseTest.EXPECTED_IPS);
} }
public void testListFreeWhenResponseIs404ReturnsEmptySet() { public void testListFreeWhenResponseIs404ReturnsEmptySet() {
@ -170,7 +170,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(404).build()) HttpResponse.builder().statusCode(404).build())
.getIpApi(); .getIpApi();
assertEquals(api.listFree(6, "Falkenberg", "OpenVZ"), emptySet()); assertEquals(api.listFree(6, "Falkenberg", "OpenVZ").toImmutableSet(), emptySet());
} }
public void testAddWhenResponseIs2xx() { public void testAddWhenResponseIs2xx() {
@ -183,7 +183,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getIpApi(); .getIpApi();
api.addIpToServer("31.192.227.37", "vz1946889"); api.addToServer("31.192.227.37", "vz1946889");
} }
@Test(expectedExceptions = AuthorizationException.class) @Test(expectedExceptions = AuthorizationException.class)
@ -196,7 +196,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("serverid", "vz1946889").build(), .addFormParam("serverid", "vz1946889").build(),
HttpResponse.builder().statusCode(401).build()) HttpResponse.builder().statusCode(401).build())
.getIpApi(); .getIpApi();
api.addIpToServer("31.192.227.37", "vz1946889"); api.addToServer("31.192.227.37", "vz1946889");
} }
public void testRemoveWhenResponseIs2xx() { public void testRemoveWhenResponseIs2xx() {
@ -209,7 +209,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getIpApi(); .getIpApi();
api.removeIpFromServer("31.192.227.37", "vz1946889"); api.removeFromServer("31.192.227.37", "vz1946889");
} }
@Test(expectedExceptions = HttpResponseException.class) @Test(expectedExceptions = HttpResponseException.class)
@ -223,7 +223,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(400).build()) HttpResponse.builder().statusCode(400).build())
.getIpApi(); .getIpApi();
api.removeIpFromServer("31.192.227.37", "vz1946889"); api.removeFromServer("31.192.227.37", "vz1946889");
} }
public void testRemoveAndReleaseWhenResponseIs2xx() { public void testRemoveAndReleaseWhenResponseIs2xx() {
@ -237,7 +237,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getIpApi(); .getIpApi();
api.removeIpFromServerAndRelease("31.192.227.37", "vz1946889"); api.removeFromServerAndRelease("31.192.227.37", "vz1946889");
} }
@Test(expectedExceptions = HttpResponseException.class) @Test(expectedExceptions = HttpResponseException.class)
@ -252,7 +252,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(400).build()) HttpResponse.builder().statusCode(400).build())
.getIpApi(); .getIpApi();
api.removeIpFromServerAndRelease("31.192.227.37", "vz1946889"); api.removeFromServerAndRelease("31.192.227.37", "vz1946889");
} }
public void testSetPrtWhenResponseIs2xx() { public void testSetPrtWhenResponseIs2xx() {

View File

@ -33,6 +33,7 @@ import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -61,13 +62,13 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@Test @Test
public void testListFree() throws Exception { public void testListFree() throws Exception {
Set<String> freeIps = api.listFree(4, "Falkenberg", "Xen"); FluentIterable<String> freeIps = api.listFree(4, "Falkenberg", "Xen");
assertFalse(freeIps.isEmpty()); assertFalse(freeIps.isEmpty());
} }
@Test @Test
public void reserveIp() throws Exception { public void reserveIp() throws Exception {
Set<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ"); FluentIterable<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
assertFalse(openVzIps.isEmpty()); assertFalse(openVzIps.isEmpty());
reservedIp = api.take(Iterables.get(openVzIps, 0)); reservedIp = api.take(Iterables.get(openVzIps, 0));
assertTrue(reservedIp.isReserved()); assertTrue(reservedIp.isReserved());
@ -86,21 +87,21 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@Test(dependsOnMethods = "reserveIp") @Test(dependsOnMethods = "reserveIp")
public void testList() throws Exception { public void testList() throws Exception {
Set<IpDetails> ownIps = api.listIps(); FluentIterable<IpDetails> ownIps = api.list();
assertTrue(ownIps.contains(reservedIp)); assertTrue(ownIps.contains(reservedIp));
ownIps = api.listIps(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter())); ownIps = api.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()));
assertTrue(ownIps.contains(reservedIp)); assertTrue(ownIps.contains(reservedIp));
ownIps = api.listIps(ListIpOptions.Builder.platform(reservedIp.getPlatform())); ownIps = api.list(ListIpOptions.Builder.platform(reservedIp.getPlatform()));
assertTrue(ownIps.contains(reservedIp)); assertTrue(ownIps.contains(reservedIp));
ownIps = api.listIps(ListIpOptions.Builder.ipVersion(reservedIp.getVersion())); ownIps = api.list(ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
assertTrue(ownIps.contains(reservedIp)); assertTrue(ownIps.contains(reservedIp));
ownIps = api.listIps(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()), ownIps = api.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()),
ListIpOptions.Builder.platform(reservedIp.getPlatform()), ListIpOptions.Builder.platform(reservedIp.getPlatform()),
ListIpOptions.Builder.ipVersion(reservedIp.getVersion())); ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
assertTrue(ownIps.contains(reservedIp)); assertTrue(ownIps.contains(reservedIp));
ownIps = api.listIps(ListIpOptions.Builder.serverId("xmthisisnotaserverid")); ownIps = api.list(ListIpOptions.Builder.serverId("xmthisisnotaserverid"));
assertTrue(ownIps.isEmpty()); assertTrue(ownIps.isEmpty());
} }
@ -115,20 +116,20 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@Test @Test
public void testGetOpenVZDetails() throws Exception { public void testGetOpenVZDetails() throws Exception {
Set<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ"); FluentIterable<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
assertFalse(openVzIps.isEmpty()); assertFalse(openVzIps.isEmpty());
String openVzIp = openVzIps.iterator().next(); String openVzIp = openVzIps.iterator().next();
IpDetails ipDetails = api.getIp(openVzIp); IpDetails ipDetails = api.get(openVzIp);
checkOpenVZDefailsInFalkenberg(ipDetails); checkOpenVZDefailsInFalkenberg(ipDetails);
assertEquals(ipDetails.getAddress(), openVzIp); assertEquals(ipDetails.getAddress(), openVzIp);
} }
@Test @Test
public void testGetXenDetails() throws Exception { public void testGetXenDetails() throws Exception {
Set<String> xenVzIps = api.listFree(4, "Falkenberg", "Xen"); FluentIterable<String> xenVzIps = api.listFree(4, "Falkenberg", "Xen");
assertFalse(xenVzIps.isEmpty()); assertFalse(xenVzIps.isEmpty());
String xenIp = xenVzIps.iterator().next(); String xenIp = xenVzIps.iterator().next();
IpDetails ipDetails = api.getIp(xenIp); IpDetails ipDetails = api.get(xenIp);
assertEquals(ipDetails.getDatacenter(), "Falkenberg"); assertEquals(ipDetails.getDatacenter(), "Falkenberg");
assertEquals(ipDetails.getPlatform(), "Xen"); assertEquals(ipDetails.getPlatform(), "Xen");
assertEquals(ipDetails.getVersion(), 4); assertEquals(ipDetails.getVersion(), 4);
@ -145,7 +146,7 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
IpDetails original = reservedIp; IpDetails original = reservedIp;
IpDetails modified = api.setPtr(reservedIp.getAddress(), "wibble."); IpDetails modified = api.setPtr(reservedIp.getAddress(), "wibble.");
IpDetails modified2 = api.getIp(reservedIp.getAddress()); IpDetails modified2 = api.get(reservedIp.getAddress());
assertEquals(modified.getPtr(), "wibble."); assertEquals(modified.getPtr(), "wibble.");
assertEquals(modified2, modified); assertEquals(modified2, modified);
@ -157,16 +158,16 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@Test(dependsOnMethods = "reserveIp") @Test(dependsOnMethods = "reserveIp")
public void testAddRemove() throws Exception { public void testAddRemove() throws Exception {
IpDetails added = api.addIpToServer(reservedIp.getAddress(), serverId); IpDetails added = api.addToServer(reservedIp.getAddress(), serverId);
assertEquals(added.getAddress(), reservedIp.getAddress()); assertEquals(added.getAddress(), reservedIp.getAddress());
assertEquals(added.getPtr(), reservedIp.getPtr()); assertEquals(added.getPtr(), reservedIp.getPtr());
assertEquals(added.getServerId(), serverId); assertEquals(added.getServerId(), serverId);
IpDetails again = api.getIp(reservedIp.getAddress()); IpDetails again = api.get(reservedIp.getAddress());
assertEquals(again, added); assertEquals(again, added);
IpDetails removed = api.removeIpFromServer(reservedIp.getAddress(), serverId); IpDetails removed = api.removeFromServer(reservedIp.getAddress(), serverId);
assertEquals(removed, added.toBuilder().serverId(null).build()); assertEquals(removed, added.toBuilder().serverId(null).build());
assertEquals(removed, reservedIp); assertEquals(removed, reservedIp);
@ -175,11 +176,11 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
openVzIps.remove(reservedIp.getAddress()); openVzIps.remove(reservedIp.getAddress());
assertFalse(openVzIps.isEmpty()); assertFalse(openVzIps.isEmpty());
added = api.addIpToServer(reservedIp.getAddress(), serverId); added = api.addToServer(reservedIp.getAddress(), serverId);
assertEquals(added.getServerId(), serverId); assertEquals(added.getServerId(), serverId);
removed = api.removeIpFromServerAndRelease(reservedIp.getAddress(), serverId); removed = api.removeFromServerAndRelease(reservedIp.getAddress(), serverId);
assertNull(removed.getServerId()); assertNull(removed.getServerId());
assertFalse(removed.isReserved()); assertFalse(removed.isReserved());

View File

@ -45,7 +45,7 @@ import org.jclouds.glesys.internal.BaseGleSYSApiExpectTest;
import org.jclouds.glesys.options.CloneServerOptions; import org.jclouds.glesys.options.CloneServerOptions;
import org.jclouds.glesys.options.CreateServerOptions; import org.jclouds.glesys.options.CreateServerOptions;
import org.jclouds.glesys.options.DestroyServerOptions; import org.jclouds.glesys.options.DestroyServerOptions;
import org.jclouds.glesys.options.EditServerOptions; import org.jclouds.glesys.options.UpdateServerOptions;
import org.jclouds.glesys.options.ServerStatusOptions; import org.jclouds.glesys.options.ServerStatusOptions;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
@ -72,7 +72,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(204).payload(payloadFromResource("/server_list.json")).build()).getServerApi(); HttpResponse.builder().statusCode(204).payload(payloadFromResource("/server_list.json")).build()).getServerApi();
Server expected = Server.builder().id("vz1541880").hostname("mammamia").datacenter("Falkenberg").platform("OpenVZ").build(); Server expected = Server.builder().id("vz1541880").hostname("mammamia").datacenter("Falkenberg").platform("OpenVZ").build();
assertEquals(api.listServers(), ImmutableSet.<Server>of(expected)); assertEquals(api.list().toImmutableSet(), ImmutableSet.<Server>of(expected));
} }
public void testListServersWhenReponseIs404IsEmpty() { public void testListServersWhenReponseIs404IsEmpty() {
@ -82,7 +82,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(), .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
HttpResponse.builder().statusCode(404).build()).getServerApi(); HttpResponse.builder().statusCode(404).build()).getServerApi();
assertTrue(api.listServers().isEmpty()); assertTrue(api.list().isEmpty());
} }
public void testGetAllowedArgumentsWhenResponseIs2xx() throws Exception { public void testGetAllowedArgumentsWhenResponseIs2xx() throws Exception {
@ -117,7 +117,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.build(); .build();
expected.put("Xen", xen); expected.put("Xen", xen);
expected.put("OpenVZ", openvz); expected.put("OpenVZ", openvz);
assertEquals(api.getAllowedArgumentsForCreateServerByPlatform(), expected); assertEquals(api.getAllowedArgumentsForCreateByPlatform(), expected);
} }
public void testGetTemplatesWhenResponseIs2xx() throws Exception { public void testGetTemplatesWhenResponseIs2xx() throws Exception {
@ -147,7 +147,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
expectedBuilder.add(OSTemplate.builder().name(name).minDiskSize(20).minMemSize(1024).os("windows").platform("Xen").build()); expectedBuilder.add(OSTemplate.builder().name(name).minDiskSize(20).minMemSize(1024).os("windows").platform("Xen").build());
} }
assertEquals(api.listTemplates(), expectedBuilder.build()); assertEquals(api.listTemplates().toImmutableSet(), expectedBuilder.build());
} }
public void testGetServerDetailsWhenResponseIs2xx() throws Exception { public void testGetServerDetailsWhenResponseIs2xx() throws Exception {
@ -159,7 +159,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("serverid", "xm3276891").build(), .addFormParam("serverid", "xm3276891").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerApi();
ServerDetails actual = api.getServerDetails("xm3276891"); ServerDetails actual = api.get("xm3276891");
assertEquals(actual.toString(), expectedServerDetails().toString()); assertEquals(actual.toString(), expectedServerDetails().toString());
} }
@ -181,7 +181,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("serverid", "xm3276891").build(), .addFormParam("serverid", "xm3276891").build(),
HttpResponse.builder().statusCode(404).build()).getServerApi(); HttpResponse.builder().statusCode(404).build()).getServerApi();
assertNull(api.getServerDetails("xm3276891")); assertNull(api.get("xm3276891"));
} }
@Test @Test
@ -206,7 +206,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.templateName("Ubuntu 11.04 64-bit").description("description").cpuCores(1).memorySizeMB(128).diskSizeGB(5).transferGB(50).cost(cost).build(); .templateName("Ubuntu 11.04 64-bit").description("description").cpuCores(1).memorySizeMB(128).diskSizeGB(5).transferGB(50).cost(cost).build();
assertEquals( assertEquals(
api.createServerWithHostnameAndRootPassword( api.createWithHostnameAndRootPassword(
ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 32-bit") ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 32-bit")
.diskSizeGB(5).memorySizeMB(512).cpuCores(1).transferGB(50).build(), "jclouds-test", "password").toString(), .diskSizeGB(5).memorySizeMB(512).cpuCores(1).transferGB(50).build(), "jclouds-test", "password").toString(),
expected.toString()); expected.toString());
@ -233,13 +233,13 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
CreateServerOptions options = CreateServerOptions.Builder.description("Description-of-server").ip("10.0.0.1"); CreateServerOptions options = CreateServerOptions.Builder.description("Description-of-server").ip("10.0.0.1");
assertEquals(api.createServerWithHostnameAndRootPassword(ServerSpec.builder().datacenter("Falkenberg") assertEquals(api.createWithHostnameAndRootPassword(ServerSpec.builder().datacenter("Falkenberg")
.platform("OpenVZ").templateName("Ubuntu 32-bit").diskSizeGB(5).memorySizeMB(512).cpuCores(1).transferGB(50) .platform("OpenVZ").templateName("Ubuntu 32-bit").diskSizeGB(5).memorySizeMB(512).cpuCores(1).transferGB(50)
.build(), "jclouds-test", "password", options), expectedServerDetails()); .build(), "jclouds-test", "password", options), expectedServerDetails());
} }
@Test @Test
public void testEditServerWhenResponseIs2xx() throws Exception { public void testUpdateServerWhenResponseIs2xx() throws Exception {
ServerApi api = requestSendsResponse( ServerApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/server/edit/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/server/edit/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
@ -249,12 +249,11 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("hostname", "new-hostname").build(), .addFormParam("hostname", "new-hostname").build(),
HttpResponse.builder().statusCode(206).build()).getServerApi(); HttpResponse.builder().statusCode(206).build()).getServerApi();
api.editServer("xm3276891", EditServerOptions.Builder.description("this is a different description!"), api.update("xm3276891", UpdateServerOptions.Builder.description("this is a different description!").hostname("new-hostname"));
EditServerOptions.Builder.hostname("new-hostname"));
} }
@Test @Test
public void testEditServerWithOptsWhenResponseIs2xx() throws Exception { public void testUpdateServerWithOptsWhenResponseIs2xx() throws Exception {
ServerApi api = requestSendsResponse( ServerApi api = requestSendsResponse(
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/server/edit/format/json") HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/server/edit/format/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json")
@ -267,10 +266,10 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("hostname", "jclouds-test").build(), .addFormParam("hostname", "jclouds-test").build(),
HttpResponse.builder().statusCode(200).build()).getServerApi(); HttpResponse.builder().statusCode(200).build()).getServerApi();
EditServerOptions options = UpdateServerOptions options =
EditServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1).hostname("jclouds-test"); UpdateServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1).hostname("jclouds-test");
api.editServer("xm3276891", options); api.update("xm3276891", options);
} }
@Test @Test
@ -283,7 +282,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("hostname", "hostname1").build(), .addFormParam("hostname", "hostname1").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerApi();
assertEquals(api.cloneServer("xm3276891", "hostname1"), expectedServerDetails()); assertEquals(api.clone("xm3276891", "hostname1"), expectedServerDetails());
} }
@Test @Test
@ -301,7 +300,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerApi(); HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerApi();
CloneServerOptions options = (CloneServerOptions) CloneServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1); CloneServerOptions options = (CloneServerOptions) CloneServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1);
assertEquals(api.cloneServer("xm3276891", "hostname1", options), expectedServerDetails()); assertEquals(api.clone("xm3276891", "hostname1", options), expectedServerDetails());
} }
@Test(expectedExceptions = {ResourceNotFoundException.class}) @Test(expectedExceptions = {ResourceNotFoundException.class})
@ -314,7 +313,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
.addFormParam("hostname", "hostname1").build(), .addFormParam("hostname", "hostname1").build(),
HttpResponse.builder().statusCode(404).build()).getServerApi(); HttpResponse.builder().statusCode(404).build()).getServerApi();
api.cloneServer("xm3276891", "hostname1"); api.clone("xm3276891", "hostname1");
} }
public void testGetServerStatusWhenResponseIs2xx() throws Exception { public void testGetServerStatusWhenResponseIs2xx() throws Exception {
@ -326,7 +325,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json")).build()) HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json")).build())
.getServerApi(); .getServerApi();
assertEquals(api.getServerStatus("xm3276891"), expectedServerStatus()); assertEquals(api.getStatus("xm3276891"), expectedServerStatus());
} }
public void testGetServerStatusWithOptsWhenResponseIs2xx() throws Exception { public void testGetServerStatusWithOptsWhenResponseIs2xx() throws Exception {
@ -339,7 +338,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json")).build()) HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json")).build())
.getServerApi(); .getServerApi();
assertEquals(api.getServerStatus("server321", ServerStatusOptions.Builder.state()), expectedServerStatus()); assertEquals(api.getStatus("server321", ServerStatusOptions.Builder.state()), expectedServerStatus());
} }
public void testGetServerStatusWhenResponseIs4xx() throws Exception { public void testGetServerStatusWhenResponseIs4xx() throws Exception {
@ -352,7 +351,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(404).build()) HttpResponse.builder().statusCode(404).build())
.getServerApi(); .getServerApi();
assertNull(api.getServerStatus("server321", ServerStatusOptions.Builder.state())); assertNull(api.getStatus("server321", ServerStatusOptions.Builder.state()));
} }
public void testGetServerLimitsWhenResponseIs2xx() throws Exception { public void testGetServerLimitsWhenResponseIs2xx() throws Exception {
@ -364,7 +363,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_limits.json")).build()) HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_limits.json")).build())
.getServerApi(); .getServerApi();
api.getServerLimits("server321"); api.getLimits("server321");
} }
public void testGetConsoleWhenResponseIs2xx() throws Exception { public void testGetConsoleWhenResponseIs2xx() throws Exception {
@ -402,7 +401,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getServerApi(); .getServerApi();
api.startServer("server777"); api.start("server777");
} }
@Test(expectedExceptions = {AuthorizationException.class}) @Test(expectedExceptions = {AuthorizationException.class})
@ -415,7 +414,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(401).build()) HttpResponse.builder().statusCode(401).build())
.getServerApi(); .getServerApi();
api.startServer("server777"); api.start("server777");
} }
public void testStopServerWhenResponseIs2xx() throws Exception { public void testStopServerWhenResponseIs2xx() throws Exception {
@ -427,7 +426,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getServerApi(); .getServerApi();
api.stopServer("server777"); api.stop("server777");
} }
public void testHardStopServerWhenResponseIs2xx() throws Exception { public void testHardStopServerWhenResponseIs2xx() throws Exception {
@ -440,7 +439,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getServerApi(); .getServerApi();
api.hardStopServer("server777"); api.hardStop("server777");
} }
@Test(expectedExceptions = {AuthorizationException.class}) @Test(expectedExceptions = {AuthorizationException.class})
@ -453,7 +452,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(401).build()) HttpResponse.builder().statusCode(401).build())
.getServerApi(); .getServerApi();
api.stopServer("server777"); api.stop("server777");
} }
public void testRebootServerWhenResponseIs2xx() throws Exception { public void testRebootServerWhenResponseIs2xx() throws Exception {
@ -465,7 +464,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getServerApi(); .getServerApi();
api.rebootServer("server777"); api.reboot("server777");
} }
@Test(expectedExceptions = {AuthorizationException.class}) @Test(expectedExceptions = {AuthorizationException.class})
@ -478,7 +477,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(401).build()) HttpResponse.builder().statusCode(401).build())
.getServerApi(); .getServerApi();
api.rebootServer("server777"); api.reboot("server777");
} }
public void testDestroyServerWhenResponseIs2xx() throws Exception { public void testDestroyServerWhenResponseIs2xx() throws Exception {
@ -490,7 +489,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getServerApi(); .getServerApi();
api.destroyServer("server777", DestroyServerOptions.Builder.keepIp()); api.destroy("server777", DestroyServerOptions.Builder.keepIp());
} }
@Test(expectedExceptions = {AuthorizationException.class}) @Test(expectedExceptions = {AuthorizationException.class})
@ -503,7 +502,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
HttpResponse.builder().statusCode(401).build()) HttpResponse.builder().statusCode(401).build())
.getServerApi(); .getServerApi();
api.destroyServer("server777", DestroyServerOptions.Builder.discardIp()); api.destroy("server777", DestroyServerOptions.Builder.discardIp());
} }
public void testResourceUsageWhenResponseIs2xx() throws Exception { public void testResourceUsageWhenResponseIs2xx() throws Exception {

View File

@ -23,7 +23,6 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.glesys.domain.AllowedArgumentsForCreateServer; import org.jclouds.glesys.domain.AllowedArgumentsForCreateServer;
@ -38,14 +37,15 @@ import org.jclouds.glesys.domain.ServerStatus;
import org.jclouds.glesys.internal.BaseGleSYSApiWithAServerLiveTest; import org.jclouds.glesys.internal.BaseGleSYSApiWithAServerLiveTest;
import org.jclouds.glesys.options.CloneServerOptions; import org.jclouds.glesys.options.CloneServerOptions;
import org.jclouds.glesys.options.DestroyServerOptions; import org.jclouds.glesys.options.DestroyServerOptions;
import org.jclouds.glesys.options.EditServerOptions;
import org.jclouds.glesys.options.ServerStatusOptions; import org.jclouds.glesys.options.ServerStatusOptions;
import org.jclouds.glesys.options.UpdateServerOptions;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
/** /**
* Tests behavior of {@code ServerApi} * Tests behavior of {@code ServerApi}
@ -65,7 +65,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@AfterGroups(groups = {"live"}) @AfterGroups(groups = {"live"})
public void deleteExtraServer() { public void deleteExtraServer() {
if (testServerId2 != null) { if (testServerId2 != null) {
api.destroyServer(testServerId2, DestroyServerOptions.Builder.discardIp()); api.destroy(testServerId2, DestroyServerOptions.Builder.discardIp());
} }
} }
@ -79,7 +79,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@Test @Test
public void testAllowedArguments() throws Exception { public void testAllowedArguments() throws Exception {
Map<String,AllowedArgumentsForCreateServer> templates = api.getAllowedArgumentsForCreateServerByPlatform(); Map<String,AllowedArgumentsForCreateServer> templates = api.getAllowedArgumentsForCreateByPlatform();
assertTrue(templates.containsKey("OpenVZ")); assertTrue(templates.containsKey("OpenVZ"));
assertTrue(templates.containsKey("Xen")); assertTrue(templates.containsKey("Xen"));
@ -101,7 +101,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
} }
public void testListTemplates() throws Exception { public void testListTemplates() throws Exception {
Set<OSTemplate> oSTemplates = api.listTemplates(); FluentIterable<OSTemplate> oSTemplates = api.listTemplates();
for(OSTemplate oSTemplate : oSTemplates) { for(OSTemplate oSTemplate : oSTemplates) {
checkTemplate(oSTemplate); checkTemplate(oSTemplate);
@ -119,12 +119,12 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
} }
public void testListServers() throws Exception { public void testListServers() throws Exception {
Set<Server> response = api.listServers(); FluentIterable<Server> response = api.list();
assertNotNull(response); assertNotNull(response);
assertTrue(response.size() > 0); assertTrue(response.size() > 0);
for (Server server : response) { for (Server server : response) {
ServerDetails newDetails = api.getServerDetails(server.getId()); ServerDetails newDetails = api.get(server.getId());
assertEquals(newDetails.getId(), server.getId()); assertEquals(newDetails.getId(), server.getId());
assertEquals(newDetails.getHostname(), server.getHostname()); assertEquals(newDetails.getHostname(), server.getHostname());
assertEquals(newDetails.getPlatform(), server.getPlatform()); assertEquals(newDetails.getPlatform(), server.getPlatform());
@ -134,7 +134,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
} }
public void testServerDetails() throws Exception { public void testServerDetails() throws Exception {
ServerDetails details = api.getServerDetails(serverId); ServerDetails details = api.get(serverId);
checkServer(details); checkServer(details);
assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplateName()); assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplateName());
assertEquals("Falkenberg", details.getDatacenter()); assertEquals("Falkenberg", details.getDatacenter());
@ -146,22 +146,22 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
} }
public void testServerStatus() throws Exception { public void testServerStatus() throws Exception {
ServerStatus newStatus = api.getServerStatus(serverId); ServerStatus newStatus = api.getStatus(serverId);
checkStatus(newStatus); checkStatus(newStatus);
} }
public void testEditServer() throws Exception { public void testUpdateServer() throws Exception {
ServerDetails edited = api.editServer(serverId, EditServerOptions.Builder.description("this is a different description!")); ServerDetails edited = api.update(serverId, UpdateServerOptions.Builder.description("this is a different description!"));
assertEquals(edited.getDescription(), "this is a different description!"); assertEquals(edited.getDescription(), "this is a different description!");
edited = api.editServer(serverId, EditServerOptions.Builder.description("another description!"), EditServerOptions.Builder.hostname("host-name1")); edited = api.update(serverId, UpdateServerOptions.Builder.description("another description!").hostname("host-name1"));
assertEquals(edited.getDescription(), "another description!"); assertEquals(edited.getDescription(), "another description!");
assertEquals(edited.getHostname(), "host-name1"); assertEquals(edited.getHostname(), "host-name1");
edited = api.resetPassword(serverId, "anotherpass"); edited = api.resetPassword(serverId, "anotherpass");
assertEquals(edited.getHostname(), "host-name1"); assertEquals(edited.getHostname(), "host-name1");
edited = api.editServer(serverId, EditServerOptions.Builder.hostname(hostName)); edited = api.update(serverId, UpdateServerOptions.Builder.hostname(hostName));
assertEquals(edited.getHostname(), hostName); assertEquals(edited.getHostname(), hostName);
} }
@ -169,7 +169,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
public void testRebootServer() throws Exception { public void testRebootServer() throws Exception {
assertTrue(serverStatusChecker.apply(Server.State.RUNNING)); assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
api.rebootServer(serverId); api.reboot(serverId);
assertTrue(serverStatusChecker.apply(Server.State.RUNNING)); assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
} }
@ -178,17 +178,17 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
public void testStopAndStartServer() throws Exception { public void testStopAndStartServer() throws Exception {
assertTrue(serverStatusChecker.apply(Server.State.RUNNING)); assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
api.stopServer(serverId); api.stop(serverId);
assertTrue(serverStatusChecker.apply(Server.State.STOPPED)); assertTrue(serverStatusChecker.apply(Server.State.STOPPED));
api.startServer(serverId); api.start(serverId);
assertTrue(serverStatusChecker.apply(Server.State.RUNNING)); assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
} }
public void testServerLimits() throws Exception { public void testServerLimits() throws Exception {
Map<String, ServerLimit> limits = api.getServerLimits(serverId); Map<String, ServerLimit> limits = api.getLimits(serverId);
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());
@ -204,7 +204,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
public void testResourceUsage() throws Exception { public void testResourceUsage() throws Exception {
// test server has only been in existence for less than a minute - check all servers // test server has only been in existence for less than a minute - check all servers
for (Server server : api.listServers()) { for (Server server : api.list()) {
ResourceUsage usage = api.getResourceUsage(server.getId(), "diskioread", "minute"); ResourceUsage usage = api.getResourceUsage(server.getId(), "diskioread", "minute");
assertEquals(usage.getInfo().getResource(), "diskioread"); assertEquals(usage.getInfo().getResource(), "diskioread");
assertEquals(usage.getInfo().getResolution(), "minute"); assertEquals(usage.getInfo().getResolution(), "minute");
@ -226,7 +226,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
// takes a few minutes and requires an extra server (used 1 already) // takes a few minutes and requires an extra server (used 1 already)
@Test(enabled=false) @Test(enabled=false)
public void testCloneServer() throws Exception { public void testCloneServer() throws Exception {
ServerDetails testServer2 = api.cloneServer(serverId, testHostName2, CloneServerOptions.Builder.cpucores(1)); ServerDetails testServer2 = api.clone(serverId, testHostName2, CloneServerOptions.Builder.cpucores(1));
assertNotNull(testServer2.getId()); assertNotNull(testServer2.getId());
assertEquals(testServer2.getHostname(), "jclouds-test2"); assertEquals(testServer2.getHostname(), "jclouds-test2");
@ -237,19 +237,19 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
RetryablePredicate<Server.State> cloneChecker = new ServerStatusChecker(api, testServerId2, 300, 10, TimeUnit.SECONDS); RetryablePredicate<Server.State> cloneChecker = new ServerStatusChecker(api, testServerId2, 300, 10, TimeUnit.SECONDS);
assertTrue(cloneChecker.apply(Server.State.STOPPED)); assertTrue(cloneChecker.apply(Server.State.STOPPED));
api.startServer(testServer2.getId()); api.start(testServer2.getId());
// TODO ServerStatus==STOPPED suggests the previous call to start should have worked // TODO ServerStatus==STOPPED suggests the previous call to start should have worked
cloneChecker = new RetryablePredicate<Server.State>( cloneChecker = new RetryablePredicate<Server.State>(
new Predicate<Server.State>() { new Predicate<Server.State>() {
public boolean apply(Server.State value) { public boolean apply(Server.State value) {
ServerStatus status = api.getServerStatus(testServerId2, ServerStatusOptions.Builder.state()); ServerStatus status = api.getStatus(testServerId2, ServerStatusOptions.Builder.state());
if (status.getState() == value) { if (status.getState() == value) {
return true; return true;
} }
api.startServer(testServerId2); api.start(testServerId2);
return false; return false;
} }

View File

@ -56,11 +56,11 @@ public class BaseGleSYSApiLiveTest extends BaseComputeServiceContextLiveTest {
protected void createDomain(String domain) { protected void createDomain(String domain) {
final DomainApi api = gleContext.getApi().getDomainApi(); final DomainApi api = gleContext.getApi().getDomainApi();
int before = api.listDomains().size(); int before = api.list().size();
api.addDomain(domain); api.create(domain);
RetryablePredicate<Integer> result = new RetryablePredicate<Integer>(new Predicate<Integer>() { RetryablePredicate<Integer> result = new RetryablePredicate<Integer>(new Predicate<Integer>() {
public boolean apply(Integer value) { public boolean apply(Integer value) {
return api.listDomains().size() == value; return api.list().size() == value;
} }
}, 30, 1, TimeUnit.SECONDS); }, 30, 1, TimeUnit.SECONDS);

View File

@ -69,17 +69,17 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
@AfterGroups(groups = {"integration", "live"}) @AfterGroups(groups = {"integration", "live"})
@Override @Override
public final void tearDownContext() { public final void tearDownContext() {
gleContext.getApi().getServerApi().destroyServer(serverId, DestroyServerOptions.Builder.discardIp()); gleContext.getApi().getServerApi().destroy(serverId, DestroyServerOptions.Builder.discardIp());
super.tearDownContext(); super.tearDownContext();
} }
protected void createDomain(String domain) { protected void createDomain(String domain) {
final DomainApi api = gleContext.getApi().getDomainApi(); final DomainApi api = gleContext.getApi().getDomainApi();
int before = api.listDomains().size(); int before = api.list().size();
api.addDomain(domain); api.create(domain);
RetryablePredicate<Integer> result = new RetryablePredicate<Integer>(new Predicate<Integer>() { RetryablePredicate<Integer> result = new RetryablePredicate<Integer>(new Predicate<Integer>() {
public boolean apply(Integer value) { public boolean apply(Integer value) {
return api.listDomains().size() == value; return api.list().size() == value;
} }
}, 30, 1, TimeUnit.SECONDS); }, 30, 1, TimeUnit.SECONDS);
@ -89,7 +89,7 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
protected ServerStatusChecker createServer(String hostName) { protected ServerStatusChecker createServer(String hostName) {
ServerApi api = gleContext.getApi().getServerApi(); ServerApi api = gleContext.getApi().getServerApi();
ServerDetails testServer = api.createServerWithHostnameAndRootPassword( ServerDetails testServer = api.createWithHostnameAndRootPassword(
ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 10.04 LTS 32-bit") ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 10.04 LTS 32-bit")
.diskSizeGB(5).memorySizeMB(512).cpuCores(1).transferGB(50).build(), hostName, UUID.randomUUID() .diskSizeGB(5).memorySizeMB(512).cpuCores(1).transferGB(50).build(), hostName, UUID.randomUUID()
.toString().replace("-","")); .toString().replace("-",""));
@ -117,7 +117,7 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
super(new Predicate<Server.State>() { super(new Predicate<Server.State>() {
public boolean apply(Server.State value) { public boolean apply(Server.State value) {
ServerStatus status = api.getServerStatus(serverId, ServerStatusOptions.Builder.state()); ServerStatus status = api.getStatus(serverId, ServerStatusOptions.Builder.state());
return status.getState() == value; return status.getState() == value;
} }