Remove async from glesys

This commit is contained in:
Andrew Bayer 2013-08-02 07:57:30 -07:00
parent d4bf51128e
commit a14c03ba0b
19 changed files with 439 additions and 1035 deletions

View File

@ -29,7 +29,6 @@ import org.jclouds.rest.annotations.Delegate;
* Provides synchronous access to GleSYS.
* <p/>
*
* @see GleSYSAsyncApi
* @see <a href="https://customer.glesys.com/api.php" />
* @author Adrian Cole
*/

View File

@ -24,11 +24,10 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.glesys.compute.config.GleSYSComputeServiceContextModule;
import org.jclouds.glesys.config.GleSYSRestClientModule;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import org.jclouds.glesys.config.GleSYSHttpApiModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
@ -36,17 +35,8 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
public class GleSYSApiMetadata extends BaseRestApiMetadata {
public class GleSYSApiMetadata extends BaseHttpApiMetadata {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GleSYSApi.class)} as
* {@link GleSYSAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<GleSYSApi, GleSYSAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<GleSYSApi, GleSYSAsyncApi>>() {
private static final long serialVersionUID = 1L;
};
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@ -61,17 +51,16 @@ public class GleSYSApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty("jclouds.ssh.max-retries", "5");
properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties;
}
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
public static class Builder extends BaseHttpApiMetadata.Builder<GleSYSApi, Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(GleSYSApi.class, GleSYSAsyncApi.class);
id("glesys")
.name("GleSYS API")
.identityName("Username")
@ -82,7 +71,7 @@ public class GleSYSApiMetadata extends BaseRestApiMetadata {
.defaultEndpoint("https://api.glesys.com")
.defaultProperties(GleSYSApiMetadata.defaultProperties())
.view(typeToken(ComputeServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(GleSYSComputeServiceContextModule.class, GleSYSRestClientModule.class));
.defaultModules(ImmutableSet.<Class<? extends Module>>of(GleSYSComputeServiceContextModule.class, GleSYSHttpApiModule.class));
}
@Override

View File

@ -1,71 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF 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;
import java.io.Closeable;
import org.jclouds.glesys.features.ArchiveAsyncApi;
import org.jclouds.glesys.features.DomainAsyncApi;
import org.jclouds.glesys.features.EmailAccountAsyncApi;
import org.jclouds.glesys.features.IpAsyncApi;
import org.jclouds.glesys.features.ServerAsyncApi;
import org.jclouds.rest.annotations.Delegate;
/**
* Provides asynchronous access to GleSYS via their REST API.
* <p/>
*
* @see GleSYSApi
* @see <a href="https://customer.glesys.com/api.php" />
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GleSYSApi.class)} as
* {@link GleSYSAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface GleSYSAsyncApi extends Closeable {
/**
* Provides asynchronous access to Server features.
*/
@Delegate
ServerAsyncApi getServerApi();
/**
* Provides asynchronous access to Ip Address features.
*/
@Delegate
IpAsyncApi getIpApi();
/**
* Provides asynchronous access to Archive features.
*/
@Delegate
ArchiveAsyncApi getArchiveApi();
/**
* Provides asynchronous access to DNS features.
*/
@Delegate
DomainAsyncApi getDomainApi();
/**
* Provides asynchronous access to E-Mail features.
*/
@Delegate
EmailAccountAsyncApi getEmailAccountApi();
}

View File

@ -24,7 +24,6 @@ import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
import static com.google.common.io.BaseEncoding.base16;
import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import static org.jclouds.util.Predicates2.retry;
import java.util.Map;
@ -53,7 +52,6 @@ import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.glesys.GleSYSApi;
import org.jclouds.glesys.GleSYSAsyncApi;
import org.jclouds.glesys.compute.options.GleSYSTemplateOptions;
import org.jclouds.glesys.domain.AllowedArgumentsForCreateServer;
import org.jclouds.glesys.domain.OSTemplate;
@ -72,8 +70,6 @@ import com.google.common.base.Supplier;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
/**
@ -89,17 +85,15 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
protected Logger logger = Logger.NULL;
private final GleSYSApi api;
private final GleSYSAsyncApi aapi;
private final ListeningExecutorService userExecutor;
private final Timeouts timeouts;
private final Supplier<Set<? extends Location>> locations;
@Inject
public GleSYSComputeServiceAdapter(GleSYSApi api, GleSYSAsyncApi aapi,
public GleSYSComputeServiceAdapter(GleSYSApi api,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, Timeouts timeouts,
@Memoized Supplier<Set<? extends Location>> locations) {
this.api = checkNotNull(api, "api");
this.aapi = checkNotNull(aapi, "aapi");
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
this.timeouts = checkNotNull(timeouts, "timeouts");
this.locations = checkNotNull(locations, "locations");
@ -210,11 +204,11 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override
public Iterable<ServerDetails> listNodes() {
return transformParallel(api.getServerApi().list(), new Function<Server, ListenableFuture<? extends ServerDetails>>() {
public ListenableFuture<ServerDetails> apply(Server from) {
return aapi.getServerApi().get(from.getId());
return api.getServerApi().list().transform(new Function<Server, ServerDetails>() {
public ServerDetails apply(Server from) {
return api.getServerApi().get(from.getId());
}
}, userExecutor, null, logger, "server details");
});
}
@Override

View File

@ -16,20 +16,7 @@
*/
package org.jclouds.glesys.config;
import java.util.Map;
import org.jclouds.glesys.GleSYSApi;
import org.jclouds.glesys.GleSYSAsyncApi;
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.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;
import org.jclouds.glesys.features.ServerAsyncApi;
import org.jclouds.glesys.handlers.GleSYSErrorHandler;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler;
@ -40,9 +27,8 @@ import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule;
import org.jclouds.rest.config.HttpApiModule;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Scopes;
/**
@ -51,19 +37,7 @@ import com.google.inject.Scopes;
* @author Adrian Cole
*/
@ConfiguresRestClient
public class GleSYSRestClientModule extends RestClientModule<GleSYSApi, GleSYSAsyncApi> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(ServerApi.class, ServerAsyncApi.class)//
.put(IpApi.class, IpAsyncApi.class)//
.put(ArchiveApi.class, ArchiveAsyncApi.class)//
.put(DomainApi.class, DomainAsyncApi.class)//
.put(EmailAccountApi.class, EmailAccountAsyncApi.class)//
.build();
public GleSYSRestClientModule() {
super(DELEGATE_MAP);
}
public class GleSYSHttpApiModule extends HttpApiModule<GleSYSApi> {
@Override
protected void configure() {

View File

@ -16,8 +16,21 @@
*/
package org.jclouds.glesys.features;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.Archive;
import org.jclouds.glesys.domain.ArchiveAllowedArguments;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
@ -26,14 +39,20 @@ import com.google.common.collect.FluentIterable;
* <p/>
*
* @author Adam Lowe
* @see ArchiveAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface ArchiveApi {
/**
* Lists all active disks on this account.
*/
@Named("archive:list")
@POST
@Path("/archive/list/format/json")
@SelectJson("archives")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<Archive> list();
/**
@ -42,24 +61,39 @@ public interface ArchiveApi {
* @param username the username associated with the archive
* @return the archive information or null if not found
*/
Archive get(String username);
@Named("archive:details")
@POST
@Path("/archive/details/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
Archive get(@FormParam("username") String username);
/**
* Create a new backup volume.
*
* @param username the archive username, this must be prefixed by Glesys account name (in lower case) and an
* @param username the archive username, this must be prefixed by Glesys account name (in lower case) and an
* underscore, ex. "c100005_archive1"
* @param password the new password
* @param size the new size required in GB
*/
Archive createWithCredentialsAndSize(String username, String password, int size);
@Named("archive:create")
@POST
@Path("/archive/create/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
Archive createWithCredentialsAndSize(@FormParam("username") String username, @FormParam("password") String password,
@FormParam("size")int size);
/**
* Delete an archive volume. All files on the volume
*
* @param username the username associated with the archive
*/
void delete(String username);
@Named("archive:delete")
@POST
@Path("/archive/delete/format/json")
void delete(@FormParam("username") String username);
/**
* Resize an archive volume. It is only possible to upgrade the size of the disk. Downgrading is currently not
@ -69,7 +103,12 @@ public interface ArchiveApi {
* @param username the username associated with the archive
* @param size the new size required, see #getAllowedArguments for valid values
*/
Archive resize(String username, int size);
@Named("archive:resize")
@POST
@Path("/archive/resize/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
Archive resize(@FormParam("username") String username, @FormParam("size") int size);
/**
* Change the password for an archive user.
@ -77,11 +116,22 @@ public interface ArchiveApi {
* @param username the archive username
* @param password the new password
*/
Archive changePassword(String username, String password);
@Named("archive:changepassword")
@POST
@Path("/archive/changepassword/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
Archive changePassword(@FormParam("username") String username, @FormParam("password") String password);
/**
* Lists the allowed arguments for some of the functions in this module such as archive size.
*/
@Named("archive:allowedarguments")
@GET
@Path("/archive/allowedarguments/format/json")
@SelectJson("argumentslist")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
ArchiveAllowedArguments getAllowedArguments();
}

View File

@ -1,121 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.glesys.features;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.glesys.domain.Archive;
import org.jclouds.glesys.domain.ArchiveAllowedArguments;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to Archive data via the Glesys REST API.
* <p/>
*
* @author Adam Lowe
* @see ArchiveApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface ArchiveAsyncApi {
/**
* @see ArchiveApi#list
*/
@Named("archive:list")
@POST
@Path("/archive/list/format/json")
@SelectJson("archives")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<FluentIterable<Archive>> list();
/**
* @see ArchiveApi#get
*/
@Named("archive:details")
@POST
@Path("/archive/details/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<Archive> get(@FormParam("username") String username);
/**
* @see ArchiveApi#createWithCredentialsAndSize
*/
@Named("archive:create")
@POST
@Path("/archive/create/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Archive> createWithCredentialsAndSize(@FormParam("username") String username, @FormParam("password") String password,
@FormParam("size")int size);
/**
* @see ArchiveApi#delete
*/
@Named("archive:delete")
@POST
@Path("/archive/delete/format/json")
ListenableFuture<Void> delete(@FormParam("username") String username);
/**
* @see ArchiveApi#resize
*/
@Named("archive:resize")
@POST
@Path("/archive/resize/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Archive> resize(@FormParam("username") String username, @FormParam("size") int size);
/**
* @see ArchiveApi#changePassword
*/
@Named("archive:changepassword")
@POST
@Path("/archive/changepassword/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Archive> changePassword(@FormParam("username") String username, @FormParam("password") String password);
/**
* @see org.jclouds.glesys.features.ArchiveApi#getAllowedArguments
*/
@Named("archive:allowedarguments")
@GET
@Path("/archive/allowedarguments/format/json")
@SelectJson("argumentslist")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<ArchiveAllowedArguments> getAllowedArguments();
}

View File

@ -17,12 +17,25 @@
package org.jclouds.glesys.features;
import java.util.Set;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.Domain;
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.UpdateRecordOptions;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
@ -31,9 +44,9 @@ import com.google.common.collect.FluentIterable;
* <p/>
*
* @author Adam Lowe
* @see DomainAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface DomainApi {
/**
@ -41,6 +54,12 @@ public interface DomainApi {
*
* @return an account's associated domain objects.
*/
@Named("domain:list")
@POST
@Path("/domain/list/format/json")
@SelectJson("domains")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<Domain> list();
/**
@ -48,16 +67,27 @@ public interface DomainApi {
*
* @return the requested domain object.
*/
Domain get(String domain);
@Named("domain:details")
@POST
@Path("/domain/details/format/json")
@SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
Domain get(@FormParam("domainname") String name);
/**
* Add a domain to the Glesys dns-system
*
* @param domain the name of the domain to add.
* @param name the name of the domain to add.
* @param options optional parameters
* @return information about the added domain
*/
Domain create(String domain, AddDomainOptions... options);
@Named("domain:add")
@POST
@Path("/domain/add/format/json")
@SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON)
Domain create(@FormParam("domainname") String name, AddDomainOptions... options);
/**
* Update a domain to the Glesys dns-system
@ -66,21 +96,34 @@ public interface DomainApi {
* @param options optional parameters
* @return information about the modified domain
*/
Domain update(String domain, DomainOptions options);
@Named("domain:edit")
@POST
@Path("/domain/edit/format/json")
@SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON)
Domain update(@FormParam("domainname") String domain, DomainOptions options);
/**
* Remove a domain to the Glesys dns-system
*
* @param domain the name of the domain to remove
*/
void delete(String domain);
@Named("domain:delete")
@POST
@Path("/domain/delete/format/json")
void delete(@FormParam("domainname") String domain);
/**
* Retrieve the DNS records for a given domain
*
* @param domain the name of the domain to retrieve records for
*/
Set<DomainRecord> listRecords(String domain);
@Named("domain:listrecords")
@POST
@Path("/domain/listrecords/format/json")
@SelectJson("records")
@Consumes(MediaType.APPLICATION_JSON)
Set<DomainRecord> listRecords(@FormParam("domainname") String domain);
/**
* Add a DNS Record
@ -88,7 +131,14 @@ public interface DomainApi {
* @param domain the domain to add the record to
* @param options optional settings for the record
*/
DomainRecord createRecord(String domain, String host, String type, String data, AddRecordOptions... options);
@Named("domain:addrecord")
@POST
@Path("/domain/addrecord/format/json")
@SelectJson("record")
@Consumes(MediaType.APPLICATION_JSON)
DomainRecord createRecord(@FormParam("domainname") String domain, @FormParam("host") String host,
@FormParam("type") String type, @FormParam("data") String data,
AddRecordOptions... options);
/**
* Modify a specific DNS Record
@ -97,7 +147,12 @@ public interface DomainApi {
* @param options the settings to change
* @see #listRecords to retrieve the necessary ids
*/
DomainRecord updateRecord(String recordId, UpdateRecordOptions options);
@Named("domain:updaterecord")
@POST
@Path("/domain/updaterecord/format/json")
@SelectJson("record")
@Consumes(MediaType.APPLICATION_JSON)
DomainRecord updateRecord(@FormParam("recordid") String recordId, UpdateRecordOptions options);
/**
* Delete a DNS record
@ -105,6 +160,9 @@ public interface DomainApi {
* @param recordId the id for the record to delete
* @see #listRecords to retrieve the necessary ids
*/
void deleteRecord(String recordId);
@Named("domain:deleterecord")
@POST
@Path("/domain/deleterecord/format/json")
void deleteRecord(@FormParam("recordid") String recordId);
}

View File

@ -1,146 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.glesys.features;
import java.util.Set;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.glesys.domain.Domain;
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.UpdateRecordOptions;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to Domain (DNS) data via the Glesys REST API.
* <p/>
*
* @author Adam Lowe
* @see DomainApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface DomainAsyncApi {
/**
* @see org.jclouds.glesys.features.DomainApi#list
*/
@Named("domain:list")
@POST
@Path("/domain/list/format/json")
@SelectJson("domains")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<FluentIterable<Domain>> list();
/**
* @see org.jclouds.glesys.features.DomainApi#get
*/
@Named("domain:details")
@POST
@Path("/domain/details/format/json")
@SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<Domain> get(@FormParam("domainname") String name);
/**
* @see DomainApi#create
*/
@Named("domain:add")
@POST
@Path("/domain/add/format/json")
@SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Domain> create(@FormParam("domainname") String name, AddDomainOptions... options);
/**
* @see DomainApi#update
*/
@Named("domain:edit")
@POST
@Path("/domain/edit/format/json")
@SelectJson("domain")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Domain> update(@FormParam("domainname") String domain, DomainOptions options);
/**
* @see DomainApi#delete
*/
@Named("domain:delete")
@POST
@Path("/domain/delete/format/json")
ListenableFuture<Void> delete(@FormParam("domainname") String domain);
/**
* @see DomainApi#listRecords
*/
@Named("domain:listrecords")
@POST
@Path("/domain/listrecords/format/json")
@SelectJson("records")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Set<DomainRecord>> listRecords(@FormParam("domainname") String domain);
/**
* @see DomainApi#createRecord
*/
@Named("domain:addrecord")
@POST
@Path("/domain/addrecord/format/json")
@SelectJson("record")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<DomainRecord> createRecord(@FormParam("domainname") String domain, @FormParam("host") String host,
@FormParam("type") String type, @FormParam("data") String data,
AddRecordOptions... options);
/**
* @see DomainApi#updateRecord
*/
@Named("domain:updaterecord")
@POST
@Path("/domain/updaterecord/format/json")
@SelectJson("record")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<DomainRecord> updateRecord(@FormParam("recordid") String record_id, UpdateRecordOptions options);
/**
* @see DomainApi#deleteRecord
*/
@Named("domain:deleterecord")
@POST
@Path("/domain/deleterecord/format/json")
ListenableFuture<Void> deleteRecord(@FormParam("recordid") String recordId);
}

View File

@ -16,11 +16,23 @@
*/
package org.jclouds.glesys.features;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks;
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.UpdateAccountOptions;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
@ -29,9 +41,9 @@ import com.google.common.collect.FluentIterable;
* <p/>
*
* @author Adam Lowe
* @see org.jclouds.glesys.features.EmailAccountAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface EmailAccountApi {
/**
@ -39,6 +51,12 @@ public interface EmailAccountApi {
*
* @return the relevant summary data
*/
@Named("email:overview")
@POST
@Path("/email/overview/format/json")
@SelectJson("overview")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
EmailOverview getOverview();
/**
@ -46,14 +64,26 @@ public interface EmailAccountApi {
*
* @return the relevant set of details
*/
FluentIterable<EmailAccount> listDomain(String domain);
@Named("email:list:accounts")
@POST
@Path("/email/list/format/json")
@SelectJson("emailaccounts")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<EmailAccount> listDomain(@FormParam("domainname") String domain);
/**
* Get the set of details about e-mail aliases
*
* @return the relevant set of details
*/
FluentIterable<EmailAlias> listAliasesInDomain(String domain);
@Named("email:list:aliases")
@POST
@Path("/email/list/format/json")
@SelectJson("emailaliases")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<EmailAlias> listAliasesInDomain(@FormParam("domainname") String domain);
/**
* Create a new e-mail account
@ -63,7 +93,12 @@ public interface EmailAccountApi {
* @param options optional parameters
* @see DomainApi#create
*/
EmailAccount createWithPassword(String accountAddress, String password, CreateAccountOptions... options);
@Named("email:createaccount")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("emailaccount")
@Path("/email/createaccount/format/json")
EmailAccount createWithPassword(@FormParam("emailaccount") String accountAddress, @FormParam("password") String password, CreateAccountOptions... options);
/**
* Create an e-mail alias for an e-mail account
@ -72,7 +107,12 @@ public interface EmailAccountApi {
* @param toEmailAddress the existing e-mail account address the alias should forward to
* @see DomainApi#create
*/
EmailAlias createAlias(String aliasAddress, String toEmailAddress);
@Named("email:createalias")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("alias")
@Path("/email/createalias/format/json")
EmailAlias createAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
/**
* Adjust an e-mail account's settings
@ -80,7 +120,12 @@ public interface EmailAccountApi {
* @param accountAddress the existing e-mail account address
* @param options optional parameters
*/
EmailAccount update(String accountAddress, UpdateAccountOptions... options);
@Named("email:editaccount")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("emailaccount")
@Path("/email/editaccount/format/json")
EmailAccount update(@FormParam("emailaccount") String accountAddress, UpdateAccountOptions... options);
/**
* Adjust (re-target) an e-mail alias
@ -88,13 +133,22 @@ public interface EmailAccountApi {
* @param aliasAddress the existing alias e-mail address
* @param toEmailAddress the existing e-mail account address the alias should forward to
*/
EmailAlias updateAlias(String aliasAddress, String toEmailAddress);
@Named("email:editalias")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("alias")
@Path("/email/editalias/format/json")
EmailAlias updateAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
/**
* Delete an e-mail account or alias
*
* @param accountAddress the existing alias e-mail account or alias address
*/
boolean delete(String accountAddress);
@Named("email:delete")
@POST
@Path("/email/delete/format/json")
@Fallback(Fallbacks.TrueOnNotFoundOr404.class)
boolean delete(@FormParam("email") String accountAddress);
}

View File

@ -1,135 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.glesys.features;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.Fallbacks.TrueOnNotFoundOr404;
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.UpdateAccountOptions;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to E-Mail data via the Glesys REST API.
* <p/>
*
* @author Adam Lowe
* @see org.jclouds.glesys.features.EmailAccountApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface EmailAccountAsyncApi {
/**
* @see org.jclouds.glesys.features.EmailAccountApi#getOverview
*/
@Named("email:overview")
@POST
@Path("/email/overview/format/json")
@SelectJson("overview")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<EmailOverview> getOverview();
/**
* @see org.jclouds.glesys.features.EmailAccountApi#listDomain
*/
@Named("email:list:accounts")
@POST
@Path("/email/list/format/json")
@SelectJson("emailaccounts")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<FluentIterable<EmailAccount>> listDomain(@FormParam("domainname") String domain);
/**
* @see org.jclouds.glesys.features.EmailAccountApi#listAliasesInDomain
*/
@Named("email:list:aliases")
@POST
@Path("/email/list/format/json")
@SelectJson("emailaliases")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<FluentIterable<EmailAlias>> listAliasesInDomain(@FormParam("domainname") String domain);
/**
* @see org.jclouds.glesys.features.EmailAccountApi#createWithPassword
*/
@Named("email:createaccount")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("emailaccount")
@Path("/email/createaccount/format/json")
ListenableFuture<EmailAccount> createWithPassword(@FormParam("emailaccount") String accountAddress, @FormParam("password") String password, CreateAccountOptions... options);
/**
* @see org.jclouds.glesys.features.EmailAccountApi#createAlias
*/
@Named("email:createalias")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("alias")
@Path("/email/createalias/format/json")
ListenableFuture<EmailAlias> createAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
/**
* @see org.jclouds.glesys.features.EmailAccountApi#update
*/
@Named("email:editaccount")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("emailaccount")
@Path("/email/editaccount/format/json")
ListenableFuture<EmailAccount> update(@FormParam("emailaccount") String accountAddress, UpdateAccountOptions... options);
/**
* @see org.jclouds.glesys.features.EmailAccountApi#updateAlias
*/
@Named("email:editalias")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("alias")
@Path("/email/editalias/format/json")
ListenableFuture<EmailAlias> updateAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
/**
* @see org.jclouds.glesys.features.EmailAccountApi#delete
*/
@Named("email:delete")
@POST
@Path("/email/delete/format/json")
@Fallback(TrueOnNotFoundOr404.class)
ListenableFuture<Boolean> delete(@FormParam("email") String accountAddress);
}

View File

@ -16,8 +16,23 @@
*/
package org.jclouds.glesys.features;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.IpDetails;
import org.jclouds.glesys.options.ListIpOptions;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
@ -26,9 +41,9 @@ import com.google.common.collect.FluentIterable;
* <p/>
*
* @author Adrian Cole, Mattias Holmqvist, Adam Lowe
* @see IpAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface IpApi {
/**
* Get a set of all IP addresses that are available and not used on any account or server.
@ -38,7 +53,15 @@ public interface IpApi {
* @param platform the platform
* @return a set of free IP addresses
*/
FluentIterable<String> listFree(int ipVersion, String datacenter, String platform);
@Named("ip:listfree")
@GET
@Path("/ip/listfree/ipversion/{ipversion}/datacenter/{datacenter}/platform/{platform}/format/json")
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("ipaddresses")
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<String> listFree(@PathParam("ipversion") int ipVersion,
@PathParam("datacenter") String datacenter,
@PathParam("platform") String platform);
/**
* Take a free IP address and add it to this account. You can list free IP addresses with the function listFree().
@ -46,7 +69,12 @@ public interface IpApi {
*
* @param ipAddress the IP address to be add to this account (reserve)
*/
IpDetails take(String ipAddress);
@Named("ip:take")
@POST
@Path("/ip/take/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
IpDetails take(@FormParam("ipaddress") String ipAddress);
/**
* Return an unused IP address to the pool of free ips. If the IP address is allocated to a server,
@ -54,7 +82,12 @@ public interface IpApi {
*
* @param ipAddress the IP address to be released
*/
IpDetails release(String ipAddress);
@Named("ip:release")
@POST
@Path("/ip/release/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
IpDetails release(@FormParam("ipaddress") String ipAddress);
/**
* Get IP addresses associated with your account (reserved, assigned to servers, etc)
@ -62,6 +95,12 @@ public interface IpApi {
* @param options options to filter the results (by IPV4/6, serverId, etc)
* @return the set of IP addresses
*/
@Named("ip:listown")
@GET
@Path("/ip/listown/format/json")
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("iplist")
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<IpDetails> list(ListIpOptions... options);
/**
@ -71,7 +110,13 @@ public interface IpApi {
* @param ipAddress the ip address
* @return details about the given IP address
*/
IpDetails get(String ipAddress);
@Named("ip:details")
@GET
@Path("/ip/details/ipaddress/{ipaddress}/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
IpDetails get(@PathParam("ipaddress") 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
@ -82,7 +127,13 @@ public interface IpApi {
* @param ipAddress the IP address to remove
* @param serverId the server to add the IP address to
*/
IpDetails addToServer(String ipAddress, String serverId);
@Named("ip:add")
@POST
@Path("/ip/add/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
IpDetails addToServer(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") 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
@ -93,7 +144,13 @@ public interface IpApi {
* @param serverId the server to remove the IP address from
* @see #removeFromServerAndRelease
*/
IpDetails removeFromServer(String ipAddress, String serverId);
@Named("ip:remove")
@POST
@Path("/ip/remove/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
IpDetails removeFromServer(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId);
/**
* Remove an IP address from a server and release it back to GleSYS pool of free ips.
@ -102,16 +159,34 @@ public interface IpApi {
* @param serverId the server to remove the IP address from
* @see #removeFromServer
*/
IpDetails removeFromServerAndRelease(String ipAddress, String serverId);
@Named("ip:remove:release")
@POST
@FormParams(keys = "release", values = "true")
@Path("/ip/remove/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
IpDetails removeFromServerAndRelease(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId);
/**
* Sets PTR data for an IP. Use ip/listown or ip/details to get current PTR data
*/
IpDetails setPtr(String ipAddress, String ptr);
@Named("ip:setptr")
@POST
@Path("/ip/setptr/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
IpDetails setPtr(@FormParam("ipaddress") String ipAddress,
@FormParam("data") String ptr);
/**
* Resets PTR data for an IP back to the default value
*/
IpDetails resetPtr(String ipAddress);
@Named("ip:resetptr")
@POST
@Path("/ip/resetptr/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
IpDetails resetPtr(@FormParam("ipaddress") String ipAddress);
}

View File

@ -1,162 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.glesys.features;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.glesys.domain.IpDetails;
import org.jclouds.glesys.options.ListIpOptions;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to IP Addresses via their REST API.
* <p/>
*
* @author Adrian Cole, Mattias Holmqvist, Adam Lowe
* @see IpApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface IpAsyncApi {
/**
* @see IpApi#listFree
*/
@Named("ip:listfree")
@GET
@Path("/ip/listfree/ipversion/{ipversion}/datacenter/{datacenter}/platform/{platform}/format/json")
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("ipaddresses")
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<FluentIterable<String>> listFree(@PathParam("ipversion") int ipversion,
@PathParam("datacenter") String datacenter,
@PathParam("platform") String platform);
/**
* @see IpApi#take
*/
@Named("ip:take")
@POST
@Path("/ip/take/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> take(@FormParam("ipaddress") String ipAddress);
/**
* @see IpApi#release
*/
@Named("ip:release")
@POST
@Path("/ip/release/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> release(@FormParam("ipaddress") String ipAddress);
/**
* @see IpApi#list
*/
@Named("ip:listown")
@GET
@Path("/ip/listown/format/json")
@Consumes(MediaType.APPLICATION_JSON)
@SelectJson("iplist")
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<FluentIterable<IpDetails>> list(ListIpOptions... options);
/**
* @see IpApi#get
*/
@Named("ip:details")
@GET
@Path("/ip/details/ipaddress/{ipaddress}/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<IpDetails> get(@PathParam("ipaddress") String ipAddress);
/**
* @see IpApi#addToServer
*/
@Named("ip:add")
@POST
@Path("/ip/add/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> addToServer(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId);
/**
* @see IpApi#removeFromServer
*/
@Named("ip:remove")
@POST
@Path("/ip/remove/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> removeFromServer(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId);
/**
* @see IpApi#removeFromServer
*/
@Named("ip:remove:release")
@POST
@FormParams(keys = "release", values = "true")
@Path("/ip/remove/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> removeFromServerAndRelease(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId);
/**
* @see IpApi#setPtr
*/
@Named("ip:setptr")
@POST
@Path("/ip/setptr/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> setPtr(@FormParam("ipaddress") String ipAddress,
@FormParam("data") String ptr);
/**
* @see IpApi#resetPtr
*/
@Named("ip:resetptr")
@POST
@Path("/ip/resetptr/format/json")
@SelectJson("details")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<IpDetails> resetPtr(@FormParam("ipaddress") String ipAddress);
}

View File

@ -17,6 +17,17 @@
package org.jclouds.glesys.features;
import java.util.Map;
import java.util.SortedMap;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.AllowedArgumentsForCreateServer;
import org.jclouds.glesys.domain.Console;
import org.jclouds.glesys.domain.OSTemplate;
@ -26,13 +37,21 @@ import org.jclouds.glesys.domain.ServerDetails;
import org.jclouds.glesys.domain.ServerLimit;
import org.jclouds.glesys.domain.ServerSpec;
import org.jclouds.glesys.domain.ServerStatus;
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.UpdateServerOptions;
import org.jclouds.glesys.options.ServerStatusOptions;
import org.jclouds.glesys.options.UpdateServerOptions;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.MapBinder;
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 com.google.common.annotations.Beta;
import com.google.common.collect.FluentIterable;
/**
@ -41,9 +60,9 @@ import com.google.common.collect.FluentIterable;
*
* @author Adrian Cole
* @author Adam Lowe
* @see ServerAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface ServerApi {
/**
@ -51,6 +70,12 @@ public interface ServerApi {
*
* @return an account's associated server objects.
*/
@Named("server:list")
@POST
@Path("/server/list/format/json")
@SelectJson("servers")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<Server> list();
/**
@ -61,7 +86,14 @@ public interface ServerApi {
* @param id id of the server
* @return server or null if not found
*/
ServerDetails get(String id);
@Named("server:details")
@POST
@Path("/server/details/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
@FormParams(keys = "includestate", values = "true")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
ServerDetails get(@FormParam("serverid") String id);
/**
* Get detailed information about a server status including up-time and
@ -71,7 +103,13 @@ public interface ServerApi {
* @param options optional parameters
* @return the status of the server or null if not found
*/
ServerStatus getStatus(String id, ServerStatusOptions... options);
@Named("server:status")
@POST
@Path("/server/status/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
ServerStatus getStatus(@FormParam("serverid") String id, ServerStatusOptions... options);
/**
* Get detailed information about a server's limits (for OpenVZ only).
@ -80,7 +118,13 @@ public interface ServerApi {
* @param id id of the server
* @return the requested information about the server or null if not found
*/
Map<String, ServerLimit> getLimits(String id);
@Named("server:limits")
@POST
@Path("/server/limits/format/json")
@SelectJson("limits")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
SortedMap<String, ServerLimit> getLimits(@FormParam("serverid") String id);
/**
* Get information about how to connect to a server via VNC
@ -88,21 +132,38 @@ public interface ServerApi {
* @param id id of the server
* @return the requested information about the server or null if not found
*/
Console getConsole(String id);
@Named("server:console")
@POST
@Path("/server/console/format/json")
@SelectJson("console")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
Console getConsole(@FormParam("serverid") String id);
/**
* Get information about the OS templates available
*
* @return the set of information about each template
*/
FluentIterable<OSTemplate> listTemplates();
@Named("server:allowedarguments")
@GET
@Path("/server/allowedarguments/format/json")
@SelectJson("argumentslist")
@Consumes(MediaType.APPLICATION_JSON)
Map<String, AllowedArgumentsForCreateServer> getAllowedArgumentsForCreateByPlatform();
/**
* Get information about valid arguments to #createServer for each platform
*
* @return a map of argument lists, keyed on platform
*/
Map<String, AllowedArgumentsForCreateServer> getAllowedArgumentsForCreateByPlatform();
@Named("server:templates")
@GET
@Path("/server/templates/format/json")
@ResponseParser(ParseTemplatesFromHttpResponse.class)
@Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
@Consumes(MediaType.APPLICATION_JSON)
FluentIterable<OSTemplate> listTemplates();
/**
* Reset the fail count for a server limit (for OpenVZ only).
@ -110,35 +171,61 @@ public interface ServerApi {
* @param id id of the server
* @param type the type of limit to reset
*/
Map<String, ServerLimit> resetLimit(String id, String type);
@Named("server:resetlimit")
@POST
@Path("/server/resetlimit/format/json")
@Consumes(MediaType.APPLICATION_JSON)
SortedMap<String, ServerLimit> resetLimit(@FormParam("serverid") String id,
@FormParam("type") String type);
/**
* Reboot a server
*
* @param id id of the server
*/
ServerDetails reboot(String id);
@Named("server:reboot")
@POST
@SelectJson("server")
@Path("/server/reboot/format/json")
@Consumes(MediaType.APPLICATION_JSON)
ServerDetails reboot(@FormParam("serverid") String id);
/**
* Start a server
*
* @param id id of the server
*/
ServerDetails start(String id);
@Named("server:start")
@POST
@SelectJson("server")
@Path("/server/start/format/json")
@Consumes(MediaType.APPLICATION_JSON)
ServerDetails start(@FormParam("serverid") String id);
/**
* Stop a server
*
* @param id id of the server
*/
ServerDetails stop(String id);
@Named("server:stop")
@POST
@SelectJson("server")
@Path("/server/stop/format/json")
@Consumes(MediaType.APPLICATION_JSON)
ServerDetails stop(@FormParam("serverid") String id);
/**
* hard stop a server
*
* @param id id of the server
*/
ServerDetails hardStop(String id);
@Named("server:stop:hard")
@POST
@SelectJson("server")
@Path("/server/stop/format/json")
@FormParams(keys = "type", values = "hard")
@Consumes(MediaType.APPLICATION_JSON)
ServerDetails hardStop(@FormParam("serverid") String id);
/**
* Create a new server
@ -147,16 +234,15 @@ public interface ServerApi {
* @param rootPassword the root password to use
* @param options optional settings ex. description
*/
ServerDetails createWithHostnameAndRootPassword(ServerSpec serverSpec, String hostname, String rootPassword,
CreateServerOptions... options);
/**
* Update the configuration of a server
*
* @param serverid the serverId of the server to edit
* @param options the settings to change
*/
ServerDetails update(String serverid, UpdateServerOptions options);
@Named("server:create")
@POST
@SelectJson("server")
@Path("/server/create/format/json")
@Consumes(MediaType.APPLICATION_JSON)
@MapBinder(CreateServerOptions.class)
ServerDetails createWithHostnameAndRootPassword(ServerSpec serverSpec,
@PayloadParam("hostname") String hostname, @PayloadParam("rootpassword") String rootPassword,
CreateServerOptions... options);
/**
* Clone a server
@ -165,7 +251,26 @@ public interface ServerApi {
* @param hostname the new host name of the cloned server
* @param options the settings to change
*/
ServerDetails clone(String serverid, String hostname, CloneServerOptions... options);
@Named("server:clone")
@POST
@Path("/server/clone/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
ServerDetails clone(@FormParam("serverid") String serverid,
@FormParam("hostname") String hostname, CloneServerOptions... options);
/**
* Update the configuration of a server
*
* @param serverid the serverId of the server to edit
* @param options the settings to change
*/
@Named("server:edit")
@POST
@Path("/server/edit/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
ServerDetails update(@FormParam("serverid") String serverid, UpdateServerOptions options);
/**
* Destroy a server
@ -173,7 +278,10 @@ 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 destroy(String id, DestroyServerOptions keepIp);
@Named("server:destroy")
@POST
@Path("/server/destroy/format/json")
void destroy(@FormParam("serverid") String id, DestroyServerOptions keepIp);
/**
* Reset the root password of a server
@ -181,7 +289,12 @@ public interface ServerApi {
* @param id the id of the server
* @param password the new password to use
*/
ServerDetails resetPassword(String id, String password);
@Named("server:resetpassword")
@POST
@Path("/server/resetpassword/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
ServerDetails resetPassword(@FormParam("serverid") String id, @FormParam("rootpassword") String password);
/**
* Return resource usage over time for server
@ -190,8 +303,12 @@ public interface ServerApi {
* @param resource the name of the resource to retrieve usage information for (e.g. "cpuusage")
* @param resolution the time-period to extract data for (one of "minute", "hour" or "day)
*/
@Beta
// TODO: better name
ResourceUsage getResourceUsage(String id, String resource, String resolution);
@Named("server:resourceusage")
@POST
@Path("/server/resourceusage/format/json")
@SelectJson("usage")
@Consumes(MediaType.APPLICATION_JSON)
ResourceUsage getResourceUsage(@FormParam("serverid") String id, @FormParam("resource") String resource,
@FormParam("resolution") String resolution);
}

View File

@ -1,262 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.glesys.features;
import java.util.Map;
import java.util.SortedMap;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.glesys.domain.AllowedArgumentsForCreateServer;
import org.jclouds.glesys.domain.Console;
import org.jclouds.glesys.domain.OSTemplate;
import org.jclouds.glesys.domain.ResourceUsage;
import org.jclouds.glesys.domain.Server;
import org.jclouds.glesys.domain.ServerDetails;
import org.jclouds.glesys.domain.ServerLimit;
import org.jclouds.glesys.domain.ServerSpec;
import org.jclouds.glesys.domain.ServerStatus;
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.ServerStatusOptions;
import org.jclouds.glesys.options.UpdateServerOptions;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.MapBinder;
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 com.google.common.collect.FluentIterable;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to Server via their REST API.
* <p/>
*
* @author Adrian Cole
* @author Adam Lowe
* @see ServerApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
@RequestFilters(BasicAuthentication.class)
public interface ServerAsyncApi {
/**
* @see ServerApi#list
*/
@Named("server:list")
@POST
@Path("/server/list/format/json")
@SelectJson("servers")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
ListenableFuture<FluentIterable<Server>> list();
/**
* @see ServerApi#get
*/
@Named("server:details")
@POST
@Path("/server/details/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
@FormParams(keys = "includestate", values = "true")
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<ServerDetails> get(@FormParam("serverid") String id);
/**
* @see ServerApi#getStatus
*/
@Named("server:status")
@POST
@Path("/server/status/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<ServerStatus> getStatus(@FormParam("serverid") String id, ServerStatusOptions... options);
/**
* @see ServerApi#getLimits
*/
@Named("server:limits")
@POST
@Path("/server/limits/format/json")
@SelectJson("limits")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<SortedMap<String, ServerLimit>> getLimits(@FormParam("serverid") String id);
/**
* @see ServerApi#getConsole
*/
@Named("server:console")
@POST
@Path("/server/console/format/json")
@SelectJson("console")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<Console> getConsole(@FormParam("serverid") String id);
/**
* @see ServerApi#getAllowedArgumentsForCreateByPlatform
*/
@Named("server:allowedarguments")
@GET
@Path("/server/allowedarguments/format/json")
@SelectJson("argumentslist")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<Map<String, AllowedArgumentsForCreateServer>> getAllowedArgumentsForCreateByPlatform();
/**
* @see ServerApi#listTemplates
*/
@Named("server:templates")
@GET
@Path("/server/templates/format/json")
@ResponseParser(ParseTemplatesFromHttpResponse.class)
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<FluentIterable<OSTemplate>> listTemplates();
/**
* @see ServerApi#stop
*/
@Named("server:resetlimit")
@POST
@Path("/server/resetlimit/format/json")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<SortedMap<String, ServerLimit>> resetLimit(@FormParam("serverid") String id,
@FormParam("type") String type);
/**
* @see ServerApi#reboot
*/
@Named("server:reboot")
@POST
@SelectJson("server")
@Path("/server/reboot/format/json")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> reboot(@FormParam("serverid") String id);
/**
* @see ServerApi#start
*/
@Named("server:start")
@POST
@SelectJson("server")
@Path("/server/start/format/json")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> start(@FormParam("serverid") String id);
/**
* @see ServerApi#stop
*/
@Named("server:stop")
@POST
@SelectJson("server")
@Path("/server/stop/format/json")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> stop(@FormParam("serverid") String id);
/**
* @see ServerApi#hardStop
*/
@Named("server:stop:hard")
@POST
@SelectJson("server")
@Path("/server/stop/format/json")
@FormParams(keys = "type", values = "hard")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> hardStop(@FormParam("serverid") String id);
/**
* @see ServerApi#createWithHostnameAndRootPassword
*/
@Named("server:create")
@POST
@SelectJson("server")
@Path("/server/create/format/json")
@Consumes(MediaType.APPLICATION_JSON)
@MapBinder(CreateServerOptions.class)
ListenableFuture<ServerDetails> createWithHostnameAndRootPassword(ServerSpec serverSpec,
@PayloadParam("hostname") String hostname, @PayloadParam("rootpassword") String rootPassword,
CreateServerOptions... options);
/**
* @see ServerApi#clone
*/
@Named("server:clone")
@POST
@Path("/server/clone/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> clone(@FormParam("serverid") String serverid,
@FormParam("hostname") String hostname, CloneServerOptions... options);
/**
* @see ServerApi#update
*/
@Named("server:edit")
@POST
@Path("/server/edit/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> update(@FormParam("serverid") String serverid, UpdateServerOptions options);
/**
* @see ServerApi#destroy
*/
@Named("server:destroy")
@POST
@Path("/server/destroy/format/json")
ListenableFuture<Void> destroy(@FormParam("serverid") String id, DestroyServerOptions keepIp);
/**
* @see ServerApi#resetPassword
*/
@Named("server:resetpassword")
@POST
@Path("/server/resetpassword/format/json")
@SelectJson("server")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ServerDetails> resetPassword(@FormParam("serverid") String id, @FormParam("rootpassword") String password);
/**
* @see ServerApi#getResourceUsage
*/
@Named("server:resourceusage")
@POST
@Path("/server/resourceusage/format/json")
@SelectJson("usage")
@Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ResourceUsage> getResourceUsage(@FormParam("serverid") String id, @FormParam("resource") String resource,
@FormParam("resolution") String resolution);
}

View File

@ -26,15 +26,14 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Tests behavior of {@code GleSYSAsyncApi}
* Tests behavior of {@code GleSYSApi}
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "GleSYSAsyncApiTest")
public class GleSYSAsyncApiTest extends BaseAsyncApiTest<GleSYSAsyncApi> {
private GleSYSAsyncApi asyncApi;
@Test(groups = "unit", testName = "GleSYSApiTest")
public class GleSYSApiTest extends BaseAsyncApiTest<GleSYSApi> {
private GleSYSApi syncApi;
@Override
@ -49,18 +48,10 @@ public class GleSYSAsyncApiTest extends BaseAsyncApiTest<GleSYSAsyncApi> {
assert syncApi.getArchiveApi() != null;
}
public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
assert asyncApi.getServerApi() != null;
assert asyncApi.getIpApi() != null;
assert asyncApi.getDomainApi() != null;
assert asyncApi.getArchiveApi() != null;
}
@BeforeClass
@Override
protected void setupFactory() throws IOException {
super.setupFactory();
asyncApi = injector.getInstance(GleSYSAsyncApi.class);
syncApi = injector.getInstance(GleSYSApi.class);
}

View File

@ -35,7 +35,7 @@ import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
/**
* Tests parsing of {@code ArchiveAsyncApi}
* Tests parsing of {@code ArchiveApi}
*
* @author Adam Lowe
*/

View File

@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
/**
* Tests annotation parsing of {@code DomainAsyncApi}
* Tests annotation parsing of {@code DomainApi}
*
* @author Adam Lowe
*/

View File

@ -55,12 +55,12 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/**
* Tests annotation parsing of {@code ServerAsyncApi}
* Tests annotation parsing of {@code ServerApi}
*
* @author Adrian Cole
* @author Adam Lowe
*/
@Test(groups = "unit", testName = "ServerAsyncApiTest")
@Test(groups = "unit", testName = "ServerApiTest")
public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
public void testListServersWhenResponseIs2xx() throws Exception {