From e3ada5b7268c87deddc7b4dfb619f05ebf1a872e Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Fri, 3 Oct 2014 19:13:22 -0700 Subject: [PATCH] JCLOUDS-296 unasync legacy cloudservers provider. --- .../cloudservers/CloudServersApiMetadata.java | 28 +- .../cloudservers/CloudServersAsyncClient.java | 387 ------------------ .../cloudservers/CloudServersClient.java | 242 +++++++++-- ...oudServersComputeServiceContextModule.java | 4 - ...le.java => CloudServersHttpApiModule.java} | 9 +- ...tTest.java => CloudServersClientTest.java} | 118 +++--- ...eCloudServersComputeServiceExpectTest.java | 10 +- .../BaseCloudServersRestClientExpectTest.java | 10 +- 8 files changed, 286 insertions(+), 522 deletions(-) delete mode 100644 apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java rename apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/{CloudServersRestClientModule.java => CloudServersHttpApiModule.java} (91%) rename apis/cloudservers/src/test/java/org/jclouds/cloudservers/{CloudServersAsyncClientTest.java => CloudServersClientTest.java} (87%) diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java index 8c6fbd8fd9..04ed2e7a0d 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java @@ -22,27 +22,14 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule; -import org.jclouds.cloudservers.config.CloudServersRestClientModule; +import org.jclouds.cloudservers.config.CloudServersHttpApiModule; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; import com.google.inject.Module; -/** - * Implementation of {@link ApiMetadata} for CloudServers 1.0 API - */ -public class CloudServersApiMetadata extends BaseRestApiMetadata { - - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudServersClient.class)} as - * {@link CloudServersAsyncClient} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; +public class CloudServersApiMetadata extends BaseHttpApiMetadata { @Override public Builder toBuilder() { @@ -58,15 +45,14 @@ public class CloudServersApiMetadata extends BaseRestApiMetadata { } public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); + Properties properties = BaseHttpApiMetadata.defaultProperties(); return properties; } - public static class Builder extends BaseRestApiMetadata.Builder { + public static class Builder extends BaseHttpApiMetadata.Builder { - @SuppressWarnings("deprecation") protected Builder() { - super(CloudServersClient.class, CloudServersAsyncClient.class); + super(CloudServersClient.class); id("cloudservers") .name("Rackspace Cloud Servers API") .identityName("Username") @@ -76,7 +62,7 @@ public class CloudServersApiMetadata extends BaseRestApiMetadata { .defaultEndpoint("https://auth.api.rackspacecloud.com") .defaultProperties(CloudServersApiMetadata.defaultProperties()) .view(typeToken(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class)); + .defaultModules(ImmutableSet.>of(CloudServersHttpApiModule.class, CloudServersComputeServiceContextModule.class)); } @Override diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java deleted file mode 100644 index 75aebdbc40..0000000000 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java +++ /dev/null @@ -1,387 +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.cloudservers; - -import java.io.Closeable; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.cloudservers.binders.BindBackupScheduleToJsonPayload; -import org.jclouds.cloudservers.domain.Addresses; -import org.jclouds.cloudservers.domain.BackupSchedule; -import org.jclouds.cloudservers.domain.Flavor; -import org.jclouds.cloudservers.domain.Image; -import org.jclouds.cloudservers.domain.Limits; -import org.jclouds.cloudservers.domain.RebootType; -import org.jclouds.cloudservers.domain.Server; -import org.jclouds.cloudservers.domain.SharedIpGroup; -import org.jclouds.cloudservers.options.CreateServerOptions; -import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions; -import org.jclouds.cloudservers.options.ListOptions; -import org.jclouds.cloudservers.options.RebuildServerOptions; -import org.jclouds.openstack.filters.AddTimestampQuery; -import org.jclouds.openstack.filters.AuthenticateRequest; -import org.jclouds.openstack.services.Compute; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Endpoint; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.Unwrap; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Cloud Servers via their REST API. - *

- * All commands return a ListenableFuture of the result from Cloud Servers. Any exceptions incurred - * during processing will be backend in an {@link ExecutionException} as documented in - * {@link ListenableFuture#get()}. - * - * @see CloudServersClient - * - * @deprecated The Rackspace First-Gen Cloud Servers product has been deprecated. Please refer to the - * Rackspace Getting Started Guide - * for accessing the Rackspace Cloud. This API will be removed in 2.0. - */ -@Deprecated -@RequestFilters({ AuthenticateRequest.class, AddTimestampQuery.class }) -@Endpoint(Compute.class) -public interface CloudServersAsyncClient extends Closeable { - - /** - * @see CloudServersClient#getLimits - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/limits") - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture getLimits(); - - /** - * @see CloudServersClient#listServers - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/servers") - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> listServers(ListOptions... options); - - /** - * @see CloudServersClient#getServer - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Fallback(NullOnNotFoundOr404.class) - @Path("/servers/{id}") - ListenableFuture getServer(@PathParam("id") int id); - - /** - * @see CloudServersClient#deleteServer - */ - @DELETE - @Fallback(FalseOnNotFoundOr404.class) - @Path("/servers/{id}") - ListenableFuture deleteServer(@PathParam("id") int id); - - /** - * @see CloudServersClient#rebootServer - */ - @POST - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/action") - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D") - ListenableFuture rebootServer(@PathParam("id") int id, @PayloadParam("type") RebootType rebootType); - - /** - * @see CloudServersClient#resizeServer - */ - @POST - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/action") - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"resize\":%7B\"flavorId\":{flavorId}%7D%7D") - ListenableFuture resizeServer(@PathParam("id") int id, @PayloadParam("flavorId") int flavorId); - - /** - * @see CloudServersClient#confirmResizeServer - */ - @POST - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/action") - @Produces(MediaType.APPLICATION_JSON) - @Payload("{\"confirmResize\":null}") - ListenableFuture confirmResizeServer(@PathParam("id") int id); - - /** - * @see CloudServersClient#revertResizeServer - */ - @POST - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/action") - @Produces(MediaType.APPLICATION_JSON) - @Payload("{\"revertResize\":null}") - ListenableFuture revertResizeServer(@PathParam("id") int id); - - /** - * @see CloudServersClient#createServer - */ - @POST - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/servers") - @MapBinder(CreateServerOptions.class) - ListenableFuture createServer(@PayloadParam("name") String name, @PayloadParam("imageId") int imageId, - @PayloadParam("flavorId") int flavorId, CreateServerOptions... options); - - /** - * @see CloudServersClient#rebuildServer - */ - @POST - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/action") - @MapBinder(RebuildServerOptions.class) - ListenableFuture rebuildServer(@PathParam("id") int id, RebuildServerOptions... options); - - /** - * @see CloudServersClient#shareIp - */ - @PUT - @Path("/servers/{id}/ips/public/{address}") - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"shareIp\":%7B\"sharedIpGroupId\":{sharedIpGroupId},\"configureServer\":{configureServer}%7D%7D") - ListenableFuture shareIp(@PathParam("address") String addressToShare, - @PathParam("id") int serverToTosignBindressTo, @PayloadParam("sharedIpGroupId") int sharedIpGroup, - @PayloadParam("configureServer") boolean configureServer); - - /** - * @see CloudServersClient#unshareIp - */ - @DELETE - @Path("/servers/{id}/ips/public/{address}") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture unshareIp(@PathParam("address") String addressToShare, - @PathParam("id") int serverToTosignBindressTo); - - /** - * @see CloudServersClient#changeAdminPass - */ - @PUT - @Path("/servers/{id}") - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"server\":%7B\"adminPass\":\"{adminPass}\"%7D%7D") - ListenableFuture changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass); - - /** - * @see CloudServersClient#renameServer - */ - @PUT - @Path("/servers/{id}") - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D") - ListenableFuture renameServer(@PathParam("id") int id, @PayloadParam("name") String newName); - - /** - * @see CloudServersClient#listFlavors - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/flavors") - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> listFlavors(ListOptions... options); - - /** - * @see CloudServersClient#getFlavor - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/flavors/{id}") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getFlavor(@PathParam("id") int id); - - /** - * @see CloudServersClient#listImages - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/images") - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> listImages(ListOptions... options); - - /** - * @see CloudServersClient#getImage - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - @QueryParams(keys = "format", values = "json") - @Path("/images/{id}") - ListenableFuture getImage(@PathParam("id") int id); - - /** - * @see CloudServersClient#deleteImage - */ - @DELETE - @Fallback(FalseOnNotFoundOr404.class) - @Path("/images/{id}") - ListenableFuture deleteImage(@PathParam("id") int id); - - /** - * @see CloudServersClient#createImageFromServer - */ - @POST - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/images") - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"image\":%7B\"serverId\":{serverId},\"name\":\"{name}\"%7D%7D") - ListenableFuture createImageFromServer(@PayloadParam("name") String imageName, - @PayloadParam("serverId") int serverId); - - /** - * @see CloudServersClient#listSharedIpGroups - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/shared_ip_groups") - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> listSharedIpGroups(ListOptions... options); - - /** - * @see CloudServersClient#getSharedIpGroup - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/shared_ip_groups/{id}") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getSharedIpGroup(@PathParam("id") int id); - - /** - * @see CloudServersClient#createSharedIpGroup - */ - @POST - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/shared_ip_groups") - @MapBinder(CreateSharedIpGroupOptions.class) - ListenableFuture createSharedIpGroup(@PayloadParam("name") String name, - CreateSharedIpGroupOptions... options); - - /** - * @see CloudServersClient#deleteSharedIpGroup - */ - @DELETE - @Fallback(FalseOnNotFoundOr404.class) - @Path("/shared_ip_groups/{id}") - ListenableFuture deleteSharedIpGroup(@PathParam("id") int id); - - /** - * @see CloudServersClient#listBackupSchedule - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/backup_schedule") - ListenableFuture getBackupSchedule(@PathParam("id") int serverId); - - /** - * @see CloudServersClient#deleteBackupSchedule - */ - @DELETE - @Fallback(FalseOnNotFoundOr404.class) - @Path("/servers/{id}/backup_schedule") - ListenableFuture deleteBackupSchedule(@PathParam("id") int serverId); - - /** - * @see CloudServersClient#replaceBackupSchedule - */ - @POST - @Path("/servers/{id}/backup_schedule") - ListenableFuture replaceBackupSchedule(@PathParam("id") int id, - @BinderParam(BindBackupScheduleToJsonPayload.class) BackupSchedule backupSchedule); - - /** - * @see CloudServersClient#listAddresses - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/ips") - ListenableFuture getAddresses(@PathParam("id") int serverId); - - /** - * @see CloudServersClient#listPublicAddresses - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/ips/public") - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> listPublicAddresses(@PathParam("id") int serverId); - - /** - * @see CloudServersClient#listPrivateAddresses - */ - @GET - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @QueryParams(keys = "format", values = "json") - @Path("/servers/{id}/ips/private") - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> listPrivateAddresses(@PathParam("id") int serverId); - -} diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersClient.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersClient.java index 4fe9761714..ff9b21ef87 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersClient.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersClient.java @@ -16,10 +16,24 @@ */ package org.jclouds.cloudservers; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.jclouds.Fallbacks.*; + import java.io.Closeable; import java.util.Set; -import javax.ws.rs.PathParam; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks; +import org.jclouds.cloudservers.binders.BindBackupScheduleToJsonPayload; import org.jclouds.cloudservers.domain.Addresses; import org.jclouds.cloudservers.domain.BackupSchedule; import org.jclouds.cloudservers.domain.Flavor; @@ -32,20 +46,31 @@ import org.jclouds.cloudservers.options.CreateServerOptions; import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions; import org.jclouds.cloudservers.options.ListOptions; import org.jclouds.cloudservers.options.RebuildServerOptions; +import org.jclouds.openstack.filters.AddTimestampQuery; +import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.services.Compute; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.Unwrap; + +import com.google.common.util.concurrent.ListenableFuture; /** * Provides access to Cloud Servers via their REST API. - *

- * All commands return a Future of the result from Cloud Servers. Any exceptions incurred during - * processing will be backend in an {@link ExecutionException} as documented in {@link Future#get()}. - * - * @see CloudServersAsyncClient * * @deprecated The Rackspace First-Gen Cloud Servers product has been deprecated. Please refer to the * Rackspace Getting Started Guide * for accessing the Rackspace Cloud. This API will be removed in 2.0. */ @Deprecated +@RequestFilters({ AuthenticateRequest.class, AddTimestampQuery.class }) +@Endpoint(Compute.class) public interface CloudServersClient extends Closeable { /** * All accounts, by default, have a preconfigured set of thresholds (or limits) to manage @@ -55,6 +80,12 @@ public interface CloudServersClient extends Closeable { * * @return limits on the account */ + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/limits") + @Fallback(NullOnNotFoundOr404.class) Limits getLimits(); /** @@ -67,6 +98,12 @@ public interface CloudServersClient extends Closeable { * in order to retrieve all details, pass the option {@link ListOptions#withDetails() * withDetails()} */ + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/servers") + @Fallback(EmptySetOnNotFoundOr404.class) Set listServers(ListOptions... options); /** @@ -76,6 +113,12 @@ public interface CloudServersClient extends Closeable { * @return null, if the server is not found * @see Server */ + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Fallback(NullOnNotFoundOr404.class) + @Path("/servers/{id}") Server getServer(@PathParam("id") int id); /** @@ -87,6 +130,9 @@ public interface CloudServersClient extends Closeable { * @return false if the server is not found * @see Server */ + @DELETE + @Fallback(FalseOnNotFoundOr404.class) + @Path("/servers/{id}") boolean deleteServer(@PathParam("id") int id); /** @@ -103,7 +149,12 @@ public interface CloudServersClient extends Closeable { * graceful shutdown of all processes. A hard reboot is the equivalent of power cycling * the server. */ - void rebootServer(int id, RebootType rebootType); + @POST + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/action") + @Produces(APPLICATION_JSON) + @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D") + void rebootServer(@PathParam("id") int id, @PayloadParam("type") RebootType rebootType); /** * The resize function converts an existing server to a different flavor, in essence, scaling the @@ -118,7 +169,12 @@ public interface CloudServersClient extends Closeable { *

* ACTIVE - QUEUE_RESIZE - ACTIVE (on error) */ - void resizeServer(int id, int flavorId); + @POST + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/action") + @Produces(APPLICATION_JSON) + @Payload("%7B\"resize\":%7B\"flavorId\":{flavorId}%7D%7D") + void resizeServer(@PathParam("id") int id, @PayloadParam("flavorId") int flavorId); /** * The resize function converts an existing server to a different flavor, in essence, scaling the @@ -131,7 +187,12 @@ public interface CloudServersClient extends Closeable { *

* VERIFY_RESIZE - ACTIVE */ - void confirmResizeServer(int id); + @POST + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/action") + @Produces(APPLICATION_JSON) + @Payload("{\"confirmResize\":null}") + void confirmResizeServer(@PathParam("id") int id); /** * The resize function converts an existing server to a different flavor, in essence, scaling the @@ -144,7 +205,12 @@ public interface CloudServersClient extends Closeable { *

* VERIFY_RESIZE - ACTIVE */ - void revertResizeServer(int id); + @POST + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/action") + @Produces(APPLICATION_JSON) + @Payload("{\"revertResize\":null}") + void revertResizeServer(@PathParam("id") int id); /** * This operation asynchronously provisions a new server. The progress of this operation depends @@ -157,7 +223,14 @@ public interface CloudServersClient extends Closeable { * @param options * - used to specify extra files, metadata, or ip parameters during server creation. */ - Server createServer(String name, int imageId, int flavorId, CreateServerOptions... options); + @POST + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/servers") + @MapBinder(CreateServerOptions.class) + Server createServer(@PayloadParam("name") String name, @PayloadParam("imageId") int imageId, + @PayloadParam("flavorId") int flavorId, CreateServerOptions... options); /** * The rebuild function removes all data on the server and replaces it with the specified image. @@ -174,7 +247,11 @@ public interface CloudServersClient extends Closeable { * - imageId is an optional argument. If it is not specified, the server is rebuilt * with the original imageId. */ - void rebuildServer(int id, RebuildServerOptions... options); + @POST + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/action") + @MapBinder(RebuildServerOptions.class) + void rebuildServer(@PathParam("id") int id, RebuildServerOptions... options); /** * /** This operation allows you share an IP address to the specified server @@ -196,7 +273,12 @@ public interface CloudServersClient extends Closeable { * (e.g. keepalived) can then be used within the servers to perform health checks and * manage IP failover. */ - void shareIp(String addressToShare, int serverToTosignBindressTo, int sharedIpGroup, boolean configureServer); + @PUT + @Path("/servers/{id}/ips/public/{address}") + @Produces(APPLICATION_JSON) + @Payload("%7B\"shareIp\":%7B\"sharedIpGroupId\":{sharedIpGroupId},\"configureServer\":{configureServer}%7D%7D") + void shareIp(@PathParam("address") String addressToShare, @PathParam("id") int serverToTosignBindressTo, + @PayloadParam("sharedIpGroupId") int sharedIpGroup, @PayloadParam("configureServer") boolean configureServer); /** * This operation removes a shared IP address from the specified server. @@ -207,7 +289,10 @@ public interface CloudServersClient extends Closeable { * @param serverToTosignBindressTo * @return */ - void unshareIp(String addressToShare, int serverToTosignBindressTo); + @DELETE + @Path("/servers/{id}/ips/public/{address}") + @Fallback(VoidOnNotFoundOr404.class) + void unshareIp(@PathParam("address") String addressToShare, @PathParam("id") int serverToTosignBindressTo); /** * This operation allows you to change the administrative password. @@ -215,7 +300,11 @@ public interface CloudServersClient extends Closeable { * Status Transition: ACTIVE - PASSWORD - ACTIVE * */ - void changeAdminPass(int id, String adminPass); + @PUT + @Path("/servers/{id}") + @Produces(APPLICATION_JSON) + @Payload("%7B\"server\":%7B\"adminPass\":\"{adminPass}\"%7D%7D") + void changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass); /** * This operation allows you to update the name of the server. This operation changes the name of @@ -224,7 +313,11 @@ public interface CloudServersClient extends Closeable { * Status Transition: ACTIVE - PASSWORD - ACTIVE * */ - void renameServer(int id, String newName); + @PUT + @Path("/servers/{id}") + @Produces(APPLICATION_JSON) + @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D") + void renameServer(@PathParam("id") int id, @PayloadParam("name") String newName); /** * @@ -233,6 +326,12 @@ public interface CloudServersClient extends Closeable { * in order to retrieve all details, pass the option {@link ListOptions#withDetails() * withDetails()} */ + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/flavors") + @Fallback(EmptySetOnNotFoundOr404.class) Set listFlavors(ListOptions... options); /** @@ -242,7 +341,13 @@ public interface CloudServersClient extends Closeable { * @return null, if the flavor is not found * @see Flavor */ - Flavor getFlavor(int id); + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/flavors/{id}") + @Fallback(NullOnNotFoundOr404.class) + Flavor getFlavor(@PathParam("id") int id); /** * @@ -251,6 +356,12 @@ public interface CloudServersClient extends Closeable { * in order to retrieve all details, pass the option {@link ListOptions#withDetails() * withDetails()} */ + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/images") + @Fallback(EmptySetOnNotFoundOr404.class) Set listImages(ListOptions... options); /** @@ -261,7 +372,13 @@ public interface CloudServersClient extends Closeable { * * @see Image */ - Image getImage(int id); + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + @QueryParams(keys = "format", values = "json") + @Path("/images/{id}") + Image getImage(@PathParam("id") int id); /** * @@ -273,7 +390,10 @@ public interface CloudServersClient extends Closeable { * @return false if the image is not found * @see Image */ - boolean deleteImage(int id); + @DELETE + @Fallback(FalseOnNotFoundOr404.class) + @Path("/images/{id}") + boolean deleteImage(@PathParam("id") int id); /** * @@ -291,11 +411,17 @@ public interface CloudServersClient extends Closeable { * Note: At present, image creation is an asynchronous operation, so coordinating the creation * with data quiescence, etc. is currently not possible. * - * @throws ResourceNotFoundException - * if the server is not found + * @throws ResourceNotFoundException if the server is not found * @see Image */ - Image createImageFromServer(String imageName, int serverId); + @POST + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/images") + @Produces(APPLICATION_JSON) + @Payload("%7B\"image\":%7B\"serverId\":{serverId},\"name\":\"{name}\"%7D%7D") + Image createImageFromServer(@PayloadParam("name") String imageName, @PayloadParam("serverId") int serverId); /** * @@ -304,6 +430,12 @@ public interface CloudServersClient extends Closeable { * in order to retrieve all details, pass the option {@link ListOptions#withDetails() * withDetails()} */ + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/shared_ip_groups") + @Fallback(EmptySetOnNotFoundOr404.class) Set listSharedIpGroups(ListOptions... options); /** @@ -314,7 +446,13 @@ public interface CloudServersClient extends Closeable { * * @see SharedIpGroup */ - SharedIpGroup getSharedIpGroup(int id); + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/shared_ip_groups/{id}") + @Fallback(NullOnNotFoundOr404.class) + SharedIpGroup getSharedIpGroup(@PathParam("id") int id); /** * This operation creates a new shared IP group. Please note, all responses to requests for @@ -322,7 +460,14 @@ public interface CloudServersClient extends Closeable { * can be created empty or can be initially populated with a single server. Use * {@link CreateSharedIpGroupOptions} to specify an server. */ - SharedIpGroup createSharedIpGroup(String name, CreateSharedIpGroupOptions... options); + @POST + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/shared_ip_groups") + @MapBinder(CreateSharedIpGroupOptions.class) + SharedIpGroup createSharedIpGroup(@PayloadParam("name") String name, + CreateSharedIpGroupOptions... options); /** * This operation deletes the specified shared IP group. This operation will ONLY succeed if 1) @@ -332,15 +477,22 @@ public interface CloudServersClient extends Closeable { * @return false if the shared ip group is not found * @see SharedIpGroup */ - boolean deleteSharedIpGroup(int id); + @DELETE + @Fallback(FalseOnNotFoundOr404.class) + @Path("/shared_ip_groups/{id}") + boolean deleteSharedIpGroup(@PathParam("id") int id); /** * List the backup schedule for the specified server * - * @throws ResourceNotFoundException - * , if the server doesn't exist + * @throws ResourceNotFoundException, if the server doesn't exist */ - BackupSchedule getBackupSchedule(int serverId); + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/backup_schedule") + BackupSchedule getBackupSchedule(@PathParam("id") int serverId); /** * Delete backup schedule for the specified server. @@ -349,33 +501,55 @@ public interface CloudServersClient extends Closeable { * * @return false if the schedule is not found */ - boolean deleteBackupSchedule(int serverId); + @DELETE + @Fallback(FalseOnNotFoundOr404.class) + @Path("/servers/{id}/backup_schedule") + boolean deleteBackupSchedule(@PathParam("id") int serverId); /** * Enable/update the backup schedule for the specified server * */ - void replaceBackupSchedule(int id, BackupSchedule backupSchedule); + @POST + @Path("/servers/{id}/backup_schedule") + void replaceBackupSchedule(@PathParam("id") int id, + @BinderParam(BindBackupScheduleToJsonPayload.class) BackupSchedule backupSchedule); /** * List all server addresses * * returns empty set if the server doesn't exist */ - Addresses getAddresses(int serverId); + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/ips") + Addresses getAddresses(@PathParam("id") int serverId); /** * List all public server addresses * * returns empty set if the server doesn't exist */ - Set listPublicAddresses(int serverId); + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/ips/public") + @Fallback(EmptySetOnNotFoundOr404.class) + Set listPublicAddresses(@PathParam("id") int serverId); /** * List all private server addresses * * returns empty set if the server doesn't exist */ - Set listPrivateAddresses(int serverId); - + @GET + @Unwrap + @Consumes(APPLICATION_JSON) + @QueryParams(keys = "format", values = "json") + @Path("/servers/{id}/ips/private") + @Fallback(EmptySetOnNotFoundOr404.class) + Set listPrivateAddresses(@PathParam("id") int serverId); } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java index 44d9ec4c29..44cbb95f23 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java @@ -48,10 +48,6 @@ import com.google.inject.Injector; import com.google.inject.Provides; import com.google.inject.TypeLiteral; -/** - * Configures the {@link CloudServersComputeServiceContext}; requires {@link BaseComputeService} - * bound. - */ public class CloudServersComputeServiceContextModule extends ComputeServiceAdapterContextModule { diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersHttpApiModule.java similarity index 91% rename from apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java rename to apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersHttpApiModule.java index 82609b7959..71aa0a6118 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersHttpApiModule.java @@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; -import org.jclouds.cloudservers.CloudServersAsyncClient; import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse; import org.jclouds.date.TimeStamp; @@ -38,15 +37,15 @@ import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; import org.jclouds.openstack.services.Compute; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.ConfiguresHttpApi; import org.jclouds.rest.annotations.ApiVersion; -import org.jclouds.rest.config.RestClientModule; +import org.jclouds.rest.config.HttpApiModule; import com.google.common.base.Supplier; import com.google.inject.Provides; -@ConfiguresRestClient -public class CloudServersRestClientModule extends RestClientModule { +@ConfiguresHttpApi +public class CloudServersHttpApiModule extends HttpApiModule { @Override protected void configure() { diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientTest.java similarity index 87% rename from apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java rename to apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientTest.java index 9ced9a20cd..67ecd33161 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientTest.java @@ -41,7 +41,7 @@ import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.apis.ApiMetadata; -import org.jclouds.cloudservers.config.CloudServersRestClientModule; +import org.jclouds.cloudservers.config.CloudServersHttpApiModule; import org.jclouds.cloudservers.domain.BackupSchedule; import org.jclouds.cloudservers.domain.DailyBackup; import org.jclouds.cloudservers.domain.RebootType; @@ -61,7 +61,7 @@ import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.GetAuth; import org.jclouds.openstack.keystone.v1_1.domain.Auth; import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.ConfiguresHttpApi; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; @@ -71,16 +71,12 @@ import com.google.common.collect.ImmutableMap; import com.google.common.reflect.Invokable; import com.google.inject.Module; import com.google.inject.Provides; -/** - * Tests behavior of {@code CloudServersAsyncClient} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", singleThreaded = true, testName = "CloudServersAsyncClientTest") -public class CloudServersAsyncClientTest extends BaseAsyncClientTest { + +@Test(groups = "unit", singleThreaded = true, testName = "CloudServersClientTest") +public class CloudServersClientTest extends BaseAsyncClientTest { public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException { - Invokable method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + Invokable method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class, CreateServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1)); @@ -98,7 +94,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + Invokable method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class, CreateServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withSharedIpGroup(2))); @@ -116,7 +112,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + Invokable method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class, CreateServerOptions[].class); GeneratedHttpRequest request = processor .createRequest(method, ImmutableList. of("ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes()))); @@ -137,7 +133,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + Invokable method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class, CreateServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withMetadata(ImmutableMap.of("foo", "bar")))); @@ -158,7 +154,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class, + Invokable method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class, CreateServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withSharedIpGroup(2).withSharedIp("127.0.0.1"))); @@ -178,7 +174,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "deleteImage", int.class); + Invokable method = method(CloudServersClient.class, "deleteImage", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2 HTTP/1.1"); @@ -193,7 +189,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "getLimits"); + Invokable method = method(CloudServersClient.class, "getLimits"); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/limits?format=json HTTP/1.1"); @@ -202,13 +198,13 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listServers", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); @@ -225,7 +221,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listServers", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -241,7 +237,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listServers", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/detail?format=json HTTP/1.1"); @@ -256,7 +252,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "getServer", int.class); + Invokable method = method(CloudServersClient.class, "getServer", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2?format=json HTTP/1.1"); @@ -271,7 +267,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listFlavors", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json HTTP/1.1"); @@ -286,7 +282,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listFlavors", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -302,7 +298,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listFlavors", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json HTTP/1.1"); @@ -317,7 +313,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listFlavors", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -333,7 +329,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "getFlavor", int.class); + Invokable method = method(CloudServersClient.class, "getFlavor", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/2?format=json HTTP/1.1"); @@ -348,7 +344,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listImages", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1"); @@ -363,7 +359,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listImages", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json HTTP/1.1"); @@ -378,7 +374,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listImages", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -394,7 +390,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listImages", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -410,7 +406,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "getImage", int.class); + Invokable method = method(CloudServersClient.class, "getImage", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2?format=json HTTP/1.1"); @@ -425,7 +421,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "deleteServer", int.class); + Invokable method = method(CloudServersClient.class, "deleteServer", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); @@ -440,7 +436,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "shareIp", String.class, int.class, int.class, + Invokable method = method(CloudServersClient.class, "shareIp", String.class, int.class, int.class, boolean.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, false)); @@ -458,7 +454,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "shareIp", String.class, int.class, int.class, + Invokable method = method(CloudServersClient.class, "shareIp", String.class, int.class, int.class, boolean.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, true)); @@ -477,7 +473,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "unshareIp", String.class, int.class); + Invokable method = method(CloudServersClient.class, "unshareIp", String.class, int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, false)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1"); @@ -493,7 +489,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "replaceBackupSchedule", int.class, BackupSchedule.class); + Invokable method = method(CloudServersClient.class, "replaceBackupSchedule", int.class, BackupSchedule.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, BackupSchedule.builder().weekly(WeeklyBackup.MONDAY) .daily(DailyBackup.H_0800_1000).enabled(true).build())); @@ -512,7 +508,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "deleteBackupSchedule", int.class); + Invokable method = method(CloudServersClient.class, "deleteBackupSchedule", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1"); @@ -528,7 +524,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "changeAdminPass", int.class, String.class); + Invokable method = method(CloudServersClient.class, "changeAdminPass", int.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, "foo")); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); @@ -544,7 +540,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "renameServer", int.class, String.class); + Invokable method = method(CloudServersClient.class, "renameServer", int.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, "foo")); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); @@ -560,7 +556,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listSharedIpGroups", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1"); @@ -575,7 +571,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listSharedIpGroups", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -591,7 +587,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listSharedIpGroups", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json HTTP/1.1"); @@ -606,7 +602,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class); + Invokable method = method(CloudServersClient.class, "listSharedIpGroups", ListOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, @@ -622,7 +618,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "getSharedIpGroup", int.class); + Invokable method = method(CloudServersClient.class, "getSharedIpGroup", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2?format=json HTTP/1.1"); @@ -637,7 +633,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "createSharedIpGroup", String.class, + Invokable method = method(CloudServersClient.class, "createSharedIpGroup", String.class, CreateSharedIpGroupOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie")); @@ -654,7 +650,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "createSharedIpGroup", String.class, + Invokable method = method(CloudServersClient.class, "createSharedIpGroup", String.class, CreateSharedIpGroupOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", withServer(2))); @@ -671,7 +667,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "deleteSharedIpGroup", int.class); + Invokable method = method(CloudServersClient.class, "deleteSharedIpGroup", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2 HTTP/1.1"); @@ -686,7 +682,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "getAddresses", int.class); + Invokable method = method(CloudServersClient.class, "getAddresses", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips?format=json HTTP/1.1"); @@ -701,7 +697,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listPublicAddresses", int.class); + Invokable method = method(CloudServersClient.class, "listPublicAddresses", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public?format=json HTTP/1.1"); @@ -716,7 +712,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "listPrivateAddresses", int.class); + Invokable method = method(CloudServersClient.class, "listPrivateAddresses", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/private?format=json HTTP/1.1"); @@ -731,7 +727,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "getBackupSchedule", int.class); + Invokable method = method(CloudServersClient.class, "getBackupSchedule", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule?format=json HTTP/1.1"); @@ -746,7 +742,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "createImageFromServer", String.class, int.class); + Invokable method = method(CloudServersClient.class, "createImageFromServer", String.class, int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1"); @@ -763,7 +759,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "rebuildServer", int.class, + Invokable method = method(CloudServersClient.class, "rebuildServer", int.class, RebuildServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(3)); @@ -779,7 +775,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "rebuildServer", int.class, + Invokable method = method(CloudServersClient.class, "rebuildServer", int.class, RebuildServerOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(3, withImage(2))); @@ -795,7 +791,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "rebootServer", int.class, RebootType.class); + Invokable method = method(CloudServersClient.class, "rebootServer", int.class, RebootType.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, RebootType.HARD)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); @@ -810,7 +806,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "resizeServer", int.class, int.class); + Invokable method = method(CloudServersClient.class, "resizeServer", int.class, int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, 3)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); @@ -826,7 +822,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "confirmResizeServer", int.class); + Invokable method = method(CloudServersClient.class, "confirmResizeServer", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); @@ -841,7 +837,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = method(CloudServersAsyncClient.class, "revertResizeServer", int.class); + Invokable method = method(CloudServersClient.class, "revertResizeServer", int.class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); @@ -865,11 +861,11 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest extends BaseKe @Override protected Module createModule() { - return new TestCloudServersRestClientModule(); + return new TestCloudServersHttpApiModule(); } - @ConfiguresRestClient - protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { + @ConfiguresHttpApi + protected static class TestCloudServersHttpApiModule extends CloudServersHttpApiModule { @Override public Supplier provideCacheBusterDate() { diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java index edc2477d99..fcb875a693 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java @@ -24,10 +24,10 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.cloudservers.CloudServersApiMetadata; import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.cloudservers.config.CloudServersRestClientModule; +import org.jclouds.cloudservers.config.CloudServersHttpApiModule; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.ConfiguresHttpApi; import com.google.common.base.Supplier; import com.google.inject.Module; @@ -63,11 +63,11 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient */ @Override protected Module createModule() { - return new TestCloudServersRestClientModule(); + return new TestCloudServersHttpApiModule(); } - @ConfiguresRestClient - protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { + @ConfiguresHttpApi + protected static class TestCloudServersHttpApiModule extends CloudServersHttpApiModule { @Override public Supplier provideCacheBusterDate() {