mirror of https://github.com/apache/jclouds.git
conventions update for glesys
This commit is contained in:
parent
e4a41e49fa
commit
171c0804e0
|
@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.glesys.features.ArchiveApi;
|
||||
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.ServerApi;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
@ -67,6 +67,6 @@ public interface GleSYSApi {
|
|||
* Provides synchronous access to E-Mail features.
|
||||
*/
|
||||
@Delegate
|
||||
EmailApi getEmailApi();
|
||||
EmailAccountApi getEmailAccountApi();
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.glesys;
|
|||
|
||||
import org.jclouds.glesys.features.ArchiveAsyncApi;
|
||||
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.ServerAsyncApi;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
@ -63,6 +63,6 @@ public interface GleSYSAsyncApi {
|
|||
* Provides asynchronous access to E-Mail features.
|
||||
*/
|
||||
@Delegate
|
||||
EmailAsyncApi getEmailApi();
|
||||
EmailAccountAsyncApi getEmailAccountApi();
|
||||
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
|
|||
// and set if present
|
||||
|
||||
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);
|
||||
logger.trace("<< server(%s)", result.getId());
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
|
|||
Set<OSTemplate> images = listImages();
|
||||
|
||||
for (Entry<String, AllowedArgumentsForCreateServer> platformToArgs : api.getServerApi()
|
||||
.getAllowedArgumentsForCreateServerByPlatform().entrySet())
|
||||
.getAllowedArgumentsForCreateByPlatform().entrySet())
|
||||
for (String datacenter : platformToArgs.getValue().getDataCenters())
|
||||
for (int diskSizeGB : platformToArgs.getValue().getDiskSizesInGB())
|
||||
for (int cpuCores : platformToArgs.getValue().getCpuCoreOptions())
|
||||
|
@ -192,7 +192,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
|
|||
|
||||
@Override
|
||||
public Set<OSTemplate> listImages() {
|
||||
return api.getServerApi().listTemplates();
|
||||
return api.getServerApi().listTemplates().toImmutableSet();
|
||||
}
|
||||
|
||||
// cheat until we have a getTemplate command
|
||||
|
@ -210,10 +210,10 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
|
|||
|
||||
@Override
|
||||
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
|
||||
public Future<ServerDetails> apply(Server from) {
|
||||
return aapi.getServerApi().getServerDetails(from.getId());
|
||||
return aapi.getServerApi().get(from.getId());
|
||||
}
|
||||
|
||||
}, userThreads, null, logger, "server details"));
|
||||
|
@ -222,7 +222,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
|
|||
@Override
|
||||
public Set<String> listLocations() {
|
||||
return ImmutableSet.copyOf(Iterables.concat(Iterables.transform(api.getServerApi()
|
||||
.getAllowedArgumentsForCreateServerByPlatform().values(),
|
||||
.getAllowedArgumentsForCreateByPlatform().values(),
|
||||
new Function<AllowedArgumentsForCreateServer, Set<String>>() {
|
||||
|
||||
@Override
|
||||
|
@ -235,7 +235,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
|
|||
|
||||
@Override
|
||||
public ServerDetails getNode(String id) {
|
||||
return api.getServerApi().getServerDetails(id);
|
||||
return api.getServerApi().get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -245,7 +245,7 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
|
|||
@Override
|
||||
public boolean apply(String arg0) {
|
||||
try {
|
||||
api.getServerApi().destroyServer(arg0, DestroyServerOptions.Builder.discardIp());
|
||||
api.getServerApi().destroy(arg0, DestroyServerOptions.Builder.discardIp());
|
||||
return true;
|
||||
} catch (IllegalStateException e) {
|
||||
return false;
|
||||
|
@ -257,16 +257,16 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
|
|||
|
||||
@Override
|
||||
public void rebootNode(String id) {
|
||||
api.getServerApi().rebootServer(id);
|
||||
api.getServerApi().reboot(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeNode(String id) {
|
||||
api.getServerApi().startServer(id);
|
||||
api.getServerApi().start(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suspendNode(String id) {
|
||||
api.getServerApi().stopServer(id);
|
||||
api.getServerApi().stop(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class GleSYSTemplateOptions extends TemplateOptions implements Cloneable
|
|||
|
||||
/**
|
||||
*
|
||||
* @see ServerApi#createServerWithHostnameAndRootPassword
|
||||
* @see ServerApi#createWithHostnameAndRootPassword
|
||||
* @see InetAddresses#isInetAddress
|
||||
*/
|
||||
public TemplateOptions ip(String ip) {
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.jclouds.glesys.features.ArchiveApi;
|
|||
import org.jclouds.glesys.features.ArchiveAsyncApi;
|
||||
import org.jclouds.glesys.features.DomainApi;
|
||||
import org.jclouds.glesys.features.DomainAsyncApi;
|
||||
import org.jclouds.glesys.features.EmailApi;
|
||||
import org.jclouds.glesys.features.EmailAsyncApi;
|
||||
import org.jclouds.glesys.features.EmailAccountApi;
|
||||
import org.jclouds.glesys.features.EmailAccountAsyncApi;
|
||||
import org.jclouds.glesys.features.IpApi;
|
||||
import org.jclouds.glesys.features.IpAsyncApi;
|
||||
import org.jclouds.glesys.features.ServerApi;
|
||||
|
@ -60,7 +60,7 @@ public class GleSYSRestClientModule extends RestClientModule<GleSYSApi, GleSYSAs
|
|||
.put(IpApi.class, IpAsyncApi.class)//
|
||||
.put(ArchiveApi.class, ArchiveAsyncApi.class)//
|
||||
.put(DomainApi.class, DomainAsyncApi.class)//
|
||||
.put(EmailApi.class, EmailAsyncApi.class)//
|
||||
.put(EmailAccountApi.class, EmailAccountAsyncApi.class)//
|
||||
.build();
|
||||
|
||||
public GleSYSRestClientModule() {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ArchiveAllowedArguments {
|
|||
protected List<Integer> archiveSizes = ImmutableList.of();
|
||||
|
||||
/**
|
||||
* @see ArchiveAllowedArguments#getArchiveSizes()
|
||||
* @see ArchiveAllowedArguments#getSizes()
|
||||
*/
|
||||
public T archiveSizes(List<Integer> archiveSizes) {
|
||||
this.archiveSizes = ImmutableList.copyOf(checkNotNull(archiveSizes, "archiveSizes"));
|
||||
|
@ -65,7 +65,7 @@ public class ArchiveAllowedArguments {
|
|||
}
|
||||
|
||||
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
|
||||
*/
|
||||
public List<Integer> getArchiveSizes() {
|
||||
public List<Integer> getSizes() {
|
||||
return this.archiveSizes;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class Domain {
|
|||
protected int minimum;
|
||||
|
||||
/**
|
||||
* @see Domain#getDomainName()
|
||||
* @see Domain#getName()
|
||||
*/
|
||||
public T domainName(String domainName) {
|
||||
this.domainName = checkNotNull(domainName, "domainName");
|
||||
|
@ -152,7 +152,7 @@ public class Domain {
|
|||
}
|
||||
|
||||
public T fromDomain(Domain in) {
|
||||
return this.domainName(in.getDomainName())
|
||||
return this.domainName(in.getName())
|
||||
.createTime(in.getCreateTime())
|
||||
.recordCount(in.getRecordCount())
|
||||
.useGlesysNameServer(in.isUseGlesysNameServer())
|
||||
|
@ -207,7 +207,7 @@ public class Domain {
|
|||
/**
|
||||
* @return the domain name, ex. "jclouds.org"
|
||||
*/
|
||||
public String getDomainName() {
|
||||
public String getName() {
|
||||
return this.domainName;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class DomainRecord {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see DomainRecord#getDomainname()
|
||||
* @see DomainRecord#getname()
|
||||
*/
|
||||
public T domainname(String domainname) {
|
||||
this.domainname = checkNotNull(domainname, "domainname");
|
||||
|
@ -107,7 +107,7 @@ public class DomainRecord {
|
|||
|
||||
public T fromDomainRecord(DomainRecord in) {
|
||||
return this.id(in.getId())
|
||||
.domainname(in.getDomainname())
|
||||
.domainname(in.getname())
|
||||
.host(in.getHost())
|
||||
.type(in.getType())
|
||||
.data(in.getData())
|
||||
|
@ -152,7 +152,7 @@ public class DomainRecord {
|
|||
/**
|
||||
* @return the zone content of the record
|
||||
*/
|
||||
public String getDomainname() {
|
||||
public String getname() {
|
||||
return this.domainname;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class EmailOverview {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see EmailOverview#getDomains()
|
||||
* @see EmailOverview#gets()
|
||||
*/
|
||||
public T domains(Set<EmailOverviewDomain> domains) {
|
||||
this.domains = ImmutableSet.copyOf(checkNotNull(domains, "domains"));
|
||||
|
@ -77,7 +77,7 @@ public class EmailOverview {
|
|||
}
|
||||
|
||||
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
|
||||
*/
|
||||
public Set<EmailOverviewDomain> getDomains() {
|
||||
public Set<EmailOverviewDomain> gets() {
|
||||
return this.domains;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class EmailOverviewDomain {
|
|||
protected int aliases;
|
||||
|
||||
/**
|
||||
* @see EmailOverviewDomain#getDomain()
|
||||
* @see EmailOverviewDomain#get()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = checkNotNull(domain, "domain");
|
||||
|
@ -79,7 +79,7 @@ public class EmailOverviewDomain {
|
|||
}
|
||||
|
||||
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 */
|
||||
public String getDomain() {
|
||||
public String get() {
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,13 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.glesys.features;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.glesys.domain.Archive;
|
||||
import org.jclouds.glesys.domain.ArchiveAllowedArguments;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Archive requests.
|
||||
* <p/>
|
||||
|
@ -39,7 +40,7 @@ public interface ArchiveApi {
|
|||
/**
|
||||
* Lists all active disks on this account.
|
||||
*/
|
||||
Set<Archive> listArchives();
|
||||
FluentIterable<Archive> list();
|
||||
|
||||
/**
|
||||
* Get detailed information about an archive volume.
|
||||
|
@ -47,7 +48,7 @@ public interface ArchiveApi {
|
|||
* @param username the username associated with the archive
|
||||
* @return the archive information or null if not found
|
||||
*/
|
||||
Archive getArchive(String username);
|
||||
Archive get(String username);
|
||||
|
||||
/**
|
||||
* Create a new backup volume.
|
||||
|
@ -57,14 +58,14 @@ public interface ArchiveApi {
|
|||
* @param password the new password
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
|
@ -72,9 +73,9 @@ public interface ArchiveApi {
|
|||
* Then delete the old volume.
|
||||
*
|
||||
* @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.
|
||||
|
@ -82,11 +83,11 @@ public interface ArchiveApi {
|
|||
* @param username the archive username
|
||||
* @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.
|
||||
*/
|
||||
ArchiveAllowedArguments getArchiveAllowedArguments();
|
||||
ArchiveAllowedArguments getAllowedArguments();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.glesys.features;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.FormParam;
|
||||
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.RequestFilters;
|
||||
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 com.google.common.collect.FluentIterable;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
|
@ -50,67 +49,67 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
public interface ArchiveAsyncApi {
|
||||
|
||||
/**
|
||||
* @see ArchiveApi#listArchives
|
||||
* @see ArchiveApi#list
|
||||
*/
|
||||
@POST
|
||||
@Path("/archive/list/format/json")
|
||||
@SelectJson("archives")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<Archive>> listArchives();
|
||||
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
|
||||
ListenableFuture<FluentIterable<Archive>> list();
|
||||
|
||||
/**
|
||||
* @see ArchiveApi#getArchive
|
||||
* @see ArchiveApi#get
|
||||
*/
|
||||
@POST
|
||||
@Path("/archive/details/format/json")
|
||||
@SelectJson("details")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Archive> getArchive(@FormParam("username") String username);
|
||||
ListenableFuture<Archive> get(@FormParam("username") String username);
|
||||
|
||||
/**
|
||||
* @see ArchiveApi#createArchive
|
||||
* @see ArchiveApi#createWithCredentialsAndSize
|
||||
*/
|
||||
@POST
|
||||
@Path("/archive/create/format/json")
|
||||
@SelectJson("details")
|
||||
@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);
|
||||
|
||||
/**
|
||||
* @see ArchiveApi#deleteArchive
|
||||
* @see ArchiveApi#delete
|
||||
*/
|
||||
@POST
|
||||
@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
|
||||
@Path("/archive/resize/format/json")
|
||||
@SelectJson("details")
|
||||
@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
|
||||
@Path("/archive/changepassword/format/json")
|
||||
@SelectJson("details")
|
||||
@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
|
||||
@Path("/archive/allowedarguments/format/json")
|
||||
@SelectJson("argumentslist")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ArchiveAllowedArguments> getArchiveAllowedArguments();
|
||||
ListenableFuture<ArchiveAllowedArguments> getAllowedArguments();
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,9 @@ import org.jclouds.glesys.domain.DomainRecord;
|
|||
import org.jclouds.glesys.options.AddDomainOptions;
|
||||
import org.jclouds.glesys.options.AddRecordOptions;
|
||||
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.
|
||||
|
@ -45,14 +47,14 @@ public interface DomainApi {
|
|||
*
|
||||
* @return an account's associated domain objects.
|
||||
*/
|
||||
Set<Domain> listDomains();
|
||||
FluentIterable<Domain> list();
|
||||
|
||||
/**
|
||||
* Get a specific domain.
|
||||
*
|
||||
* @return the requested domain object.
|
||||
*/
|
||||
Domain getDomain(String domain);
|
||||
Domain get(String domain);
|
||||
|
||||
/**
|
||||
* Add a domain to the Glesys dns-system
|
||||
|
@ -61,23 +63,23 @@ public interface DomainApi {
|
|||
* @param options optional parameters
|
||||
* @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 options optional parameters
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
|
@ -92,7 +94,7 @@ public interface DomainApi {
|
|||
* @param domain the domain to add the record to
|
||||
* @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
|
||||
|
@ -101,7 +103,7 @@ public interface DomainApi {
|
|||
* @param options the settings to change
|
||||
* @see #listRecords to retrieve the necessary ids
|
||||
*/
|
||||
DomainRecord editRecord(String recordId, EditRecordOptions... options);
|
||||
DomainRecord updateRecord(String recordId, UpdateRecordOptions options);
|
||||
|
||||
/**
|
||||
* Delete a DNS record
|
||||
|
|
|
@ -31,14 +31,15 @@ import org.jclouds.glesys.domain.DomainRecord;
|
|||
import org.jclouds.glesys.options.AddDomainOptions;
|
||||
import org.jclouds.glesys.options.AddRecordOptions;
|
||||
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.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnEmptyFluentIterableOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
|
@ -53,50 +54,50 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
public interface DomainAsyncApi {
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.features.DomainApi#listDomains
|
||||
* @see org.jclouds.glesys.features.DomainApi#list
|
||||
*/
|
||||
@POST
|
||||
@Path("/domain/list/format/json")
|
||||
@SelectJson("domains")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<Domain>> listDomains();
|
||||
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
|
||||
ListenableFuture<FluentIterable<Domain>> list();
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.features.DomainApi#getDomain
|
||||
* @see org.jclouds.glesys.features.DomainApi#get
|
||||
*/
|
||||
@POST
|
||||
@Path("/domain/details/format/json")
|
||||
@SelectJson("domain")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Domain> getDomain(@FormParam("domainname") String name);
|
||||
ListenableFuture<Domain> get(@FormParam("domainname") String name);
|
||||
|
||||
/**
|
||||
* @see DomainApi#addDomain
|
||||
* @see DomainApi#create
|
||||
*/
|
||||
@POST
|
||||
@Path("/domain/add/format/json")
|
||||
@SelectJson("domain")
|
||||
@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
|
||||
@Path("/domain/edit/format/json")
|
||||
@SelectJson("domain")
|
||||
@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
|
||||
@Path("/domain/delete/format/json")
|
||||
ListenableFuture<Void> deleteDomain(@FormParam("domainname") String domain);
|
||||
ListenableFuture<Void> delete(@FormParam("domainname") String domain);
|
||||
|
||||
/**
|
||||
* @see DomainApi#listRecords
|
||||
|
@ -108,24 +109,24 @@ public interface DomainAsyncApi {
|
|||
ListenableFuture<Set<DomainRecord>> listRecords(@FormParam("domainname") String domain);
|
||||
|
||||
/**
|
||||
* @see DomainApi#addRecord
|
||||
* @see DomainApi#createRecord
|
||||
*/
|
||||
@POST
|
||||
@Path("/domain/addrecord/format/json")
|
||||
@SelectJson("record")
|
||||
@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,
|
||||
AddRecordOptions... options);
|
||||
|
||||
/**
|
||||
* @see DomainApi#editRecord
|
||||
* @see DomainApi#updateRecord
|
||||
*/
|
||||
@POST
|
||||
@Path("/domain/updaterecord/format/json")
|
||||
@SelectJson("record")
|
||||
@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
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.glesys.features;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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.EmailOverview;
|
||||
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.
|
||||
* <p/>
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see org.jclouds.glesys.features.EmailAsyncApi
|
||||
* @see org.jclouds.glesys.features.EmailAccountAsyncApi
|
||||
* @see <a href="https://customer.glesys.com/api.php" />
|
||||
*/
|
||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||
public interface EmailApi {
|
||||
public interface EmailAccountApi {
|
||||
|
||||
/**
|
||||
* Get a summary of e-mail accounts associated with this Glesys account
|
||||
*
|
||||
* @return the relevant summary data
|
||||
*/
|
||||
EmailOverview getEmailOverview();
|
||||
EmailOverview getOverview();
|
||||
|
||||
/**
|
||||
* Get the set of detailed information about e-mail accounts
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @return the relevant set of details
|
||||
*/
|
||||
Set<EmailAlias> listAliases(String domain);
|
||||
FluentIterable<EmailAlias> listAliasesInDomain(String domain);
|
||||
|
||||
/**
|
||||
* 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 password the password to use for the mailbox
|
||||
* @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
|
||||
*
|
||||
* @param aliasAddress the address to use for the alias (the domain should already exist)
|
||||
* @param toEmailAddress the existing e-mail account address the alias should forward to
|
||||
* @see DomainApi#addDomain
|
||||
* @see DomainApi#create
|
||||
*/
|
||||
EmailAlias createAlias(String aliasAddress, String toEmailAddress);
|
||||
|
||||
|
@ -85,7 +86,7 @@ public interface EmailApi {
|
|||
* @param accountAddress the existing e-mail account address
|
||||
* @param options optional parameters
|
||||
*/
|
||||
EmailAccount editAccount(String accountAddress, EditAccountOptions... options);
|
||||
EmailAccount update(String accountAddress, UpdateAccountOptions... options);
|
||||
|
||||
/**
|
||||
* Adjust (re-target) an e-mail alias
|
||||
|
@ -93,7 +94,7 @@ public interface EmailApi {
|
|||
* @param aliasAddress the existing alias e-mail address
|
||||
* @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
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.glesys.features;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.FormParam;
|
||||
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.EmailOverview;
|
||||
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.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnEmptyFluentIterableOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
|
@ -45,53 +44,53 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* <p/>
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see org.jclouds.glesys.features.EmailApi
|
||||
* @see org.jclouds.glesys.features.EmailAccountApi
|
||||
* @see <a href="https://customer.glesys.com/api.php" />
|
||||
*/
|
||||
@RequestFilters(BasicAuthentication.class)
|
||||
public interface EmailAsyncApi {
|
||||
public interface EmailAccountAsyncApi {
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.features.EmailApi#getEmailOverview
|
||||
* @see org.jclouds.glesys.features.EmailAccountApi#getOverview
|
||||
*/
|
||||
@POST
|
||||
@Path("/email/overview/format/json")
|
||||
@SelectJson("overview")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<EmailOverview> getEmailOverview();
|
||||
ListenableFuture<EmailOverview> getOverview();
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.features.EmailApi#listAccounts
|
||||
* @see org.jclouds.glesys.features.EmailAccountApi#listDomain
|
||||
*/
|
||||
@POST
|
||||
@Path("/email/list/format/json")
|
||||
@SelectJson("emailaccounts")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<EmailAccount>> listAccounts(@FormParam("domainname") String domain);
|
||||
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
|
||||
ListenableFuture<FluentIterable<EmailAccount>> listDomain(@FormParam("domainname") String domain);
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.features.EmailApi#listAccounts
|
||||
* @see org.jclouds.glesys.features.EmailAccountApi#listAliasesInDomain
|
||||
*/
|
||||
@POST
|
||||
@Path("/email/list/format/json")
|
||||
@SelectJson("emailaliases")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<EmailAlias>> listAliases(@FormParam("domainname") String domain);
|
||||
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
|
||||
ListenableFuture<FluentIterable<EmailAlias>> listAliasesInDomain(@FormParam("domainname") String domain);
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.features.EmailApi#createAccount
|
||||
* @see org.jclouds.glesys.features.EmailAccountApi#createWithPassword
|
||||
*/
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@SelectJson("emailaccount")
|
||||
@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
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
|
@ -100,25 +99,25 @@ public interface EmailAsyncApi {
|
|||
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
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@SelectJson("emailaccount")
|
||||
@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
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@SelectJson("alias")
|
||||
@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
|
||||
@Path("/email/delete/format/json")
|
|
@ -18,13 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.glesys.features;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.glesys.domain.IpDetails;
|
||||
import org.jclouds.glesys.options.ListIpOptions;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to IP Addresses.
|
||||
* <p/>
|
||||
|
@ -43,7 +44,7 @@ public interface IpApi {
|
|||
* @param platform the platform
|
||||
* @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().
|
||||
|
@ -67,7 +68,7 @@ public interface IpApi {
|
|||
* @param options options to filter the results (by IPV4/6, serverId, etc)
|
||||
* @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
|
||||
|
@ -76,7 +77,7 @@ public interface IpApi {
|
|||
* @param ipAddress the 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
|
||||
|
@ -87,27 +88,27 @@ public interface IpApi {
|
|||
* @param ipAddress the IP address to remove
|
||||
* @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
|
||||
* 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 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.
|
||||
*
|
||||
* @param ipAddress the IP address to remove
|
||||
* @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
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.glesys.features;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.FormParam;
|
||||
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.RequestFilters;
|
||||
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 com.google.common.collect.FluentIterable;
|
||||
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")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@SelectJson("ipaddresses")
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<String>> listFree(@PathParam("ipversion") int ipversion,
|
||||
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
|
||||
ListenableFuture<FluentIterable<String>> listFree(@PathParam("ipversion") int ipversion,
|
||||
@PathParam("datacenter") String datacenter,
|
||||
@PathParam("platform") String platform);
|
||||
|
||||
|
@ -81,54 +80,54 @@ public interface IpAsyncApi {
|
|||
ListenableFuture<IpDetails> release(@FormParam("ipaddress") String ipAddress);
|
||||
|
||||
/**
|
||||
* @see IpApi#listIps
|
||||
* @see IpApi#list
|
||||
*/
|
||||
@GET
|
||||
@Path("/ip/listown/format/json")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@SelectJson("iplist")
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<IpDetails>> listIps(ListIpOptions... options);
|
||||
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
|
||||
ListenableFuture<FluentIterable<IpDetails>> list(ListIpOptions... options);
|
||||
|
||||
/**
|
||||
* @see IpApi#getIp
|
||||
* @see IpApi#get
|
||||
*/
|
||||
@GET
|
||||
@Path("/ip/details/ipaddress/{ipaddress}/format/json")
|
||||
@SelectJson("details")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<IpDetails> getIp(@PathParam("ipaddress") String ipAddress);
|
||||
ListenableFuture<IpDetails> get(@PathParam("ipaddress") String ipAddress);
|
||||
|
||||
/**
|
||||
* @see IpApi#addIpToServer
|
||||
* @see IpApi#addToServer
|
||||
*/
|
||||
@POST
|
||||
@Path("/ip/add/format/json")
|
||||
@SelectJson("details")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<IpDetails> addIpToServer(@FormParam("ipaddress") String ipAddress,
|
||||
ListenableFuture<IpDetails> addToServer(@FormParam("ipaddress") String ipAddress,
|
||||
@FormParam("serverid") String serverId);
|
||||
|
||||
/**
|
||||
* @see IpApi#removeIpFromServer
|
||||
* @see IpApi#removeFromServer
|
||||
*/
|
||||
@POST
|
||||
@Path("/ip/remove/format/json")
|
||||
@SelectJson("details")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<IpDetails> removeIpFromServer(@FormParam("ipaddress") String ipAddress,
|
||||
ListenableFuture<IpDetails> removeFromServer(@FormParam("ipaddress") String ipAddress,
|
||||
@FormParam("serverid") String serverId);
|
||||
|
||||
/**
|
||||
* @see IpApi#removeIpFromServer
|
||||
* @see IpApi#removeFromServer
|
||||
*/
|
||||
@POST
|
||||
@FormParams(keys = "release", values = "true")
|
||||
@Path("/ip/remove/format/json")
|
||||
@SelectJson("details")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<IpDetails> removeIpFromServerAndRelease(@FormParam("ipaddress") String ipAddress,
|
||||
ListenableFuture<IpDetails> removeFromServerAndRelease(@FormParam("ipaddress") String ipAddress,
|
||||
@FormParam("serverid") String serverId);
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.glesys.features;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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.CreateServerOptions;
|
||||
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 com.google.common.annotations.Beta;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Server.
|
||||
|
@ -57,7 +57,7 @@ public interface ServerApi {
|
|||
*
|
||||
* @return an account's associated server objects.
|
||||
*/
|
||||
Set<Server> listServers();
|
||||
FluentIterable<Server> list();
|
||||
|
||||
/**
|
||||
* Get detailed information about a server such as hostname, hardware
|
||||
|
@ -67,7 +67,7 @@ public interface ServerApi {
|
|||
* @param id id of the server
|
||||
* @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
|
||||
|
@ -77,7 +77,7 @@ public interface ServerApi {
|
|||
* @param options optional parameters
|
||||
* @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).
|
||||
|
@ -86,7 +86,7 @@ public interface ServerApi {
|
|||
* @param id id of the server
|
||||
* @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
|
||||
|
@ -101,14 +101,14 @@ public interface ServerApi {
|
|||
*
|
||||
* @return the set of information about each template
|
||||
*/
|
||||
Set<OSTemplate> listTemplates();
|
||||
FluentIterable<OSTemplate> listTemplates();
|
||||
|
||||
/**
|
||||
* Get information about valid arguments to #createServer for each 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).
|
||||
|
@ -116,35 +116,35 @@ public interface ServerApi {
|
|||
* @param id id of the server
|
||||
* @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
|
||||
*
|
||||
* @param id id of the server
|
||||
*/
|
||||
ServerDetails rebootServer(String id);
|
||||
ServerDetails reboot(String id);
|
||||
|
||||
/**
|
||||
* Start a server
|
||||
*
|
||||
* @param id id of the server
|
||||
*/
|
||||
ServerDetails startServer(String id);
|
||||
ServerDetails start(String id);
|
||||
|
||||
/**
|
||||
* Stop a server
|
||||
*
|
||||
* @param id id of the server
|
||||
*/
|
||||
ServerDetails stopServer(String id);
|
||||
ServerDetails stop(String id);
|
||||
|
||||
/**
|
||||
* hard stop a server
|
||||
*
|
||||
* @param id id of the server
|
||||
*/
|
||||
ServerDetails hardStopServer(String id);
|
||||
ServerDetails hardStop(String id);
|
||||
|
||||
/**
|
||||
* Create a new server
|
||||
|
@ -154,16 +154,16 @@ public interface ServerApi {
|
|||
* @param options optional settings ex. description
|
||||
*/
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
ServerDetails createServerWithHostnameAndRootPassword(ServerSpec serverSpec, String hostname, String rootPassword,
|
||||
ServerDetails createWithHostnameAndRootPassword(ServerSpec serverSpec, String hostname, String rootPassword,
|
||||
CreateServerOptions... options);
|
||||
|
||||
/**
|
||||
* Edit the configuration of a server
|
||||
* Update the configuration of a server
|
||||
*
|
||||
* @param serverid the serverId of the server to edit
|
||||
* @param options the settings to change
|
||||
*/
|
||||
ServerDetails editServer(String serverid, EditServerOptions... options);
|
||||
ServerDetails update(String serverid, UpdateServerOptions options);
|
||||
|
||||
/**
|
||||
* Clone a server
|
||||
|
@ -173,7 +173,7 @@ public interface ServerApi {
|
|||
* @param options the settings to change
|
||||
*/
|
||||
@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
|
||||
|
@ -181,7 +181,7 @@ public interface ServerApi {
|
|||
* @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
|
||||
*/
|
||||
ServerDetails destroyServer(String id, DestroyServerOptions keepIp);
|
||||
ServerDetails destroy(String id, DestroyServerOptions keepIp);
|
||||
|
||||
/**
|
||||
* Reset the root password of a server
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.glesys.features;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
|
||||
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.CreateServerOptions;
|
||||
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.http.filters.BasicAuthentication;
|
||||
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.ResponseParser;
|
||||
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 com.google.common.collect.FluentIterable;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
|
@ -70,17 +70,17 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
public interface ServerAsyncApi {
|
||||
|
||||
/**
|
||||
* @see ServerApi#listServers
|
||||
* @see ServerApi#list
|
||||
*/
|
||||
@POST
|
||||
@Path("/server/list/format/json")
|
||||
@SelectJson("servers")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<Server>> listServers();
|
||||
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
|
||||
ListenableFuture<FluentIterable<Server>> list();
|
||||
|
||||
/**
|
||||
* @see ServerApi#getServerDetails
|
||||
* @see ServerApi#get
|
||||
*/
|
||||
@POST
|
||||
@Path("/server/details/format/json")
|
||||
|
@ -88,27 +88,27 @@ public interface ServerAsyncApi {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@FormParams(keys = "includestate", values = "true")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<ServerDetails> getServerDetails(@FormParam("serverid") String id);
|
||||
ListenableFuture<ServerDetails> get(@FormParam("serverid") String id);
|
||||
|
||||
/**
|
||||
* @see ServerApi#getServerStatus
|
||||
* @see ServerApi#getStatus
|
||||
*/
|
||||
@POST
|
||||
@Path("/server/status/format/json")
|
||||
@SelectJson("server")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@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
|
||||
@Path("/server/limits/format/json")
|
||||
@SelectJson("limits")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<SortedMap<String, ServerLimit>> getServerLimits(@FormParam("serverid") String id);
|
||||
ListenableFuture<SortedMap<String, ServerLimit>> getLimits(@FormParam("serverid") String id);
|
||||
|
||||
/**
|
||||
* @see ServerApi#getConsole
|
||||
|
@ -121,13 +121,13 @@ public interface ServerAsyncApi {
|
|||
ListenableFuture<Console> getConsole(@FormParam("serverid") String id);
|
||||
|
||||
/**
|
||||
* @see ServerApi#getAllowedArgumentsForCreateServerByPlatform
|
||||
* @see ServerApi#getAllowedArgumentsForCreateByPlatform
|
||||
*/
|
||||
@GET
|
||||
@Path("/server/allowedarguments/format/json")
|
||||
@SelectJson("argumentslist")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<Map<String, AllowedArgumentsForCreateServer>> getAllowedArgumentsForCreateServerByPlatform();
|
||||
ListenableFuture<Map<String, AllowedArgumentsForCreateServer>> getAllowedArgumentsForCreateByPlatform();
|
||||
|
||||
/**
|
||||
* @see ServerApi#listTemplates
|
||||
|
@ -135,92 +135,93 @@ public interface ServerAsyncApi {
|
|||
@GET
|
||||
@Path("/server/templates/format/json")
|
||||
@ResponseParser(ParseTemplatesFromHttpResponse.class)
|
||||
@ExceptionParser(ReturnEmptyFluentIterableOnNotFoundOr404.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<Set<OSTemplate>> listTemplates();
|
||||
ListenableFuture<FluentIterable<OSTemplate>> listTemplates();
|
||||
|
||||
/**
|
||||
* @see ServerApi#stopServer
|
||||
* @see ServerApi#stop
|
||||
*/
|
||||
@POST
|
||||
@Path("/server/resetlimit/format/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);
|
||||
|
||||
/**
|
||||
* @see ServerApi#rebootServer
|
||||
* @see ServerApi#reboot
|
||||
*/
|
||||
@POST
|
||||
@SelectJson("server")
|
||||
@Path("/server/reboot/format/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
|
||||
@SelectJson("server")
|
||||
@Path("/server/start/format/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
|
||||
@SelectJson("server")
|
||||
@Path("/server/stop/format/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
|
||||
@SelectJson("server")
|
||||
@Path("/server/stop/format/json")
|
||||
@FormParams(keys = "type", values = "hard")
|
||||
@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
|
||||
@SelectJson("server")
|
||||
@Path("/server/create/format/json")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@MapBinder(CreateServerOptions.class)
|
||||
ListenableFuture<ServerDetails> createServerWithHostnameAndRootPassword(ServerSpec serverSpec,
|
||||
ListenableFuture<ServerDetails> createWithHostnameAndRootPassword(ServerSpec serverSpec,
|
||||
@PayloadParam("hostname") String hostname, @PayloadParam("rootpassword") String rootPassword,
|
||||
CreateServerOptions... options);
|
||||
|
||||
/**
|
||||
* @see ServerApi#cloneServer
|
||||
* @see ServerApi#clone
|
||||
*/
|
||||
@POST
|
||||
@Path("/server/clone/format/json")
|
||||
@SelectJson("server")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
ListenableFuture<ServerDetails> cloneServer(@FormParam("serverid") String serverid,
|
||||
ListenableFuture<ServerDetails> clone(@FormParam("serverid") String serverid,
|
||||
@FormParam("hostname") String hostname, CloneServerOptions... options);
|
||||
|
||||
/**
|
||||
* @see ServerApi#editServer
|
||||
* @see ServerApi#update
|
||||
*/
|
||||
@POST
|
||||
@Path("/server/edit/format/json")
|
||||
@SelectJson("server")
|
||||
@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
|
||||
@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
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
|||
import org.jclouds.json.internal.GsonWrapper;
|
||||
|
||||
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.inject.Inject;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
@ -40,7 +40,7 @@ import com.google.inject.TypeLiteral;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@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;
|
||||
|
||||
@Inject
|
||||
|
@ -50,10 +50,10 @@ public class ParseTemplatesFromHttpResponse implements Function<HttpResponse, Se
|
|||
}, "templates");
|
||||
}
|
||||
|
||||
public Set<OSTemplate> apply(HttpResponse response) {
|
||||
public FluentIterable<OSTemplate> apply(HttpResponse response) {
|
||||
checkNotNull(response, "response");
|
||||
Map<String, Set<OSTemplate>> toParse = parser.apply(response);
|
||||
checkNotNull(toParse, "parsed result from %s", response);
|
||||
return ImmutableSet.copyOf(Iterables.concat(toParse.values()));
|
||||
return FluentIterable.from(Iterables.concat(toParse.values()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.jclouds.glesys.options;
|
|||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
public class CloneServerOptions extends EditServerOptions {
|
||||
public class CloneServerOptions extends UpdateServerOptions {
|
||||
public static class Builder {
|
||||
/**
|
||||
* @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) {
|
||||
return CloneServerOptions.class.cast(new CloneServerOptions().description(description));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -21,54 +21,59 @@ package org.jclouds.glesys.options;
|
|||
/**
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
public class EditRecordOptions extends AddRecordOptions {
|
||||
public class UpdateRecordOptions extends AddRecordOptions {
|
||||
|
||||
public static class Builder {
|
||||
/**
|
||||
* @see EditRecordOptions#host
|
||||
* @see UpdateRecordOptions#host
|
||||
*/
|
||||
public static EditRecordOptions host(String host) {
|
||||
return new EditRecordOptions().host(host);
|
||||
public static UpdateRecordOptions host(String host) {
|
||||
return new UpdateRecordOptions().host(host);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EditRecordOptions#type
|
||||
* @see UpdateRecordOptions#type
|
||||
*/
|
||||
public static EditRecordOptions type(String type) {
|
||||
return new EditRecordOptions().type(type);
|
||||
public static UpdateRecordOptions type(String type) {
|
||||
return new UpdateRecordOptions().type(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EditRecordOptions#data
|
||||
* @see UpdateRecordOptions#data
|
||||
*/
|
||||
public static EditRecordOptions data(String data) {
|
||||
return new EditRecordOptions().data(data);
|
||||
public static UpdateRecordOptions data(String data) {
|
||||
return new UpdateRecordOptions().data(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EditRecordOptions#ttl
|
||||
* @see UpdateRecordOptions#ttl
|
||||
*/
|
||||
public static EditRecordOptions ttl(int ttl) {
|
||||
return EditRecordOptions.class.cast(new EditRecordOptions().ttl(ttl));
|
||||
public static UpdateRecordOptions ttl(int ttl) {
|
||||
return UpdateRecordOptions.class.cast(new UpdateRecordOptions().ttl(ttl));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Configure the hostname attached to this record */
|
||||
public EditRecordOptions host(String host) {
|
||||
public UpdateRecordOptions host(String host) {
|
||||
formParameters.put("host", host);
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Configure the type of record, ex. "A", "CNAME" or "MX" */
|
||||
public EditRecordOptions type(String type) {
|
||||
public UpdateRecordOptions type(String type) {
|
||||
formParameters.put("type", type);
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Set the content of this record (depending on type, for an "A" record this would be an ip address) */
|
||||
public EditRecordOptions data(String data) {
|
||||
public UpdateRecordOptions data(String data) {
|
||||
formParameters.put("data", data);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateRecordOptions ttl(int ttl) {
|
||||
return UpdateRecordOptions.class.cast(super.ttl(ttl));
|
||||
}
|
||||
}
|
|
@ -24,87 +24,87 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
|||
*
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
public class EditServerOptions extends BaseHttpRequestOptions {
|
||||
public class UpdateServerOptions extends BaseHttpRequestOptions {
|
||||
|
||||
public static class Builder {
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#diskSizeGB
|
||||
* @see org.jclouds.glesys.options.UpdateServerOptions#diskSizeGB
|
||||
*/
|
||||
public static EditServerOptions disksizeGB(int disksizeGB) {
|
||||
return new EditServerOptions().diskSizeGB(disksizeGB);
|
||||
public static UpdateServerOptions disksizeGB(int 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) {
|
||||
return new EditServerOptions().memorySizeMB(memorysizeMB);
|
||||
public static UpdateServerOptions memorysizeMB(int 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) {
|
||||
EditServerOptions options = new EditServerOptions();
|
||||
public static UpdateServerOptions cpucores(int cpucores) {
|
||||
UpdateServerOptions options = new UpdateServerOptions();
|
||||
return options.cpuCores(cpucores);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#transferGB
|
||||
* @see org.jclouds.glesys.options.UpdateServerOptions#transferGB
|
||||
*/
|
||||
public static EditServerOptions transferGB(int transferGB) {
|
||||
return new EditServerOptions().transferGB(transferGB);
|
||||
public static UpdateServerOptions transferGB(int 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) {
|
||||
EditServerOptions options = new EditServerOptions();
|
||||
public static UpdateServerOptions hostname(String hostname) {
|
||||
UpdateServerOptions options = new UpdateServerOptions();
|
||||
return options.hostname(hostname);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.options.EditServerOptions#description
|
||||
* @see org.jclouds.glesys.options.UpdateServerOptions#description
|
||||
*/
|
||||
public static EditServerOptions description(String description) {
|
||||
EditServerOptions options = new EditServerOptions();
|
||||
public static UpdateServerOptions description(String description) {
|
||||
UpdateServerOptions options = new UpdateServerOptions();
|
||||
return options.description(description);
|
||||
}
|
||||
}
|
||||
|
||||
/** 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));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** 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));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** 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));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Configure the transfer setting for the server */
|
||||
public EditServerOptions transferGB(int transferGB) {
|
||||
public UpdateServerOptions transferGB(int transferGB) {
|
||||
formParameters.put("transfer", Integer.toString(transferGB));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** 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);
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Configure the description of the server */
|
||||
public EditServerOptions description(String description) {
|
||||
public UpdateServerOptions description(String description) {
|
||||
formParameters.put("description", description);
|
||||
return this;
|
||||
}
|
|
@ -50,15 +50,15 @@ public class GleSYSAsyncApiTest extends BaseAsyncApiTest<GleSYSAsyncApi> {
|
|||
public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
|
||||
assert syncApi.getServerApi() != null;
|
||||
assert syncApi.getIpApi() != null;
|
||||
assert syncApi.getArchiveApi() != null;
|
||||
assert syncApi.getDomainApi() != null;
|
||||
assert syncApi.getArchiveApi() != null;
|
||||
}
|
||||
|
||||
public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
|
||||
assert asyncApi.getServerApi() != null;
|
||||
assert asyncApi.getIpApi() != null;
|
||||
assert asyncApi.getArchiveApi() != null;
|
||||
assert asyncApi.getDomainApi() != null;
|
||||
assert asyncApi.getArchiveApi() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import static org.testng.Assert.assertNull;
|
||||
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.ArchiveAllowedArguments;
|
||||
|
@ -33,8 +33,8 @@ import org.jclouds.http.HttpResponseException;
|
|||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests parsing of {@code ArchiveAsyncApi}
|
||||
|
@ -52,10 +52,10 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_list.json")).build())
|
||||
.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());
|
||||
|
||||
assertEquals(api.listArchives(), expected);
|
||||
assertEquals(api.list().toImmutableSet(), expected);
|
||||
}
|
||||
|
||||
public void testListArchivesWhenResponseIs4xxReturnsEmpty() {
|
||||
|
@ -65,7 +65,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getArchiveApi();
|
||||
|
||||
assertTrue(api.listArchives().isEmpty());
|
||||
assertTrue(api.list().isEmpty());
|
||||
}
|
||||
|
||||
public void testArchiveDetailsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -77,7 +77,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/archive_details.json")).build())
|
||||
.getArchiveApi();
|
||||
|
||||
assertEquals(api.getArchive("xxxxxx_test1"), detailsInArchiveDetails());
|
||||
assertEquals(api.get("xxxxxx_test1"), detailsInArchiveDetails());
|
||||
}
|
||||
|
||||
private Archive detailsInArchiveDetails() {
|
||||
|
@ -92,7 +92,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("username", "xxxxxx_test1").build(),
|
||||
HttpResponse.builder().statusCode(404).build())
|
||||
.getArchiveApi();
|
||||
assertNull(api.getArchive("xxxxxx_test1"));
|
||||
assertNull(api.get("xxxxxx_test1"));
|
||||
}
|
||||
|
||||
public void testCreateArchiveWhenResponseIs2xx() throws Exception {
|
||||
|
@ -105,7 +105,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.put("size", "5")
|
||||
.put("password", "somepass").build()).build(),
|
||||
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 {
|
||||
|
@ -115,7 +115,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("username", "xxxxxx_test1").build(),
|
||||
HttpResponse.builder().statusCode(200).build()).getArchiveApi();
|
||||
|
||||
api.deleteArchive("xxxxxx_test1");
|
||||
api.delete("xxxxxx_test1");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {HttpResponseException.class})
|
||||
|
@ -125,7 +125,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("username", "xxxxxx_test1").build(),
|
||||
HttpResponse.builder().statusCode(402).build()).getArchiveApi();
|
||||
api.deleteArchive("xxxxxx_test1");
|
||||
api.delete("xxxxxx_test1");
|
||||
}
|
||||
|
||||
public void testResizeArchiveWhenResponseIs2xx() throws Exception {
|
||||
|
@ -137,7 +137,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("size", "5").build(),
|
||||
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})
|
||||
|
@ -150,7 +150,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("size", "5").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getArchiveApi();
|
||||
|
||||
api.resizeArchive("username1", 5);
|
||||
api.resize("username1", 5);
|
||||
}
|
||||
|
||||
public void testChangeArchivePasswordWhenResponseIs2xx() throws Exception {
|
||||
|
@ -163,7 +163,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("password", "newpass").build(),
|
||||
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})
|
||||
|
@ -177,7 +177,7 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("password", "newpass").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getArchiveApi();
|
||||
|
||||
api.changeArchivePassword("username", "newpass");
|
||||
api.changePassword("username", "newpass");
|
||||
}
|
||||
|
||||
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();
|
||||
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 {
|
||||
|
@ -200,6 +200,6 @@ public class ArchiveApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getArchiveApi();
|
||||
|
||||
assertNull(api.getArchiveAllowedArguments());
|
||||
assertNull(api.getAllowedArguments());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,15 +51,15 @@ public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
archiveCounter = new RetryablePredicate<Integer>(
|
||||
new Predicate<Integer>() {
|
||||
public boolean apply(Integer value){
|
||||
return api.listArchives().size() == value;
|
||||
return api.list().size() == value;
|
||||
}
|
||||
}, 30, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@AfterClass(groups = { "integration", "live" })
|
||||
protected void tearDownContext() {
|
||||
int before = api.listArchives().size();
|
||||
api.deleteArchive(archiveUser);
|
||||
int before = api.list().size();
|
||||
api.delete(archiveUser);
|
||||
assertTrue(archiveCounter.apply(before - 1));
|
||||
|
||||
super.tearDownContext();
|
||||
|
@ -71,12 +71,12 @@ public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
|
||||
@Test
|
||||
public void testAllowedArguments() throws Exception {
|
||||
ArchiveAllowedArguments args = api.getArchiveAllowedArguments();
|
||||
ArchiveAllowedArguments args = api.getAllowedArguments();
|
||||
assertNotNull(args);
|
||||
assertNotNull(args.getArchiveSizes());
|
||||
assertTrue(args.getArchiveSizes().size() > 0);
|
||||
assertNotNull(args.getSizes());
|
||||
assertTrue(args.getSizes().size() > 0);
|
||||
|
||||
for (int size : args.getArchiveSizes()) {
|
||||
for (int size : args.getSizes()) {
|
||||
assertTrue(size > 0);
|
||||
}
|
||||
}
|
||||
|
@ -84,37 +84,37 @@ public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
@Test
|
||||
public void testCreateArchive() throws Exception {
|
||||
try {
|
||||
api.deleteArchive(archiveUser);
|
||||
api.delete(archiveUser);
|
||||
} 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));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateArchive")
|
||||
public void testArchiveDetails() throws Exception {
|
||||
Archive details = api.getArchive(archiveUser);
|
||||
Archive details = api.get(archiveUser);
|
||||
assertEquals(details.getUsername(), archiveUser);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateArchive")
|
||||
public void testChangePassword() throws Exception {
|
||||
api.changeArchivePassword(archiveUser, "newpassword");
|
||||
api.changePassword(archiveUser, "newpassword");
|
||||
// TODO assert something useful!
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateArchive")
|
||||
public void testResizeArchive() throws Exception {
|
||||
api.resizeArchive(archiveUser, 20);
|
||||
api.resize(archiveUser, 20);
|
||||
|
||||
assertTrue(new RetryablePredicate<String>(
|
||||
new Predicate<String>() {
|
||||
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,7 +30,8 @@ import org.jclouds.glesys.domain.Domain;
|
|||
import org.jclouds.glesys.domain.DomainRecord;
|
||||
import org.jclouds.glesys.internal.BaseGleSYSApiExpectTest;
|
||||
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.HttpResponse;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
|
@ -57,8 +58,8 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
Domain expected =
|
||||
Domain.builder().domainName("testglesys.jclouds.org").createTime(dateService.iso8601SecondsDateParse("2012-01-31T12:19:03+01:00")).build();
|
||||
|
||||
Domain actual = Iterables.getOnlyElement(api.listDomains());
|
||||
assertEquals(expected.getDomainName(), actual.getDomainName());
|
||||
Domain actual = Iterables.getOnlyElement(api.list());
|
||||
assertEquals(expected.getName(), actual.getName());
|
||||
assertEquals(expected.getCreateTime(), actual.getCreateTime());
|
||||
}
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getDomainApi();
|
||||
|
||||
assertTrue(api.listDomains().isEmpty());
|
||||
assertTrue(api.list().isEmpty());
|
||||
}
|
||||
|
||||
public void testListDomainRecordsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -112,7 +113,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getDomainApi();
|
||||
|
||||
assertTrue(api.listDomains().isEmpty());
|
||||
assertTrue(api.list().isEmpty());
|
||||
}
|
||||
|
||||
public void testAddDomainRecordsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -128,7 +129,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.payload(payloadFromResourceWithContentType("/domain_record.json", MediaType.APPLICATION_JSON)).build())
|
||||
.getDomainApi();
|
||||
|
||||
assertEquals(api.addRecord("jclouds.org", "jclouds.org", "A", ""), recordInDomainRecord());
|
||||
assertEquals(api.createRecord("jclouds.org", "jclouds.org", "A", ""), recordInDomainRecord());
|
||||
}
|
||||
|
||||
protected DomainRecord recordInDomainRecord() {
|
||||
|
@ -147,10 +148,10 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("data", "").build(),
|
||||
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(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/updaterecord/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
|
@ -162,11 +163,11 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.payload(payloadFromResourceWithContentType("/domain_record.json", MediaType.APPLICATION_JSON)).build())
|
||||
.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)
|
||||
public void testEditDomainRecordsWhenResponseIs4xx() throws Exception {
|
||||
public void testUpdateDomainRecordsWhenResponseIs4xx() throws Exception {
|
||||
DomainApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/updaterecord/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
|
@ -176,7 +177,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("ttl", "1800").build(),
|
||||
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 {
|
||||
|
@ -212,7 +213,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build())
|
||||
.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())
|
||||
.getDomainApi();
|
||||
|
||||
assertNull(api.getDomain("cl66666_x"));
|
||||
assertNull(api.get("cl66666_x"));
|
||||
}
|
||||
|
||||
protected Domain domainInDomainDetails() {
|
||||
|
@ -242,7 +243,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build())
|
||||
.getDomainApi();
|
||||
|
||||
assertEquals(api.addDomain("cl66666_x"), domainInDomainDetails());
|
||||
assertEquals(api.create("cl66666_x"), domainInDomainDetails());
|
||||
}
|
||||
|
||||
public void testAddDomainWithOptsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -264,32 +265,34 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
AddDomainOptions options = (AddDomainOptions) AddDomainOptions.Builder.primaryNameServer("ns1.somewhere.x")
|
||||
.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(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/edit/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("domainname", "x").build(),
|
||||
.addFormParam("domainname", "x")
|
||||
.addFormParam("expire", "1").build(),
|
||||
HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/domain_details.json", MediaType.APPLICATION_JSON)).build())
|
||||
.getDomainApi();
|
||||
|
||||
assertEquals(api.editDomain("x"), domainInDomainDetails());
|
||||
assertEquals(api.update("x", DomainOptions.Builder.expire(1)), domainInDomainDetails());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {ResourceNotFoundException.class})
|
||||
public void testEditDomainWhenResponseIs4xxThrows() throws Exception {
|
||||
public void testUpdateDomainWhenResponseIs4xxThrows() throws Exception {
|
||||
DomainApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/domain/edit/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("domainname", "x").build(),
|
||||
.addFormParam("domainname", "x")
|
||||
.addFormParam("expire", "1").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getDomainApi();
|
||||
|
||||
api.editDomain("x");
|
||||
api.update("x", DomainOptions.Builder.expire(1));
|
||||
}
|
||||
|
||||
public void testDeleteDomainWhenResponseIs2xx() throws Exception {
|
||||
|
@ -299,7 +302,7 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("domainname", "x").build(),
|
||||
HttpResponse.builder().statusCode(200).build()).getDomainApi();
|
||||
|
||||
api.deleteDomain("x");
|
||||
api.delete("x");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {ResourceNotFoundException.class})
|
||||
|
@ -310,6 +313,6 @@ public class DomainApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("domainname", "x").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getDomainApi();
|
||||
|
||||
api.deleteDomain("x");
|
||||
api.delete("x");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jclouds.glesys.domain.Domain;
|
|||
import org.jclouds.glesys.domain.DomainRecord;
|
||||
import org.jclouds.glesys.internal.BaseGleSYSApiLiveTest;
|
||||
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.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
|
@ -54,7 +54,7 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
domainCounter = new RetryablePredicate<Integer>(
|
||||
new Predicate<Integer>() {
|
||||
public boolean apply(Integer value) {
|
||||
return api.listDomains().size() == value;
|
||||
return api.list().size() == value;
|
||||
}
|
||||
}, 30, 1, TimeUnit.SECONDS);
|
||||
recordCounter = new RetryablePredicate<Integer>(
|
||||
|
@ -65,7 +65,7 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
}, 30, 1, TimeUnit.SECONDS);
|
||||
|
||||
try {
|
||||
api.deleteDomain(testDomain);
|
||||
api.delete(testDomain);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,8 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
|
||||
@AfterGroups(groups = {"live"})
|
||||
public void tearDownContext() {
|
||||
int before = api.listDomains().size();
|
||||
api.deleteDomain(testDomain);
|
||||
int before = api.list().size();
|
||||
api.delete(testDomain);
|
||||
assertTrue(domainCounter.apply(before - 1));
|
||||
|
||||
super.tearDownContext();
|
||||
|
@ -87,16 +87,16 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
|
||||
@Test
|
||||
public void testGetDomain() throws Exception {
|
||||
Domain domain = api.getDomain(testDomain);
|
||||
Domain domain = api.get(testDomain);
|
||||
assertNotNull(domain);
|
||||
assertEquals(domain.getDomainName(), testDomain);
|
||||
assertEquals(domain.getName(), testDomain);
|
||||
assertNotNull(domain.getCreateTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditDomain() throws Exception {
|
||||
api.editDomain(testDomain, DomainOptions.Builder.responsiblePerson("another-tester.jclouds.org."));
|
||||
Domain domain = api.getDomain(testDomain);
|
||||
public void testUpdateDomain() throws Exception {
|
||||
api.update(testDomain, DomainOptions.Builder.responsiblePerson("another-tester.jclouds.org."));
|
||||
Domain domain = api.get(testDomain);
|
||||
assertEquals(domain.getResponsiblePerson(), "another-tester.jclouds.org.");
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
public void testCreateRecord() throws Exception {
|
||||
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));
|
||||
|
||||
|
@ -117,10 +117,10 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEditRecord() throws Exception {
|
||||
public void testUpdateRecord() throws Exception {
|
||||
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));
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
|||
|
||||
assertNotNull(recordId);
|
||||
|
||||
api.editRecord(recordId, EditRecordOptions.Builder.host("testeditafter"));
|
||||
api.updateRecord(recordId, UpdateRecordOptions.Builder.host("testeditafter"));
|
||||
|
||||
boolean found = false;
|
||||
for(DomainRecord record : api.listRecords(testDomain)) {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.glesys.domain.EmailOverviewDomain;
|
|||
import org.jclouds.glesys.domain.EmailOverviewSummary;
|
||||
import org.jclouds.glesys.domain.EmailQuota;
|
||||
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.HttpResponse;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
|
@ -44,20 +44,20 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code EmailApi}
|
||||
* Tests annotation parsing of {@code EmailAccountApi}
|
||||
*
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "unit", testName = "EmailAsyncApiTest")
|
||||
public class EmailApiExpectTest extends BaseGleSYSApiExpectTest {
|
||||
@Test(groups = "unit", testName = "EmailAccountAsyncApiTest")
|
||||
public class EmailAccountApiExpectTest extends BaseGleSYSApiExpectTest {
|
||||
|
||||
public void testListWhenResponseIs2xx() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.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);
|
||||
Set<EmailAccount> expected =
|
||||
|
@ -69,108 +69,108 @@ public class EmailApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.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(Iterables.get(actual, 0).toString(), Iterables.get(expected, 0).toString());
|
||||
}
|
||||
|
||||
public void testListWhenResponseIs404IsEmpty() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.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 {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.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 actual = Iterables.getOnlyElement(api.listAliases("cl13016.test.jclouds.org"));
|
||||
EmailAlias actual = Iterables.getOnlyElement(api.listAliasesInDomain("cl13016.test.jclouds.org"));
|
||||
assertEquals(actual, expected);
|
||||
}
|
||||
|
||||
public void testListAliasesWhenResponseIs404IsEmpty() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/list/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.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 {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/overview/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.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();
|
||||
EmailOverviewDomain domain = EmailOverviewDomain.builder().domain("cl13016.test.jclouds.org").accounts(2).aliases(0).build();
|
||||
EmailOverview expected = EmailOverview.builder().summary(summary).domains(domain).build();
|
||||
|
||||
assertEquals(api.getEmailOverview(), expected);
|
||||
assertEquals(api.getOverview(), expected);
|
||||
}
|
||||
|
||||
public void testOverviewWhenResponseIs404ReturnsNull() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/overview/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.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 {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createaccount/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("emailaccount", "test@jclouds.org")
|
||||
.addFormParam("password", "newpass").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 {
|
||||
EmailApi api = requestSendsResponse(
|
||||
public void testUpdateAccountWhenResponseIs2xx() throws Exception {
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editaccount/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("emailaccount", "test@jclouds.org")
|
||||
.addFormParam("password", "anotherpass").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)
|
||||
public void testEditAccountWhenResponseIs4xx() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
public void testUpdateAccountWhenResponseIs4xx() throws Exception {
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editaccount/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("emailaccount", "test@jclouds.org")
|
||||
.addFormParam("password", "anotherpass").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() {
|
||||
|
@ -184,84 +184,84 @@ public class EmailApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
|
||||
@Test(expectedExceptions = {ResourceNotFoundException.class})
|
||||
public void testCreateAccountWhenResponseIs4xxThrows() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createaccount/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("emailaccount", "test@jclouds.org")
|
||||
.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 {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createalias/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("emailalias", "test2@jclouds.org")
|
||||
.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");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {AuthorizationException.class})
|
||||
public void testCreateAliasWhenResponseIs4xxThrows() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/createalias/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("emailalias", "test2@jclouds.org")
|
||||
.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");
|
||||
}
|
||||
|
||||
public void testEditAliasWhenResponseIs2xx() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
public void testUpdateAliasWhenResponseIs2xx() throws Exception {
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editalias/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("emailalias", "test2@jclouds.org")
|
||||
.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})
|
||||
public void testEditAliasWhenResponseIs4xxThrows() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
public void testUpdateAliasWhenResponseIs4xxThrows() throws Exception {
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/editalias/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("emailalias", "test2@jclouds.org")
|
||||
.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 {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/delete/format/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("email", "test2@jclouds.org").build(),
|
||||
HttpResponse.builder().statusCode(200).build()).getEmailApi();
|
||||
HttpResponse.builder().statusCode(200).build()).getEmailAccountApi();
|
||||
|
||||
api.delete("test2@jclouds.org");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {ResourceNotFoundException.class})
|
||||
public void testDeleteWhenResponseIs4xxThrows() throws Exception {
|
||||
EmailApi api = requestSendsResponse(
|
||||
EmailAccountApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/email/delete/format/json")
|
||||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==")
|
||||
.addFormParam("email", "test2@jclouds.org").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getEmailApi();
|
||||
HttpResponse.builder().statusCode(404).build()).getEmailAccountApi();
|
||||
|
||||
api.delete("test2@jclouds.org");
|
||||
}
|
|
@ -23,7 +23,6 @@ import static org.testng.Assert.assertFalse;
|
|||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.glesys.domain.EmailAccount;
|
||||
|
@ -32,34 +31,35 @@ import org.jclouds.glesys.domain.EmailOverview;
|
|||
import org.jclouds.glesys.domain.EmailOverviewDomain;
|
||||
import org.jclouds.glesys.internal.BaseGleSYSApiWithAServerLiveTest;
|
||||
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.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code EmailApi}
|
||||
* Tests behavior of {@code EmailAccountApi}
|
||||
*
|
||||
* @author Adam Lowe
|
||||
*/
|
||||
@Test(groups = "live", testName = "EmailApiLiveTest", singleThreaded = true)
|
||||
public class EmailApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||
@Test(groups = "live", testName = "EmailAccountApiLiveTest", singleThreaded = true)
|
||||
public class EmailAccountApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||
|
||||
@BeforeGroups(groups = {"live"})
|
||||
public void setupDomains() {
|
||||
testDomain = identity + ".test.jclouds.org";
|
||||
api = gleContext.getApi().getEmailApi();
|
||||
api = gleContext.getApi().getEmailAccountApi();
|
||||
|
||||
createDomain(testDomain);
|
||||
|
||||
emailAccountCounter = new RetryablePredicate<Integer>(
|
||||
new Predicate<Integer>() {
|
||||
public boolean apply(Integer value) {
|
||||
return api.listAccounts(testDomain).size() == value;
|
||||
return api.listDomain(testDomain).size() == value;
|
||||
}
|
||||
}, 180, 5, TimeUnit.SECONDS);
|
||||
|
||||
|
@ -76,84 +76,84 @@ public class EmailApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
api.delete("test@" + testDomain);
|
||||
api.delete("test1@" + testDomain);
|
||||
assertTrue(emailAccountCounter.apply(0));
|
||||
gleContext.getApi().getDomainApi().deleteDomain(testDomain);
|
||||
gleContext.getApi().getEmailAccountApi().delete(testDomain);
|
||||
}
|
||||
|
||||
private EmailApi api;
|
||||
private EmailAccountApi api;
|
||||
private String testDomain;
|
||||
private RetryablePredicate<Integer> emailAccountCounter;
|
||||
|
||||
@Test
|
||||
public void testCreateEmail() {
|
||||
api.createAccount("test@" + testDomain, "password",
|
||||
api.createWithPassword("test@" + testDomain, "password",
|
||||
CreateAccountOptions.Builder.antiVirus(true).autorespond(true).autorespondMessage("out of office"));
|
||||
|
||||
assertTrue(emailAccountCounter.apply(1));
|
||||
|
||||
api.createAccount("test1@" + testDomain, "password");
|
||||
api.createWithPassword("test1@" + testDomain, "password");
|
||||
|
||||
assertTrue(emailAccountCounter.apply(2));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateEmail")
|
||||
public void testAliases() {
|
||||
assertTrue(api.listAliases(testDomain).isEmpty());
|
||||
assertTrue(api.listAliasesInDomain(testDomain).isEmpty());
|
||||
|
||||
EmailAlias alias = api.createAlias("test2@" + testDomain, "test@" + testDomain);
|
||||
assertEquals(alias.getAlias(), "test2@" + testDomain);
|
||||
assertEquals(alias.getForwardTo(), "test@" + testDomain);
|
||||
|
||||
EmailAlias aliasFromList = Iterables.getOnlyElement(api.listAliases(testDomain));
|
||||
EmailAlias aliasFromList = Iterables.getOnlyElement(api.listAliasesInDomain(testDomain));
|
||||
assertEquals(aliasFromList, alias);
|
||||
|
||||
EmailOverview overview = api.getEmailOverview();
|
||||
EmailOverview overview = api.getOverview();
|
||||
assertTrue(overview.getSummary().getAliases() == 1);
|
||||
|
||||
alias = api.editAlias("test2@" + testDomain, "test1@" + testDomain);
|
||||
overview = api.getEmailOverview();
|
||||
alias = api.updateAlias("test2@" + testDomain, "test1@" + testDomain);
|
||||
overview = api.getOverview();
|
||||
assertTrue(overview.getSummary().getAliases() == 1);
|
||||
|
||||
aliasFromList = Iterables.getOnlyElement(api.listAliases(testDomain));
|
||||
aliasFromList = Iterables.getOnlyElement(api.listAliasesInDomain(testDomain));
|
||||
assertEquals(aliasFromList, alias);
|
||||
|
||||
api.delete("test2@" + testDomain);
|
||||
overview = api.getEmailOverview();
|
||||
overview = api.getOverview();
|
||||
assertTrue(overview.getSummary().getAliases() == 0);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateEmail")
|
||||
public void testOverview() throws Exception {
|
||||
EmailOverview overview = api.getEmailOverview();
|
||||
EmailOverview overview = api.getOverview();
|
||||
assertNotNull(overview.getSummary());
|
||||
assertTrue(overview.getSummary().getAccounts() > 0);
|
||||
assertTrue(overview.getSummary().getAliases() > -1);
|
||||
assertTrue(overview.getSummary().getMaxAccounts() > 0);
|
||||
assertTrue(overview.getSummary().getMaxAliases() > 0);
|
||||
assertNotNull(overview.getDomains());
|
||||
assertFalse(overview.getDomains().isEmpty());
|
||||
assertNotNull(overview.gets());
|
||||
assertFalse(overview.gets().isEmpty());
|
||||
|
||||
EmailOverviewDomain domain = EmailOverviewDomain.builder().domain(testDomain).accounts(1).build();
|
||||
assertTrue(overview.getDomains().contains(domain));
|
||||
assertTrue(overview.gets().contains(domain));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateEmail")
|
||||
public void testListAccounts() throws Exception {
|
||||
Set<EmailAccount> accounts = api.listAccounts(testDomain);
|
||||
FluentIterable<EmailAccount> accounts = api.listDomain(testDomain);
|
||||
assertTrue(accounts.size() >= 1);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateEmail")
|
||||
public void testEditAccount() throws Exception {
|
||||
Set<EmailAccount> accounts = api.listAccounts(testDomain);
|
||||
public void testUpdateAccount() throws Exception {
|
||||
FluentIterable<EmailAccount> accounts = api.listDomain(testDomain);
|
||||
for (EmailAccount account : accounts) {
|
||||
if (account.getAccount().equals("test@" + testDomain)) {
|
||||
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) {
|
||||
if (account.getAccount().equals("test@" + testDomain)) {
|
||||
assertFalse(account.isAntiVirus());
|
|
@ -58,7 +58,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.nameServers("79.99.4.100", "79.99.4.101")
|
||||
.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-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(),
|
||||
HttpResponse.builder().statusCode(404).build()).getIpApi();
|
||||
|
||||
assertTrue(api.listIps().isEmpty());
|
||||
assertTrue(api.list().isEmpty());
|
||||
}
|
||||
|
||||
public void testGetIpDetailsWhenResponseIs2xx() {
|
||||
|
@ -81,7 +81,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/ip_get_details.json")).build())
|
||||
.getIpApi();
|
||||
|
||||
assertEquals(api.getIp("31.192.227.113"), getIpInIpDetails());
|
||||
assertEquals(api.get("31.192.227.113"), getIpInIpDetails());
|
||||
}
|
||||
|
||||
protected IpDetails getIpInIpDetails() {
|
||||
|
@ -100,7 +100,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
|
||||
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() {
|
||||
|
@ -159,7 +159,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/ip_list_free.json")).build())
|
||||
.getIpApi();
|
||||
|
||||
assertEquals(api.listFree(4, "Falkenberg", "OpenVZ"), ParseIpAddressFromResponseTest.EXPECTED_IPS);
|
||||
assertEquals(api.listFree(4, "Falkenberg", "OpenVZ").toImmutableSet(), ParseIpAddressFromResponseTest.EXPECTED_IPS);
|
||||
}
|
||||
|
||||
public void testListFreeWhenResponseIs404ReturnsEmptySet() {
|
||||
|
@ -170,7 +170,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(404).build())
|
||||
.getIpApi();
|
||||
|
||||
assertEquals(api.listFree(6, "Falkenberg", "OpenVZ"), emptySet());
|
||||
assertEquals(api.listFree(6, "Falkenberg", "OpenVZ").toImmutableSet(), emptySet());
|
||||
}
|
||||
|
||||
public void testAddWhenResponseIs2xx() {
|
||||
|
@ -183,7 +183,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build())
|
||||
.getIpApi();
|
||||
|
||||
api.addIpToServer("31.192.227.37", "vz1946889");
|
||||
api.addToServer("31.192.227.37", "vz1946889");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
|
@ -196,7 +196,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("serverid", "vz1946889").build(),
|
||||
HttpResponse.builder().statusCode(401).build())
|
||||
.getIpApi();
|
||||
api.addIpToServer("31.192.227.37", "vz1946889");
|
||||
api.addToServer("31.192.227.37", "vz1946889");
|
||||
}
|
||||
|
||||
public void testRemoveWhenResponseIs2xx() {
|
||||
|
@ -209,7 +209,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build())
|
||||
.getIpApi();
|
||||
|
||||
api.removeIpFromServer("31.192.227.37", "vz1946889");
|
||||
api.removeFromServer("31.192.227.37", "vz1946889");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = HttpResponseException.class)
|
||||
|
@ -223,7 +223,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(400).build())
|
||||
.getIpApi();
|
||||
|
||||
api.removeIpFromServer("31.192.227.37", "vz1946889");
|
||||
api.removeFromServer("31.192.227.37", "vz1946889");
|
||||
}
|
||||
|
||||
public void testRemoveAndReleaseWhenResponseIs2xx() {
|
||||
|
@ -237,7 +237,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build())
|
||||
.getIpApi();
|
||||
|
||||
api.removeIpFromServerAndRelease("31.192.227.37", "vz1946889");
|
||||
api.removeFromServerAndRelease("31.192.227.37", "vz1946889");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = HttpResponseException.class)
|
||||
|
@ -252,7 +252,7 @@ public class IpApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(400).build())
|
||||
.getIpApi();
|
||||
|
||||
api.removeIpFromServerAndRelease("31.192.227.37", "vz1946889");
|
||||
api.removeFromServerAndRelease("31.192.227.37", "vz1946889");
|
||||
}
|
||||
|
||||
public void testSetPrtWhenResponseIs2xx() {
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.testng.annotations.AfterGroups;
|
|||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
@ -61,13 +62,13 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
|
||||
@Test
|
||||
public void testListFree() throws Exception {
|
||||
Set<String> freeIps = api.listFree(4, "Falkenberg", "Xen");
|
||||
FluentIterable<String> freeIps = api.listFree(4, "Falkenberg", "Xen");
|
||||
assertFalse(freeIps.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reserveIp() throws Exception {
|
||||
Set<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
|
||||
FluentIterable<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
|
||||
assertFalse(openVzIps.isEmpty());
|
||||
reservedIp = api.take(Iterables.get(openVzIps, 0));
|
||||
assertTrue(reservedIp.isReserved());
|
||||
|
@ -86,21 +87,21 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
|
||||
@Test(dependsOnMethods = "reserveIp")
|
||||
public void testList() throws Exception {
|
||||
Set<IpDetails> ownIps = api.listIps();
|
||||
FluentIterable<IpDetails> ownIps = api.list();
|
||||
assertTrue(ownIps.contains(reservedIp));
|
||||
ownIps = api.listIps(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()));
|
||||
ownIps = api.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()));
|
||||
assertTrue(ownIps.contains(reservedIp));
|
||||
ownIps = api.listIps(ListIpOptions.Builder.platform(reservedIp.getPlatform()));
|
||||
ownIps = api.list(ListIpOptions.Builder.platform(reservedIp.getPlatform()));
|
||||
assertTrue(ownIps.contains(reservedIp));
|
||||
ownIps = api.listIps(ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
|
||||
ownIps = api.list(ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
|
||||
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.ipVersion(reservedIp.getVersion()));
|
||||
assertTrue(ownIps.contains(reservedIp));
|
||||
|
||||
ownIps = api.listIps(ListIpOptions.Builder.serverId("xmthisisnotaserverid"));
|
||||
ownIps = api.list(ListIpOptions.Builder.serverId("xmthisisnotaserverid"));
|
||||
assertTrue(ownIps.isEmpty());
|
||||
}
|
||||
|
||||
|
@ -115,20 +116,20 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
|
||||
@Test
|
||||
public void testGetOpenVZDetails() throws Exception {
|
||||
Set<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
|
||||
FluentIterable<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
|
||||
assertFalse(openVzIps.isEmpty());
|
||||
String openVzIp = openVzIps.iterator().next();
|
||||
IpDetails ipDetails = api.getIp(openVzIp);
|
||||
IpDetails ipDetails = api.get(openVzIp);
|
||||
checkOpenVZDefailsInFalkenberg(ipDetails);
|
||||
assertEquals(ipDetails.getAddress(), openVzIp);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetXenDetails() throws Exception {
|
||||
Set<String> xenVzIps = api.listFree(4, "Falkenberg", "Xen");
|
||||
FluentIterable<String> xenVzIps = api.listFree(4, "Falkenberg", "Xen");
|
||||
assertFalse(xenVzIps.isEmpty());
|
||||
String xenIp = xenVzIps.iterator().next();
|
||||
IpDetails ipDetails = api.getIp(xenIp);
|
||||
IpDetails ipDetails = api.get(xenIp);
|
||||
assertEquals(ipDetails.getDatacenter(), "Falkenberg");
|
||||
assertEquals(ipDetails.getPlatform(), "Xen");
|
||||
assertEquals(ipDetails.getVersion(), 4);
|
||||
|
@ -145,7 +146,7 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
IpDetails original = reservedIp;
|
||||
|
||||
IpDetails modified = api.setPtr(reservedIp.getAddress(), "wibble.");
|
||||
IpDetails modified2 = api.getIp(reservedIp.getAddress());
|
||||
IpDetails modified2 = api.get(reservedIp.getAddress());
|
||||
|
||||
assertEquals(modified.getPtr(), "wibble.");
|
||||
assertEquals(modified2, modified);
|
||||
|
@ -157,16 +158,16 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
|
||||
@Test(dependsOnMethods = "reserveIp")
|
||||
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.getPtr(), reservedIp.getPtr());
|
||||
assertEquals(added.getServerId(), serverId);
|
||||
|
||||
IpDetails again = api.getIp(reservedIp.getAddress());
|
||||
IpDetails again = api.get(reservedIp.getAddress());
|
||||
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, reservedIp);
|
||||
|
@ -175,11 +176,11 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
openVzIps.remove(reservedIp.getAddress());
|
||||
assertFalse(openVzIps.isEmpty());
|
||||
|
||||
added = api.addIpToServer(reservedIp.getAddress(), serverId);
|
||||
added = api.addToServer(reservedIp.getAddress(), serverId);
|
||||
|
||||
assertEquals(added.getServerId(), serverId);
|
||||
|
||||
removed = api.removeIpFromServerAndRelease(reservedIp.getAddress(), serverId);
|
||||
removed = api.removeFromServerAndRelease(reservedIp.getAddress(), serverId);
|
||||
|
||||
assertNull(removed.getServerId());
|
||||
assertFalse(removed.isReserved());
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.jclouds.glesys.internal.BaseGleSYSApiExpectTest;
|
|||
import org.jclouds.glesys.options.CloneServerOptions;
|
||||
import org.jclouds.glesys.options.CreateServerOptions;
|
||||
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.http.HttpRequest;
|
||||
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();
|
||||
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() {
|
||||
|
@ -82,7 +82,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getServerApi();
|
||||
|
||||
assertTrue(api.listServers().isEmpty());
|
||||
assertTrue(api.list().isEmpty());
|
||||
}
|
||||
|
||||
public void testGetAllowedArgumentsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -117,7 +117,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.build();
|
||||
expected.put("Xen", xen);
|
||||
expected.put("OpenVZ", openvz);
|
||||
assertEquals(api.getAllowedArgumentsForCreateServerByPlatform(), expected);
|
||||
assertEquals(api.getAllowedArgumentsForCreateByPlatform(), expected);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
assertEquals(api.listTemplates(), expectedBuilder.build());
|
||||
assertEquals(api.listTemplates().toImmutableSet(), expectedBuilder.build());
|
||||
}
|
||||
|
||||
public void testGetServerDetailsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -159,7 +159,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("serverid", "xm3276891").build(),
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("serverid", "xm3276891").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getServerApi();
|
||||
|
||||
assertNull(api.getServerDetails("xm3276891"));
|
||||
assertNull(api.get("xm3276891"));
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
assertEquals(
|
||||
api.createServerWithHostnameAndRootPassword(
|
||||
api.createWithHostnameAndRootPassword(
|
||||
ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 32-bit")
|
||||
.diskSizeGB(5).memorySizeMB(512).cpuCores(1).transferGB(50).build(), "jclouds-test", "password").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");
|
||||
|
||||
|
||||
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)
|
||||
.build(), "jclouds-test", "password", options), expectedServerDetails());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditServerWhenResponseIs2xx() throws Exception {
|
||||
public void testUpdateServerWhenResponseIs2xx() throws Exception {
|
||||
ServerApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/server/edit/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
|
@ -249,12 +249,11 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("hostname", "new-hostname").build(),
|
||||
HttpResponse.builder().statusCode(206).build()).getServerApi();
|
||||
|
||||
api.editServer("xm3276891", EditServerOptions.Builder.description("this is a different description!"),
|
||||
EditServerOptions.Builder.hostname("new-hostname"));
|
||||
api.update("xm3276891", UpdateServerOptions.Builder.description("this is a different description!").hostname("new-hostname"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditServerWithOptsWhenResponseIs2xx() throws Exception {
|
||||
public void testUpdateServerWithOptsWhenResponseIs2xx() throws Exception {
|
||||
ServerApi api = requestSendsResponse(
|
||||
HttpRequest.builder().method("POST").endpoint("https://api.glesys.com/server/edit/format/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
|
@ -267,10 +266,10 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("hostname", "jclouds-test").build(),
|
||||
HttpResponse.builder().statusCode(200).build()).getServerApi();
|
||||
|
||||
EditServerOptions options =
|
||||
EditServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1).hostname("jclouds-test");
|
||||
UpdateServerOptions options =
|
||||
UpdateServerOptions.Builder.description("Description-of-server").diskSizeGB(1).memorySizeMB(512).cpuCores(1).hostname("jclouds-test");
|
||||
|
||||
api.editServer("xm3276891", options);
|
||||
api.update("xm3276891", options);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -283,7 +282,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("hostname", "hostname1").build(),
|
||||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_details.json")).build()).getServerApi();
|
||||
|
||||
assertEquals(api.cloneServer("xm3276891", "hostname1"), expectedServerDetails());
|
||||
assertEquals(api.clone("xm3276891", "hostname1"), expectedServerDetails());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -301,7 +300,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
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);
|
||||
|
||||
assertEquals(api.cloneServer("xm3276891", "hostname1", options), expectedServerDetails());
|
||||
assertEquals(api.clone("xm3276891", "hostname1", options), expectedServerDetails());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {ResourceNotFoundException.class})
|
||||
|
@ -314,7 +313,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
.addFormParam("hostname", "hostname1").build(),
|
||||
HttpResponse.builder().statusCode(404).build()).getServerApi();
|
||||
|
||||
api.cloneServer("xm3276891", "hostname1");
|
||||
api.clone("xm3276891", "hostname1");
|
||||
}
|
||||
|
||||
public void testGetServerStatusWhenResponseIs2xx() throws Exception {
|
||||
|
@ -326,7 +325,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json")).build())
|
||||
.getServerApi();
|
||||
|
||||
assertEquals(api.getServerStatus("xm3276891"), expectedServerStatus());
|
||||
assertEquals(api.getStatus("xm3276891"), expectedServerStatus());
|
||||
}
|
||||
|
||||
public void testGetServerStatusWithOptsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -339,7 +338,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(206).payload(payloadFromResource("/server_status.json")).build())
|
||||
.getServerApi();
|
||||
|
||||
assertEquals(api.getServerStatus("server321", ServerStatusOptions.Builder.state()), expectedServerStatus());
|
||||
assertEquals(api.getStatus("server321", ServerStatusOptions.Builder.state()), expectedServerStatus());
|
||||
}
|
||||
|
||||
public void testGetServerStatusWhenResponseIs4xx() throws Exception {
|
||||
|
@ -352,7 +351,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(404).build())
|
||||
.getServerApi();
|
||||
|
||||
assertNull(api.getServerStatus("server321", ServerStatusOptions.Builder.state()));
|
||||
assertNull(api.getStatus("server321", ServerStatusOptions.Builder.state()));
|
||||
}
|
||||
|
||||
public void testGetServerLimitsWhenResponseIs2xx() throws Exception {
|
||||
|
@ -364,7 +363,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_limits.json")).build())
|
||||
.getServerApi();
|
||||
|
||||
api.getServerLimits("server321");
|
||||
api.getLimits("server321");
|
||||
}
|
||||
|
||||
public void testGetConsoleWhenResponseIs2xx() throws Exception {
|
||||
|
@ -402,7 +401,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build())
|
||||
.getServerApi();
|
||||
|
||||
api.startServer("server777");
|
||||
api.start("server777");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {AuthorizationException.class})
|
||||
|
@ -415,7 +414,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(401).build())
|
||||
.getServerApi();
|
||||
|
||||
api.startServer("server777");
|
||||
api.start("server777");
|
||||
}
|
||||
|
||||
public void testStopServerWhenResponseIs2xx() throws Exception {
|
||||
|
@ -427,7 +426,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build())
|
||||
.getServerApi();
|
||||
|
||||
api.stopServer("server777");
|
||||
api.stop("server777");
|
||||
}
|
||||
|
||||
public void testHardStopServerWhenResponseIs2xx() throws Exception {
|
||||
|
@ -440,7 +439,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build())
|
||||
.getServerApi();
|
||||
|
||||
api.hardStopServer("server777");
|
||||
api.hardStop("server777");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {AuthorizationException.class})
|
||||
|
@ -453,7 +452,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(401).build())
|
||||
.getServerApi();
|
||||
|
||||
api.stopServer("server777");
|
||||
api.stop("server777");
|
||||
}
|
||||
|
||||
public void testRebootServerWhenResponseIs2xx() throws Exception {
|
||||
|
@ -465,7 +464,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build())
|
||||
.getServerApi();
|
||||
|
||||
api.rebootServer("server777");
|
||||
api.reboot("server777");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {AuthorizationException.class})
|
||||
|
@ -478,7 +477,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(401).build())
|
||||
.getServerApi();
|
||||
|
||||
api.rebootServer("server777");
|
||||
api.reboot("server777");
|
||||
}
|
||||
|
||||
public void testDestroyServerWhenResponseIs2xx() throws Exception {
|
||||
|
@ -490,7 +489,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(200).build())
|
||||
.getServerApi();
|
||||
|
||||
api.destroyServer("server777", DestroyServerOptions.Builder.keepIp());
|
||||
api.destroy("server777", DestroyServerOptions.Builder.keepIp());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {AuthorizationException.class})
|
||||
|
@ -503,7 +502,7 @@ public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
|
|||
HttpResponse.builder().statusCode(401).build())
|
||||
.getServerApi();
|
||||
|
||||
api.destroyServer("server777", DestroyServerOptions.Builder.discardIp());
|
||||
api.destroy("server777", DestroyServerOptions.Builder.discardIp());
|
||||
}
|
||||
|
||||
public void testResourceUsageWhenResponseIs2xx() throws Exception {
|
||||
|
|
|
@ -23,7 +23,6 @@ import static org.testng.Assert.assertNotNull;
|
|||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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.options.CloneServerOptions;
|
||||
import org.jclouds.glesys.options.DestroyServerOptions;
|
||||
import org.jclouds.glesys.options.EditServerOptions;
|
||||
import org.jclouds.glesys.options.ServerStatusOptions;
|
||||
import org.jclouds.glesys.options.UpdateServerOptions;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ServerApi}
|
||||
|
@ -65,7 +65,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
@AfterGroups(groups = {"live"})
|
||||
public void deleteExtraServer() {
|
||||
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
|
||||
public void testAllowedArguments() throws Exception {
|
||||
Map<String,AllowedArgumentsForCreateServer> templates = api.getAllowedArgumentsForCreateServerByPlatform();
|
||||
Map<String,AllowedArgumentsForCreateServer> templates = api.getAllowedArgumentsForCreateByPlatform();
|
||||
|
||||
assertTrue(templates.containsKey("OpenVZ"));
|
||||
assertTrue(templates.containsKey("Xen"));
|
||||
|
@ -101,7 +101,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
}
|
||||
|
||||
public void testListTemplates() throws Exception {
|
||||
Set<OSTemplate> oSTemplates = api.listTemplates();
|
||||
FluentIterable<OSTemplate> oSTemplates = api.listTemplates();
|
||||
|
||||
for(OSTemplate oSTemplate : oSTemplates) {
|
||||
checkTemplate(oSTemplate);
|
||||
|
@ -119,12 +119,12 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
}
|
||||
|
||||
public void testListServers() throws Exception {
|
||||
Set<Server> response = api.listServers();
|
||||
FluentIterable<Server> response = api.list();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.size() > 0);
|
||||
|
||||
for (Server server : response) {
|
||||
ServerDetails newDetails = api.getServerDetails(server.getId());
|
||||
ServerDetails newDetails = api.get(server.getId());
|
||||
assertEquals(newDetails.getId(), server.getId());
|
||||
assertEquals(newDetails.getHostname(), server.getHostname());
|
||||
assertEquals(newDetails.getPlatform(), server.getPlatform());
|
||||
|
@ -134,7 +134,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
}
|
||||
|
||||
public void testServerDetails() throws Exception {
|
||||
ServerDetails details = api.getServerDetails(serverId);
|
||||
ServerDetails details = api.get(serverId);
|
||||
checkServer(details);
|
||||
assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplateName());
|
||||
assertEquals("Falkenberg", details.getDatacenter());
|
||||
|
@ -146,22 +146,22 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
}
|
||||
|
||||
public void testServerStatus() throws Exception {
|
||||
ServerStatus newStatus = api.getServerStatus(serverId);
|
||||
ServerStatus newStatus = api.getStatus(serverId);
|
||||
checkStatus(newStatus);
|
||||
}
|
||||
|
||||
public void testEditServer() throws Exception {
|
||||
ServerDetails edited = api.editServer(serverId, EditServerOptions.Builder.description("this is a different description!"));
|
||||
public void testUpdateServer() throws Exception {
|
||||
ServerDetails edited = api.update(serverId, UpdateServerOptions.Builder.description("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.getHostname(), "host-name1");
|
||||
|
||||
edited = api.resetPassword(serverId, "anotherpass");
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
public void testRebootServer() throws Exception {
|
||||
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
||||
|
||||
api.rebootServer(serverId);
|
||||
api.reboot(serverId);
|
||||
|
||||
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
||||
}
|
||||
|
@ -178,17 +178,17 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
public void testStopAndStartServer() throws Exception {
|
||||
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
||||
|
||||
api.stopServer(serverId);
|
||||
api.stop(serverId);
|
||||
|
||||
assertTrue(serverStatusChecker.apply(Server.State.STOPPED));
|
||||
|
||||
api.startServer(serverId);
|
||||
api.start(serverId);
|
||||
|
||||
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
||||
}
|
||||
|
||||
public void testServerLimits() throws Exception {
|
||||
Map<String, ServerLimit> limits = api.getServerLimits(serverId);
|
||||
Map<String, ServerLimit> limits = api.getLimits(serverId);
|
||||
assertNotNull(limits);
|
||||
for (Map.Entry<String, ServerLimit> entry : limits.entrySet()) {
|
||||
assertNotNull(entry.getKey());
|
||||
|
@ -204,7 +204,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
|||
|
||||
public void testResourceUsage() throws Exception {
|
||||
// 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");
|
||||
assertEquals(usage.getInfo().getResource(), "diskioread");
|
||||
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)
|
||||
@Test(enabled=false)
|
||||
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());
|
||||
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);
|
||||
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
|
||||
cloneChecker = new RetryablePredicate<Server.State>(
|
||||
new Predicate<Server.State>() {
|
||||
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
|
||||
api.startServer(testServerId2);
|
||||
api.start(testServerId2);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,11 +56,11 @@ public class BaseGleSYSApiLiveTest extends BaseComputeServiceContextLiveTest {
|
|||
|
||||
protected void createDomain(String domain) {
|
||||
final DomainApi api = gleContext.getApi().getDomainApi();
|
||||
int before = api.listDomains().size();
|
||||
api.addDomain(domain);
|
||||
int before = api.list().size();
|
||||
api.create(domain);
|
||||
RetryablePredicate<Integer> result = new RetryablePredicate<Integer>(new Predicate<Integer>() {
|
||||
public boolean apply(Integer value) {
|
||||
return api.listDomains().size() == value;
|
||||
return api.list().size() == value;
|
||||
}
|
||||
}, 30, 1, TimeUnit.SECONDS);
|
||||
|
||||
|
|
|
@ -69,17 +69,17 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
|
|||
@AfterGroups(groups = {"integration", "live"})
|
||||
@Override
|
||||
public final void tearDownContext() {
|
||||
gleContext.getApi().getServerApi().destroyServer(serverId, DestroyServerOptions.Builder.discardIp());
|
||||
gleContext.getApi().getServerApi().destroy(serverId, DestroyServerOptions.Builder.discardIp());
|
||||
super.tearDownContext();
|
||||
}
|
||||
|
||||
protected void createDomain(String domain) {
|
||||
final DomainApi api = gleContext.getApi().getDomainApi();
|
||||
int before = api.listDomains().size();
|
||||
api.addDomain(domain);
|
||||
int before = api.list().size();
|
||||
api.create(domain);
|
||||
RetryablePredicate<Integer> result = new RetryablePredicate<Integer>(new Predicate<Integer>() {
|
||||
public boolean apply(Integer value) {
|
||||
return api.listDomains().size() == value;
|
||||
return api.list().size() == value;
|
||||
}
|
||||
}, 30, 1, TimeUnit.SECONDS);
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
|
|||
protected ServerStatusChecker createServer(String hostName) {
|
||||
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")
|
||||
.diskSizeGB(5).memorySizeMB(512).cpuCores(1).transferGB(50).build(), hostName, UUID.randomUUID()
|
||||
.toString().replace("-",""));
|
||||
|
@ -117,7 +117,7 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
|
|||
super(new Predicate<Server.State>() {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue